Computes component-wise v1 = v1 - v2,
overwriting the vector v1.

@param v1 vector
@param v2 another vector
@return v1 = v1 - v2
502874
public static double[] minusEquals(final double[] v1, final double[] v2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    for(int i = 0; i < v1.length; i++) {
      v1[i] -= v2[i];
    }
    return v1;
  }
1075607
public static float[] vMad(float[] v1, float[] v2, float s) {
        float[] dest = new float[3];
        dest[0] = v1[0] + v2[0] * s;
        dest[1] = v1[1] + v2[1] * s;
        dest[2] = v1[2] + v2[2] * s;
        return dest;
    }
1336789
public static Vector add(Vector vector1, Vector vector2) {
        if (vector2.length() != vector1.length())
            throw new IllegalArgumentException(
                    "Vectors of different sizes cannot be added");
        if (vector2 instanceof IntegerVector &&
            vector1 instanceof DoubleVector)
            return add(vector1, Vectors.asDouble(vector2));
        if (vector2 instanceof SparseVector)
            addSparseValues(vector1, vector2);
        else {
            int length = vector2.length();
            for (int i = 0; i < length; ++i) {
                double value = vector2.getValue(i).doubleValue() +
                               vector1.getValue(i).doubleValue();
                vector1.set(i, value);
            }
        }

        return vector1;
    }
1175705
public static double angle(double[] v1, double[] v2) {
    final int mindim = (v1.length <= v2.length) ? v1.length : v2.length;
    // Essentially, we want to compute this:
    // v1.transposeTimes(v2) / (v1.euclideanLength() * v2.euclideanLength());
    // We can just compute all three in parallel.
    double s = 0, e1 = 0, e2 = 0;
    for(int k = 0; k < mindim; k++) {
      final double r1 = v1[k], r2 = v2[k];
      s += r1 * r2;
      e1 += r1 * r1;
      e2 += r2 * r2;
    }
    for(int k = mindim; k < v1.length; k++) {
      final double r1 = v1[k];
      e1 += r1 * r1;
    }
    for(int k = mindim; k < v2.length; k++) {
      final double r2 = v2[k];
      e2 += r2 * r2;
    }
    double a = FastMath.sqrt((s / e1) * (s / e2));
    return (a < 1.) ? a : 1.;
  }
460720
public static double sub(Double v1, Double v2) {
		return sub((Number) v1, (Number) v2).doubleValue();
	}
983345
public static double[] plus(final double[] v1, final double s1) {
    final double[] result = new double[v1.length];
    for(int i = 0; i < result.length; i++) {
      result[i] = v1[i] + s1;
    }
    return result;
  }
579213
def v2(self):
        
        if self._v2 is None:
            self._v2 = V2(self)
        return self._v2
497612
public Vector2i mul(Vector2ic v, Vector2i dest) {
        dest.x = x * v.x();
        dest.y = y * v.y();
        return dest;
    }
363511
public Vector2i add(Vector2ic v, Vector2i dest) {
        dest.x = x + v.x();
        dest.y = y + v.y();
        return dest;
    }
433456
public static BigDecimal mul(Number v1, Number v2) {
		return mul(new Number[] { v1, v2 });
	}
724921
def dot_v2(vec1, vec2):
    """"""

    return vec1.x * vec2.x + vec1.y * vec2.y
611847
public static double[] timesPlusTimesEquals(final double[] v1, final double s1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    for(int i = 0; i < v1.length; i++) {
      v1[i] = v1[i] * s1 + v2[i] * s2;
    }
    return v1;
  }
951862
def cross_v2(vec1, vec2):
    

    return vec1.y * vec2.x - vec1.x * vec2.y
214784
public static double[] timesMinusTimesEquals(final double[] v1, final double s1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    for(int i = 0; i < v1.length; i++) {
      v1[i] = v1[i] * s1 - v2[i] * s2;
    }
    return v1;
  }
346477
def component_add(vec1, vec2):
    """"""
    if isinstance(vec1, Vector3) and isinstance(vec2, Vector3):
        addVec = Vector3()
        addVec.x = vec1.x + vec2.x
        addVec.y = vec1.y + vec2.y
        addVec.z = vec1.z + vec2.z
        return addVec

    if isinstance(vec1, Vector4) and isinstance(vec2, Vector4):
        addVec = Vector4()
        addVec.x = vec1.x + vec2.x
        addVec.y = vec1.y + vec2.y
        addVec.z = vec1.z + vec2.z
        addVec.w = vec1.w + vec2.w
        return addVec
901932
public static double[] minusTimes(final double[] v1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] sub = new double[v1.length];
    for(int i = 0; i < v1.length; i++) {
      sub[i] = v1[i] - v2[i] * s2;
    }
    return sub;
  }
1267713
public static BigDecimal add(Number v1, Number v2) {
		return add(new Number[] { v1, v2 });
	}