Class AbstractRealVector

    • Constructor Detail

      • AbstractRealVector

        public AbstractRealVector()
    • Method Detail

      • add

        public RealVector add​(double[] v)
                       throws java.lang.IllegalArgumentException
        Compute the sum of this vector and v.
        Specified by:
        add in interface RealVector
        Parameters:
        v - Vector to be added.
        Returns:
        this + v.
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • add

        public RealVector add​(RealVector v)
                       throws java.lang.IllegalArgumentException
        Compute the sum of this vector and v.
        Specified by:
        add in interface RealVector
        Parameters:
        v - Vector to be added.
        Returns:
        this + v.
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • subtract

        public RealVector subtract​(double[] v)
                            throws java.lang.IllegalArgumentException
        Subtract v from this vector.
        Specified by:
        subtract in interface RealVector
        Parameters:
        v - Vector to be subtracted.
        Returns:
        this - v.
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • subtract

        public RealVector subtract​(RealVector v)
                            throws java.lang.IllegalArgumentException
        Subtract v from this vector.
        Specified by:
        subtract in interface RealVector
        Parameters:
        v - Vector to be subtracted.
        Returns:
        this - v.
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • mapAdd

        public RealVector mapAdd​(double d)
        Add a value to each entry.
        Specified by:
        mapAdd in interface RealVector
        Parameters:
        d - Value to be added to each entry.
        Returns:
        this + d.
      • mapAddToSelf

        public RealVector mapAddToSelf​(double d)
        Add a value to each entry. The instance is changed in-place.
        Specified by:
        mapAddToSelf in interface RealVector
        Parameters:
        d - Value to be added to each entry.
        Returns:
        this.
      • dotProduct

        public double dotProduct​(double[] v)
                          throws java.lang.IllegalArgumentException
        Compute the dot product.
        Specified by:
        dotProduct in interface RealVector
        Parameters:
        v - vector with which dot product should be computed
        Returns:
        the scalar dot product between instance and v
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • dotProduct

        public double dotProduct​(RealVector v)
                          throws java.lang.IllegalArgumentException
        Compute the dot product.
        Specified by:
        dotProduct in interface RealVector
        Parameters:
        v - vector with which dot product should be computed
        Returns:
        the scalar dot product between instance and v
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • ebeDivide

        public RealVector ebeDivide​(double[] v)
                             throws java.lang.IllegalArgumentException
        Element-by-element division.
        Specified by:
        ebeDivide in interface RealVector
        Parameters:
        v - vector by which instance elements must be divided
        Returns:
        a vector containing this[i] / v[i] for all i
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • ebeMultiply

        public RealVector ebeMultiply​(double[] v)
                               throws java.lang.IllegalArgumentException
        Element-by-element multiplication.
        Specified by:
        ebeMultiply in interface RealVector
        Parameters:
        v - vector by which instance elements must be multiplied
        Returns:
        a vector containing this[i] * v[i] for all i
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • getMinIndex

        public int getMinIndex()
        Get the index of the minimum entry.
        Returns:
        index of the minimum entry or -1 if vector length is 0 or all entries are NaN
      • getMinValue

        public double getMinValue()
        Get the value of the minimum entry.
        Returns:
        value of the minimum entry or NaN if all entries are NaN
      • getMaxIndex

        public int getMaxIndex()
        Get the index of the maximum entry.
        Returns:
        index of the maximum entry or -1 if vector length is 0 or all entries are NaN
      • getMaxValue

        public double getMaxValue()
        Get the value of the maximum entry.
        Returns:
        value of the maximum entry or NaN if all entries are NaN
      • mapAbs

        public RealVector mapAbs()
        Map the Math.abs(double) function to each entry.
        Specified by:
        mapAbs in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapAbsToSelf

        public RealVector mapAbsToSelf()
        Map the Math.abs(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapAbsToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapAcos

        public RealVector mapAcos()
        Map the Math.acos(double) function to each entry.
        Specified by:
        mapAcos in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapAcosToSelf

        public RealVector mapAcosToSelf()
        Map the Math.acos(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapAcosToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapAsin

        public RealVector mapAsin()
        Map the Math.asin(double) function to each entry.
        Specified by:
        mapAsin in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapAsinToSelf

        public RealVector mapAsinToSelf()
        Map the Math.asin(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapAsinToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapAtan

        public RealVector mapAtan()
        Map the Math.atan(double) function to each entry.
        Specified by:
        mapAtan in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapAtanToSelf

        public RealVector mapAtanToSelf()
        Map the Math.atan(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapAtanToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapCbrt

        public RealVector mapCbrt()
        Map the Math.cbrt(double) function to each entry.
        Specified by:
        mapCbrt in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapCbrtToSelf

        public RealVector mapCbrtToSelf()
        Map the Math.cbrt(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapCbrtToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapCeil

        public RealVector mapCeil()
        Map the Math.ceil(double) function to each entry.
        Specified by:
        mapCeil in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapCeilToSelf

        public RealVector mapCeilToSelf()
        Map the Math.ceil(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapCeilToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapCos

        public RealVector mapCos()
        Map the Math.cos(double) function to each entry.
        Specified by:
        mapCos in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapCosToSelf

        public RealVector mapCosToSelf()
        Map the Math.cos(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapCosToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapCosh

        public RealVector mapCosh()
        Map the Math.cosh(double) function to each entry.
        Specified by:
        mapCosh in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapCoshToSelf

        public RealVector mapCoshToSelf()
        Map the Math.cosh(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapCoshToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapDivide

        public RealVector mapDivide​(double d)
        Divide each entry.
        Specified by:
        mapDivide in interface RealVector
        Parameters:
        d - Value to divide by.
        Returns:
        this / d.
      • mapDivideToSelf

        public RealVector mapDivideToSelf​(double d)
        Divide each entry. The instance is changed in-place.
        Specified by:
        mapDivideToSelf in interface RealVector
        Parameters:
        d - Value to divide by.
        Returns:
        this.
      • mapExp

        public RealVector mapExp()
        Map the Math.exp(double) function to each entry.
        Specified by:
        mapExp in interface RealVector
        Returns:
        a mapped copy of the vector.
      • mapExpToSelf

        public RealVector mapExpToSelf()
        Map Math.exp(double) operation to each entry. The instance is changed in-place.
        Specified by:
        mapExpToSelf in interface RealVector
        Returns:
        the mapped vector.
      • mapExpm1

        public RealVector mapExpm1()
        Map the Math.expm1(double) function to each entry.
        Specified by:
        mapExpm1 in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapExpm1ToSelf

        public RealVector mapExpm1ToSelf()
        Map the Math.expm1(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapExpm1ToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapFloor

        public RealVector mapFloor()
        Map the Math.floor(double) function to each entry.
        Specified by:
        mapFloor in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapFloorToSelf

        public RealVector mapFloorToSelf()
        Map the Math.floor(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapFloorToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapInv

        public RealVector mapInv()
        Map the 1/x function to each entry.
        Specified by:
        mapInv in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapInvToSelf

        public RealVector mapInvToSelf()
        Map the 1/x function to each entry.

        The instance is changed by this method.

        Specified by:
        mapInvToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapLog

        public RealVector mapLog()
        Map the Math.log(double) function to each entry.
        Specified by:
        mapLog in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapLogToSelf

        public RealVector mapLogToSelf()
        Map the Math.log(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapLogToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapLog10

        public RealVector mapLog10()
        Map the Math.log10(double) function to each entry.
        Specified by:
        mapLog10 in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapLog10ToSelf

        public RealVector mapLog10ToSelf()
        Map the Math.log10(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapLog10ToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapLog1p

        public RealVector mapLog1p()
        Map the Math.log1p(double) function to each entry.
        Specified by:
        mapLog1p in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapLog1pToSelf

        public RealVector mapLog1pToSelf()
        Map the Math.log1p(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapLog1pToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapMultiply

        public RealVector mapMultiply​(double d)
        Multiply each entry.
        Specified by:
        mapMultiply in interface RealVector
        Parameters:
        d - Multiplication factor.
        Returns:
        this * d.
      • mapMultiplyToSelf

        public RealVector mapMultiplyToSelf​(double d)
        Multiply each entry. The instance is changed in-place.
        Specified by:
        mapMultiplyToSelf in interface RealVector
        Parameters:
        d - Multiplication factor.
        Returns:
        this.
      • mapPow

        public RealVector mapPow​(double d)
        Map a power operation to each entry.
        Specified by:
        mapPow in interface RealVector
        Parameters:
        d - Operator value.
        Returns:
        a mapped copy of the vector.
      • mapPowToSelf

        public RealVector mapPowToSelf​(double d)
        Map a power operation to each entry. The instance is changed in-place.
        Specified by:
        mapPowToSelf in interface RealVector
        Parameters:
        d - Operator value.
        Returns:
        the mapped vector.
      • mapRint

        public RealVector mapRint()
        Map the Math.rint(double) function to each entry.
        Specified by:
        mapRint in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapRintToSelf

        public RealVector mapRintToSelf()
        Map the Math.rint(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapRintToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapSignum

        public RealVector mapSignum()
        Map the Math.signum(double) function to each entry.
        Specified by:
        mapSignum in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapSignumToSelf

        public RealVector mapSignumToSelf()
        Map the Math.signum(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapSignumToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapSin

        public RealVector mapSin()
        Map the Math.sin(double) function to each entry.
        Specified by:
        mapSin in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapSinToSelf

        public RealVector mapSinToSelf()
        Map the Math.sin(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapSinToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapSinh

        public RealVector mapSinh()
        Map the Math.sinh(double) function to each entry.
        Specified by:
        mapSinh in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapSinhToSelf

        public RealVector mapSinhToSelf()
        Map the Math.sinh(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapSinhToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapSqrt

        public RealVector mapSqrt()
        Map the Math.sqrt(double) function to each entry.
        Specified by:
        mapSqrt in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapSqrtToSelf

        public RealVector mapSqrtToSelf()
        Map the Math.sqrt(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapSqrtToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapSubtract

        public RealVector mapSubtract​(double d)
        Subtract a value from each entry.
        Specified by:
        mapSubtract in interface RealVector
        Parameters:
        d - Value to be subtracted.
        Returns:
        this - d.
      • mapSubtractToSelf

        public RealVector mapSubtractToSelf​(double d)
        Subtract a value from each entry. The instance is changed in-place.
        Specified by:
        mapSubtractToSelf in interface RealVector
        Parameters:
        d - Value to be subtracted.
        Returns:
        this.
      • mapTan

        public RealVector mapTan()
        Map the Math.tan(double) function to each entry.
        Specified by:
        mapTan in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapTanToSelf

        public RealVector mapTanToSelf()
        Map the Math.tan(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapTanToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapTanh

        public RealVector mapTanh()
        Map the Math.tanh(double) function to each entry.
        Specified by:
        mapTanh in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapTanhToSelf

        public RealVector mapTanhToSelf()
        Map the Math.tanh(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapTanhToSelf in interface RealVector
        Returns:
        for convenience, return this
      • mapUlp

        public RealVector mapUlp()
        Map the Math.ulp(double) function to each entry.
        Specified by:
        mapUlp in interface RealVector
        Returns:
        a vector containing the result of applying the function to each entry
      • mapUlpToSelf

        public RealVector mapUlpToSelf()
        Map the Math.ulp(double) function to each entry.

        The instance is changed by this method.

        Specified by:
        mapUlpToSelf in interface RealVector
        Returns:
        for convenience, return this
      • outerProduct

        public RealMatrix outerProduct​(RealVector v)
                                throws java.lang.IllegalArgumentException
        Compute the outer product.
        Specified by:
        outerProduct in interface RealVector
        Parameters:
        v - vector with which outer product should be computed
        Returns:
        the square matrix outer product between instance and v
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • outerProduct

        public RealMatrix outerProduct​(double[] v)
                                throws java.lang.IllegalArgumentException
        Compute the outer product.
        Specified by:
        outerProduct in interface RealVector
        Parameters:
        v - vector with which outer product should be computed
        Returns:
        the square matrix outer product between instance and v
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • projection

        public RealVector projection​(double[] v)
                              throws java.lang.IllegalArgumentException
        Find the orthogonal projection of this vector onto another vector.
        Specified by:
        projection in interface RealVector
        Parameters:
        v - vector onto which instance must be projected
        Returns:
        projection of the instance onto v
        Throws:
        DimensionMismatchException - if v is not the same size as this vector.
        java.lang.IllegalArgumentException
      • set

        public void set​(double value)
        Set all elements to a single value.
        Specified by:
        set in interface RealVector
        Parameters:
        value - single value to set for all elements
      • toArray

        public double[] toArray()
        Convert the vector to a double array.

        The array is independent from vector data, it's elements are copied.

        Specified by:
        toArray in interface RealVector
        Returns:
        array containing a copy of vector elements
      • getData

        public double[] getData()
        Returns vector entries as a double array.
        Specified by:
        getData in interface RealVector
        Returns:
        double array of entries
      • unitVector

        public RealVector unitVector()
        Creates a unit vector pointing in the direction of this vector.

        The instance is not changed by this method.

        Specified by:
        unitVector in interface RealVector
        Returns:
        a unit vector pointing in direction of this vector
      • unitize

        public void unitize()
        Converts this vector into a unit vector.

        The instance itself is changed by this method.

        Specified by:
        unitize in interface RealVector
      • sparseIterator

        public java.util.Iterator<RealVector.Entry> sparseIterator()
        Specialized implementations may choose to not iterate over all dimensions, either because those values are unset, or are equal to defaultValue(), or are small enough to be ignored for the purposes of iteration. No guarantees are made about order of iteration. In dense implementations, this method will often delegate to RealVector.iterator().
        Specified by:
        sparseIterator in interface RealVector
        Returns:
        a sparse iterator
      • iterator

        public java.util.Iterator<RealVector.Entry> iterator()
        Generic dense iterator. It iterates in increasing order of the vector index.
        Specified by:
        iterator in interface RealVector
        Returns:
        a dense iterator