Package org.carrot2.math.matrix
Class PartialSingularValueDecomposition
java.lang.Object
org.carrot2.math.matrix.PartialSingularValueDecomposition
- All Implemented Interfaces:
MatrixFactorization
Performs matrix factorization using the Singular Value Decomposition algorithm.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.carrot2.math.mahout.matrix.DoubleMatrix2D
Input matrixprotected static final int
The default number of desired base vectorsprotected int
The desired number of base vectorsprotected org.carrot2.math.mahout.matrix.DoubleMatrix2D
Base vector result matrixprotected org.carrot2.math.mahout.matrix.DoubleMatrix2D
Coefficient result matrix -
Constructor Summary
ConstructorsConstructorDescriptionPartialSingularValueDecomposition
(org.carrot2.math.mahout.matrix.DoubleMatrix2D A) Computes a partial SVD of a matrix. -
Method Summary
Modifier and TypeMethodDescriptionvoid
compute()
Computes the factorization.int
getK()
Returns the number of base vectors k .double[]
Returns singular values of the matrix.org.carrot2.math.mahout.matrix.DoubleMatrix2D
getU()
Returns the U matrix (base vectors matrix).org.carrot2.math.mahout.matrix.DoubleMatrix2D
getV()
Returns the V matrix (coefficient matrix)void
setK
(int k) Sets the number of base vectors k .toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.carrot2.math.matrix.MatrixFactorization
getU, getV
-
Field Details
-
k
protected int kThe desired number of base vectors -
DEFAULT_K
protected static final int DEFAULT_KThe default number of desired base vectors- See Also:
-
A
protected org.carrot2.math.mahout.matrix.DoubleMatrix2D AInput matrix -
U
protected org.carrot2.math.mahout.matrix.DoubleMatrix2D UBase vector result matrix -
V
protected org.carrot2.math.mahout.matrix.DoubleMatrix2D VCoefficient result matrix
-
-
Constructor Details
-
PartialSingularValueDecomposition
public PartialSingularValueDecomposition(org.carrot2.math.mahout.matrix.DoubleMatrix2D A) Computes a partial SVD of a matrix. Before accessing results, perform computations by calling thecompute()
method.- Parameters:
A
- matrix to be factorized
-
-
Method Details
-
compute
public void compute()Computes the factorization. -
toString
-
getSingularValues
public double[] getSingularValues()Returns singular values of the matrix. -
setK
public void setK(int k) Sets the number of base vectors k .- Parameters:
k
- the number of base vectors
-
getK
public int getK()Returns the number of base vectors k . -
getU
public org.carrot2.math.mahout.matrix.DoubleMatrix2D getU()Description copied from interface:MatrixFactorization
Returns the U matrix (base vectors matrix).- Specified by:
getU
in interfaceMatrixFactorization
- Returns:
- U matrix
-
getV
public org.carrot2.math.mahout.matrix.DoubleMatrix2D getV()Description copied from interface:MatrixFactorization
Returns the V matrix (coefficient matrix)- Specified by:
getV
in interfaceMatrixFactorization
- Returns:
- V matrix
-