public class FMatrixSparseTriplet extends java.lang.Object implements FMatrixSparse
Modifier and Type | Class and Description |
---|---|
static class |
FMatrixSparseTriplet.Element |
Modifier and Type | Field and Description |
---|---|
int |
numCols |
int |
numRows |
FMatrixSparseTriplet.Element[] |
nz_data |
int |
nz_length |
Constructor and Description |
---|
FMatrixSparseTriplet() |
FMatrixSparseTriplet(FMatrixSparseTriplet orig) |
FMatrixSparseTriplet(int numRows,
int numCols,
int initLength) |
Modifier and Type | Method and Description |
---|---|
void |
addItem(int row,
int col,
float 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
|
float |
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,
float 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.
|
float |
unsafe_get(int row,
int col)
Same as
FMatrix.get(int, int) but does not perform bounds check on input parameters. |
void |
unsafe_set(int row,
int col,
float value)
Same as
FMatrix.set(int, int, float) but does not perform bounds check on input parameters. |
void |
zero()
Sets all elements to zero by removing the sparse graph
|
public FMatrixSparseTriplet.Element[] nz_data
public int nz_length
public int numRows
public int numCols
public FMatrixSparseTriplet()
public FMatrixSparseTriplet(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 FMatrixSparseTriplet(FMatrixSparseTriplet orig)
public void reset()
public void reshape(int numRows, int numCols)
public void reshape(int numRows, int numCols, int arrayLength)
FMatrixSparse
reshape
in interface FMatrixSparse
numRows
- number of rowsnumCols
- number of columnsarrayLength
- Array length for storing non-zero elements.public void addItem(int row, int col, float value)
public void set(int row, int col, float value)
FMatrix
public void unsafe_set(int row, int col, float value)
FMatrix
FMatrix.set(int, int, float)
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 FMatrix
row
- Matrix element's row index..col
- Matrix element's column index.value
- The element's new value.public int getNumElements()
FMatrix
getNumElements
in interface FMatrix
public float get(int row, int col)
FMatrix
public float unsafe_get(int row, int col)
FMatrix
FMatrix.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 FMatrix
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()
FMatrixSparse
shrinkArrays
in interface FMatrixSparse
public void remove(int row, int col)
FMatrixSparse
remove
in interface FMatrixSparse
row
- the rowcol
- the columnpublic boolean isAssigned(int row, int col)
FMatrixSparse
isAssigned
in interface FMatrixSparse
row
- the rowcol
- the columnpublic void zero()
FMatrixSparse
zero
in interface FMatrixSparse
public void print()
Matrix
public void printNonZero()
FMatrixSparse
printNonZero
in interface FMatrixSparse
public MatrixType getType()
Matrix