Revision 594:495cc8973458 src/may/bits/VectorBits.java

View differences:

src/may/bits/VectorBits.java
9 9
		("Found vector of length " + v2.length +
10 10
		 ", but all so far in this arithmetic operation have had length " +
11 11
		 v1.length);
12
//	    e.printStackTrace();
13 12
	    throw e;
14 13
	}
15 14
    }
......
25 24

  
26 25
    public static void multiplyBy(double[] out, double[] in) {
27 26
	checkLengths(out, in);
28
	for (int i = 0; i < in.length && i < out.length; ++i) {
27
	for (int i = 0; i < in.length; ++i) {
29 28
	    out[i] *= in[i];
30 29
	}
31
	for (int i = in.length; i < out.length; ++i) {
32
	    out[i] *= 0.0;
33
	}
34 30
    }
35 31

  
36 32
    public static void divideBy(double[] out, double[] in) {
37 33
	checkLengths(out, in);
38
	for (int i = 0; i < in.length && i < out.length; ++i) {
34
	for (int i = 0; i < in.length; ++i) {
39 35
	    out[i] /= in[i];
40 36
	}
41 37
    }
42 38

  
43 39
    public static void addTo(double[] out, double[] in) {
44 40
	checkLengths(out, in);
45
	for (int i = 0; i < in.length && i < out.length; ++i) {
41
	for (int i = 0; i < in.length; ++i) {
46 42
	    out[i] += in[i];
47 43
	}
48 44
    }
49 45

  
50 46
    public static void subtractFrom(double[] out, double[] in) {
51 47
	checkLengths(out, in);
52
	for (int i = 0; i < in.length && i < out.length; ++i) {
48
	for (int i = 0; i < in.length; ++i) {
53 49
	    out[i] -= in[i];
54 50
	}
55 51
    }

Also available in: Unified diff