Class SelectedDenseDoubleMatrix3D
- All Implemented Interfaces:
Serializable
,Cloneable
Implementation:
Objects of this class are typically constructed via viewIndexes methods on some source matrix. The interface introduced in abstract super classes defines everything a user can do. From a user point of view there is nothing special about this class; it presents the same functionality with the same signatures and semantics as its abstract superclass(es) while introducing no additional functionality. Thus, this class need not be visible to users. By the way, the same principle applies to concrete DenseXXX and SparseXXX classes: they presents the same functionality with the same signatures and semantics as abstract superclass(es) while introducing no additional functionality. Thus, they need not be visible to users, either. Factory methods could hide all these concrete types.
This class uses no delegation. Its instances point directly to the data. Cell addressing overhead is is 1 additional int addition and 3 additional array index accesses per get/set.
Note that this implementation is not synchronized.
Memory requirements:
memory [bytes] = 4*(sliceIndexes.length+rowIndexes.length+columnIndexes.length). Thus, an index view with 100 x 100 x 100 indexes additionally uses 8 KB.
Time complexity:
Depends on the parent view holding cells.
- Version:
- 1.0, 09/24/99
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int[]
protected double[]
The elements of this matrix.protected int
The offset.protected int[]
protected int[]
The offsets of the visible cells of this matrix.Fields inherited from class cern.colt.matrix.impl.AbstractMatrix3D
columns, columnStride, columnZero, rows, rowStride, rowZero, slices, sliceStride, sliceZero
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix
isNoView
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SelectedDenseDoubleMatrix3D
(double[] elements, int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets, int offset) Constructs a matrix view with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected int
_columnOffset
(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.protected int
_rowOffset
(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.protected int
_sliceOffset
(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.double
getQuick
(int slice, int row, int column) Returns the matrix cell value at coordinate [slice,row,column].protected boolean
haveSharedCellsRaw
(DoubleMatrix3D other) Returns true if both matrices share common cells.protected int
index
(int slice, int row, int column) Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array.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.protected DoubleMatrix2D
like2D
(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) 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, double value) Sets the matrix cell at coordinate [slice,row,column] to the specified value.protected void
setUp
(int slices, int rows, int columns) Sets up a matrix with a given number of slices and rows.protected AbstractMatrix3D
vDice
(int axis0, int axis1, int axis2) Self modifying version of viewDice().viewColumn
(int column) Constructs and returns a new 2-dimensional slice view representing the slices and rows of the given column.viewRow
(int row) Constructs and returns a new 2-dimensional slice view representing the slices and columns of the given row.protected DoubleMatrix3D
viewSelectionLike
(int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets) Construct and returns a new selection view.viewSlice
(int slice) Constructs and returns a new 2-dimensional slice view representing the rows and columns of the given slice.Methods inherited from class cern.colt.matrix.DoubleMatrix3D
aggregate, aggregate, assign, assign, assign, assign, assign, cardinality, copy, equals, equals, get, getContent, getNonZeros, haveSharedCells, like, set, toArray, toString, view, viewColumnFlip, viewDice, viewPart, viewRowFlip, viewSelection, viewSelection, viewSliceFlip, viewSorted, viewStrides, zAssign27Neighbors, zSum
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix3D
_columnRank, _rowRank, _sliceRank, checkBox, checkColumn, checkColumnIndexes, checkRow, checkRowIndexes, checkShape, checkShape, checkSlice, checkSliceIndexes, columns, rows, setUp, shape, size, slices, toStringShort, vColumnFlip, vPart, vRowFlip, vSliceFlip, vStrides
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix
ensureCapacity, isView, trimToSize
Methods inherited from class cern.colt.PersistentObject
clone
-
Field Details
-
elements
protected double[] elementsThe elements of this matrix. -
sliceOffsets
protected int[] sliceOffsetsThe offsets of the visible cells of this matrix. -
rowOffsets
protected int[] rowOffsets -
columnOffsets
protected int[] columnOffsets -
offset
protected int offsetThe offset.
-
-
Constructor Details
-
SelectedDenseDoubleMatrix3D
protected SelectedDenseDoubleMatrix3D(double[] elements, int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets, int offset) Constructs a matrix view with the given parameters.- Parameters:
elements
- the cells.sliceOffsets
- The slice offsets of the cells that shall be visible.rowOffsets
- The row offsets of the cells that shall be visible.columnOffsets
- The column offsets of the cells that shall be visible.
-
-
Method Details
-
_columnOffset
protected int _columnOffset(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. Default implementation. Override, if necessary.- Overrides:
_columnOffset
in classAbstractMatrix3D
- Parameters:
rank
- the absolute rank of the element.- Returns:
- the position.
-
_rowOffset
protected int _rowOffset(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. Default implementation. Override, if necessary.- Overrides:
_rowOffset
in classAbstractMatrix3D
- Parameters:
rank
- the absolute rank of the element.- Returns:
- the position.
-
_sliceOffset
protected int _sliceOffset(int absRank) Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array. Default implementation. Override, if necessary.- Overrides:
_sliceOffset
in classAbstractMatrix3D
- Parameters:
rank
- the absolute rank of the element.- Returns:
- the position.
-
getQuick
public double getQuick(int slice, int row, int column) Returns the matrix cell value at coordinate [slice,row,column].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().
- Specified by:
getQuick
in classDoubleMatrix3D
- Parameters:
slice
- the index of the slice-coordinate.row
- the index of the row-coordinate.column
- the index of the column-coordinate.- Returns:
- the value at the specified coordinate.
-
index
protected int index(int slice, int row, int column) Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array.- Overrides:
index
in classAbstractMatrix3D
- Parameters:
slice
- the index of the slice-coordinate.row
- the index of the row-coordinate.column
- the index of the third-coordinate.
-
like
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified number of slices, rows and columns. For example, if the receiver is an instance of type DenseDoubleMatrix3D the new matrix must also be of type DenseDoubleMatrix3D, if the receiver is an instance of type SparseDoubleMatrix3D the new matrix must also be of type SparseDoubleMatrix3D, etc. In general, the new matrix should have internal parametrization as similar as possible.- Specified by:
like
in classDoubleMatrix3D
- Parameters:
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.- Returns:
- a new empty matrix of the same dynamic type.
-
like2D
protected DoubleMatrix2D like2D(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) Construct and returns a new 2-d matrix of the corresponding dynamic type, sharing the same cells. For example, if the receiver is an instance of type DenseDoubleMatrix3D the new matrix must also be of type DenseDoubleMatrix2D, if the receiver is an instance of type SparseDoubleMatrix3D the new matrix must also be of type SparseDoubleMatrix2D, etc.- Specified by:
like2D
in classDoubleMatrix3D
- Parameters:
rows
- the number of rows the matrix shall have.columns
- the number of columns the matrix shall have.rowZero
- the position of the first element.columnZero
- the position of the first element.rowStride
- the number of elements between two rows, i.e. index(i+1,j)-index(i,j).columnStride
- the number of elements between two columns, i.e. index(i,j+1)-index(i,j).- Returns:
- a new matrix of the corresponding dynamic type.
-
setQuick
public void setQuick(int slice, int row, int column, double value) Sets the matrix cell at coordinate [slice,row,column] to the specified value.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().
- Specified by:
setQuick
in classDoubleMatrix3D
- Parameters:
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.
-
setUp
protected void setUp(int slices, int rows, int columns) Sets up a matrix with a given number of slices and rows.- Overrides:
setUp
in classAbstractMatrix3D
- Parameters:
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.- Throws:
IllegalArgumentException
- if (double)rows*slices > Integer.MAX_VALUE.
-
vDice
Self modifying version of viewDice().- Overrides:
vDice
in classAbstractMatrix3D
- Throws:
IllegalArgumentException
- if some of the parameters are equal or not in range 0..2.
-
viewColumn
Constructs and returns a new 2-dimensional slice view representing the slices and rows of the given column. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.To obtain a slice view on subranges, construct a sub-ranging view (view().part(...)), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods viewColumn, viewRow) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps.
- Overrides:
viewColumn
in classDoubleMatrix3D
- Parameters:
column
- the index of the column to fix.- Returns:
- a new 2-dimensional slice view.
- Throws:
IndexOutOfBoundsException
- if column invalid input: '<' 0 || column >= columns().- See Also:
-
viewRow
Constructs and returns a new 2-dimensional slice view representing the slices and columns of the given row. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.To obtain a slice view on subranges, construct a sub-ranging view (view().part(...)), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods viewColumn, viewRow) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps.
- Overrides:
viewRow
in classDoubleMatrix3D
- Parameters:
row
- the index of the row to fix.- Returns:
- a new 2-dimensional slice view.
- Throws:
IndexOutOfBoundsException
- if row invalid input: '<' 0 || row >= row().- See Also:
-
viewSelectionLike
protected DoubleMatrix3D viewSelectionLike(int[] sliceOffsets, int[] rowOffsets, int[] columnOffsets) Construct and returns a new selection view.- Specified by:
viewSelectionLike
in classDoubleMatrix3D
- Parameters:
sliceOffsets
- the offsets of the visible elements.rowOffsets
- the offsets of the visible elements.columnOffsets
- the offsets of the visible elements.- Returns:
- a new view.
-
viewSlice
Constructs and returns a new 2-dimensional slice view representing the rows and columns of the given slice. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.To obtain a slice view on subranges, construct a sub-ranging view (view().part(...)), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods viewColumn, viewRow) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps.
- Overrides:
viewSlice
in classDoubleMatrix3D
- Parameters:
slice
- the index of the slice to fix.- Returns:
- a new 2-dimensional slice view.
- Throws:
IndexOutOfBoundsException
- if slice invalid input: '<' 0 || slice >= slices().- See Also:
-