Copy another vector
483012
def fromvector(cls, v):
        """"""
        return cls(v.x, v.y, v.z)
299624
def copy(self):
        ''' 

        '''
        return RGB(self.r, self.g, self.b, self.a)
1253252
static private Vector3f[] copyVertices(Vector3f[] vertices) {
        if (vertices == null) {
            return null;
        }
        Vector3f[] copy = new Vector3f[vertices.length];
        for (int i = 0; i < vertices.length; ++i) {
            copy[i] = new Vector3f(vertices[i]);
        }
        return copy;
    }
74542
function copy(from, to){
  to = to || from;
  from = path.join(tpl, from);
  fs.createReadStream(from).pipe(fs.createWriteStream(to));
}
922211
def copy(self):
        """"""
        params = {}
        for key, val in self.__dict__.items():
            if 'matrix' not in key:
                k = key[1:] if key[0] == '_' else key
                params[k] = val
        # params = {param: params[param] for param in params}
        return self.__class__(**params)
1318147
def apply_to_vector(self, vector):
        
        if isinstance(vector, np.ndarray):
            vector = vector.tolist()

        libfn = utils.get_lib_fn('transformVector%s' % (self._libsuffix))
        return np.asarray(libfn(self.pointer, vector))
337495
def append_vector(self, name, vector, _left=False):
        """"""
        if np.issubdtype(vector.dtype, np.integer):
            # determine the length we need
            largest = str(max(vector.max(), vector.min(), key=abs))
            length = max(len(largest), min(7, len(name)))  # how many spaces we need to represent

            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                return str(getattr(datum, name)).rjust(length)
        elif np.issubdtype(vector.dtype, np.floating):
            largest = np.format_float_positional(max(vector.max(), vector.min(), key=abs),
                                                 precision=6, trim='0')
            length = max(len(largest), min(7, len(name)))  # how many spaces we need to represent
            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                return np.format_float_positional(getattr(datum, name),
                                                  precision=6, trim='0',
                                                  ).rjust(length)
        else:
            length = 7
            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                r = repr(getattr(datum, name))
                if len(r) > length:
                    r = r[:length-3] + '...'
                return r.rjust(length)

        self.append(header, f, _left=_left)
1374819
def insert_vector(indexes, val)
      new_index = @index.add(*indexes)
      # May be create +=
      (new_index.size - @index.size).times { @data << val }
      @index = new_index
    end
160809
def component_mul(vec1, vec2):
        """"""
        new_vec = Vector2()
        new_vec.X = vec1.X * vec2.X
        new_vec.Y = vec1.Y * vec2.Y
        return new_vec
1373510
public void copyFrom(Frame<ValueType> other) {
        lastUpdateTimestamp = other.lastUpdateTimestamp;
        slotList = new ArrayList<>(other.slotList);
        isTop = other.isTop;
        isBottom = other.isBottom;
    }
607369
def copy(self):
        
        vec = np.copy(self._vec)
        return ScalarCoefs(vec, self.nmax, self.mmax)
930890
def __create_vector(self, *vec) -> Vector3:
        
        import numbers

        if len(vec) == 1:
            if hasattr(vec[0], "__getitem__"):  # Support all subscriptable types.
                try:
                    x = float(vec[0][0])
                    y = float(vec[0][1])
                    try:
                        z = float(vec[0][2])
                    except (ValueError, IndexError):
                        z = 0
                except ValueError:
                    raise ValueError(f"Unexpected type(s) for creating vector: {type(vec[0][0])}, {type(vec[0][1])}")
                except IndexError:
                    raise IndexError(f"Unexpected IndexError when creating vector from type: {type(vec[0])}")
            elif isinstance(vec[0], Vector3.Vector3):
                x = vec[0].X()
                y = vec[0].Y()
                z = vec[0].Z()
            elif isinstance(vec[0], GameDataStructVector3):
                x = vec[0].x
                y = vec[0].y
                z = vec[0].z
            else:
                raise ValueError(f"Unexpected type for creating vector: {type(vec[0])}")
        elif len(vec) == 2 or len(vec) == 3:
            if isinstance(vec[0], numbers.Number) and isinstance(vec[1], numbers.Number):
                x = vec[0]
                y = vec[1]
                if len(vec) == 2:
                    z = 0
                else:
                    if isinstance(vec[2], numbers.Number):
                        z = vec[2]
                    else:
                        raise ValueError(f"Unexpected type for creating vector: {type(vec[0])}")
            else:
                raise ValueError(f"Unexpected type(s) for creating vector: {type(vec[0])}, {type(vec[1])}")
        else:
            raise ValueError("Unexpected number of arguments for creating vector")

        return Vector3.CreateVector3(self.builder, x, y, z)
566007
function (data, noRoam, out) {
        var transform = noRoam ? this._rawTransform : this.transform;
        out = out || [];
        return transform
            ? v2ApplyTransform(out, data, transform)
            : vector.copy(out, data);
    }
1061078
def as_length(self, value):
        """"""
        new_vec = self.copy()
        new_vec.length = value
        return new_vec
1002022
def cross(self, vec):
        """"""
        if not isinstance(vec, Vector3Array):
            raise TypeError('Cross product operand must be a Vector3Array')
        if self.nV != 1 and vec.nV != 1 and self.nV != vec.nV:
            raise ValueError('Cross product operands must have the same '
                             'number of elements.')
        return Vector3Array(np.cross(self, vec))
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;
    }
263940
public void copyTo(Matrix other)
    {
        if (this.rows() != other.rows() || this.cols() != other.cols())
            throw new ArithmeticException("Matrices are not of the same dimension");
        for(int i = 0; i < rows(); i++)
            this.getRowView(i).copyTo(other.getRowView(i));
    }