Package cern.colt.matrix.impl
Class AbstractMatrix3D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.impl.AbstractMatrix
-
- cern.colt.matrix.impl.AbstractMatrix3D
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
DoubleMatrix3D,ObjectMatrix3D
public abstract class AbstractMatrix3D extends AbstractMatrix
Abstract base class for 3-d matrices holding objects or primitive data types such asint,double, etc. First see the package summary and javadoc tree view to get the broad picture.Note that this implementation is not synchronized.
- Version:
- 1.0, 09/24/99
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcolumnsthe number of columns this matrix (view) hasprotected intcolumnStridethe number of elements between two columns, i.e.protected intcolumnZerothe index of the first elementprotected introwsthe number of rows this matrix (view) hasprotected introwStridethe number of elements between two rows, i.e.protected introwZerothe index of the first elementprotected intslicesthe number of slices this matrix (view) hasprotected intsliceStridethe number of elements between two slices, i.e.protected intsliceZerothe index of the first element-
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix
isNoView
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMatrix3D()Makes this class non instantiable, but still let's others inherit from it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int_columnOffset(int absRank)Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.protected int_columnRank(int rank)Returns the absolute rank of the given relative rank.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_rowRank(int rank)Returns the absolute rank of the given relative rank.protected int_sliceOffset(int absRank)Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.protected int_sliceRank(int rank)Returns the absolute rank of the given relative rank.protected voidcheckBox(int slice, int row, int column, int depth, int height, int width)Checks whether the receiver contains the given box and throws an exception, if necessary.protected voidcheckColumn(int column)Sanity check for operations requiring a column index to be within bounds.protected voidcheckColumnIndexes(int[] indexes)Checks whether indexes are legal and throws an exception, if necessary.protected voidcheckRow(int row)Sanity check for operations requiring a row index to be within bounds.protected voidcheckRowIndexes(int[] indexes)Checks whether indexes are legal and throws an exception, if necessary.voidcheckShape(AbstractMatrix3D B)Sanity check for operations requiring two matrices with the same number of slices, rows and columns.voidcheckShape(AbstractMatrix3D B, AbstractMatrix3D C)Sanity check for operations requiring matrices with the same number of slices, rows and columns.protected voidcheckSlice(int slice)Sanity check for operations requiring a slice index to be within bounds.protected voidcheckSliceIndexes(int[] indexes)Checks whether indexes are legal and throws an exception, if necessary.intcolumns()Returns the number of columns.protected intindex(int slice, int row, int column)Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array.introws()Returns the number of rows.protected voidsetUp(int slices, int rows, int columns)Sets up a matrix with a given number of slices and rows.protected voidsetUp(int slices, int rows, int columns, int sliceZero, int rowZero, int columnZero, int sliceStride, int rowStride, int columnStride)Sets up a matrix with a given number of slices and rows and the given strides.protected int[]shape()intsize()Returns the number of cells which is slices()*rows()*columns().intslices()Returns the number of slices.java.lang.StringtoStringShort()Returns a string representation of the receiver's shape.protected AbstractMatrix3DvColumnFlip()Self modifying version of viewColumnFlip().protected AbstractMatrix3DvDice(int axis0, int axis1, int axis2)Self modifying version of viewDice().protected AbstractMatrix3DvPart(int slice, int row, int column, int depth, int height, int width)Self modifying version of viewPart().protected AbstractMatrix3DvRowFlip()Self modifying version of viewRowFlip().protected AbstractMatrix3DvSliceFlip()Self modifying version of viewSliceFlip().protected AbstractMatrix3DvStrides(int sliceStride, int rowStride, int columnStride)Self modifying version of viewStrides().-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix
ensureCapacity, isView, trimToSize
-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Field Detail
-
slices
protected int slices
the number of slices this matrix (view) has
-
rows
protected int rows
the number of rows this matrix (view) has
-
columns
protected int columns
the number of columns this matrix (view) has
-
sliceStride
protected int sliceStride
the number of elements between two slices, i.e. index(k+1,i,j) - index(k,i,j).
-
rowStride
protected int rowStride
the number of elements between two rows, i.e. index(k,i+1,j) - index(k,i,j).
-
columnStride
protected int columnStride
the number of elements between two columns, i.e. index(k,i,j+1) - index(k,i,j).
-
sliceZero
protected int sliceZero
the index of the first element
-
rowZero
protected int rowZero
the index of the first element
-
columnZero
protected int columnZero
the index of the first element
-
-
Method Detail
-
_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.- Parameters:
rank- the absolute rank of the element.- Returns:
- the position.
-
_columnRank
protected int _columnRank(int rank)
Returns the absolute rank of the given relative rank.- Parameters:
rank- the relative rank of the element.- Returns:
- the absolute rank of the element.
-
_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.- Parameters:
rank- the absolute rank of the element.- Returns:
- the position.
-
_rowRank
protected int _rowRank(int rank)
Returns the absolute rank of the given relative rank.- Parameters:
rank- the relative rank of the element.- Returns:
- the absolute rank of the element.
-
_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.- Parameters:
rank- the absolute rank of the element.- Returns:
- the position.
-
_sliceRank
protected int _sliceRank(int rank)
Returns the absolute rank of the given relative rank.- Parameters:
rank- the relative rank of the element.- Returns:
- the absolute rank of the element.
-
checkBox
protected void checkBox(int slice, int row, int column, int depth, int height, int width)Checks whether the receiver contains the given box and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if row<0 || height<0 || row+height>rows || slice<0 || depth<0 || slice+depth>slices || column<0 || width<0 || column+width>columns
-
checkColumn
protected void checkColumn(int column)
Sanity check for operations requiring a column index to be within bounds.- Throws:
java.lang.IndexOutOfBoundsException- if column < 0 || column >= columns().
-
checkColumnIndexes
protected void checkColumnIndexes(int[] indexes)
Checks whether indexes are legal and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if ! (0 <= indexes[i] < columns()) for any i=0..indexes.length()-1.
-
checkRow
protected void checkRow(int row)
Sanity check for operations requiring a row index to be within bounds.- Throws:
java.lang.IndexOutOfBoundsException- if row < 0 || row >= rows().
-
checkRowIndexes
protected void checkRowIndexes(int[] indexes)
Checks whether indexes are legal and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if ! (0 <= indexes[i] < rows()) for any i=0..indexes.length()-1.
-
checkShape
public void checkShape(AbstractMatrix3D B)
Sanity check for operations requiring two matrices with the same number of slices, rows and columns.- Throws:
java.lang.IllegalArgumentException- if slices() != B.slices() || rows() != B.rows() || columns() != B.columns().
-
checkShape
public void checkShape(AbstractMatrix3D B, AbstractMatrix3D C)
Sanity check for operations requiring matrices with the same number of slices, rows and columns.- Throws:
java.lang.IllegalArgumentException- if slices() != B.slices() || rows() != B.rows() || columns() != B.columns() || slices() != C.slices() || rows() != C.rows() || columns() != C.columns().
-
checkSlice
protected void checkSlice(int slice)
Sanity check for operations requiring a slice index to be within bounds.- Throws:
java.lang.IndexOutOfBoundsException- if slice < 0 || slice >= slices().
-
checkSliceIndexes
protected void checkSliceIndexes(int[] indexes)
Checks whether indexes are legal and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if ! (0 <= indexes[i] < slices()) for any i=0..indexes.length()-1.
-
columns
public int columns()
Returns the number of columns.
-
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.- Parameters:
slice- the index of the slice-coordinate.row- the index of the row-coordinate.column- the index of the third-coordinate.
-
rows
public int rows()
Returns the number of rows.
-
setUp
protected void setUp(int slices, int rows, int columns)Sets up a matrix with a given number of slices and rows.- 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:
java.lang.IllegalArgumentException- if (double)rows*slices > Integer.MAX_VALUE.java.lang.IllegalArgumentException- if slices<0 || rows<0 || columns<0.
-
setUp
protected void setUp(int slices, int rows, int columns, int sliceZero, int rowZero, int columnZero, int sliceStride, int rowStride, int columnStride)Sets up a matrix with a given number of slices and rows and the given strides.- 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.sliceZero- the position of the first element.rowZero- the position of the first element.columnZero- the position of the first element.sliceStride- the number of elements between two slices, i.e. index(k+1,i,j)-index(k,i,j).rowStride- the number of elements between two rows, i.e. index(k,i+1,j)-index(k,i,j).columnnStride- the number of elements between two columns, i.e. index(k,i,j+1)-index(k,i,j).- Throws:
java.lang.IllegalArgumentException- if (double)slices*rows*columnss > Integer.MAX_VALUE.java.lang.IllegalArgumentException- if slices<0 || rows<0 || columns<0.
-
shape
protected int[] shape()
-
size
public int size()
Returns the number of cells which is slices()*rows()*columns().- Specified by:
sizein classAbstractMatrix
-
slices
public int slices()
Returns the number of slices.
-
toStringShort
public java.lang.String toStringShort()
Returns a string representation of the receiver's shape.
-
vColumnFlip
protected AbstractMatrix3D vColumnFlip()
Self modifying version of viewColumnFlip().
-
vDice
protected AbstractMatrix3D vDice(int axis0, int axis1, int axis2)
Self modifying version of viewDice().- Throws:
java.lang.IllegalArgumentException- if some of the parameters are equal or not in range 0..2.
-
vPart
protected AbstractMatrix3D vPart(int slice, int row, int column, int depth, int height, int width)
Self modifying version of viewPart().- Throws:
java.lang.IndexOutOfBoundsException- if slice<0 || depth<0 || slice+depth>slices() || row<0 || height<0 || row+height>rows() || column<0 || width<0 || column+width>columns()
-
vRowFlip
protected AbstractMatrix3D vRowFlip()
Self modifying version of viewRowFlip().
-
vSliceFlip
protected AbstractMatrix3D vSliceFlip()
Self modifying version of viewSliceFlip().
-
vStrides
protected AbstractMatrix3D vStrides(int sliceStride, int rowStride, int columnStride)
Self modifying version of viewStrides().- Throws:
java.lang.IndexOutOfBoundsException- if sliceStride<=0 || rowStride<=0 || columnStride<=0.
-
-