Package cern.colt.matrix.impl
Class RCMDoubleMatrix2D
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.colt.matrix.impl.AbstractMatrix
-
- cern.colt.matrix.impl.AbstractMatrix2D
-
- cern.colt.matrix.DoubleMatrix2D
-
- cern.colt.matrix.impl.WrapperDoubleMatrix2D
-
- cern.colt.matrix.impl.RCMDoubleMatrix2D
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
class RCMDoubleMatrix2D extends WrapperDoubleMatrix2D
Sparse row-compressed-modified 2-d matrix holding double elements.- Version:
- 0.9, 04/14/2000
-
-
Field Summary
Fields Modifier and Type Field Description private IntArrayList[]
indexes
private DoubleArrayList[]
values
-
Fields inherited from class cern.colt.matrix.impl.WrapperDoubleMatrix2D
content
-
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix2D
columns, columnStride, columnZero, rows, rowStride, rowZero
-
Fields inherited from class cern.colt.matrix.impl.AbstractMatrix
isNoView
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description RCMDoubleMatrix2D(double[][] values)
Constructs a matrix with a copy of the given values.RCMDoubleMatrix2D(int rows, int columns)
Constructs a matrix with a given number of rows and columns.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DoubleMatrix2D
assign(double value)
Sets all cells to the state specified by value.protected DoubleMatrix2D
getContent()
Returns the content of this matrix if it is a wrapper; or this otherwise.double
getQuick(int row, int column)
Returns the matrix cell value at coordinate [row,column].DoubleMatrix2D
like(int rows, int columns)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified number of rows and columns.DoubleMatrix1D
like1D(int size)
Construct and returns a new 1-d matrix of the corresponding dynamic type, entirelly independent of the receiver.void
setQuick(int row, int column, double value)
Sets the matrix cell at coordinate [row,column] to the specified value.protected void
zMult(DoubleMatrix1D y, DoubleMatrix1D z, IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, double alpha, double beta)
Linear algebraic matrix-vector multiplication; z = A * y.-
Methods inherited from class cern.colt.matrix.impl.WrapperDoubleMatrix2D
like1D, viewColumn, viewColumnFlip, viewDice, viewPart, viewRow, viewRowFlip, viewSelection, viewSelectionLike, viewStrides
-
Methods inherited from class cern.colt.matrix.DoubleMatrix2D
aggregate, aggregate, assign, assign, assign, assign, cardinality, copy, equals, equals, forEachNonZero, get, getNonZeros, haveSharedCells, haveSharedCellsRaw, like, set, toArray, toString, view, viewSelection, viewSorted, zAssign8Neighbors, zMult, zMult, zMult, zMult, zSum
-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix2D
_columnOffset, _columnRank, _rowOffset, _rowRank, checkBox, checkColumn, checkColumnIndexes, checkRow, checkRowIndexes, checkShape, checkShape, columns, index, rows, setUp, setUp, size, toStringShort, vColumnFlip, vDice, vPart, vRowFlip, vStrides
-
Methods inherited from class cern.colt.matrix.impl.AbstractMatrix
ensureCapacity, isView, trimToSize
-
Methods inherited from class cern.colt.PersistentObject
clone
-
-
-
-
Field Detail
-
indexes
private IntArrayList[] indexes
-
values
private DoubleArrayList[] values
-
-
Constructor Detail
-
RCMDoubleMatrix2D
public RCMDoubleMatrix2D(double[][] values)
Constructs a matrix with a copy of the given values. values is required to have the form values[row][column] and have exactly the same number of columns in every row.The values are copied. So subsequent changes in values are not reflected in the matrix, and vice-versa.
- Parameters:
values
- The values to be filled into the new matrix.- Throws:
java.lang.IllegalArgumentException
- if for any 1 <= row < values.length: values[row].length != values[row-1].length.
-
RCMDoubleMatrix2D
public RCMDoubleMatrix2D(int rows, int columns)
Constructs a matrix with a given number of rows and columns. All entries are initially 0.- Parameters:
rows
- the number of rows the matrix shall have.columns
- the number of columns the matrix shall have.- Throws:
java.lang.IllegalArgumentException
- if rows<0 || columns<0 || (double)columns*rows > Integer.MAX_VALUE.
-
-
Method Detail
-
assign
public DoubleMatrix2D assign(double value)
Sets all cells to the state specified by value.- Overrides:
assign
in classDoubleMatrix2D
- Parameters:
value
- the value to be filled into the cells.- Returns:
- this (for convenience only).
-
getContent
protected DoubleMatrix2D getContent()
Returns the content of this matrix if it is a wrapper; or this otherwise. Override this method in wrappers.- Overrides:
getContent
in classWrapperDoubleMatrix2D
-
getQuick
public double getQuick(int row, int column)
Returns the matrix cell value at coordinate [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): 0 <= column < columns() && 0 <= row < rows().
- Overrides:
getQuick
in classWrapperDoubleMatrix2D
- Parameters:
row
- the index of the row-coordinate.column
- the index of the column-coordinate.- Returns:
- the value at the specified coordinate.
-
like
public DoubleMatrix2D like(int rows, int columns)
Construct and returns a new empty matrix of the same dynamic type as the receiver, having the specified number of rows and columns. For example, if the receiver is an instance of type DenseDoubleMatrix2D the new matrix must also be of type DenseDoubleMatrix2D, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must also be of type SparseDoubleMatrix2D, etc. In general, the new matrix should have internal parametrization as similar as possible.- Overrides:
like
in classWrapperDoubleMatrix2D
- Parameters:
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.
-
like1D
public DoubleMatrix1D like1D(int size)
Construct and returns a new 1-d matrix of the corresponding dynamic type, entirelly independent of the receiver. For example, if the receiver is an instance of type DenseDoubleMatrix2D the new matrix must be of type DenseDoubleMatrix1D, if the receiver is an instance of type SparseDoubleMatrix2D the new matrix must be of type SparseDoubleMatrix1D, etc.- Overrides:
like1D
in classWrapperDoubleMatrix2D
- Parameters:
size
- the number of cells the matrix shall have.- Returns:
- a new matrix of the corresponding dynamic type.
-
setQuick
public void setQuick(int row, int column, double value)
Sets the matrix cell at coordinate [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): 0 <= column < columns() && 0 <= row < rows().
- Overrides:
setQuick
in classWrapperDoubleMatrix2D
- Parameters:
row
- the index of the row-coordinate.column
- the index of the column-coordinate.value
- the value to be filled into the specified cell.
-
zMult
protected void zMult(DoubleMatrix1D y, DoubleMatrix1D z, IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, double alpha, double beta)
Linear algebraic matrix-vector multiplication; z = A * y. z[i] = alpha*Sum(A[i,j] * y[j]) + beta*z[i], i=0..A.rows()-1, j=0..y.size()-1. Where A == this.- Parameters:
y
- the source vector.z
- the vector where results are to be stored.- Throws:
java.lang.IllegalArgumentException
- if A.columns() != y.size() || A.rows() > z.size()).
-
-