com.multicorebsp.util
Class CRS<DataType extends MatrixData<DataType>>

java.lang.Object
  extended by com.multicorebsp.util.Matrix<DataType>
      extended by com.multicorebsp.util.SparseMatrix<DataType,CRS<DataType>>
          extended by com.multicorebsp.util.CRS<DataType>
Type Parameters:
DataType - What kind of data to store.
All Implemented Interfaces:
com.multicorebsp.core.CompulsaryCloneable<CRS<DataType>>, java.lang.Cloneable

public class CRS<DataType extends MatrixData<DataType>>
extends SparseMatrix<DataType,CRS<DataType>>

Compressed row storage of sparse matrices. The nonzeroes and column indices are stored in CRS order in full arrays. Since the nonzeroes are in CRS order, however, the row indices do not need to be contained in a full array: instead it is possible to store only the starting and ending points of each individual row. This is done by the start array.


Field Summary
 int[] index_array
          Column index array
 int[] start_array
          Row start array
 
Fields inherited from class com.multicorebsp.util.SparseMatrix
data, n
 
Fields inherited from class com.multicorebsp.util.Matrix
m, nz
 
Constructor Summary
protected CRS(CRS<DataType> toCopy)
          Deep copy constructor.
  CRS(DataType data, int m, int n, int nz)
          Base constructor.
  CRS(TS<DataType> triplet_scheme)
          Constructs CRS representation of a TS matrix.
 
Method Summary
 void removeAndAddDuplicates()
          Removes and combines any double entries.
 CRS<DataType> safeClone()
           
 CRS<DataType> toCRS()
          Warning: returns current matrix if this matrix already is CRS.
 ICRS<DataType> toICRS()
          Warning: returns current matrix if this matrix already is CRS.
 TS<DataType> toTS()
          Warning: returns current matrix if this matrix already is TS.
 
Methods inherited from class com.multicorebsp.util.SparseMatrix
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start_array

public int[] start_array
Row start array


index_array

public int[] index_array
Column index array

Constructor Detail

CRS

public CRS(DataType data,
           int m,
           int n,
           int nz)
Base constructor.

Parameters:
data - Where to store matrix data.
m - Number of rows in matrix.
n - Number of columns in matrix.
nz - Number of nonzeroes in matrix.

CRS

public CRS(TS<DataType> triplet_scheme)
Constructs CRS representation of a TS matrix.

Parameters:
triplet_scheme - The TS representation to copy.

CRS

protected CRS(CRS<DataType> toCopy)
Deep copy constructor.

Method Detail

toCRS

public CRS<DataType> toCRS()
Description copied from class: SparseMatrix
Warning: returns current matrix if this matrix already is CRS.

Specified by:
toCRS in class SparseMatrix<DataType extends MatrixData<DataType>,CRS<DataType extends MatrixData<DataType>>>
Returns:
CRS version of the current matrix.

toICRS

public ICRS<DataType> toICRS()
Description copied from class: SparseMatrix
Warning: returns current matrix if this matrix already is CRS.

Specified by:
toICRS in class SparseMatrix<DataType extends MatrixData<DataType>,CRS<DataType extends MatrixData<DataType>>>
Returns:
CRS version of the current matrix.

toTS

public TS<DataType> toTS()
Description copied from class: SparseMatrix
Warning: returns current matrix if this matrix already is TS.

Specified by:
toTS in class SparseMatrix<DataType extends MatrixData<DataType>,CRS<DataType extends MatrixData<DataType>>>
Returns:
TS version of the current matrix.

removeAndAddDuplicates

public void removeAndAddDuplicates()
Description copied from class: Matrix
Removes and combines any double entries.

Specified by:
removeAndAddDuplicates in class Matrix<DataType extends MatrixData<DataType>>

safeClone

public CRS<DataType> safeClone()