Package cc.mallet.types
Class IndexedSparseVector
- java.lang.Object
-
- cc.mallet.types.SparseVector
-
- cc.mallet.types.IndexedSparseVector
-
- All Implemented Interfaces:
ConstantMatrix
,Vector
,java.io.Serializable
public class IndexedSparseVector extends SparseVector implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class cc.mallet.types.SparseVector
hasInfinite, indices, values
-
-
Constructor Summary
Constructors Constructor Description IndexedSparseVector()
Create an empty vectorIndexedSparseVector(int[] featureIndices)
Create binary vectorIndexedSparseVector(int[] featureIndices, double[] values)
Create non-binary vector, possibly dense if "featureIndices" or possibly sparse, if notIndexedSparseVector(int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstantMatrix
cloneMatrix()
CLONINGConstantMatrix
cloneMatrixZeroed()
void
columnPlusEquals(int index, double value)
double
dotProduct(DenseVector v)
double
dotProduct(SparseVector v)
void
indexVector()
int
location(int index)
void
plusEqualsSparse(SparseVector v)
For each index i that is present in this vector, set this[i] += v[i].void
plusEqualsSparse(SparseVector v, double factor)
For each index i that is present in this vector, set this[i] += factor * v[i].void
setAll(double v)
Sets every present index in the vector to v.void
setValue(int index, double value)
Sets the value at the given index.void
setValueAtLocation(int location, double value)
Sets the value at the given location.-
Methods inherited from class cc.mallet.types.SparseVector
absNorm, addTo, addTo, arrayCopyFrom, arrayCopyFrom, arrayCopyInto, dotProduct, dotProduct, extendedDotProduct, extendedDotProduct, getDimensions, getIndices, getNumDimensions, getValues, incrementValue, indexAtLocation, infinityNorm, isBinary, isInfinite, isNaN, isNaNOrInfinite, makeBinary, makeNonBinary, map, numLocations, oneNorm, print, removeDuplicates, singleIndex, singleSize, singleToIndices, singleValue, sortIndices, timesEquals, timesEqualsSparse, timesEqualsSparse, timesEqualsSparseZero, toString, toString, twoNorm, value, value, valueAtLocation, vectorAdd
-
-
-
-
Constructor Detail
-
IndexedSparseVector
public IndexedSparseVector(int[] indices, double[] values, int capacity, int size, boolean copy, boolean checkIndicesSorted, boolean removeDuplicates)
-
IndexedSparseVector
public IndexedSparseVector()
Create an empty vector
-
IndexedSparseVector
public IndexedSparseVector(int[] featureIndices, double[] values)
Create non-binary vector, possibly dense if "featureIndices" or possibly sparse, if not
-
IndexedSparseVector
public IndexedSparseVector(int[] featureIndices)
Create binary vector
-
-
Method Detail
-
cloneMatrix
public ConstantMatrix cloneMatrix()
Description copied from class:SparseVector
CLONING- Specified by:
cloneMatrix
in interfaceConstantMatrix
- Overrides:
cloneMatrix
in classSparseVector
-
cloneMatrixZeroed
public ConstantMatrix cloneMatrixZeroed()
- Overrides:
cloneMatrixZeroed
in classSparseVector
-
indexVector
public void indexVector()
-
setValue
public final void setValue(int index, double value)
Description copied from class:SparseVector
Sets the value at the given index.- Overrides:
setValue
in classSparseVector
-
setValueAtLocation
public final void setValueAtLocation(int location, double value)
Description copied from class:SparseVector
Sets the value at the given location.- Overrides:
setValueAtLocation
in classSparseVector
-
columnPlusEquals
public void columnPlusEquals(int index, double value)
-
dotProduct
public final double dotProduct(DenseVector v)
- Overrides:
dotProduct
in classSparseVector
-
dotProduct
public final double dotProduct(SparseVector v)
- Overrides:
dotProduct
in classSparseVector
-
plusEqualsSparse
public final void plusEqualsSparse(SparseVector v, double factor)
Description copied from class:SparseVector
For each index i that is present in this vector, set this[i] += factor * v[i]. If v has indices that are not present in this, these are just ignored.- Overrides:
plusEqualsSparse
in classSparseVector
-
plusEqualsSparse
public final void plusEqualsSparse(SparseVector v)
Description copied from class:SparseVector
For each index i that is present in this vector, set this[i] += v[i]. If v has indices that are not present in this, these are just ignored.- Overrides:
plusEqualsSparse
in classSparseVector
-
setAll
public final void setAll(double v)
Description copied from class:SparseVector
Sets every present index in the vector to v.- Overrides:
setAll
in classSparseVector
-
location
public int location(int index)
- Specified by:
location
in interfaceConstantMatrix
- Overrides:
location
in classSparseVector
-
-