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, zSum
checkShape, checkShape, columns, columnStride, rows, rowStride, size, slices, sliceStride, toStringShort
isView
clone
public 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)
IntMatrix3D
assign
in class IntMatrix3D
value
- the value to be filled into the cells.public int cardinality()
IntMatrix3D
cardinality
in class IntMatrix3D
public AbstractLongIntMap elements()
IntMatrix3D
elements
in class IntMatrix3D
public void ensureCapacity(int minCapacity)
AbstractMatrix
This default implementation does nothing. Override this method if necessary.
ensureCapacity
in class AbstractMatrix
minCapacity
- the desired minimum number of non-zero (non-null) cells.public int getQuick(int slice, int row, int column)
IntMatrix3D
Provided 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 IntMatrix3D
slice
- 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)
AbstractMatrix3D
index
in class AbstractMatrix3D
slice
- 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)
IntMatrix3D
like
in class IntMatrix3D
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.public IntMatrix2D like2D(int rows, int columns)
IntMatrix3D
like2D
in class IntMatrix3D
rows
- 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)
IntMatrix3D
Provided 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 IntMatrix3D
slice
- 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()
IntMatrix3D
toString
in class IntMatrix3D
IntFormatter
public void trimToSize()
AbstractMatrix
This default implementation does nothing. Override this method if necessary.
trimToSize
in class AbstractMatrix
public IntMatrix1D vectorize()
IntMatrix3D
vectorize
in class IntMatrix3D
Jump to the Parallel Colt Homepage