public class DMatrixSparseTriplet extends java.lang.Object implements DMatrixSparse
| Modifier and Type | Field and Description |
|---|---|
int |
numCols |
int |
numRows |
int |
nz_length |
IGrowArray |
nz_rowcol
Storage for row and column coordinate for non-zero elements
|
DGrowArray |
nz_value
Storage for value of a non-zero element
|
| Constructor and Description |
|---|
DMatrixSparseTriplet() |
DMatrixSparseTriplet(DMatrixSparseTriplet orig) |
DMatrixSparseTriplet(int numRows,
int numCols,
int initLength) |
| Modifier and Type | Method and Description |
|---|---|
void |
addItem(int row,
int col,
double value) |
void |
addItemCheck(int row,
int col,
double value) |
<T extends Matrix> |
copy()
Creates an exact copy of the matrix
|
<T extends Matrix> |
createLike()
Creates a new matrix with the same shape as this matrix
|
double |
get(int row,
int col)
Returns the value of value of the specified matrix element.
|
int |
getLength() |
int |
getNonZeroLength()
Returns the number of non-zero elements.
|
int |
getNumCols()
Returns the number of columns in this matrix.
|
int |
getNumElements()
Returns the number of elements in this matrix, which is the number of rows
times the number of columns.
|
int |
getNumRows()
Returns the number of rows in this matrix.
|
MatrixType |
getType()
Returns the type of matrix
|
boolean |
isAssigned(int row,
int col)
Is the specified element explicitly assigned a value
|
int |
nz_index(int row,
int col) |
void |
print()
Prints the matrix to standard out using standard formatting.
|
void |
print(java.lang.String format)
Prints the matrix to standard out with the specified formatting.
|
void |
printNonZero()
Prints to standard out the non-zero elements only.
|
void |
remove(int row,
int col)
If the specified element is non-zero it is removed from the structure
|
void |
reset() |
void |
reshape(int numRows,
int numCols)
Changes the number of rows and columns in the matrix.
|
void |
reshape(int numRows,
int numCols,
int arrayLength)
Reshapes the matrix so that it can store a matrix with the specified dimensions and the number of
non-zero elements.
|
void |
set(int row,
int col,
double value)
Sets the value of the specified matrix element.
|
void |
set(Matrix original)
Sets this matrix to be identical to the 'original' matrix passed in.
|
void |
shrinkArrays()
Reduces the size of internal data structures to their minimal size.
|
double |
unsafe_get(int row,
int col)
Same as
DMatrix.get(int, int) but does not perform bounds check on input parameters. |
void |
unsafe_set(int row,
int col,
double value)
Same as
DMatrix.set(int, int, double) but does not perform bounds check on input parameters. |
void |
zero()
Sets all elements to zero by removing the sparse graph
|
public IGrowArray nz_rowcol
public DGrowArray nz_value
public int nz_length
public int numRows
public int numCols
public DMatrixSparseTriplet()
public DMatrixSparseTriplet(int numRows,
int numCols,
int initLength)
numRows - Number of rows in the matrixnumCols - Number of columns in the matrixinitLength - Initial maximum length of data array.public DMatrixSparseTriplet(DMatrixSparseTriplet orig)
public void reset()
public void reshape(int numRows,
int numCols)
MatrixSparseMatrixSparse.reshape(int, int, int), but the storage for non-zero elements is
not changedreshape in interface MatrixSparsereshape in interface ReshapeMatrixnumRows - number of rowsnumCols - number of columnspublic void reshape(int numRows,
int numCols,
int arrayLength)
MatrixSparsereshape in interface MatrixSparsenumRows - number of rowsnumCols - number of columnsarrayLength - Array length for storing non-zero elements.public void addItem(int row,
int col,
double value)
public void addItemCheck(int row,
int col,
double value)
public void set(int row,
int col,
double value)
DMatrixpublic void unsafe_set(int row,
int col,
double value)
DMatrixDMatrix.set(int, int, double) but does not perform bounds check on input parameters. This results in about a 25%
speed increase but potentially sacrifices stability and makes it more difficult to track down simple errors.
It is not recommended that this function be used, except in highly optimized code where the bounds are
implicitly being checked.unsafe_set in interface DMatrixrow - Matrix element's row index..col - Matrix element's column index.value - The element's new value.public int getNumElements()
DMatrixgetNumElements in interface DMatrixpublic double get(int row,
int col)
DMatrixpublic double unsafe_get(int row,
int col)
DMatrixDMatrix.get(int, int) but does not perform bounds check on input parameters. This results in about a 25%
speed increase but potentially sacrifices stability and makes it more difficult to track down simple errors.
It is not recommended that this function be used, except in highly optimized code where the bounds are
implicitly being checked.unsafe_get in interface DMatrixrow - Matrix element's row index..col - Matrix element's column index.public int nz_index(int row,
int col)
public int getLength()
public int getNumRows()
MatrixgetNumRows in interface Matrixpublic int getNumCols()
MatrixgetNumCols in interface Matrixpublic <T extends Matrix> T copy()
Matrixpublic <T extends Matrix> T createLike()
MatrixcreateLike in interface Matrixpublic void set(Matrix original)
Matrixpublic void shrinkArrays()
MatrixSparseshrinkArrays in interface MatrixSparsepublic void remove(int row,
int col)
MatrixSparseremove in interface MatrixSparserow - the rowcol - the columnpublic boolean isAssigned(int row,
int col)
MatrixSparseisAssigned in interface MatrixSparserow - the rowcol - the columnpublic void zero()
MatrixSparsezero in interface MatrixSparsepublic int getNonZeroLength()
MatrixSparsegetNonZeroLength in interface MatrixSparsepublic void print()
Matrixpublic void print(java.lang.String format)
Matrixpublic void printNonZero()
MatrixSparseprintNonZero in interface MatrixSparsepublic MatrixType getType()
Matrix