|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ru.sscc.matrix.RealMatrix | +--ru.sscc.matrix.DenseMatrix
An implementation of a rectangular dense matrix. In simple case the matrix is stored in the container "by rows", e.g. (i,j)th entry of the matrix is mapped to the (i*nColumns+j)-th entry of the matrix container. The "by columns" ordering is also possible. In common case, the position of (i,j)th entry in the underlying container is calculated by the formula startIndex + i*rowStep + j*columnStep
Common operations upon the matrix are implemented: matrix-by-vector multiplication, transposition, matrix assignment, and creation of a submatrix. A transposed matrix and submatrix share their bodies with the parent matrix.
Field Summary | |
int |
columnStep
The distance between two neighbour entries of the same row. |
int |
rowStep
The distance between two neighbour entries of the same column. |
int |
startIndex
The index of the first matrix entry in the container. |
Fields inherited from class ru.sscc.matrix.RealMatrix |
entries,
nColumns,
nRows |
Constructor Summary | |
|
DenseMatrix(int nRows,
int nColumns)
Constructs an instance with a clear double[] type matrix container and the "by rows" ordering. |
|
DenseMatrix(int nRows,
int nColumns,
boolean byRows)
Constructs an instance with a clear double[] type matrix container with selection of "by rows" or "by columns" ordering. |
|
DenseMatrix(RealContainer entries,
int nRows,
int nColumns)
Constructs an instance based on a user's real data container and ordered "by rows". |
|
DenseMatrix(RealContainer entries,
int nRows,
int nColumns,
boolean byRows)
Constructs an instance based on a user's real data container with selection of "by rows" or "by columns" ordering. |
protected |
DenseMatrix(RealContainer entries,
int nRows,
int nColumns,
int startIndex,
int rowStep,
int columnStep)
Constructs an instance based on a submatrix of a user's real data container. |
|
DenseMatrix(RealMatrix matrix)
Constructs "by rows" ordered instance as a copy of a real matrix. |
|
DenseMatrix(RealMatrix matrix,
boolean byRows)
Constructs an instance as a copy of a real matrix with selection of "by rows" or "by columns" ordering. |
Method Summary | |
double |
add(int i,
int j,
double value)
Adds the value of a matrix entry at the position (i,j). |
void |
assign(DenseMatrix matrix)
Assignment: this = matrix (a dense matrix on the right). |
void |
assign(RealMatrix matrix)
Assignment: this = matrix (an arbitrary real matrix on the right). |
java.lang.Object |
clone()
Clones the matrix. |
double |
get(int i,
int j)
Gets a value of a matrix entry at the position (i,j). |
RealVector |
getColumn(int j)
Returns the j-th column of the matrix (the vector is constructed upon the matrix container). |
RealVector |
getRow(int i)
Returns the i-th row of the matrix (the vector is constructed upon the matrix container). |
double |
mul(int i,
int j,
double value)
Multiplies a matrix entry at the position (i,j) by a value. |
void |
multiply(RealVector source,
RealVector target)
Multiplies the matrix by a column-vector. |
void |
multiplyAndAdd(double multiple,
RealVector source,
RealVector target)
Calculates y += a * Ax, eg multiplies the matrix by a source column-vector, then multiplies the result by a real number and adds the result to the target vector. |
void |
multiplyAndAddT(double multiple,
RealVector source,
RealVector target)
Calculates y += a * ATx, eg multiplies the transposed matrix by a source column-vector, then multiplies the result by a real number and adds the result to the target vector. |
void |
multiplyT(RealVector source,
RealVector target)
Multiplies the transposed matrix by a column-vector. |
double |
norm()
Calculates the euclidean matrix norm (the square root of the sum of squared entries). |
double |
normMax()
Calculates the matrix norm subordinated to the vector max-norm. |
double |
normSum()
Calculates the matrix norm subordinated to the vector sum-norm. |
protected int |
pos(int i,
int j)
Returns the position of (i,j)th matrix entry in the container. |
void |
reuse()
Allows to use the matrix in algebraic operations. |
double |
set(int i,
int j,
double value)
Sets the value of a matrix entry at the position (i,j). |
DenseMatrix |
submatrix(int i,
int j,
int nRows,
int nColumns)
Generates a submatrix that starts from (i,j)th position of the matrix. |
DenseMatrix |
submatrix(int i,
int j,
int nRows,
int nColumns,
int rowInc,
int columnInc)
Generates a submatrix that starts from (i,j)th position of the matrix and is stored in it with specified increments. |
DenseMatrix |
transpose()
Generates the transposed matrix based on the same container. |
Methods inherited from class ru.sscc.matrix.RealMatrix |
columnsNumber,
ensureAlgebraic,
ensureDimensions,
ensureDimensions,
ensureSquareMatrix,
getContainer,
lock,
multiplyNN,
multiplyNT,
multiplyTN,
multiplyTT,
relativeAccuracy,
rowsNumber,
unlock |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public final int startIndex
public final int rowStep
public final int columnStep
Constructor Detail |
public DenseMatrix(int nRows, int nColumns)
nRows
- a number of matrix rowsnColumns
- a number of matrix columnspublic DenseMatrix(int nRows, int nColumns, boolean byRows)
nRows
- a number of matrix rowsnColumns
- a number of matrix columnsbyRows
- equals true if "by rows" ordering is usedpublic DenseMatrix(RealMatrix matrix)
matrix
- the real matrix to get a copy frompublic DenseMatrix(RealMatrix matrix, boolean byRows)
matrix
- the real matrix to get a copy frompublic DenseMatrix(RealContainer entries, int nRows, int nColumns)
entries
- a container of matrix entriesnRows
- a number of matrix rowsnColumns
- a number of matrix columnspublic DenseMatrix(RealContainer entries, int nRows, int nColumns, boolean byRows)
entries
- a container of matrix entriesnRows
- a number of matrix rowsnColumns
- a number of matrix columnsbyRows
- equals true if "by rows" ordering is usedprotected DenseMatrix(RealContainer entries, int nRows, int nColumns, int startIndex, int rowStep, int columnStep)
entries
- a container of matrix entriesnRows
- a number of matrix rowsnColumns
- a number of matrix columnsstartIndex
- an index of the first matrix entry in the containerrowStep
- an interrow distancecolumnStep
- an intercolumn distanceMethod Detail |
public final DenseMatrix submatrix(int i, int j, int nRows, int nColumns)
i
- the first row numberj
- the first column numbernRows
- a number of submatrix rowsnColumns
- a number of submatrix columnspublic final DenseMatrix submatrix(int i, int j, int nRows, int nColumns, int rowInc, int columnInc)
i
- the first row numberj
- the first column numbernRows
- a number of submatrix rowsnColumns
- a number of submatrix columnsrowInc
- an increment between neighbour rowscolumnInc
- an increment between neighbour columnspublic final DenseMatrix transpose()
public void multiply(RealVector source, RealVector target)
source
- a source vector to multiplytarget
- a target vector to write the resultpublic void multiplyT(RealVector source, RealVector target)
source
- a source vector to multiplytarget
- a target vector to write the resultpublic void multiplyAndAdd(double multiple, RealVector source, RealVector target)
multiple
- a multiplesource
- a source vector to multiplytarget
- a target vector to add the resultpublic void multiplyAndAddT(double multiple, RealVector source, RealVector target)
multiple
- a multiplesource
- a source vector to multiplytarget
- a target vector to add the resultpublic final RealVector getRow(int i)
public final RealVector getColumn(int j)
public double get(int i, int j)
i
- a zero based row numberj
- a zero based column numberpublic double set(int i, int j, double value)
i
- a zero based row numberj
- a zero based column numbervalue
- a value to setpublic double add(int i, int j, double value)
i
- a zero based row numberj
- a zero based column numbervalue
- a value to setpublic double mul(int i, int j, double value)
i
- a zero based row numberj
- a zero based column numbervalue
- a value to setpublic final void reuse()
protected final int pos(int i, int j)
public java.lang.Object clone()
public void assign(RealMatrix matrix)
matrix
- the matrix to get copy frompublic void assign(DenseMatrix matrix)
matrix
- the matrix to get copy frompublic double norm()
public double normMax()
public double normSum()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |