Package cern.colt.matrix.impl
Class AbstractMatrix1D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.impl.AbstractMatrix
-
- cern.colt.matrix.impl.AbstractMatrix1D
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
DoubleMatrix1D,ObjectMatrix1D
public abstract class AbstractMatrix1D extends AbstractMatrix
Abstract base class for 1-d matrices (aka vectors) 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 intsizethe number of cells this matrix (view) hasprotected intstridethe number of indexes between any two elements, i.e.protected intzerothe 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 protectedAbstractMatrix1D()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_offset(int absRank)Returns the position of the given absolute rank within the (virtual or non-virtual) internal 1-dimensional array.protected int_rank(int rank)Returns the absolute rank of the given relative rank.protected voidcheckIndex(int index)Sanity check for operations requiring an index to be within bounds.protected voidcheckIndexes(int[] indexes)Checks whether indexes are legal and throws an exception, if necessary.protected voidcheckRange(int index, int width)Checks whether the receiver contains the given range and throws an exception, if necessary.protected voidcheckSize(double[] B)Sanity check for operations requiring two matrices with the same size.voidcheckSize(AbstractMatrix1D B)Sanity check for operations requiring two matrices with the same size.protected intindex(int rank)Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array.protected voidsetUp(int size)Sets up a matrix with a given number of cells.protected voidsetUp(int size, int zero, int stride)Sets up a matrix with the given parameters.intsize()Returns the number of cells.protected intstride(int dimension)Returns the stride of the given dimension (axis, rank).java.lang.StringtoStringShort()Returns a string representation of the receiver's shape.protected AbstractMatrix1DvFlip()Self modifying version of viewFlip().protected AbstractMatrix1DvPart(int index, int width)Self modifying version of viewPart().protected AbstractMatrix1DvStrides(int stride)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
-
-
-
-
Method Detail
-
_offset
protected int _offset(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.
-
_rank
protected int _rank(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.
-
checkIndex
protected void checkIndex(int index)
Sanity check for operations requiring an index to be within bounds.- Throws:
java.lang.IndexOutOfBoundsException- if index < 0 || index >= size().
-
checkIndexes
protected void checkIndexes(int[] indexes)
Checks whether indexes are legal and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if ! (0 <= indexes[i] < size()) for any i=0..indexes.length()-1.
-
checkRange
protected void checkRange(int index, int width)Checks whether the receiver contains the given range and throws an exception, if necessary.- Throws:
java.lang.IndexOutOfBoundsException- if index<0 || index+width>size().
-
checkSize
protected void checkSize(double[] B)
Sanity check for operations requiring two matrices with the same size.- Throws:
java.lang.IllegalArgumentException- if size() != B.size().
-
checkSize
public void checkSize(AbstractMatrix1D B)
Sanity check for operations requiring two matrices with the same size.- Throws:
java.lang.IllegalArgumentException- if size() != B.size().
-
index
protected int index(int rank)
Returns the position of the element with the given relative rank within the (virtual or non-virtual) internal 1-dimensional array. You may want to override this method for performance.- Parameters:
rank- the rank of the element.
-
setUp
protected void setUp(int size)
Sets up a matrix with a given number of cells.- Parameters:
size- the number of cells the matrix shall have.- Throws:
java.lang.IllegalArgumentException- if size<0.
-
setUp
protected void setUp(int size, int zero, int stride)Sets up a matrix with the given parameters.- Parameters:
size- the number of elements the matrix shall have.zero- the index of the first element.stride- the number of indexes between any two elements, i.e. index(i+1)-index(i).- Throws:
java.lang.IllegalArgumentException- if size<0.
-
size
public int size()
Returns the number of cells.- Specified by:
sizein classAbstractMatrix
-
stride
protected int stride(int dimension)
Returns the stride of the given dimension (axis, rank).- Returns:
- the stride in the given dimension.
- Throws:
java.lang.IllegalArgumentException- if dimension != 0.
-
toStringShort
public java.lang.String toStringShort()
Returns a string representation of the receiver's shape.
-
vFlip
protected AbstractMatrix1D vFlip()
Self modifying version of viewFlip(). What used to be index 0 is now index size()-1, ..., what used to be index size()-1 is now index 0.
-
vPart
protected AbstractMatrix1D vPart(int index, int width)
Self modifying version of viewPart().- Throws:
java.lang.IndexOutOfBoundsException- if index<0 || index+width>size().
-
vStrides
protected AbstractMatrix1D vStrides(int stride)
Self modifying version of viewStrides().- Throws:
java.lang.IndexOutOfBoundsException- if stride <= 0.
-
-