public class SparseDoubleVector extends AbstractVector
| Modifier and Type | Field and Description |
|---|---|
protected no.uib.cipr.matrix.sparse.SparseVector |
internalVector |
| Constructor and Description |
|---|
SparseDoubleVector(double[] data)
Creates a new SparseDoubleVector which contains the given values.
|
SparseDoubleVector(int dimension)
Creates a new SparseDoubleVector which contains only zero values.
|
SparseDoubleVector(int[] indices,
double[] values,
int dimension)
Creates a new SparseDoubleVector which contains the given values.
|
SparseDoubleVector(no.uib.cipr.matrix.sparse.SparseVector mtjVector)
Creates a new SparseDoubleVector from an MTJ
SparseVector. |
| Modifier and Type | Method and Description |
|---|---|
void |
addConstant(double constant)
Adds the given constant to this vector.
|
void |
addVector(double[] vectorAsArray)
Adds the given double array interpreted as a vector to this vector.
|
void |
addVector(Vector vector)
Adds the given vector to this vector.
|
double[] |
asArray()
Returns this vector as a double array.
|
void |
divideByConstant(double constant)
Divides this vector by the given constant.
|
void |
divideByVectorPairwise(double[] vectorAsArray)
Divides this vector by the given double array interpreted as a pairwise
vector and stores the result in this vector.
|
void |
divideByVectorPairwise(Vector secondVector)
Divides this vector by the given pairwise vector and stores the result in
this vector.
|
double |
dotProduct(double[] vectorAsArray)
Computes the dot product of the given vector and this vector.
|
double |
dotProduct(Vector vector)
Computes the dot product of the given vector and this vector.
|
Vector |
duplicate()
Creates a deep copy of this vector.
|
boolean |
equals(java.lang.Object obj) |
void |
fillRandomly()
Fills this vector with random values from the unit interval.
|
int[] |
getNonZeroIndices()
Returns an array containing the non-zero indices of this sparse vector.
|
double |
getValue(int index)
Returns the value at the given index of this vector.
|
int |
hashCode() |
boolean |
isSparse()
Checks if this vector is sparse.
|
Vector |
kroneckerProduct(double[] vectorAsArray)
Computes the kronecker product of this vector (v) with the given vector (w).
|
int |
length()
Returns the number of dimensions of this vector.
|
void |
multiplyByConstant(double constant)
Multiplies this vector with the given constant.
|
void |
multiplyByVectorPairwise(double[] vectorAsArray)
Multiplies this vector with the given double array interpreted as a pairwise
vector and stores the result in this vector.
|
void |
multiplyByVectorPairwise(Vector secondVector)
Multiplies this vector with the given vector pairwisely and stores the result
in this vector.
|
void |
normalize()
Normalizes this vector to the unit interval.
|
void |
setValue(int index,
double value)
Sets the value at the given index of this vector to the given value.
|
void |
subtractConstant(double constant)
Subtracts the given constant from this vector.
|
void |
subtractVector(double[] vectorAsArray)
Subtracts the given double array interpreted as a vector from this vector.
|
void |
subtractVector(Vector vector)
Subtracts the given vector from this vector.
|
DenseDoubleVector |
toDenseVector()
Returns this vector as
DenseDoubleVector. |
SparseDoubleVector |
toSparseVector()
Returns this vector as
SparseDoubleVector. |
addConstantToCopy, addVectorToCopy, addVectorToCopy, average, divideByConstantToCopy, divideByVectorPairwiseToCopy, divideByVectorPairwiseToCopy, euclideanNorm, incrementValueAt, kroneckerProductInternal, mean, multiplyByConstantToCopy, multiplyByVectorPairwiseToCopy, multiplyByVectorPairwiseToCopy, squareRoot, squareRootToCopy, standardDeviation, subtractConstantFromCopy, subtractVectorFromCopy, subtractVectorFromCopy, sum, toString, zeroAllDimensionspublic SparseDoubleVector(int[] indices,
double[] values,
int dimension)
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.public SparseDoubleVector(int dimension)
dimension - The dimension of the vector.public SparseDoubleVector(double[] data)
data - A double array, which can be interpreted as a vector.public SparseDoubleVector(no.uib.cipr.matrix.sparse.SparseVector mtjVector)
SparseVector.mtjVector - The MTJ vector.public void addVector(double[] vectorAsArray)
VectorvectorAsArray - The vector to be added as array.public void subtractVector(double[] vectorAsArray)
VectorvectorAsArray - The vector to be subtracted as an array.public void multiplyByVectorPairwise(double[] vectorAsArray)
VectorvectorAsArray - The vector to be multiplied with.public void divideByVectorPairwise(double[] vectorAsArray)
VectorvectorAsArray - The vector to be divided by.public double dotProduct(double[] vectorAsArray)
VectorvectorAsArray - The vector to compute dot product with.public int length()
Vectorpublic double getValue(int index)
Vectorindex - The index of the value to look for.public void setValue(int index,
double value)
Vectorindex - The index to set the value at.value - The value to be set at the specified index.public void addVector(Vector vector)
Vectorvector - The vector to be added to this vector.public void subtractVector(Vector vector)
Vectorvector - The vector to subtract from this vector.public void multiplyByVectorPairwise(Vector secondVector)
VectorsecondVector - The vector to be multiplied with.public void multiplyByConstant(double constant)
Vectorconstant - The constant to multiply this vector with.public void divideByVectorPairwise(Vector secondVector)
VectorsecondVector - The vector to be divided by.public void divideByConstant(double constant)
Vectorconstant - The constant to divide this vector by.public double dotProduct(Vector vector)
Vectorvector - The vector to compute dot product with.public boolean isSparse()
Vectortrue, if this vector is sparse, false if not.public double[] asArray()
Vectorpublic DenseDoubleVector toDenseVector()
VectorDenseDoubleVector.public SparseDoubleVector toSparseVector()
VectorSparseDoubleVector.public Vector duplicate()
Vectorpublic void normalize()
Vectorpublic void addConstant(double constant)
Vectorconstant - The constant to be added.public void subtractConstant(double constant)
Vectorconstant - The constant to be subtracted.public void fillRandomly()
Vectorpublic int[] getNonZeroIndices()
public Vector kroneckerProduct(double[] vectorAsArray)
VectorvectorAsArray - the vector to perform the kronecker product with. i.e. the
right-hand operandpublic int hashCode()
hashCode in class AbstractVectorpublic boolean equals(java.lang.Object obj)
equals in class AbstractVector