Class SparseDoubleVector

  • All Implemented Interfaces:
    org.api4.java.common.math.IVector

    public class SparseDoubleVector
    extends AbstractVector
    Sparse vector implementation wrapping the MTJ implementation of a sparse vector.
    • Field Detail

      • internalVector

        protected no.uib.cipr.matrix.sparse.SparseVector internalVector
    • Constructor Detail

      • SparseDoubleVector

        public SparseDoubleVector​(int[] indices,
                                  double[] values,
                                  int dimension)
        Creates a new SparseDoubleVector which contains the given values.
        Parameters:
        indices - An array which includes all indices for which there exists a value.
        values - An array which contains all values.
        dimension - The total dimension of the vector.
      • SparseDoubleVector

        public SparseDoubleVector​(int dimension)
        Creates a new SparseDoubleVector which contains only zero values.
        Parameters:
        dimension - The dimension of the vector.
      • SparseDoubleVector

        public SparseDoubleVector​(double[] data)
        Creates a new SparseDoubleVector which contains the given values.
        Parameters:
        data - A double array, which can be interpreted as a vector.
      • SparseDoubleVector

        public SparseDoubleVector​(no.uib.cipr.matrix.sparse.SparseVector mtjVector)
        Creates a new SparseDoubleVector from an MTJ SparseVector.
        Parameters:
        mtjVector - The MTJ vector.
    • Method Detail

      • addVector

        public void addVector​(double[] vectorAsArray)
      • subtractVector

        public void subtractVector​(double[] vectorAsArray)
      • multiplyByVectorPairwise

        public void multiplyByVectorPairwise​(double[] vectorAsArray)
      • divideByVectorPairwise

        public void divideByVectorPairwise​(double[] vectorAsArray)
      • dotProduct

        public double dotProduct​(double[] vectorAsArray)
      • length

        public int length()
      • getValue

        public double getValue​(int index)
      • setValue

        public void setValue​(int index,
                             double value)
      • addVector

        public void addVector​(org.api4.java.common.math.IVector vector)
      • subtractVector

        public void subtractVector​(org.api4.java.common.math.IVector vector)
      • multiplyByVectorPairwise

        public void multiplyByVectorPairwise​(org.api4.java.common.math.IVector secondVector)
      • multiplyByConstant

        public void multiplyByConstant​(double constant)
      • divideByVectorPairwise

        public void divideByVectorPairwise​(org.api4.java.common.math.IVector secondVector)
      • divideByConstant

        public void divideByConstant​(double constant)
      • dotProduct

        public double dotProduct​(org.api4.java.common.math.IVector vector)
      • isSparse

        public boolean isSparse()
      • asArray

        public double[] asArray()
      • duplicate

        public org.api4.java.common.math.IVector duplicate()
      • normalize

        public void normalize()
      • addConstant

        public void addConstant​(double constant)
      • subtractConstant

        public void subtractConstant​(double constant)
      • fillRandomly

        public void fillRandomly()
      • getNonZeroIndices

        public int[] getNonZeroIndices()
        Returns an array containing the non-zero indices of this sparse vector.
        Returns:
        an integer array containing the non-zero indices of this sparse vector
      • kroneckerProduct

        public org.api4.java.common.math.IVector kroneckerProduct​(double[] vectorAsArray)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class AbstractVector