org.mymedialite.datatype
Class SymmetricSparseMatrix<T>

java.lang.Object
  extended by org.mymedialite.datatype.SparseMatrix<T>
      extended by org.mymedialite.datatype.SymmetricSparseMatrix<T>
All Implemented Interfaces:
IMatrix<T>
Direct Known Subclasses:
SkewSymmetricSparseMatrix

public class SymmetricSparseMatrix<T>
extends SparseMatrix<T>

A symmetric sparse matrix; consumes less memory. Be careful when accessing the matrix via the NonEmptyRows property: this contains only the entries with x > y, but not their symmetric counterparts.


Field Summary
 
Fields inherited from class org.mymedialite.datatype.SparseMatrix
row_list
 
Constructor Summary
SymmetricSparseMatrix(int dimension, T d)
          Create a symmetric sparse matrix with a given dimension.
 
Method Summary
 IMatrix<T> createMatrix(int num_rows, int num_columns)
          Create a matrix with a given number of rows and columns.
 T get(int x, int y)
          Access the elements of the sparse matrix.
 boolean isSymmetric()
          Always true because the data type is symmetric.
 java.util.List<Pair<java.lang.Integer,java.lang.Integer>> nonEmptyEntryIDs()
          The row and column IDs of non-empty entries in the matrix.
 int numberOfNonEmptyEntries()
          The number of non-empty entries in the matrix.
 void set(int x, int y, T value)
          Set the value at (i,j)
 
Methods inherited from class org.mymedialite.datatype.SparseMatrix
get, grow, nonEmptyRows, numberOfColumns, numberOfRows, transpose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SymmetricSparseMatrix

public SymmetricSparseMatrix(int dimension,
                             T d)
Create a symmetric sparse matrix with a given dimension.

Parameters:
dimension - the dimension (number of rows/columns)
d - the default value for elements, or null
Method Detail

get

public T get(int x,
             int y)
Access the elements of the sparse matrix.

Specified by:
get in interface IMatrix<T>
Overrides:
get in class SparseMatrix<T>
Parameters:
x - the row ID
y - the column ID
Returns:
the value at (i,j)

set

public void set(int x,
                int y,
                T value)
Description copied from interface: IMatrix
Set the value at (i,j)

Specified by:
set in interface IMatrix<T>
Overrides:
set in class SparseMatrix<T>
Parameters:
x - the row ID
y - the column ID
value - the value

isSymmetric

public boolean isSymmetric()
Always true because the data type is symmetric.

Specified by:
isSymmetric in interface IMatrix<T>
Overrides:
isSymmetric in class SparseMatrix<T>
Returns:
Always true because the data type is symmetric

createMatrix

public IMatrix<T> createMatrix(int num_rows,
                               int num_columns)
Description copied from interface: IMatrix
Create a matrix with a given number of rows and columns.

Specified by:
createMatrix in interface IMatrix<T>
Overrides:
createMatrix in class SparseMatrix<T>
Parameters:
num_rows - the number of rows
num_columns - the number of columns
Returns:
a matrix with num_rows rows and num_column columns

nonEmptyEntryIDs

public java.util.List<Pair<java.lang.Integer,java.lang.Integer>> nonEmptyEntryIDs()
Description copied from class: SparseMatrix
The row and column IDs of non-empty entries in the matrix.

Overrides:
nonEmptyEntryIDs in class SparseMatrix<T>
Returns:
The row and column IDs of non-empty entries in the matrix

numberOfNonEmptyEntries

public int numberOfNonEmptyEntries()
Description copied from class: SparseMatrix
The number of non-empty entries in the matrix.

Overrides:
numberOfNonEmptyEntries in class SparseMatrix<T>
Returns:
The number of non-empty entries in the matrix