|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--idl.tmt.representation.matrix.TmtMatrix
Encapsulates matrix representation and manipulation via the colt library.
This class contains many constructors, allowing the initialization of matrix operations from a variety of data structures, allowing both sparse and dense representation.
To insulate users from the details of colt, a TmTMatrix contains functionality for basic data analysis. For example, the class can compute, store, and provide access to the SVD of the matrix it contains. Likewise it can pre- or post-multiply itself with another TmtMatrix.
| Field Summary | |
private boolean |
isSparse
|
private SingularValueDecomposition |
mySVD
|
protected DoubleMatrix2D |
theMatrix
|
| Constructor Summary | |
TmtMatrix(double[][] denseMatrix)
constructor for a dense matrix from a 2D array of doubles |
|
TmtMatrix(DoubleMatrix2D newMatrix)
constructor to build a matrix from a colt-formatted version |
|
TmtMatrix(int rows,
int cols,
java.util.ArrayList rowInd,
java.util.ArrayList colInd,
java.util.ArrayList values)
constructor for a sparse matrix from data stored in memory |
|
TmtMatrix(int rows,
int cols,
boolean sparse)
constructor for a basic zero matrix (dense) |
|
TmtMatrix(java.lang.String fileName,
boolean sparse)
constructor for reading a matrix (sparse or dense) from disk when we know the number of rows and columns beforehand |
|
TmtMatrix(java.lang.String fileName,
int rows,
int cols,
boolean sparse)
constructor for reading a matrix (sparse or dense) from disk when we know the number of rows and columns beforehand |
|
TmtMatrix(TmtMatrix m)
|
|
| Method Summary | |
TmtMatrix |
addMatrix(TmtMatrix b)
returns the matrix sum of this matrix with another matrix |
int |
columnCount()
access to the number of columns in the matrix |
TmtVector |
getColumn(int i)
get a column from the matrix |
TmtMatrix |
getColumnCentered()
returns column-centered version of the matrix |
TmtMatrix |
getColumnNormalized()
returns column-normalized (unit length) version of the matrix |
TmtMatrix |
getColumns(int start,
int end)
construct a new matrix containing a subset of the columns of this matrix |
TmtMatrix |
getCorrelationMatrix()
computes and returns the correlation matrix of this matrix |
TmtMatrix |
getLeftSingularVectors()
returns a TmtMatrix containing the left singular vectors of this matrix |
DoubleMatrix2D |
getMatrix()
|
TmtMatrix |
getRightSingularVectors()
returns a TmtMatrix containing the right singular vectors of this matrix |
TmtVector |
getRow(int i)
get a row from the matrix |
TmtMatrix |
getRows(int start,
int end)
construct a new matrix containing a subset of the columns of this matrix |
TmtMatrix |
getSingularValues()
returns a diagonal TmtMatrix containing the singular values of this matrix |
double |
getValue(int row,
int column)
|
TmtMatrix |
postMultiplyBy(TmtMatrix b)
postmultiply this matrix by another matrix B |
TmtMatrix |
preMultiplyBy(TmtMatrix b)
premuliply this matrix by another matrix B |
int |
rowCount()
access to the number of rows in the matrix |
TmtMatrix |
scalarMultiply(double d)
returns the product of this matrix times a scalar |
void |
showMatrix()
prints the matrix to stdout |
void |
svd()
computes the singular value decomposition for this matrix, storing the results as a member of this matrix's class |
Instances |
toWekaInstances()
converts this matrix into a set of Weka Instances for further processing. |
TmtMatrix |
transpose()
creates a new matrix that is the transpose of this one |
double |
zSum()
returns the sum of all elements of the matrix |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected DoubleMatrix2D theMatrix
private SingularValueDecomposition mySVD
private boolean isSparse
| Constructor Detail |
public TmtMatrix(int rows,
int cols,
boolean sparse)
rows - cols - sparse - public TmtMatrix(double[][] denseMatrix)
denseMatrix -
public TmtMatrix(int rows,
int cols,
java.util.ArrayList rowInd,
java.util.ArrayList colInd,
java.util.ArrayList values)
throws BadDimensionException
rows - the number of rowscols - the number of columnsrowInd - an arrayList of row indices of nonzeroscolInd - an arrayList of column indicies of nonzerosvalues - an arrayList of the nonzero values
public TmtMatrix(java.lang.String fileName,
int rows,
int cols,
boolean sparse)
fileName - rows - cols - sparse -
public TmtMatrix(java.lang.String fileName,
boolean sparse)
fileName - rows - cols - sparse - public TmtMatrix(DoubleMatrix2D newMatrix)
newMatrix - a matrix from coltpublic TmtMatrix(TmtMatrix m)
| Method Detail |
public void showMatrix()
public int rowCount()
public int columnCount()
public TmtMatrix transpose()
public TmtVector getColumn(int i)
i - the (0-based) index of the column to retrievepublic TmtVector getRow(int i)
i - the (0-based) index of the row to retrieve
public double getValue(int row,
int column)
public TmtMatrix getColumns(int start,
int end)
start - the (0-indexed) starting point of the subsetend - the end point
public TmtMatrix getRows(int start,
int end)
start - the (0-indexed) starting point of the subsetend - the end pointpublic TmtMatrix getColumnCentered()
public TmtMatrix getColumnNormalized()
public double zSum()
public DoubleMatrix2D getMatrix()
public TmtMatrix addMatrix(TmtMatrix b)
b - the matrix to addpublic TmtMatrix scalarMultiply(double d)
d - the scalar to multiply bypublic TmtMatrix preMultiplyBy(TmtMatrix b)
b - the matrix to premultiply bypublic TmtMatrix postMultiplyBy(TmtMatrix b)
b - the matrix to postmultiply bypublic TmtMatrix getCorrelationMatrix()
public void svd()
public TmtMatrix getLeftSingularVectors()
public TmtMatrix getRightSingularVectors()
public TmtMatrix getSingularValues()
public Instances toWekaInstances()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||