public class SparseIntMatrix3D extends IntMatrix3D
Implementation:
Note that this implementation is not synchronized. Uses a
OpenLongIntHashMap, which is a compact and
performant hashing technique.
Cells that
trimToSize().
| Constructor and Description |
|---|
SparseIntMatrix3D(int[][][] values)
Constructs a matrix with a copy of the given values.
|
SparseIntMatrix3D(int slices,
int rows,
int columns)
Constructs a matrix with a given number of slices, rows and columns and
default memory usage.
|
SparseIntMatrix3D(int slices,
int rows,
int columns,
int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Constructs a matrix with a given number of slices, rows and columns using
memory as specified.
|
| Modifier and Type | Method and Description |
|---|---|
IntMatrix3D |
assign(int value)
Sets all cells to the state specified by value.
|
int |
cardinality()
Returns the number of cells having non-zero values; ignores tolerance.
|
AbstractLongIntMap |
elements()
Returns the elements of this matrix.
|
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of
non-zero (non-null) cells without needing to allocate new internal
memory.
|
int |
getQuick(int slice,
int row,
int column)
Returns the matrix cell value at coordinate [slice,row,column].
|
long |
index(int slice,
int row,
int column)
Returns the position of the given coordinate within the (virtual or
non-virtual) internal 1-dimensional array.
|
IntMatrix3D |
like(int slices,
int rows,
int columns)
Construct and returns a new empty matrix of the same dynamic type
as the receiver, having the specified number of slices, rows and columns.
|
IntMatrix2D |
like2D(int rows,
int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic
type, sharing the same cells.
|
void |
setQuick(int slice,
int row,
int column,
int value)
Sets the matrix cell at coordinate [slice,row,column] to the
specified value.
|
String |
toString()
Returns a string representation using default formatting.
|
void |
trimToSize()
Releases any superfluous internal memory.
|
IntMatrix1D |
vectorize()
Returns a vector obtained by stacking the columns of each slice of the
matrix on top of one another.
|
aggregate, aggregate, aggregate, aggregate, assign, assign, assign, assign, assign, assign, assign, assign, copy, equals, equals, get, getMaxLocation, getMinLocation, getNegativeValues, getNonZeros, getPositiveValues, like, set, toArray, viewColumn, viewColumnFlip, viewDice, viewPart, viewRow, viewRowFlip, viewSelection, viewSelection, viewSlice, viewSliceFlip, viewSorted, viewStrides, zSumcheckShape, checkShape, columns, columnStride, rows, rowStride, size, slices, sliceStride, toStringShortisViewclonepublic SparseIntMatrix3D(int[][][] values)
The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
values - The values to be filled into the new matrix.IllegalArgumentException - if
for any 1 <= slice < values.length: values[slice].length != values[slice-1].length
.IllegalArgumentException - if
for any 1 <= row < values[0].length: values[slice][row].length != values[slice][row-1].length
.public SparseIntMatrix3D(int slices,
int rows,
int columns)
slices - the number of slices the matrix shall have.rows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.IllegalArgumentException - if (int)slices*columns*rows > Integer.MAX_VALUE.IllegalArgumentException - if slices<0 || rows<0 || columns<0.public SparseIntMatrix3D(int slices,
int rows,
int columns,
int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
OpenLongIntHashMap.slices - the number of slices the matrix shall have.rows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.initialCapacity - the initial capacity of the hash map. If not known, set
initialCapacity=0 or small.minLoadFactor - the minimum load factor of the hash map.maxLoadFactor - the maximum load factor of the hash map.IllegalArgumentException - if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)
.IllegalArgumentException - if (double)columns*rows > Integer.MAX_VALUE.IllegalArgumentException - if slices<0 || rows<0 || columns<0.public IntMatrix3D assign(int value)
IntMatrix3Dassign in class IntMatrix3Dvalue - the value to be filled into the cells.public int cardinality()
IntMatrix3Dcardinality in class IntMatrix3Dpublic AbstractLongIntMap elements()
IntMatrix3Delements in class IntMatrix3Dpublic void ensureCapacity(int minCapacity)
AbstractMatrixThis default implementation does nothing. Override this method if necessary.
ensureCapacity in class AbstractMatrixminCapacity - the desired minimum number of non-zero (non-null) cells.public int getQuick(int slice,
int row,
int column)
IntMatrix3DProvided with invalid parameters this method may return invalid objects without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): slice<0 || slice>=slices() || row<0 || row>=rows() || column<0 || column>=column().
getQuick in class IntMatrix3Dslice - the index of the slice-coordinate.row - the index of the row-coordinate.column - the index of the column-coordinate.public long index(int slice,
int row,
int column)
AbstractMatrix3Dindex in class AbstractMatrix3Dslice - the index of the slice-coordinate.row - the index of the row-coordinate.column - the index of the third-coordinate.public IntMatrix3D like(int slices, int rows, int columns)
IntMatrix3Dlike in class IntMatrix3Dslices - the number of slices the matrix shall have.rows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.public IntMatrix2D like2D(int rows, int columns)
IntMatrix3Dlike2D in class IntMatrix3Drows - the number of rows the matrix shall have.columns - the number of columns the matrix shall have.public void setQuick(int slice,
int row,
int column,
int value)
IntMatrix3DProvided with invalid parameters this method may access illegal indexes without throwing any exception. You should only use this method when you are absolutely sure that the coordinate is within bounds. Precondition (unchecked): slice<0 || slice>=slices() || row<0 || row>=rows() || column<0 || column>=column().
setQuick in class IntMatrix3Dslice - the index of the slice-coordinate.row - the index of the row-coordinate.column - the index of the column-coordinate.value - the value to be filled into the specified cell.public String toString()
IntMatrix3DtoString in class IntMatrix3DIntFormatterpublic void trimToSize()
AbstractMatrixThis default implementation does nothing. Override this method if necessary.
trimToSize in class AbstractMatrixpublic IntMatrix1D vectorize()
IntMatrix3Dvectorize in class IntMatrix3DJump to the Parallel Colt Homepage