public class DMatrixSparseTriplet extends java.lang.Object implements DMatrixSparse
Modifier and Type | Class and Description |
---|---|
static class |
DMatrixSparseTriplet.Element |
Modifier and Type | Field and Description |
---|---|
int |
numCols |
int |
numRows |
DMatrixSparseTriplet.Element[] |
nz_data |
int |
nz_length |
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) |
<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 |
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
|
void |
growData(int max_nz_length)
Will resize the array and keep all the old data
|
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.
|
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) |
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 DMatrixSparseTriplet.Element[] nz_data
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)
public void reshape(int numRows, int numCols, int arrayLength)
DMatrixSparse
reshape
in interface DMatrixSparse
numRows
- number of rowsnumCols
- number of columnsarrayLength
- Array length for storing non-zero elements.public void addItem(int row, int col, double value)
public void set(int row, int col, double value)
DMatrix
public void unsafe_set(int row, int col, double value)
DMatrix
DMatrix.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 DMatrix
row
- Matrix element's row index..col
- Matrix element's column index.value
- The element's new value.public int getNumElements()
DMatrix
getNumElements
in interface DMatrix
public double get(int row, int col)
DMatrix
public double unsafe_get(int row, int col)
DMatrix
DMatrix.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 DMatrix
row
- Matrix element's row index..col
- Matrix element's column index.public int nz_index(int row, int col)
public void growData(int max_nz_length)
max_nz_length
- New maximum length of datapublic int getLength()
public int getNumRows()
Matrix
getNumRows
in interface Matrix
public int getNumCols()
Matrix
getNumCols
in interface Matrix
public <T extends Matrix> T copy()
Matrix
public <T extends Matrix> T createLike()
Matrix
createLike
in interface Matrix
public void set(Matrix original)
Matrix
public void shrinkArrays()
DMatrixSparse
shrinkArrays
in interface DMatrixSparse
public void remove(int row, int col)
DMatrixSparse
remove
in interface DMatrixSparse
row
- the rowcol
- the columnpublic boolean isAssigned(int row, int col)
DMatrixSparse
isAssigned
in interface DMatrixSparse
row
- the rowcol
- the columnpublic void zero()
DMatrixSparse
zero
in interface DMatrixSparse
public void print()
Matrix
public void printNonZero()
DMatrixSparse
printNonZero
in interface DMatrixSparse
public MatrixType getType()
Matrix