public class SymmetricMatrix extends Object implements Matrix, Densifiable
A[i][j] = A[j][i]| Constructor and Description |
|---|
SymmetricMatrix(double[][] data)
Construct a symmetric matrix from a 2D
double[][] array. |
SymmetricMatrix(int dim)
Construct a symmetric matrix of dimension dim * dim.
|
SymmetricMatrix(Matrix A)
Cast an (almost) symmetric matrix into SymmetricMatrix by averaging A(i,j) and
A(j,i).
|
SymmetricMatrix(Matrix A,
boolean copyLower)
Cast an (almost) symmetric matrix into SymmetricMatrix.
|
SymmetricMatrix(SymmetricMatrix S)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix that)
this + that
|
SymmetricMatrix |
deepCopy()
The implementation returns an instance created from
this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
boolean |
equals(Object obj) |
double |
get(int i,
int j)
Get the matrix entry at [i,j].
|
Vector |
getColumn(int j)
Get the specified column in the matrix as a vector.
|
Vector |
getRow(int i)
Get the specified row in the matrix as a vector.
|
int |
hashCode() |
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()
Gets the number of columns.
|
int |
nRows()
Gets the number of rows.
|
SymmetricMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
SymmetricMatrix |
opposite()
Get the opposite of this matrix.
|
SymmetricMatrix |
scaled(double scalar)
Scale this matrix, A, by a constant.
|
void |
set(int row,
int col,
double value)
Set the matrix entry at [i,j] to a value.
|
SymmetricMatrix |
t()
The transpose of a symmetric matrix is the same as itself.
|
DenseMatrix |
toDense()
Densify a matrix, i.e., convert a matrix implementation to the standard dense matrix,
DenseMatrix. |
String |
toString() |
SymmetricMatrix |
ZERO()
Get a zero matrix that has the same dimension as this matrix.
|
public SymmetricMatrix(int dim)
dim - the matrix dimensionpublic SymmetricMatrix(double[][] data)
double[][] array.
The array specifies only the lower triangular part (main diagonal inclusive) of the whole
matrix.
For example,
new double[][]{
{1},
{2, 3},
{4, 5, 6},
{7, 8, 9, 10},
{11, 12, 13, 14, 15}});
gives
\[
\begin{bmatrix}
1 & 2 & 4 & 7 & 11\\
2 & 3 & 5 & 8 & 12\\
4 & 5 & 6 & 9 & 13\\
7 & 8 & 9 & 10 & 14\\
11 & 12 & 13 & 14 & 15
\end{bmatrix}
\]
This constructor uses lower instead of upper triangular representation for visual reason.data - the lower triangular specificationpublic SymmetricMatrix(Matrix A)
A - an (almost) symmetric matrixpublic SymmetricMatrix(Matrix A, boolean copyLower)
A - an (almost) symmetric matrixcopyLower - true if the lower triangular portion of A is used; otherwise, the
average values of A(i,j) and A(j,i) are usedpublic SymmetricMatrix(SymmetricMatrix S)
S - a symmetric matrixpublic int nRows()
Tablepublic int nCols()
Tablepublic SymmetricMatrix deepCopy()
DeepCopyablethis by the copy
constructor of the class, or just this if the instance itself is
immutable.deepCopy in interface MatrixdeepCopy in interface DeepCopyablepublic DenseMatrix toDense()
DensifiableDenseMatrix.toDense in interface DensifiableDenseMatrixpublic void set(int row,
int col,
double value)
throws MatrixAccessException
MatrixAccessset in interface MatrixAccessrow - the row indexcol - the column indexvalue - the value to set A[i,j] toMatrixAccessException - if i or j is out of rangepublic double get(int i,
int j)
throws MatrixAccessException
MatrixAccessget in interface MatrixAccessi - the row indexj - the column indexMatrixAccessException - if i or j is out of rangepublic Vector getRow(int i) throws MatrixAccessException
MatrixgetRow in interface Matrixi - the row indexMatrixAccessException - when i < 1, or when i > the number of rowspublic Vector getColumn(int j) throws MatrixAccessException
MatrixgetColumn in interface Matrixj - the column indexMatrixAccessException - when j < 1, or when j > the number of columnspublic Matrix add(Matrix that)
MatrixRingadd in interface MatrixRingadd in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix minus(Matrix that)
MatrixRingminus in interface MatrixRingminus in interface AbelianGroup<Matrix>that - a matrixthis and thatpublic Matrix multiply(Matrix that)
MatrixRingmultiply in interface MatrixRingmultiply in interface Monoid<Matrix>that - a matrixthis and thatpublic SymmetricMatrix t()
t in interface MatrixRingpublic SymmetricMatrix scaled(double scalar)
Matrixpublic SymmetricMatrix opposite()
MatrixRingopposite in interface MatrixRingopposite in interface AbelianGroup<Matrix>public SymmetricMatrix ZERO()
MatrixRingZERO in interface MatrixRingZERO in interface AbelianGroup<Matrix>public SymmetricMatrix ONE()
MatrixRingONE in interface MatrixRingONE in interface Monoid<Matrix>public Vector multiply(Vector v)
MatrixCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.