public abstract class FMatrixD1 extends java.lang.Object implements ReshapeMatrix, FMatrix
Modifier and Type | Field and Description |
---|---|
float[] |
data
Where the raw data for the matrix is stored.
|
int |
numCols
Number of columns in the matrix.
|
int |
numRows
Number of rows in the matrix.
|
Constructor and Description |
---|
FMatrixD1() |
Modifier and Type | Method and Description |
---|---|
float |
div(int index,
float val)
Divides the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] /= val; |
float |
get(int index)
Returns the value of the matrix at the specified internal array index.
|
float[] |
getData()
Used to get a reference to the internal data.
|
abstract int |
getIndex(int row,
int col)
Returns the internal array index for the specified row and column.
|
int |
getNumCols()
Returns the number of columns in this matrix.
|
int |
getNumRows()
Returns the number of rows in this matrix.
|
FMatrixIterator |
iterator(boolean rowMajor,
int minRow,
int minCol,
int maxRow,
int maxCol)
Creates a new iterator for traversing through a submatrix inside this matrix.
|
float |
minus(int index,
float val)
Subtracts the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] -= val; |
float |
plus(int index,
float val)
Adds the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] += val; |
void |
reshape(int numRows,
int numCols)
Equivalent to invoking reshape(numRows,numCols,false);
|
abstract void |
reshape(int numRows,
int numCols,
boolean saveValues)
Changes the number of rows and columns in the matrix, allowing its size to grow or shrink.
|
void |
set(FMatrixD1 b)
Sets the value of this matrix to be the same as the value of the provided matrix.
|
float |
set(int index,
float val)
Sets the element's value at the specified index.
|
void |
setData(float[] data)
Changes the internal array reference.
|
void |
setNumCols(int numCols)
Sets the number of columns.
|
void |
setNumRows(int numRows)
Sets the number of rows.
|
float |
times(int index,
float val)
Multiplies the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] *= val; |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, getNumElements, set, unsafe_get, unsafe_set
public float[] data
public int numRows
public int numCols
public float[] getData()
public void setData(float[] data)
public abstract int getIndex(int row, int col)
row
- Row index.col
- Column index.public void set(FMatrixD1 b)
b
- The matrix that this matrix is to be set equal to.public float get(int index)
index
- Internal array index.public float set(int index, float val)
index
- Index of element that is to be set.val
- The new value of the index.public float plus(int index, float val)
Adds the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] += val;
Intended for use in highly optimized code. The row/column coordinate of the modified element is dependent upon the matrix's internal structure.
index
- The index which is being modified.val
- The value that is being added.public float minus(int index, float val)
Subtracts the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] -= val;
Intended for use in highly optimized code. The row/column coordinate of the modified element is dependent upon the matrix's internal structure.
index
- The index which is being modified.val
- The value that is being subtracted.public float times(int index, float val)
Multiplies the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] *= val;
Intended for use in highly optimized code. The row/column coordinate of the modified element is dependent upon the matrix's internal structure.
index
- The index which is being modified.val
- The value that is being multiplied.public float div(int index, float val)
Divides the specified value to the internal data array at the specified index.
Equivalent to: this.data[index] /= val;
Intended for use in highly optimized code. The row/column coordinate of the modified element is dependent upon the matrix's internal structure.
index
- The index which is being modified.val
- The value that is being divided.public abstract void reshape(int numRows, int numCols, boolean saveValues)
Changes the number of rows and columns in the matrix, allowing its size to grow or shrink. If the saveValues flag is set to true, then the previous values will be maintained, but reassigned to new elements in a row-major ordering. If saveValues is false values will only be maintained when the requested size is less than or equal to the internal array size. The primary use for this function is to encourage data reuse and avoid unnecessarily declaring and initialization of new memory.
Examples:
[ 1 2 ; 3 4 ] → reshape( 2 , 3 , true ) = [ 1 2 3 ; 4 0 0 ]
[ 1 2 ; 3 4 ] → reshape( 1 , 2 , true ) = [ 1 2 ]
[ 1 2 ; 3 4 ] → reshape( 1 , 2 , false ) = [ 1 2 ]
[ 1 2 ; 3 4 ] → reshape( 2 , 3 , false ) = [ 0 0 0 ; 0 0 0 ]
numRows
- The new number of rows in the matrix.numCols
- The new number of columns in the matrix.saveValues
- If true then the value of each element will be save using a row-major reordering. Typically this should be false.public void reshape(int numRows, int numCols)
reshape
in interface ReshapeMatrix
numRows
- The new number of rows in the matrix.numCols
- The new number of columns in the matrix.public FMatrixIterator iterator(boolean rowMajor, int minRow, int minCol, int maxRow, int maxCol)
rowMajor
- true means it will traverse through the submatrix by row first, false by columns.minRow
- first row it will start at.minCol
- first column it will start at.maxRow
- last row it will stop at.maxCol
- last column it will stop at.public int getNumRows()
getNumRows
in interface Matrix
public int getNumCols()
getNumCols
in interface Matrix
public void setNumRows(int numRows)
numRows
- Number of rowspublic void setNumCols(int numCols)
numCols
- Number of columns