Class AbstractMatrix2D
java.lang.Object
cern.colt.PersistentObject
cern.colt.matrix.impl.AbstractMatrix
cern.colt.matrix.impl.AbstractMatrix2D
- All Implemented Interfaces:
Serializable, Cloneable
- Direct Known Subclasses:
DoubleMatrix2D, ObjectMatrix2D
Abstract base class for 2-d matrices holding objects or primitive data types such as
int, 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intthe number of colums and rows this matrix (view) hasprotected intthe number of elements between two columns, i.e.protected intthe index of the first elementprotected intthe number of colums and rows this matrix (view) hasprotected intthe number of elements between two rows, i.e.protected intthe index of the first elementFields inherited from class AbstractMatrix
isNoViewFields inherited from class PersistentObject
serialVersionUID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMakes this class non instantiable, but still let's others inherit from it. -
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_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 voidcheckBox(int row, int column, 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.voidSanity check for operations requiring two matrices with the same number of columns and rows.voidSanity check for operations requiring matrices with the same number of columns and rows.intcolumns()Returns the number of columns.protected intindex(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 rows, int columns) Sets up a matrix with a given number of rows and columns.protected voidsetUp(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) Sets up a matrix with a given number of rows and columns and the given strides.intsize()Returns the number of cells which is rows()*columns().Returns a string representation of the receiver's shape.protected AbstractMatrix2DSelf modifying version of viewColumnFlip().protected AbstractMatrix2DvDice()Self modifying version of viewDice().protected AbstractMatrix2DvPart(int row, int column, int height, int width) Self modifying version of viewPart().protected AbstractMatrix2DvRowFlip()Self modifying version of viewRowFlip().protected AbstractMatrix2DvStrides(int rowStride, int columnStride) Self modifying version of viewStrides().Methods inherited from class AbstractMatrix
ensureCapacity, isView, trimToSizeMethods inherited from class PersistentObject
clone
-
Field Details
-
columns
protected int columnsthe number of colums and rows this matrix (view) has -
rows
protected int rowsthe number of colums and rows this matrix (view) has -
rowStride
protected int rowStridethe number of elements between two rows, i.e. index(i+1,j,k) - index(i,j,k). -
columnStride
protected int columnStridethe number of elements between two columns, i.e. index(i,j+1,k) - index(i,j,k). -
rowZero
protected int rowZerothe index of the first element -
columnZero
protected int columnZerothe index of the first element
-
-
Constructor Details
-
AbstractMatrix2D
protected AbstractMatrix2D()Makes this class non instantiable, but still let's others inherit from it.
-
-
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.- 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.
-
checkBox
protected void checkBox(int row, int column, int height, int width) Checks whether the receiver contains the given box and throws an exception, if necessary.- Throws:
IndexOutOfBoundsException- if columninvalid input: '<'0 || widthinvalid input: '<'0 || column+width>columns() || rowinvalid input: '<'0 || heightinvalid input: '<'0 || row+height>rows()
-
checkColumn
protected void checkColumn(int column) Sanity check for operations requiring a column index to be within bounds.- Throws:
IndexOutOfBoundsException- if column invalid input: '<' 0 || column >= columns().
-
checkColumnIndexes
protected void checkColumnIndexes(int[] indexes) Checks whether indexes are legal and throws an exception, if necessary.- Throws:
IndexOutOfBoundsException- if ! (0 invalid input: '<'= indexes[i] invalid input: '<' 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:
IndexOutOfBoundsException- if row invalid input: '<' 0 || row >= rows().
-
checkRowIndexes
protected void checkRowIndexes(int[] indexes) Checks whether indexes are legal and throws an exception, if necessary.- Throws:
IndexOutOfBoundsException- if ! (0 invalid input: '<'= indexes[i] invalid input: '<' rows()) for any i=0..indexes.length()-1.
-
checkShape
Sanity check for operations requiring two matrices with the same number of columns and rows.- Throws:
IllegalArgumentException- if columns() != B.columns() || rows() != B.rows().
-
checkShape
Sanity check for operations requiring matrices with the same number of columns and rows.- Throws:
IllegalArgumentException- if columns() != B.columns() || rows() != B.rows() || columns() != C.columns() || rows() != C.rows().
-
columns
public int columns()Returns the number of columns. -
index
protected int index(int row, int column) Returns the position of the given coordinate within the (virtual or non-virtual) internal 1-dimensional array.- Parameters:
row- the index of the row-coordinate.column- the index of the column-coordinate.
-
rows
public int rows()Returns the number of rows. -
setUp
protected void setUp(int rows, int columns) Sets up a matrix with a given number of rows and columns.- Parameters:
rows- the number of rows the matrix shall have.columns- the number of columns the matrix shall have.- Throws:
IllegalArgumentException- if rowsinvalid input: '<'0 || columnsinvalid input: '<'0 || (double)columns*rows > Integer.MAX_VALUE.
-
setUp
protected void setUp(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) Sets up a matrix with a given number of rows and columns and the given strides.- 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).- Throws:
IllegalArgumentException- if rowsinvalid input: '<'0 || columnsinvalid input: '<'0 || (double)columns*rows > Integer.MAX_VALUE or flip's are illegal.
-
size
public int size()Returns the number of cells which is rows()*columns().- Specified by:
sizein classAbstractMatrix
-
toStringShort
Returns a string representation of the receiver's shape. -
vColumnFlip
Self modifying version of viewColumnFlip(). -
vDice
Self modifying version of viewDice(). -
vPart
Self modifying version of viewPart().- Throws:
IndexOutOfBoundsException- if columninvalid input: '<'0 || widthinvalid input: '<'0 || column+width>columns() || rowinvalid input: '<'0 || heightinvalid input: '<'0 || row+height>rows()
-
vRowFlip
Self modifying version of viewRowFlip(). -
vStrides
Self modifying version of viewStrides().- Throws:
IndexOutOfBoundsException- if rowStrideinvalid input: '<'=0 || columnStrideinvalid input: '<'=0.
-