Documentation of 'mikera.vectorz.Vector2' Java class
Vector2
mikera.vectorz

Class Vector2

    • Field Detail

      • x

        public double x
      • y

        public double y
    • Constructor Detail

      • Vector2

        public Vector2()
      • Vector2

        public Vector2(double x,
                       double y)
    • Method Detail

      • of

        public static Vector2 of(double x,
                                 double y)
      • of

        public static Vector2 of(double... values)
      • applyOp

        public void applyOp(Op op)
        Description copied from interface: INDArray
        Applies a unary operator to all elements of the array (in-place)
        Specified by:
        applyOp in interface INDArray
        Overrides:
        applyOp in class AVector
      • reduce

        public double reduce(Op2 op,
                             double init)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the initial/previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • reduce

        public double reduce(Op2 op)
        Description copied from interface: INDArray
        Reduces over all elements of the array in row-major order. Applies the operator to the previous result at each step. Returns the final result.
        Specified by:
        reduce in interface INDArray
        Overrides:
        reduce in class AVector
      • isZero

        public boolean isZero()
        Description copied from class: AVector
        Returns true if this vector is a zero vector (all components zero)
        Specified by:
        isZero in interface INDArray
        Overrides:
        isZero in class AVector
      • add

        public void add(Vector2 v)
      • sub

        public void sub(Vector2 v)
      • addMultiple

        public void addMultiple(Vector2 v,
                                double factor)
      • addProduct

        public void addProduct(Vector2 a,
                               Vector2 b,
                               double factor)
      • dotProduct

        public double dotProduct(AVector a)
        Description copied from class: AVector
        Returns the dot product of this vector with another vector The vectors must have the same length: if not the result is undefined
        Overrides:
        dotProduct in class AVector
        Returns:
      • dotProduct

        public double dotProduct(double[] data,
                                 int offset)
        Description copied from class: AVector
        Fast dot product with a double[] array. Performs no bounds checking. Likely to be faster than most other dot product operations
        Specified by:
        dotProduct in class AVector
      • dotProduct

        public double dotProduct(Vector2 a)
      • scaleAdd

        public void scaleAdd(double factor,
                             double constant)
        Description copied from class: AVector
        Scales this vector and adds a constant to every element
        Specified by:
        scaleAdd in interface INDArray
        Overrides:
        scaleAdd in class AVector
      • scaleAdd

        public void scaleAdd(double factor,
                             AVector constant)
        Description copied from class: AVector
        Scales this vector then adds another vector
        Overrides:
        scaleAdd in class AVector
      • scaleAdd

        public void scaleAdd(double factor,
                             Vector2 constant)
      • complexMultiply

        public void complexMultiply(Vector2 a)
        Complex multiplication by another Vector2, treating an (x,y) vector as the complex value x+iy
        Parameters:
        a -
      • complexConjugate

        public Vector2 complexConjugate()
      • complexReciprocal

        public Vector2 complexReciprocal()
      • complexNegation

        public Vector2 complexNegation()
      • negate

        public void negate()
        Description copied from class: AVector
        Negates all emlements of this vector in place.
        Specified by:
        negate in interface INDArray
        Overrides:
        negate in class AVector
      • multiply

        public void multiply(double factor)
        Description copied from class: AVector
        Multiplies the vector by a constant factor
        Specified by:
        multiply in interface INDArray
        Overrides:
        multiply in class AVector
        Parameters:
        factor - Factor by which to multiply each component of the vector
      • add

        public void add(double constant)
        Description copied from interface: INDArray
        Adds a double value to all elements in this array. Implementations may optimize the case of 0.0
        Specified by:
        add in interface INDArray
        Overrides:
        add in class AVector
      • add

        public void add(double dx,
                        double dy)
      • add

        public void add(AVector v)
        Description copied from class: AVector
        Adds another vector to this one
        Overrides:
        add in class AVector
      • length

        public int length()
        Description copied from interface: IVector
        Returns the length of a vector, in terms of the number of elements. For Euclidean length, use magnitude() instead
        Specified by:
        length in interface IVector
        Specified by:
        length in class AVector
        Returns:
      • elementSum

        public double elementSum()
        Description copied from class: AVector
        Returns the sum of all elements in a vector
        Specified by:
        elementSum in interface INDArray
        Overrides:
        elementSum in class AVector
      • elementMax

        public double elementMax()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMax in interface INDArray
        Overrides:
        elementMax in class AVector
      • elementMin

        public double elementMin()
        Description copied from interface: INDArray
        Returns the maximum element value in this array. Throws an error if there are no elements.
        Specified by:
        elementMin in interface INDArray
        Overrides:
        elementMin in class AVector
      • magnitude

        public double magnitude()
        Description copied from class: AVector
        Returns the magnitude (Euclidean length) of the vector
        Overrides:
        magnitude in class AVector
        Returns:
      • get

        public double get(int i)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 1D vector
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IVector
        Specified by:
        get in class AVector
      • unsafeGet

        public double unsafeGet(int i)
        Description copied from class: AVector
        Like get, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeGet in class AVector
      • getElements

        public void getElements(double[] data,
                                int offset)
        Description copied from interface: INDArray
        Copies all elements of this array a double array at the specified offset
        Specified by:
        getElements in interface INDArray
        Overrides:
        getElements in class AVector
      • toDoubleBuffer

        public void toDoubleBuffer(java.nio.DoubleBuffer dest)
        Description copied from interface: INDArray
        Copies the elements of this INDArray to the specified double buffer.
        Specified by:
        toDoubleBuffer in interface INDArray
        Overrides:
        toDoubleBuffer in class AVector
      • toDoubleArray

        public double[] toDoubleArray()
        Description copied from interface: INDArray
        Copies the elements of this array to a new double[] array.
        Specified by:
        toDoubleArray in interface INDArray
        Overrides:
        toDoubleArray in class AVector
      • toNormal

        public Vector2 toNormal()
        Description copied from class: AVector
        Creates a new mutable vector representing the normalised value of this vector Returns null if the vector cannot be normalised (i.e. is a zero length vector)
        Overrides:
        toNormal in class APrimitiveVector
        Returns:
      • set

        public void set(int i,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 1D array
        Specified by:
        set in interface INDArray
        Specified by:
        set in interface IVector
        Specified by:
        set in class AVector
      • unsafeSet

        public void unsafeSet(int i,
                              double value)
        Description copied from class: AVector
        Like set, but performs no bounds checking. Results are undefined if the index is out of range
        Overrides:
        unsafeSet in class AVector
      • fill

        public void fill(double v)
        Description copied from class: AVector
        Fills the entire vector with a given value
        Specified by:
        fill in interface INDArray
        Overrides:
        fill in class AVector
      • addAt

        public void addAt(int i,
                          double value)
        Description copied from class: AVector
        Adds a value to a specific element of the vector This function does not perform bounds checking, i.e. is an unsafe operation
        Overrides:
        addAt in class AVector
      • rotate2D

        public void rotate2D(double angle)
        Rotates a 2D vector around the origin by a given angle in radians
        Parameters:
        angle -
      • rotate2DCopy

        public Vector2 rotate2DCopy(double angle)
        Rotates a 2D vector around the origin by a given angle in radians, returning a new Vector2
        Parameters:
        angle -
      • setValues

        public void setValues(double x,
                              double y)
      • clone

        public Vector2 clone()
        Description copied from class: AVector
        Clones the vector, creating a new mutable copy of all data. The clone is: - not guaranteed to be of the same type. - guaranteed to be fully mutable - guaranteed not to contain a reference (i.e. is a full deep copy)
        Specified by:
        clone in interface INDArray
        Specified by:
        clone in interface IVector
        Specified by:
        clone in class APrimitiveVector
      • equals

        public boolean equals(AVector v)
        Description copied from class: AbstractArray
        Returns true if this array is exactly equal to a vector.
        Overrides:
        equals in class AVector
        Returns:
      • equals

        public boolean equals(Vector2 v)
      • equalsArray

        public boolean equalsArray(double[] data,
                                   int offset)
        Description copied from class: AVector
        Returns true if this vector exactly matches the elements in double[] array, starting from the specified offset
        Specified by:
        equalsArray in interface INDArray
        Overrides:
        equalsArray in class AVector
        Parameters:
        data - Array of double element values to check for equality
        offset - Offset into the data array
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.