edu.iu.iv.common.datamodels.matrixmodel
Class SparseDoubleMatrixModel

java.lang.Object
  |
  +--edu.iu.iv.common.datamodels.matrixmodel.SparseDoubleMatrixModel
All Implemented Interfaces:
DoubleMatrixModel

public class SparseDoubleMatrixModel
extends java.lang.Object
implements DoubleMatrixModel

An adapter class that implements the DoubleMatrixModel interface and extends the Cern Colt API's fast hashed implementation of a sparse 2D matrix. This type of matrix model is oriented towards users who have data in matrix format that is sparsely filled. An example of such a matrix is a term-document matrix where most terms occur in very few documents, resulting in an extremely sparse matrix. Using a sparse matrix model for such problems instead of a dense one usually results in significantly lower memory utilization and higher performance. Users new to to using matrices are urged to use the methods defined by the interface rather than using the inherited methods directly since this model is optimized for speed at the cost of error checking. Some methods such as getQuick and setQuick do not do any bounds checking and hence the result of such function calls is undefined in case of error. We recommend you to read the documentation for the CERN Colt API.

Version:
0.1
Author:
TeamIVC
See Also:
SparseDoubleMatrix2D

Constructor Summary
SparseDoubleMatrixModel(double[][] values)
          Creates a matrix and fills them with the elements of the array passed in.
SparseDoubleMatrixModel(int numRows, int numCols)
          Creates a matrix with numRows rows and numCols columns and fills them with zero values.
 
Method Summary
 double get(int row, int column)
          Gets the element at the specified row and column.
 java.lang.String getColumnLabel(int column)
          Gets the label for the specified column.
 int getNumberOfColumns()
           
 int getNumberOfRows()
           
 java.lang.String getRowLabel(int row)
          Gets the label for the specified row.
 void set(int row, int column, double value)
          Sets the value of the element at the specified row and column.
 void setColumnLabel(int column, java.lang.String text)
          Sets the label at the specified column to the specified text.
 void setRowLabel(int row, java.lang.String text)
          Sets the label of the specified row to the specified text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseDoubleMatrixModel

public SparseDoubleMatrixModel(int numRows,
                               int numCols)
Creates a matrix with numRows rows and numCols columns and fills them with zero values. Also allocates memory for row and column labels.

Parameters:
numRows - The number of rows for this matrix.
numCols - The number of columns for this matrix.

SparseDoubleMatrixModel

public SparseDoubleMatrixModel(double[][] values)
Creates a matrix and fills them with the elements of the array passed in. Also allocates memory for row and column labels.

Parameters:
values - The array containing matrix elements.
Method Detail

set

public void set(int row,
                int column,
                double value)
Description copied from interface: DoubleMatrixModel
Sets the value of the element at the specified row and column.

Specified by:
set in interface DoubleMatrixModel
Parameters:
row - The row number.
column - The column number.
value - The value of the element.
See Also:
DoubleMatrixModel.set(int, int, double)

get

public double get(int row,
                  int column)
Description copied from interface: DoubleMatrixModel
Gets the element at the specified row and column.

Specified by:
get in interface DoubleMatrixModel
Parameters:
row - The row number of this element.
column - The column number of this element.
Returns:
The value at matrix(row, column)
See Also:
DoubleMatrixModel.get(int, int)

setColumnLabel

public void setColumnLabel(int column,
                           java.lang.String text)
Description copied from interface: DoubleMatrixModel
Sets the label at the specified column to the specified text.

Specified by:
setColumnLabel in interface DoubleMatrixModel
Parameters:
column - The column number.
text - The text of the label.
See Also:
DoubleMatrixModel.setColumnLabel(int, java.lang.String)

getColumnLabel

public java.lang.String getColumnLabel(int column)
Description copied from interface: DoubleMatrixModel
Gets the label for the specified column.

Specified by:
getColumnLabel in interface DoubleMatrixModel
Parameters:
column - The column number.
Returns:
The text of the label.
See Also:
DoubleMatrixModel.getColumnLabel(int)

setRowLabel

public void setRowLabel(int row,
                        java.lang.String text)
Description copied from interface: DoubleMatrixModel
Sets the label of the specified row to the specified text.

Specified by:
setRowLabel in interface DoubleMatrixModel
Parameters:
row - The row number.
text - The text of the label.
See Also:
DoubleMatrixModel.setRowLabel(int, java.lang.String)

getRowLabel

public java.lang.String getRowLabel(int row)
Description copied from interface: DoubleMatrixModel
Gets the label for the specified row.

Specified by:
getRowLabel in interface DoubleMatrixModel
Parameters:
row - The row number.
Returns:
The text of the label.
See Also:
DoubleMatrixModel.getRowLabel(int)

getNumberOfRows

public int getNumberOfRows()
Specified by:
getNumberOfRows in interface DoubleMatrixModel
Returns:
The number of rows of the matrix.

getNumberOfColumns

public int getNumberOfColumns()
Specified by:
getNumberOfColumns in interface DoubleMatrixModel
Returns:
The number of columns of the matrix.