public class DiagonalMatrix extends Object
| Constructor and Description |
|---|
DiagonalMatrix(DiagonalMatrix that)
Copy constructor.
|
DiagonalMatrix(double[] data)
Constructs a diagonal matrix from a
double[]. |
DiagonalMatrix(double[] data,
int nRows,
int nCols) |
DiagonalMatrix(int dim)
Constructs a 0 diagonal matrix of dimension dim * dim.
|
DiagonalMatrix(int nRows,
int nCols) |
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix that)
Computes the sum of two diagonal matrices.
|
DiagonalMatrix |
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.
|
DenseVector |
getDiagonal()
Gets the main diagonal of the matrix.
|
Vector |
getRow(int i)
Get the specified row in the matrix as a vector.
|
DenseVector |
getSubDiagonal()
Gets the sub-diagonal of the matrix.
|
DenseVector |
getSuperDiagonal()
Gets the super-diagonal of the matrix.
|
int |
hashCode() |
Matrix |
minus(Matrix that)
Computes the difference between two diagonal matrices.
|
Matrix |
multiply(Matrix that)
Computes the product of two diagonal matrices.
|
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.
|
DiagonalMatrix |
ONE()
Get an identity matrix that has the same dimension as this matrix.
|
DiagonalMatrix |
opposite()
For each a in G, there exists an element b in G such that
a + b = b + a = 0.
|
DiagonalMatrix |
scaled(double scalar)
Scale this matrix, A, by a constant.
|
void |
set(int i,
int j,
double value)
Set the matrix entry at [i,j] to a value.
|
DiagonalMatrix |
t()
The transpose of a diagonal 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() |
DiagonalMatrix |
ZERO()
The additive element 0 in the group, such that for all elements a in the group,
the equation 0 + a = a + 0 = a holds.
|
public DiagonalMatrix(double[] data)
double[]. For example,
gives \[ \begin{bmatrix} 1 & 0 & 0 & 0 & 0\\ 0 & 2 & 0 & 0 & 0\\ 0 & 0 & 3 & 0 & 0\\ 0 & 0 & 0 & 4 & 0\\ 0 & 0 & 0 & 0 & 5 \end{bmatrix} \]new double[][]{ {1, 2, 3, 4, 5}, }
data - the 1D array inputpublic DiagonalMatrix(double[] data,
int nRows,
int nCols)
public DiagonalMatrix(int dim)
dim - the matrix dimensionpublic DiagonalMatrix(int nRows,
int nCols)
public DiagonalMatrix(DiagonalMatrix that)
that - a diagonal matrixpublic DiagonalMatrix deepCopy()
DeepCopyablethis by the copy
constructor of the class, or just this if the instance itself is
immutable.public int nRows()
Tablepublic int nCols()
Tablepublic Matrix add(Matrix that)
add in interface MatrixRingadd in interface AbelianGroup<Matrix>that - a diagonal matrixthis + thatpublic Matrix minus(Matrix that)
minus in interface MatrixRingminus in interface AbelianGroup<Matrix>that - a diagonal matrixthis - thatpublic Matrix multiply(Matrix that)
multiply in interface MatrixRingmultiply in interface Monoid<Matrix>that - a diagonal matrixthis * thatpublic Vector multiply(Vector v)
Matrixpublic DiagonalMatrix scaled(double scalar)
Matrixscalar - a doublepublic DiagonalMatrix opposite()
AbelianGroupthis.add(this.opposite()) == this.ZEROpublic DiagonalMatrix t()
public DiagonalMatrix ZERO()
AbelianGrouppublic DiagonalMatrix ONE()
MatrixRingpublic String toString()
public DenseMatrix toDense()
DensifiableDenseMatrix.toDense in interface DensifiableDenseMatrixpublic DenseVector getDiagonal()
public DenseVector getSuperDiagonal()
public DenseVector getSubDiagonal()
public void set(int i,
int j,
double value)
throws MatrixAccessException
MatrixAccessset in interface MatrixAccessi - the row indexj - 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)
Matrixpublic Vector getColumn(int j)
MatrixCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.