Creates a new vector from the current vector with the same direction but with provided length/magnitude.
@memberof Vec2#
@param   {Number} n
@returns {Vec2}
765872
function(n){
        var mult = Math.sqrt(n*n/this.dot(this));
        return new Vec2(this.x*mult, this.y*mult);
    }
151241
static Vector2d newUnitVector(final Tuple2d from, final Tuple2d to) {
        final Vector2d vector = new Vector2d(to.x - from.x, to.y - from.y);
        vector.normalize();
        return vector;
    }
714826
function create2x2(a, b, c, d){
    if (undef(a)) throw new Error("At least one argument must be provided.");

    if (undef(b)){
        // Everything = a
        b = a;
        c = a;
        d = a;
    }
    else{
        // we have a and b
        if(undef(c)){
            c = a;
            d = b;
        }
        else{
            if(undef(d)) throw new Error("Argument 'd' must be provided if 'c' is.");
        }
    }

    return new Vector([[a, b],[c, d]]);
}
793538
function add(a, b){
    return Vector3(a.x+b.x, a.y+b.y, a.z+b.z);
  }
1093652
def component_div(vec1, vec2):
        """"""
        new_vec = Vector2()
        new_vec.X = vec1.X / vec2.X
        new_vec.Y = vec1.Y / vec2.Y
        return new_vec
1179388
public static BasicVector fromMap(Map<Integer, ? extends Number> map, int length) {
        return Vector.fromMap(map, length).to(Vectors.BASIC);
    }
166601
function(vector) {
    var V = vector.elements || vector;
    var i, product = 0, n = this.elements.length;
    if (n != V.length) { return null; }
    do { product += this.elements[n-1] * V[n-1]; } while (--n);
    return product;
  }
1201808
private static DoubleVector generateInitialVector(int length,
                                                      double mean,
                                                      double std) {
        DoubleVector vector = new DenseVector(length);
        for (int i = 0; i < length; ++i) {
            double v = RANDOM.nextGaussian();
            v = std * v + mean;
            vector.set(i, v);
        }
        return vector;
    }
732700
private static Vector newVector(final int size) {
		final Vector v = new Vector(size);
		v.setSize(size);
		return v;
	}
598013
function(vec2, returnNew) {
      if (!returnNew) {
        this.x += vec2.x; this.y += vec2.y;
        return this.change();
      } else {
        // Return a new vector if `returnNew` is truthy
        return new Vec2(
          this.x + vec2.x,
          this.y + vec2.y
        );
      }
    }
238900
function (str, n) {
      n = window.parseInt(n, 10);
      return new Array(n + 1).join(str);
    }
433322
function(n) {
      return {
        x1: n.x - n.size,
        y1: n.y - n.size,
        x2: n.x + n.size,
        y2: n.y - n.size,
        height: n.size * 2
      };
    }
453863
function(vector$$1) {
                var V = vector$$1.elements || vector$$1;
                return Line.create([
                  this.anchor.elements[0] + V[0],
                  this.anchor.elements[1] + V[1],
                  this.anchor.elements[2] + (V[2] || 0)
                ], this.direction);
              }
30788
function (number, width) {
            number += '';
            width -= number.length;
            if (width > 0) {
                return new Array(width + 1).join('0') + number;
            }
            return number + '';
        }
813187
function(point) {
                var P = point.elements || point;
                var A = this.anchor.elements, N = this.normal.elements;
                var dot = (A[0] - P[0]) * N[0] + (A[1] - P[1]) * N[1] + (A[2] - (P[2] || 0)) * N[2];
                return vector.create([P[0] + N[0] * dot, P[1] + N[1] * dot, (P[2] || 0) + N[2] * dot]);
              }
29686
function createWithDimensions(dims, val){
    if(!Array.isArray(dims)) throw new Error("dims must be an array.");
    if(undef(val)) throw new Error("val must be defined.");
    
    const l = dims[dims.length - 1];
    const nextDims = dims.slice(0, -1);
    const array = new Array(l).fill(val);

    if(nextDims.length === 0) return new Vector(array);
    return createWithDimensions(nextDims, array);
}
404767
public static Vector from (XY from, XY to) {
        return new Vector(to.x() - from.x(), to.y() - from.y());
    }