@CodeReview(reviewer="Jonathan McClain", date="2006-05-19", changesNeeded=true, comments="Comments indicated with / / / ", response=@CodeReviewResponse(respondent="Kevin R. Dixon",date="2006-05-22",moreChangesNeeded=false,comments="Fixed comments for writeObject and readObject")) @PublicationReference(author="Bjorn-Ove Heimsund", title="Matrix Toolkits for Java DenseMatrix", type=WebPage, year=2006, url="http://ressim.berlios.de/doc/no/uib/cipr/matrix/DenseMatrix.html", notes="This class wraps the DenseMatrix class from Heimsund\'s MTJ package") public class DenseMatrix extends AbstractMTJMatrix implements java.io.Serializable
| Modifier | Constructor and Description |
|---|---|
protected |
DenseMatrix(no.uib.cipr.matrix.DenseMatrix internalMatrix)
Creates a new instance of DenseMatrix
|
protected |
DenseMatrix(DenseMatrix matrix)
Creates a new instance of DenseMatrix
|
protected |
DenseMatrix(int numRows,
int numColumns)
Creates a new instance of DenseMatrix
|
protected |
DenseMatrix(Matrix matrix)
Creates a new instance of DenseMatrix
|
protected |
DenseMatrix(MatrixReader reader)
Creates a new instance of DenseMatrix
|
| Modifier and Type | Method and Description |
|---|---|
DenseMatrix |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
convertFromVector(DenseVector parameters)
Incorporates the parameters in the given vector back into the object.
|
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)
|
protected double[] |
getArray()
Gets the underlying double array from the MTJ matrix
|
DenseVector |
getColumn(int columnIndex)
Gets the specified column from the zero-based index and returns a
vector that corresponds to that column.
|
int |
getEntryCount()
Gets the number of active entries in the matrix.
|
MatrixFactory<?> |
getMatrixFactory()
Gets a matrix factory, typically one associated with this type of matrix.
|
DenseVector |
getRow(int rowIndex)
Gets the specified row from the zero-based index and returns a vector
that corresponds to that column
|
DenseMatrix |
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)
|
boolean |
isSparse()
Returns true if this matrix has a potentially sparse underlying
structure.
|
DenseMatrix |
pseudoInverse(double effectiveZero)
Computes the effective pseudo-inverse of
this, using a
rather expensive procedure (SVD) |
protected void |
solveInto(DenseMatrix B,
DenseMatrix X)
Solve for "X" in the equation: this*X = B
|
protected void |
solveInto(DenseVector b,
DenseVector x)
Solve for "x" in the equation: this*x = b
|
DenseMatrix |
times(AbstractMTJMatrix matrix)
Matrix multiplication of
this and matrix,
operates like the "*" operator in Matlab |
DenseVector |
times(AbstractMTJVector vector)
Returns the column vector from the equation
return = this * vector
|
java.lang.String |
toString()
Writes the DenseMatrix out as a matrix of values (no indices are printed)
|
java.lang.String |
toString(java.text.NumberFormat format)
Converts the vector to a
String, using the given formatter. |
DenseMatrix |
transpose()
Returns the transpose of
this |
dotTimesEquals, dotTimesEquals, equals, get, getElement, getInternalMatrix, getNumColumns, getNumRows, getSubMatrixInto, identity, increment, inverse, isSquare, isSymmetric, iterator, logDeterminant, minusEquals, minusEquals, normFrobenius, normFrobeniusSquared, plusEquals, plusEquals, rank, scaledMinusEquals, scaledPlusEquals, scaledPlusEquals, scaleEquals, set, setElement, setInternalMatrix, solve, solve, solve, solve, times, times, timesInto, timesInto, transposeInto, zeroassertMultiplicationDimensions, assertSameDimensions, checkMultiplicationDimensions, checkSameDimensions, decrement, decrement, dotDivide, dotDivideEquals, equals, equals, getColumnInto, getRowInto, hashCode, increment, isSymmetric, isZero, pseudoInverse, rank, setColumn, setRow, setSubMatrix, sumOfColumns, sumOfRows, toArray, trace, valuesAsListdotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlusfinalize, getClass, notify, notifyAll, wait, wait, waitdotTimes, isZero, minus, negative, negativeEquals, plus, scale, scaledMinus, scaledMinusEquals, scaledPlusprotected DenseMatrix(int numRows,
int numColumns)
numRows - number of rows in the matrixnumColumns - number of columns in the matrixprotected DenseMatrix(no.uib.cipr.matrix.DenseMatrix internalMatrix)
internalMatrix - Internal MTJ-based matrixprotected DenseMatrix(Matrix matrix)
matrix - Matrix from which to pull data, will not be modifiedprotected DenseMatrix(DenseMatrix matrix)
matrix - DenseMatrix from which to pull data, will not be modifiedprotected DenseMatrix(MatrixReader reader) throws java.io.IOException
reader - takes in information from a java streamjava.io.IOException - if the stream is invalidpublic DenseMatrix clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface Matrixclone in interface Vectorizableclone in interface Ring<Matrix>clone in interface CloneableSerializableclone in class AbstractMTJMatrixpublic DenseMatrix 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 DenseVector times(AbstractMTJVector vector)
AbstractMTJMatrixtimes in class AbstractMTJMatrixvector - Vector by which to post-multiply this, must have the
same number of rows as thisprotected void solveInto(DenseMatrix B, DenseMatrix X)
B - must satisfy this.getNumRows() == B.numRows()X - must satisfy this.getNumColumns() == X.getNumRows()protected void solveInto(DenseVector b, DenseVector x)
b - must satisfy this.getNumRows() == b.getDimensionality()x - must satisfy this.getNumColumns() == x.getDimensionality()public DenseMatrix pseudoInverse(double effectiveZero)
Matrixthis, using a
rather expensive procedure (SVD)pseudoInverse in interface MatrixeffectiveZero - effective zero to pass along to the SVDthispublic DenseMatrix 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 DenseMatrix transpose()
Matrixthispublic java.lang.String toString()
public java.lang.String toString(java.text.NumberFormat format)
MatrixString, using the given formatter.public DenseVector getColumn(int columnIndex)
Matrixpublic DenseVector getRow(int rowIndex)
Matrixpublic boolean isSparse()
Matrixpublic int getEntryCount()
MatrixgetEntryCount in interface Matrixprotected double[] getArray()
public 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 void convertFromVector(DenseVector parameters)
parameters - The parameters to incorporate.public MatrixFactory<?> getMatrixFactory()
MatrixgetMatrixFactory in interface Matrix