Package org.ejml.data
Class DMatrixRBlock
- java.lang.Object
-
- org.ejml.data.DMatrixD1
-
- org.ejml.data.DMatrixRBlock
-
- All Implemented Interfaces:
java.io.Serializable,DMatrix,Matrix,ReshapeMatrix
public class DMatrixRBlock extends DMatrixD1
A row-major block matrix declared on to one continuous array.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description intblockLength
-
Constructor Summary
Constructors Constructor Description DMatrixRBlock()DMatrixRBlock(int numRows, int numCols)DMatrixRBlock(int numRows, int numCols, int blockLength)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DMatrixRBlockcopy()Creates an exact copy of the matrix<T extends Matrix>
Tcreate(int numRows, int numCols)Creates a new matrix of the same type with the specified shape<T extends Matrix>
TcreateLike()Creates a new matrix with the same shape as this matrixdoubleget(int row, int col)Returns the value of value of the specified matrix element.double[]getData()Used to get a reference to the internal data.intgetIndex(int row, int col)Returns the internal array index for the specified row and column.intgetNumCols()Returns the number of columns in this matrix.intgetNumElements()Returns the number of elements in this matrix, which is the number of rows times the number of columns.intgetNumRows()Returns the number of rows in this matrix.MatrixTypegetType()Returns the type of matrixvoidreshape(int numRows, int numCols, boolean saveValues)Changes the number of rows and columns in the matrix, allowing its size to grow or shrink.voidreshape(int numRows, int numCols, int blockLength, boolean saveValues)voidset(int row, int col, double val)Sets the value of the specified matrix element.voidset(DMatrixRBlock A)voidset(Matrix original)Sets this matrix to be identical to the 'original' matrix passed in.doubleunsafe_get(int row, int col)Same asDMatrix.get(int, int)but does not perform bounds check on input parameters.voidunsafe_set(int row, int col, double val)Same asDMatrix.set(int, int, double)but does not perform bounds check on input parameters.static DMatrixRBlockwrap(double[] data, int numRows, int numCols, int blockLength)voidzero()Sets all values inside the matrix to zero
-
-
-
Method Detail
-
set
public void set(DMatrixRBlock A)
-
wrap
public static DMatrixRBlock wrap(double[] data, int numRows, int numCols, int blockLength)
-
getData
public double[] getData()
Description copied from class:DMatrixD1Used to get a reference to the internal data.
-
reshape
public void reshape(int numRows, int numCols, boolean saveValues)Description copied from class:DMatrixD1Changes 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 ]
-
reshape
public void reshape(int numRows, int numCols, int blockLength, boolean saveValues)
-
getIndex
public int getIndex(int row, int col)Description copied from class:DMatrixD1Returns the internal array index for the specified row and column.
-
get
public double get(int row, int col)Description copied from interface:DMatrixReturns the value of value of the specified matrix element.- Parameters:
row- Matrix element's row index..col- Matrix element's column index.- Returns:
- The specified element's value.
-
unsafe_get
public double unsafe_get(int row, int col)Description copied from interface:DMatrixSame asDMatrix.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.- Parameters:
row- Matrix element's row index..col- Matrix element's column index.- Returns:
- The specified element's value.
-
set
public void set(int row, int col, double val)Description copied from interface:DMatrixSets the value of the specified matrix element.- Parameters:
row- Matrix element's row index..col- Matrix element's column index.val- The element's new value.
-
unsafe_set
public void unsafe_set(int row, int col, double val)Description copied from interface:DMatrixSame asDMatrix.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.- Parameters:
row- Matrix element's row index..col- Matrix element's column index.val- The element's new value.
-
getNumRows
public int getNumRows()
Description copied from class:DMatrixD1Returns the number of rows in this matrix.- Specified by:
getNumRowsin interfaceMatrix- Overrides:
getNumRowsin classDMatrixD1- Returns:
- Number of rows.
-
getNumCols
public int getNumCols()
Description copied from class:DMatrixD1Returns the number of columns in this matrix.- Specified by:
getNumColsin interfaceMatrix- Overrides:
getNumColsin classDMatrixD1- Returns:
- Number of columns.
-
zero
public void zero()
Description copied from interface:MatrixSets all values inside the matrix to zero
-
createLike
public <T extends Matrix> T createLike()
Description copied from interface:MatrixCreates a new matrix with the same shape as this matrix
-
create
public <T extends Matrix> T create(int numRows, int numCols)
Description copied from interface:MatrixCreates a new matrix of the same type with the specified shape
-
set
public void set(Matrix original)
Description copied from interface:MatrixSets this matrix to be identical to the 'original' matrix passed in.
-
getNumElements
public int getNumElements()
Description copied from interface:DMatrixReturns the number of elements in this matrix, which is the number of rows times the number of columns.- Returns:
- Number of elements in this matrix.
-
copy
public DMatrixRBlock copy()
Description copied from interface:MatrixCreates an exact copy of the matrix
-
getType
public MatrixType getType()
Description copied from interface:MatrixReturns the type of matrix
-
-