@PublicationReference(author="Bjorn-Ove Heimsund", title="Matrix Toolkits for Java BandMatrix", type=WebPage, year=2006, url="http://ressim.berlios.de/doc/no/uib/cipr/matrix/BandMatrix.html", notes="This class wraps the BandMatrix class from Heimsund\'s MTJ package") public class DiagonalMatrixMTJ extends AbstractMTJMatrix implements DiagonalMatrix
Modifier | Constructor and Description |
---|---|
protected |
DiagonalMatrixMTJ(DiagonalMatrixMTJ other)
Copy Constructor
|
protected |
DiagonalMatrixMTJ(double[] diagonal)
Creates a new instance of DiagonalMatrixMTJ
|
protected |
DiagonalMatrixMTJ(int dim)
Creates a new instance of DiagonalMatrixMTJ
|
Modifier and Type | Method and Description |
---|---|
void |
convertFromVector(Vector parameters)
uploads a matrix from a column-stacked vector of parameters, so that
v(k) = A(i,j) = A( k%M, k/M )
|
DenseVector |
convertToVector()
Creates a column-stacked version of this, so that
v(k) = A(i,j) = v(j*M+i)
|
DiagonalMatrixMTJ |
dotTimes(Matrix matrix)
Element-wise multiplication of
this and other |
void |
dotTimesEquals(AbstractMTJMatrix matrix)
Inline element-wise multiplication of the elements in
this
and matrix , modifies the elements of this |
Vector |
getColumn(int columnIndex)
Gets the specified column from the zero-based index and returns a
vector that corresponds to that column.
|
double[] |
getDiagonal()
Gets the data along the diagonal
|
int |
getDimensionality()
Gets the dimensionality of this square matrix, which is equal to either
the number of rows or the number of columns
|
double |
getElement(int index)
Gets the zero-based index diagonal element into the diagonal matrix
|
double |
getElement(int rowIndex,
int columnIndex)
Gets the Matrix element at the specified zero-based indices
throws ArrayIndexOutOfBoundsException if either rowIndex or columnIndex
are less than 0, or greater than the number of rows (columns) minus one
(0 <= index <= num-1)
|
int |
getEntryCount()
Gets the number of active entries in the matrix.
|
no.uib.cipr.matrix.BandMatrix |
getInternalMatrix()
Gets the internal MTJ matrix that this class is wrapping.
|
MatrixFactory<?> |
getMatrixFactory()
Gets a matrix factory, typically one associated with this type of matrix.
|
Vector |
getRow(int rowIndex)
Gets the specified row from the zero-based index and returns a vector
that corresponds to that column
|
SparseMatrix |
getSubMatrix(int minRow,
int maxRow,
int minColumn,
int maxColumn)
Gets the embedded submatrix inside of the Matrix, specified by the
inclusive, zero-based indices such that the result matrix will have size
(maxRow-minRow+1) x (maxColum-minCcolumn+1)
|
DiagonalMatrixMTJ |
inverse()
Computes the full-blown inverse of
this , which must be a
square matrix |
boolean |
isSparse()
Returns true if this matrix has a potentially sparse underlying
structure.
|
boolean |
isSquare()
Determines if the matrix is square (numRows == numColumns)
|
boolean |
isSymmetric()
Determines if the matrix is symmetric.
|
boolean |
isSymmetric(double effectiveZero)
Determines if the matrix is effectively symmetric
|
ComplexNumber |
logDeterminant()
Computes the natural logarithm of the determinant of
this . |
double |
normFrobenius()
Compute the Frobenius norm of
this , which is just a fancy
way of saying that I will square each element, add those up, and square
root the result. |
DiagonalMatrixMTJ |
pseudoInverse()
Computes the effective pseudo-inverse of
this , using a
rather expensive procedure (SVD) |
DiagonalMatrixMTJ |
pseudoInverse(double effectiveZero)
Computes the effective pseudo-inverse of
this , using a
rather expensive procedure (SVD) |
int |
rank(double effectiveZero)
Computes the effective rank of
this , which is the number of
linearly independent rows and columns in this . |
void |
setElement(int index,
double value)
Sets the zero-based index diagonal element into the diagonal matrix
|
void |
setElement(int rowIndex,
int columnIndex,
double value)
Sets the Matrix element at the specified zero-based indices
throws ArrayIndexOutOfBoundsException if either rowIndex or columnIndex
are less than 0, or greater than the number of rows (columns) minus one
(0 <= index <= num-1)
|
protected void |
setInternalMatrix(no.uib.cipr.matrix.Matrix internalMatrix)
Setter for internalMatrix
|
Vector |
solve(AbstractMTJVector b)
Solves for "x" in the equation: this*x = b
|
Matrix |
solve(Matrix B)
Solves for "X" in the equation: this*X = B
|
Vector |
solve(Vector b)
Solves for "x" in the equation: this*x = b
|
AbstractMTJMatrix |
times(AbstractMTJMatrix matrix)
Matrix multiplication of
this and matrix ,
operates like the "* " operator in Matlab |
AbstractMTJVector |
times(AbstractMTJVector vector)
Returns the column vector from the equation
return = this * vector
|
DiagonalMatrixMTJ |
times(DiagonalMatrix matrix)
Multiplies this by the given DiagonalMatrix, leaving this unmodified
|
void |
timesEquals(DiagonalMatrix matrix)
Multiplies this by the other diagonal matrix, stores the result in this
|
java.lang.String |
toString() |
java.lang.String |
toString(java.text.NumberFormat format)
Converts the vector to a
String , using the given formatter. |
DiagonalMatrixMTJ |
transpose()
Returns the transpose of
this |
clone, dotTimesEquals, equals, get, getNumColumns, getNumRows, getSubMatrixInto, identity, increment, iterator, minusEquals, minusEquals, normFrobeniusSquared, plusEquals, plusEquals, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, set, solve, times, times, timesInto, timesInto, transposeInto, zero
assertMultiplicationDimensions, assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, decrement, decrement, dotDivide, dotDivideEquals, equals, equals, getColumnInto, getRowInto, hashCode, increment, isZero, rank, setColumn, setRow, setSubMatrix, sumOfColumns, sumOfRows, toArray, trace, valuesAsList
isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlus
finalize, getClass, notify, notifyAll, wait, wait, wait
assertMultiplicationDimensions, assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, clone, decrement, decrement, dotDivide, dotDivideEquals, get, getNumColumns, getNumRows, identity, increment, increment, normFrobeniusSquared, rank, set, setColumn, setRow, setSubMatrix, sumOfColumns, sumOfRows, times, times, toArray, trace, valuesAsList
dotTimesEquals, equals, equals, isZero, isZero, minus, minusEquals, negative, negativeEquals, plus, plusEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, scaledPlusEquals, scaleEquals, zero
protected DiagonalMatrixMTJ(int dim)
dim
- Dimensionality of the square diagonal matrixprotected DiagonalMatrixMTJ(DiagonalMatrixMTJ other)
other
- DiagonalMatrixMTJ to copyprotected DiagonalMatrixMTJ(double[] diagonal)
diagonal
- Array of elements to set the diagonal topublic int getDimensionality()
DiagonalMatrix
getDimensionality
in interface DiagonalMatrix
public no.uib.cipr.matrix.BandMatrix getInternalMatrix()
AbstractMTJMatrix
getInternalMatrix
in class AbstractMTJMatrix
protected void setInternalMatrix(no.uib.cipr.matrix.Matrix internalMatrix)
AbstractMTJMatrix
setInternalMatrix
in class AbstractMTJMatrix
internalMatrix
- internal MTJ-based matrixpublic AbstractMTJMatrix times(AbstractMTJMatrix matrix)
AbstractMTJMatrix
this
and matrix
,
operates like the "*
" operator in Matlabtimes
in class AbstractMTJMatrix
matrix
- this.getNumColumns()==matrix.getNumRows()
this
and
matrix
, will this.getNumRows()
rows and
matrix.getNumColumns()
columnspublic DiagonalMatrixMTJ times(DiagonalMatrix matrix)
DiagonalMatrix
times
in interface DiagonalMatrix
matrix
- DigonalMatrix to multiply thispublic void timesEquals(DiagonalMatrix matrix)
DiagonalMatrix
timesEquals
in interface DiagonalMatrix
matrix
- Diagonal matrix to multiply this bypublic AbstractMTJVector times(AbstractMTJVector vector)
AbstractMTJMatrix
times
in class AbstractMTJMatrix
vector
- Vector by which to post-multiply this, must have the
same number of rows as thispublic DiagonalMatrixMTJ dotTimes(Matrix matrix)
Ring
this
and other
dotTimes
in interface DiagonalMatrix
dotTimes
in interface Ring<Matrix>
dotTimes
in class AbstractRing<Matrix>
matrix
- elements of other will be multiplied to the corresponding
elements of this
this
and
other
public void dotTimesEquals(AbstractMTJMatrix matrix)
AbstractMTJMatrix
this
and matrix
, modifies the elements of this
dotTimesEquals
in class AbstractMTJMatrix
matrix
- Must have same dimensions this
public boolean isSquare()
Matrix
isSquare
in interface Matrix
isSquare
in class AbstractMTJMatrix
public boolean isSymmetric()
Matrix
isSymmetric
in interface Matrix
isSymmetric
in class AbstractMatrix
public boolean isSymmetric(double effectiveZero)
Matrix
isSymmetric
in interface Matrix
isSymmetric
in class AbstractMTJMatrix
effectiveZero
- tolerance to determine symmetrypublic ComplexNumber logDeterminant()
Matrix
this
.
Very computationally intensive. Please THINK LONG AND HARD before
invoking this method on sparse matrices, as they have to be converted
to a DenseMatrix first.logDeterminant
in interface Matrix
logDeterminant
in class AbstractMTJMatrix
this
public double normFrobenius()
Matrix
this
, which is just a fancy
way of saying that I will square each element, add those up, and square
root the result. This is probably the most intuitive of the matrix normsnormFrobenius
in interface Matrix
normFrobenius
in class AbstractMTJMatrix
this
public int rank(double effectiveZero)
Matrix
this
, which is the number of
linearly independent rows and columns in this
. Rank is
typically based on the SVD, which is a fairly computationally expensive
procedure and should be used carefullyrank
in interface Matrix
rank
in class AbstractMTJMatrix
effectiveZero
- parameter to pass along to SVD to determine linear dependencethis
, equivalent to the number of linearly
indepenedent rows and columns in this
public Vector solve(AbstractMTJVector b)
AbstractMTJMatrix
solve
in class AbstractMTJMatrix
b
- must satisfy this.getNumColumns() == b.getDimensionality()public Matrix solve(Matrix B)
Matrix
solve
in interface Matrix
solve
in class AbstractMTJMatrix
B
- Must satisfy this.getNumColumns() == B.getNumRows();public Vector solve(Vector b)
Matrix
solve
in interface Matrix
solve
in class AbstractMTJMatrix
b
- must satisfy this.getNumColumns() == b.getDimensionality()public SparseMatrix getSubMatrix(int minRow, int maxRow, int minColumn, int maxColumn)
Matrix
getSubMatrix
in interface Matrix
minRow
- Zero-based index into the rows of the Matrix, must be less
than or equal to maxRowmaxRow
- Zero-based index into the rows of the Matrix, must be
greater than or equal to minRowminColumn
- Zero-based index into the rows of the Matrix, must be
less than or equal to maxColumnmaxColumn
- Zero-based index into the rows of the Matrix, must be
greater than or equal to minColumnpublic DiagonalMatrixMTJ transpose()
Matrix
this
public double[] getDiagonal()
getDiagonal
in interface DiagonalMatrix
public DiagonalMatrixMTJ pseudoInverse()
Matrix
this
, using a
rather expensive procedure (SVD)pseudoInverse
in interface DiagonalMatrix
pseudoInverse
in interface Matrix
pseudoInverse
in class AbstractMatrix
this
public DiagonalMatrixMTJ pseudoInverse(double effectiveZero)
Matrix
this
, using a
rather expensive procedure (SVD)pseudoInverse
in interface DiagonalMatrix
pseudoInverse
in interface Matrix
effectiveZero
- effective zero to pass along to the SVDthis
public DiagonalMatrixMTJ inverse()
Matrix
this
, which must be a
square matrixinverse
in interface DiagonalMatrix
inverse
in interface Matrix
inverse
in class AbstractMTJMatrix
this
, such that
this.times(this.inverse()) == this.inverse().times(this)
==
identity matrixpublic boolean isSparse()
Matrix
public int getEntryCount()
Matrix
getEntryCount
in interface Matrix
public Vector getColumn(int columnIndex)
Matrix
public Vector getRow(int rowIndex)
Matrix
public double getElement(int rowIndex, int columnIndex)
Matrix
getElement
in interface Matrix
getElement
in class AbstractMTJMatrix
rowIndex
- Zero-based index into the MatrixcolumnIndex
- Zero-based index into the Matrixpublic void setElement(int rowIndex, int columnIndex, double value)
Matrix
setElement
in interface Matrix
setElement
in class AbstractMTJMatrix
rowIndex
- Zero-based index into the rows of the MatrixcolumnIndex
- Zero-based index into the columns of the Matrixvalue
- Value to set at the specified indexpublic double getElement(int index)
DiagonalMatrix
getElement
in interface DiagonalMatrix
index
- Zero-based index into the diagonal to getpublic void setElement(int index, double value)
DiagonalMatrix
setElement
in interface DiagonalMatrix
index
- Zero-based index into the diagonal to setvalue
- Value to setpublic DenseVector convertToVector()
Matrix
convertToVector
in interface Matrix
convertToVector
in interface Vectorizable
convertToVector
in class AbstractMTJMatrix
public void convertFromVector(Vector parameters)
Matrix
convertFromVector
in interface Matrix
convertFromVector
in interface Vectorizable
convertFromVector
in class AbstractMTJMatrix
parameters
- column-stacked version of thispublic java.lang.String toString()
public java.lang.String toString(java.text.NumberFormat format)
Matrix
String
, using the given formatter.public MatrixFactory<?> getMatrixFactory()
Matrix
getMatrixFactory
in interface Matrix