|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.matrix.doubles.operation.SubMatrixRef
public class SubMatrixRef
This class creates a 'reference' to a sub-part of a large matrix without copying it. Often, we only need to work on a part of a matrix. We do not want to make copies of a matrix for performance reason.
Example applications include printing a sub-matrix.
The reference sub-matrix is immutable.
| Constructor Summary | |
|---|---|
SubMatrixRef(Matrix A)
Construct a sub-matrix reference. |
|
SubMatrixRef(Matrix A,
int rowFrom,
int rowTo,
int colFrom,
int colTo)
Construct a sub-matrix reference. |
|
| Method Summary | |
|---|---|
Matrix |
add(Matrix that)
this + that |
SubMatrixRef |
deepCopy()
Return 'this' as this Matrix is immutable. |
double |
get(int row,
int col)
Get the matrix entry at [row, col]. |
Vector |
getColumn(int col)
Get a specified column as a vector. |
Vector |
getRow(int row)
Get a specified row as a vector. |
Matrix |
minus(Matrix that)
this - that |
Matrix |
multiply(Matrix that)
this %*% that |
Vector |
multiply(Vector v)
Right multiply this matrix, A by a vector. |
int |
nCols()
Get the number of columns. |
int |
nRows()
Get the number of rows. |
Matrix |
ONE()
Get an identity matrix that has the same dimension as this matrix. |
Matrix |
opposite()
Get the opposite of this matrix. |
Matrix |
scaled(double scalar)
scalar * this |
void |
set(int row,
int col,
double value)
Deprecated. SubMatrixRef is immutable |
Matrix |
t()
t(this)
Compute the transpose of this matrix. |
java.lang.String |
toString()
|
Matrix |
ZERO()
Get a zero matrix that has the same dimension as this matrix. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SubMatrixRef(Matrix A,
int rowFrom,
int rowTo,
int colFrom,
int colTo)
A - the matrix to be taken a sub-snapshot from without copyingrowFrom - the beginning row indexrowTo - the ending row indexcolFrom - the beginning column indexcolTo - the ending column index
java.lang.IndexOutOfBoundsException - if rowFrom, rowTo, colFrom, colTo are invalidpublic SubMatrixRef(Matrix A)
A - the matrix to be referenced| Method Detail |
|---|
public int nRows()
MatrixDimension
nRows in interface MatrixDimensionpublic int nCols()
MatrixDimension
nCols in interface MatrixDimension
public double get(int row,
int col)
MatrixAccessor[row, col].
get in interface MatrixAccessorrow - the row indexcol - the column index
A[row, col]public Vector getRow(int row)
MatrixAccessor
getRow in interface MatrixAccessorrow - the row index
A[row, ]public Vector getColumn(int col)
MatrixAccessor
getColumn in interface MatrixAccessorcol - the column index
A[, col]public Matrix add(Matrix that)
MatrixRingthis + that
add in interface AbelianGroup<Matrix>add in interface MatrixRingthat - another matrix
this and thatpublic Matrix minus(Matrix that)
MatrixRingthis - that
minus in interface AbelianGroup<Matrix>minus in interface MatrixRingthat - another matrix
this and thatpublic Matrix multiply(Matrix that)
MatrixRingthis %*% that
multiply in interface Monoid<Matrix>multiply in interface MatrixRingthat - another matrix
this and thatpublic Vector multiply(Vector v)
MatrixA by a vector.
multiply in interface Matrixv - a vector
A %*% vpublic Matrix scaled(double scalar)
Matrixscalar * this
scaled in interface Matrixscalar - a double
scalar * thispublic Matrix opposite()
MatrixRing
opposite in interface AbelianGroup<Matrix>opposite in interface MatrixRing-thispublic Matrix ZERO()
MatrixRing
ZERO in interface AbelianGroup<Matrix>ZERO in interface MatrixRingpublic Matrix ONE()
MatrixRingFor a non-square matrix, it zeros out the rows (columns) with index > nCols (nRows).
ONE in interface Monoid<Matrix>ONE in interface MatrixRingpublic java.lang.String toString()
toString in class java.lang.Objectpublic Matrix t()
MatrixRingt(this)
Compute the transpose of this matrix. The original matrix does not change. The returned value is independent and can be modified anyhow.
This is the involution on the matrix ring.
t in interface MatrixRingpublic SubMatrixRef deepCopy()
Matrix is immutable. To produce a mutable
copy, a deep copy of the referenced matrix is needed.
deepCopy in interface DeepCopyabledeepCopy in interface Matrix
@Deprecated
public void set(int row,
int col,
double value)
throws MatrixAccessException
MatrixAccessor[row, col] to value.
This is the only method that may change the entries of a matrix.
set in interface MatrixAccessorrow - the row indexcol - the column indexvalue - the value to set A[row, col] to
MatrixAccessException - if row or col is out of range
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||