Class SelectedDenseDoubleMatrix1D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.impl.AbstractMatrix
-
- cern.colt.matrix.impl.AbstractMatrix1D
-
- cern.colt.matrix.DoubleMatrix1D
-
- cern.colt.matrix.impl.SelectedDenseDoubleMatrix1D
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
class SelectedDenseDoubleMatrix1D extends DoubleMatrix1D
Selection view on dense 1-d matrices holding double elements. First see the package summary and javadoc tree view to get the broad picture.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, 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 1 additional array index access per get/set.
Note that this implementation is not synchronized.
Memory requirements:
memory [bytes] = 4*indexes.length. Thus, an index view with 1000 indexes additionally uses 4 KB.
Time complexity:
Depends on the parent view holding cells.
- Version:
- 1.0, 09/24/99
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]
elements
The elements of this matrix.protected int
offset
The offset.protected int[]
offsets
The offsets of visible indexes of this matrix.-
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix1D
size, stride, zero
-
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix
isNoView
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SelectedDenseDoubleMatrix1D(double[] elements, int[] offsets)
Constructs a matrix view with the given parameters.protected
SelectedDenseDoubleMatrix1D(int size, double[] elements, int zero, int stride, int[] offsets, int offset)
Constructs a matrix view with the given parameters.
-
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.double
getQuick(int index)
Returns the matrix cell value at coordinate index.protected boolean
haveSharedCellsRaw(DoubleMatrix1D other)
Returns true if both matrices share at least one identical cell.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.DoubleMatrix1D
like(int size)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size.DoubleMatrix2D
like2D(int rows, int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver.void
setQuick(int index, double value)
Sets the matrix cell at coordinate index to the specified value.protected void
setUp(int size)
Sets up a matrix with a given number of cells.protected DoubleMatrix1D
viewSelectionLike(int[] offsets)
Construct and returns a new selection view.-
Methods inherited from class cern.colt.matrix.DoubleMatrix1D
aggregate, aggregate, assign, assign, assign, assign, assign, assign, cardinality, cardinality, copy, equals, equals, get, getContent, getNonZeros, getNonZeros, haveSharedCells, like, set, swap, toArray, toArray, toString, view, viewFlip, viewPart, viewSelection, viewSelection, viewSorted, viewStrides, zDotProduct, zDotProduct, zDotProduct, zDotProduct, zSum
-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix1D
_rank, checkIndex, checkIndexes, checkRange, checkSize, checkSize, setUp, size, stride, toStringShort, vFlip, vPart, vStrides
-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix
ensureCapacity, isView, trimToSize
-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Constructor Detail
-
SelectedDenseDoubleMatrix1D
protected SelectedDenseDoubleMatrix1D(double[] elements, int[] offsets)
Constructs a matrix view with the given parameters.- Parameters:
elements
- the cells.indexes
- The indexes of the cells that shall be visible.
-
SelectedDenseDoubleMatrix1D
protected SelectedDenseDoubleMatrix1D(int size, double[] elements, int zero, int stride, int[] offsets, int offset)
Constructs a matrix view with the given parameters.- Parameters:
size
- the number of cells the matrix shall have.elements
- the cells.zero
- the index of the first element.stride
- the number of indexes between any two elements, i.e. index(i+1)-index(i).offsets
- the offsets of the cells that shall be visible.offset
-
-
-
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.- Overrides:
_offset
in classAbstractMatrix1D
- Parameters:
rank
- the absolute rank of the element.- Returns:
- the position.
-
getQuick
public double getQuick(int index)
Returns the matrix cell value at coordinate index.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): index<0 || index>=size().
- Specified by:
getQuick
in classDoubleMatrix1D
- Parameters:
index
- the index of the cell.- Returns:
- the value of the specified cell.
-
haveSharedCellsRaw
protected boolean haveSharedCellsRaw(DoubleMatrix1D other)
Returns true if both matrices share at least one identical cell.- Overrides:
haveSharedCellsRaw
in classDoubleMatrix1D
-
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.- Overrides:
index
in classAbstractMatrix1D
- Parameters:
rank
- the rank of the element.
-
like
public DoubleMatrix1D like(int size)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified size. For example, if the receiver is an instance of type DenseDoubleMatrix1D the new matrix must also be of type DenseDoubleMatrix1D, if the receiver is an instance of type SparseDoubleMatrix1D the new matrix must also be of type SparseDoubleMatrix1D, etc. In general, the new matrix should have internal parametrization as similar as possible.- Specified by:
like
in classDoubleMatrix1D
- Parameters:
size
- the number of cell the matrix shall have.- Returns:
- a new empty matrix of the same dynamic type.
-
like2D
public DoubleMatrix2D like2D(int rows, int columns)
Construct and returns a new 2-d matrix of the corresponding dynamic type, entirelly independent of the receiver. For example, if the receiver is an instance of type DenseDoubleMatrix1D the new matrix must be of type DenseDoubleMatrix2D, if the receiver is an instance of type SparseDoubleMatrix1D the new matrix must be of type SparseDoubleMatrix2D, etc.- Specified by:
like2D
in classDoubleMatrix1D
- Parameters:
rows
- the number of rows the matrix shall have.columns
- the number of columns the matrix shall have.- Returns:
- a new matrix of the corresponding dynamic type.
-
setQuick
public void setQuick(int index, double value)
Sets the matrix cell at coordinate index 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): index<0 || index>=size().
- Specified by:
setQuick
in classDoubleMatrix1D
- Parameters:
index
- the index of the cell.value
- the value to be filled into the specified cell.
-
setUp
protected void setUp(int size)
Sets up a matrix with a given number of cells.- Overrides:
setUp
in classAbstractMatrix1D
- Parameters:
size
- the number of cells the matrix shall have.
-
viewSelectionLike
protected DoubleMatrix1D viewSelectionLike(int[] offsets)
Construct and returns a new selection view.- Specified by:
viewSelectionLike
in classDoubleMatrix1D
- Parameters:
offsets
- the offsets of the visible elements.- Returns:
- a new view.
-
-