public class SemanticSpaceMatrix extends AbstractMatrix
Matrix implementation whose data is backed by a SemanticSpace. This class provides a bridge between numerical operations
that use the space's data and the results of the algorithm itself.Matrix.Type| Constructor and Description |
|---|
SemanticSpaceMatrix(SemanticSpace sspace)
Creates a
Matrix whose data is backed by the provided SemanticSpace. |
| Modifier and Type | Method and Description |
|---|---|
int |
columns()
Returns the number of columns in this
Matrix. |
Integer |
getRowIndex(String term)
Returns the row to which the provided term is mapped or
null if
the term is not mapped to any row. |
DoubleVector |
getRowVector(int row)
Returns a
DoubleVector for an entire row. |
int |
rows()
Returns the number of rows in this
Matrix. |
void |
set(int row,
int col,
double val)
Throws an
UnsupportedOperationException if called (matrix is
unmodifiable). |
void |
setColumn(int column,
DoubleVector values)
Sets the values for the column of this
Matrix using the provided
DoubleVector. |
void |
setRow(int row,
DoubleVector values)
Sets the values for the row of this
Matrix using the provided
DoubleVector. |
equals, get, getColumn, getColumnVector, getRow, hashCode, setColumn, setRow, toDenseArraypublic SemanticSpaceMatrix(SemanticSpace sspace)
Matrix whose data is backed by the provided SemanticSpace. The rows of this matrix are not guaranteed to be mapped
to any specific ordering of the words in the SemanticSpace.
Further, once this matrix is created, the underlying semantic space
should not be modified in such a way as to add new rows or to change the
vector length.public Integer getRowIndex(String term)
null if
the term is not mapped to any row.public DoubleVector getRowVector(int row)
DoubleVector for an entire row. Implementations should
return an approriately typed DoubleVector. Whether updates to the vector
are written through to the backing matrix is left open to the specific
implementation. Implementations that maintain their data in a sparse
format are encouraged to return a SparseVector instance.getRowVector in interface MatrixgetRowVector in class AbstractMatrixrow - the index of the row to return.DoubleVector representing the row at row.public int columns()
Matrix.columns in interface Matrixcolumns in class AbstractMatrixMatrix.public int rows()
Matrix.rows in interface Matrixrows in class AbstractMatrixMatrix.public void set(int row,
int col,
double val)
UnsupportedOperationException if called (matrix is
unmodifiable).set in interface Matrixset in class AbstractMatrixrow - The row of the cell to update.col - The column of the cell to update.val - The new value of the specified cell.public void setColumn(int column,
DoubleVector values)
Matrix using the provided
DoubleVector. Note that the DoubleVector itself is not
made internal to the instance itself.setColumn in interface MatrixsetColumn in class AbstractMatrixcolumn - The column to update.values - The values to update into column.public void setRow(int row,
DoubleVector values)
Matrix using the provided
DoubleVector. Note that the DoubleVector itself is not
made internal to the instance itself.setRow in interface MatrixsetRow in class AbstractMatrixrow - The row to update.values - The values to update into row.Copyright © 2012. All Rights Reserved.