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

java.lang.Object
  extended by com.multicorebsp.util.Matrix<DataType>
      extended by com.multicorebsp.util.SparseMatrix<DataType,TS<DataType>>
          extended by com.multicorebsp.util.TS<DataType>
All Implemented Interfaces:
com.multicorebsp.core.CompulsaryCloneable<TS<DataType>>, java.lang.Cloneable

public class TS<DataType extends MatrixData<DataType>>
extends SparseMatrix<DataType,TS<DataType>>
implements com.multicorebsp.core.CompulsaryCloneable<TS<DataType>>

Base class for reading in a matrix in Triplet Scheme format, from an (Extended) Matrix-market file. Supports distributed matrices.


Field Summary
 int[] i
          Holds, for each nonzero, the row index
 int[] j
          Holds, for each nonzero, the column index
 int[] p
          Holds, for matrices in global view, the processor index
 int[] Pstart
          Controls which parts of the triplet structure corresponds to which processor.
protected  com.multicorebsp.util.SortSupport<DataType,TS<DataType>> SORT
          Sort method to be used for this class of matrices.
 
Fields inherited from class com.multicorebsp.util.SparseMatrix
data, n
 
Fields inherited from class com.multicorebsp.util.Matrix
m, nz
 
Constructor Summary
  TS(DataType data)
          Constructs an empty 0 by 0 TS matrix.
protected TS(DataType _data, int _m, int _n, int _nz, int[] _i, int[] _j, int[] _p, int[] _Pstart)
          Deep copy constructor.
  TS(DataType data, int m, int n, int nz, int distributed, boolean global_view)
          Constructs a new matrix, holding the given data with the other arrays (e.g., i and j) zeroed-out.
 
Method Summary
 java.lang.Object clone()
           
 void CRSSort()
          Sorts the data structure using the standard sort defined in the final class.
protected  int[] getSubMatrixColumnSizes()
          This function assumes Pstart is not null.
protected  int[] getSubMatrixRowSizes()
          This function assumes Pstart is not null.
protected  int partition(com.multicorebsp.util.SortSupport<DataType,TS<DataType>> sup, int left, int right, int pivotIndex)
          Quicksort helper function.
 void printLocalStats()
          Prints ranges of this matrix: for each processor, the size of its submatrix is reported.
protected  void quicksort()
          Quicksort implementation on arbitrary datatypes.
protected  void quicksort(com.multicorebsp.util.SortSupport<DataType,TS<DataType>> sup, int lo_bound, int hi_bound)
          Quicksort implementation on arbitrary datatypes.
 void removeAndAddDuplicates()
          Takes care of detecting duplicates and adding combining those values.
 TS<DataType> safeClone()
           
protected  void setCRSSort()
          Activates sorting for CRS-ordering
 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.
 java.util.ArrayList<CRS<DataType>> toLocalCRS()
           
 java.util.ArrayList<ICRS<DataType>> toLocalICRS()
           
 TS<DataType> toTS()
          Warning: returns current matrix if this matrix already is TS.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i

public int[] i
Holds, for each nonzero, the row index


j

public int[] j
Holds, for each nonzero, the column index


p

public int[] p
Holds, for matrices in global view, the processor index

See Also:
MMobject

Pstart

public int[] Pstart
Controls which parts of the triplet structure corresponds to which processor.


SORT

protected com.multicorebsp.util.SortSupport<DataType extends MatrixData<DataType>,TS<DataType extends MatrixData<DataType>>> SORT
Sort method to be used for this class of matrices.

Constructor Detail

TS

public TS(DataType data)
Constructs an empty 0 by 0 TS matrix.

Parameters:
data - Where to store the new matrix data.

TS

public TS(DataType data,
          int m,
          int n,
          int nz,
          int distributed,
          boolean global_view)
Constructs a new matrix, holding the given data with the other arrays (e.g., i and j) zeroed-out.

Parameters:
data - Where data is to be stored.
m - Row dimension of the input matrix.
n - Column dimension of the input matrix.
nz - Number of nonzeroes in the input matrix.
distributed - Equal to the number of processors the matrix is distributed over; 0 if not distributed.
global_view - Whether the matrix is in global view.

TS

protected TS(DataType _data,
             int _m,
             int _n,
             int _nz,
             int[] _i,
             int[] _j,
             int[] _p,
             int[] _Pstart)
Deep copy constructor.

Method Detail

toLocalCRS

public java.util.ArrayList<CRS<DataType>> toLocalCRS()
Returns:
Returns an array of P CRS data structures, where P is the number of processors the current matrix is distributed over.

getSubMatrixColumnSizes

protected int[] getSubMatrixColumnSizes()
This function assumes Pstart is not null.


getSubMatrixRowSizes

protected int[] getSubMatrixRowSizes()
This function assumes Pstart is not null.


toLocalICRS

public java.util.ArrayList<ICRS<DataType>> toLocalICRS()
Returns:
Returns an array of P ICRS data structures, where P is the number of processors the current matrix is distributed over.

CRSSort

public void CRSSort()
Sorts the data structure using the standard sort defined in the final class.


removeAndAddDuplicates

public void removeAndAddDuplicates()
Takes care of detecting duplicates and adding combining those values.

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

partition

protected int partition(com.multicorebsp.util.SortSupport<DataType,TS<DataType>> sup,
                        int left,
                        int right,
                        int pivotIndex)
Quicksort helper function. Performs a single swap-according-to-pivot

Parameters:
sup - The sort-enabling class.
left - Left bound.
right - Right bound, inclusive.
pivotIndex - Pivot index.
Returns:
New pivot index.

quicksort

protected void quicksort()
Quicksort implementation on arbitrary datatypes. Not the quickest implementation. Will be quadratic on already-sorted arrays due to naive pivotting. Uses the sort defined in the static variable MMTS.SORT.


quicksort

protected void quicksort(com.multicorebsp.util.SortSupport<DataType,TS<DataType>> sup,
                         int lo_bound,
                         int hi_bound)
Quicksort implementation on arbitrary datatypes. Not the quickest implementation. Will be quadratic on already-sorted arrays due to naive pivotting.

Parameters:
sup - Supporting class required for sorting
lo_bound - Lower bound on index (incusive)
hi_bound - Upper bound on index (exclusive)

printLocalStats

public void printLocalStats()
Prints ranges of this matrix: for each processor, the size of its submatrix is reported.


clone

public java.lang.Object clone()
Specified by:
clone in interface com.multicorebsp.core.CompulsaryCloneable<TS<DataType extends MatrixData<DataType>>>
Overrides:
clone in class SparseMatrix<DataType extends MatrixData<DataType>,TS<DataType extends MatrixData<DataType>>>

safeClone

public TS<DataType> safeClone()
Specified by:
safeClone in interface com.multicorebsp.core.CompulsaryCloneable<TS<DataType extends MatrixData<DataType>>>

setCRSSort

protected void setCRSSort()
Activates sorting for CRS-ordering


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>,TS<DataType extends MatrixData<DataType>>>
Returns:
CRS version of the current matrix.

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>,TS<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>,TS<DataType extends MatrixData<DataType>>>
Returns:
TS version of the current matrix.