@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, zeroassertMultiplicationDimensions, assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, decrement, decrement, dotDivide, dotDivideEquals, equals, equals, getColumnInto, getRowInto, hashCode, increment, isZero, rank, setColumn, setRow, setSubMatrix, sumOfColumns, sumOfRows, toArray, trace, valuesAsListisZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlusfinalize, getClass, notify, notifyAll, wait, wait, waitassertMultiplicationDimensions, 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, valuesAsListdotTimesEquals, equals, equals, isZero, isZero, minus, minusEquals, negative, negativeEquals, plus, plusEquals, scale, scaledMinus, scaledMinusEquals, scaledPlus, scaledPlusEquals, scaleEquals, zeroprotected 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()
DiagonalMatrixgetDimensionality in interface DiagonalMatrixpublic no.uib.cipr.matrix.BandMatrix getInternalMatrix()
AbstractMTJMatrixgetInternalMatrix in class AbstractMTJMatrixprotected void setInternalMatrix(no.uib.cipr.matrix.Matrix internalMatrix)
AbstractMTJMatrixsetInternalMatrix in class AbstractMTJMatrixinternalMatrix - internal MTJ-based matrixpublic AbstractMTJMatrix times(AbstractMTJMatrix matrix)
AbstractMTJMatrixthis and matrix,
operates like the "*" operator in Matlabtimes in class AbstractMTJMatrixmatrix - this.getNumColumns()==matrix.getNumRows()this and
matrix, will this.getNumRows() rows and
matrix.getNumColumns() columnspublic DiagonalMatrixMTJ times(DiagonalMatrix matrix)
DiagonalMatrixtimes in interface DiagonalMatrixmatrix - DigonalMatrix to multiply thispublic void timesEquals(DiagonalMatrix matrix)
DiagonalMatrixtimesEquals in interface DiagonalMatrixmatrix - Diagonal matrix to multiply this bypublic AbstractMTJVector times(AbstractMTJVector vector)
AbstractMTJMatrixtimes in class AbstractMTJMatrixvector - Vector by which to post-multiply this, must have the
same number of rows as thispublic DiagonalMatrixMTJ dotTimes(Matrix matrix)
Ringthis and otherdotTimes in interface DiagonalMatrixdotTimes in interface Ring<Matrix>dotTimes in class AbstractRing<Matrix>matrix - elements of other will be multiplied to the corresponding
elements of thisthis and
otherpublic void dotTimesEquals(AbstractMTJMatrix matrix)
AbstractMTJMatrixthis
and matrix, modifies the elements of thisdotTimesEquals in class AbstractMTJMatrixmatrix - Must have same dimensions thispublic boolean isSquare()
MatrixisSquare in interface MatrixisSquare in class AbstractMTJMatrixpublic boolean isSymmetric()
MatrixisSymmetric in interface MatrixisSymmetric in class AbstractMatrixpublic boolean isSymmetric(double effectiveZero)
MatrixisSymmetric in interface MatrixisSymmetric in class AbstractMTJMatrixeffectiveZero - tolerance to determine symmetrypublic ComplexNumber logDeterminant()
Matrixthis.
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 MatrixlogDeterminant in class AbstractMTJMatrixthispublic double normFrobenius()
Matrixthis, 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 MatrixnormFrobenius in class AbstractMTJMatrixthispublic int rank(double effectiveZero)
Matrixthis, 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 Matrixrank in class AbstractMTJMatrixeffectiveZero - parameter to pass along to SVD to determine linear dependencethis, equivalent to the number of linearly
indepenedent rows and columns in thispublic Vector solve(AbstractMTJVector b)
AbstractMTJMatrixsolve in class AbstractMTJMatrixb - must satisfy this.getNumColumns() == b.getDimensionality()public Matrix solve(Matrix B)
Matrixsolve in interface Matrixsolve in class AbstractMTJMatrixB - Must satisfy this.getNumColumns() == B.getNumRows();public Vector solve(Vector b)
Matrixsolve in interface Matrixsolve in class AbstractMTJMatrixb - must satisfy this.getNumColumns() == b.getDimensionality()public SparseMatrix getSubMatrix(int minRow, int maxRow, int minColumn, int maxColumn)
MatrixgetSubMatrix in interface MatrixminRow - 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()
Matrixthispublic double[] getDiagonal()
getDiagonal in interface DiagonalMatrixpublic DiagonalMatrixMTJ pseudoInverse()
Matrixthis, using a
rather expensive procedure (SVD)pseudoInverse in interface DiagonalMatrixpseudoInverse in interface MatrixpseudoInverse in class AbstractMatrixthispublic DiagonalMatrixMTJ pseudoInverse(double effectiveZero)
Matrixthis, using a
rather expensive procedure (SVD)pseudoInverse in interface DiagonalMatrixpseudoInverse in interface MatrixeffectiveZero - effective zero to pass along to the SVDthispublic DiagonalMatrixMTJ inverse()
Matrixthis, which must be a
square matrixinverse in interface DiagonalMatrixinverse in interface Matrixinverse in class AbstractMTJMatrixthis, such that
this.times(this.inverse()) == this.inverse().times(this)
== identity matrixpublic boolean isSparse()
Matrixpublic int getEntryCount()
MatrixgetEntryCount in interface Matrixpublic Vector getColumn(int columnIndex)
Matrixpublic Vector getRow(int rowIndex)
Matrixpublic double getElement(int rowIndex,
int columnIndex)
MatrixgetElement in interface MatrixgetElement in class AbstractMTJMatrixrowIndex - Zero-based index into the MatrixcolumnIndex - Zero-based index into the Matrixpublic void setElement(int rowIndex,
int columnIndex,
double value)
MatrixsetElement in interface MatrixsetElement in class AbstractMTJMatrixrowIndex - 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)
DiagonalMatrixgetElement in interface DiagonalMatrixindex - Zero-based index into the diagonal to getpublic void setElement(int index,
double value)
DiagonalMatrixsetElement in interface DiagonalMatrixindex - Zero-based index into the diagonal to setvalue - Value to setpublic DenseVector convertToVector()
MatrixconvertToVector in interface MatrixconvertToVector in interface VectorizableconvertToVector in class AbstractMTJMatrixpublic void convertFromVector(Vector parameters)
MatrixconvertFromVector in interface MatrixconvertFromVector in interface VectorizableconvertFromVector in class AbstractMTJMatrixparameters - column-stacked version of thispublic java.lang.String toString()
public java.lang.String toString(java.text.NumberFormat format)
MatrixString, using the given formatter.public MatrixFactory<?> getMatrixFactory()
MatrixgetMatrixFactory in interface Matrix