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()
DeepCopyable
this
by the copy
constructor of the class, or just this
if the instance itself is
immutable.public int nRows()
Table
public int nCols()
Table
public Matrix add(Matrix that)
add
in interface MatrixRing
add
in interface AbelianGroup<Matrix>
that
- a diagonal matrixthis
+ that
public Matrix minus(Matrix that)
minus
in interface MatrixRing
minus
in interface AbelianGroup<Matrix>
that
- a diagonal matrixthis
- that
public Matrix multiply(Matrix that)
multiply
in interface MatrixRing
multiply
in interface Monoid<Matrix>
that
- a diagonal matrixthis
* that
public Vector multiply(Vector v)
Matrix
public DiagonalMatrix scaled(double scalar)
Matrix
scalar
- a doublepublic DiagonalMatrix opposite()
AbelianGroup
this.add(this.opposite()) == this.ZERO
public DiagonalMatrix t()
public DiagonalMatrix ZERO()
AbelianGroup
public DiagonalMatrix ONE()
MatrixRing
public String toString()
public DenseMatrix toDense()
Densifiable
DenseMatrix
.toDense
in interface Densifiable
DenseMatrix
public DenseVector getDiagonal()
public DenseVector getSuperDiagonal()
public DenseVector getSubDiagonal()
public void set(int i, int j, double value) throws MatrixAccessException
MatrixAccess
set
in interface MatrixAccess
i
- 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
MatrixAccess
get
in interface MatrixAccess
i
- the row indexj
- the column indexMatrixAccessException
- if i or j is out of rangepublic Vector getRow(int i)
Matrix
public Vector getColumn(int j)
Matrix
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.