org.carrot2.matrix.factorization
Class PartialSingularValueDecomposition

java.lang.Object
  extended by org.carrot2.matrix.factorization.PartialSingularValueDecomposition
All Implemented Interfaces:
IMatrixFactorization

public class PartialSingularValueDecomposition
extends Object
implements IMatrixFactorization

Performs matrix factorization using the Singular Value Decomposition algorithm.


Field Summary
protected  org.apache.mahout.math.matrix.DoubleMatrix2D A
          Input matrix
protected static int DEFAULT_K
          The default number of desired base vectors
protected  int k
          The desired number of base vectors
protected  org.apache.mahout.math.matrix.DoubleMatrix2D U
          Base vector result matrix
protected  org.apache.mahout.math.matrix.DoubleMatrix2D V
          Coefficient result matrix
 
Constructor Summary
PartialSingularValueDecomposition(org.apache.mahout.math.matrix.DoubleMatrix2D A)
          Computes a partial SVD of a matrix.
 
Method Summary
 void compute()
          Computes the factorization.
 int getK()
          Returns the number of base vectors k .
 double[] getSingularValues()
          Returns singular values of the matrix.
 org.apache.mahout.math.matrix.DoubleMatrix2D getU()
          Returns the U matrix (base vectors matrix).
 org.apache.mahout.math.matrix.DoubleMatrix2D getV()
          Returns the V matrix (coefficient matrix)
 void setK(int k)
          Sets the number of base vectors k .
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.carrot2.matrix.factorization.IMatrixFactorization
getU, getV
 

Field Detail

k

protected int k
The desired number of base vectors


DEFAULT_K

protected static final int DEFAULT_K
The default number of desired base vectors

See Also:
Constant Field Values

A

protected org.apache.mahout.math.matrix.DoubleMatrix2D A
Input matrix


U

protected org.apache.mahout.math.matrix.DoubleMatrix2D U
Base vector result matrix


V

protected org.apache.mahout.math.matrix.DoubleMatrix2D V
Coefficient result matrix

Constructor Detail

PartialSingularValueDecomposition

public PartialSingularValueDecomposition(org.apache.mahout.math.matrix.DoubleMatrix2D A)
Computes a partial SVD of a matrix. Before accessing results, perform computations by calling the compute()method.

Parameters:
A - matrix to be factorized
Method Detail

compute

public void compute()
Computes the factorization.


toString

public String toString()
Overrides:
toString in class Object

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.apache.mahout.math.matrix.DoubleMatrix2D getU()
Description copied from interface: IMatrixFactorization
Returns the U matrix (base vectors matrix).

Specified by:
getU in interface IMatrixFactorization
Returns:
U matrix

getV

public org.apache.mahout.math.matrix.DoubleMatrix2D getV()
Description copied from interface: IMatrixFactorization
Returns the V matrix (coefficient matrix)

Specified by:
getV in interface IMatrixFactorization
Returns:
V matrix


Copyright (c) Dawid Weiss, Stanislaw Osinski