Class CDMatrix
- java.lang.Object
- 
- gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrix
- 
- gov.nih.mipav.view.renderer.WildMagic.AAM.CDMatrix
 
 
- 
 public class CDMatrix extends CVisDMatrix This is the Java modified version of C++ active appearance model API (AAM_API). It is modified with a subset of required functions for automatic MRI prostate segmentation. AAM-API LICENSE - file: license.txt This software is freely available for non-commercial use such as research and education. Please see the full disclaimer below. All publications describing work using this software should cite the reference given below. Copyright (c) 2000-2003 Mikkel B. Stegmann, mbs@imm.dtu.dk IMM, Informatics & Mathematical Modelling DTU, Technical University of Denmark Richard Petersens Plads, Building 321 DK-2800 Lyngby, Denmark http://www.imm.dtu.dk/~aam/ REFERENCES Please use the reference below, when writing articles, reports etc. where the AAM-API has been used. A draft version the article is available from the homepage. I will be happy to receive pre- or reprints of such articles. /Mikkel ------------- M. B. Stegmann, B. K. Ersboll, R. Larsen, "FAME -- A Flexible Appearance Modelling Environment", IEEE Transactions on Medical Imaging, IEEE, 2003 (to appear) ------------- 3RD PART SOFTWARE The software is partly based on the following libraries: - The Microsoft(tm) Vision Software Developers Kit, VisSDK - LAPACK DISCLAIMER This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any non-commercial purpose, and to alter it, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. -- No guarantees of performance accompany this software, nor is any responsibility assumed on the part of the author or IMM. This software is provided by Mikkel B. Stegmann and IMM ``as is'' and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall IMM or Mikkel B. Stegmann be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. $Revision: 1.4 $ $Date: 2003/04/23 14:49:15 $ Base matrix operations within AAM model.- Author:
- Ruida Cheng
 
- 
- 
Field SummaryFields Modifier and Type Field Description static intRAND_MAX- 
Fields inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrixeftData, eftDims, eftEnd, eftName, FieldType, m_data, m_fExternalStorage, m_nCols, m_nRows, s_fVerboseOutput
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description CDMatrixassign(double value)Assignment operator (double).CDMatrixassign(double[][] value)Assignment operatorCDMatrixassign(CDMatrix mat)Assignment operator (CDMatrix).CDMatrixassign(CVisDMatrix mat)Assignment operator (CVisDMatrix).voidCol(int i, CDVector vCol)Return the i-th column of the matrix.voidCombVert(CVisDMatrix Top, CVisDMatrix Bottom)Composes the matrix of Top and Bottom (on top of each other).doubleDet()Calculates the determinant of a square matrix up to the 3rd order.voidDiag(CDVector vec)Make the matrix a diagonal matrix containing 'vec'.voidElementDivide(CDMatrix matrix)Element-wise matrix division.voidElementMultiply(CDMatrix matrix)Element-wise matrix multiply.voidEq(double B, CDMatrix C)Element wise equal to.voidEq(CDMatrix B, CDMatrix C)Element wise equal to.voidEye()Converts the matrix in the identity matrix - i.e. zeros all-over except the ones in the diagonal.voidFlipLR()FlipLR modifies the matrix with row preserved and columns flipped in the left/right direction.voidFlipUD()Flip matrix in up/down direction.voidFromFile(java.io.DataInputStream fh)Reads a matrix from disk in binary format (from the current position of the file pointer), as written from ToFile().voidFromFile(java.lang.String sFilename)Reads a matrix from disk in binary format, as written from ToFile().voidGe(double B, CDMatrix C)Element wise greater than or equal.voidGe(CDMatrix B, CDMatrix C)Element wise greater than or equal.voidGt(double B, CDMatrix C)Element wise greater than.voidGt(CDMatrix B, CDMatrix C)Element wise greater than.voidKron(CDMatrix mX, CDMatrix mY)Forms the Kronecker tensor product of two matrices.voidLe(double B, CDMatrix C)Element wise less than or equal.voidLe(CDMatrix B, CDMatrix C)Element wise less than or equal.voidLog()Takes the natural logarithm (base e=2.71..) of each matrix element.voidLt(double B, CDMatrix C)Element wise less than.voidLt(CDMatrix B, CDMatrix C)Element wise less than.doubleMean()Calcs the mean value of the matrix.voidMeanCol(CDVector vMean)Calc the mean of each column into a vector.voidNe(double B, CDMatrix C)Element wise not equal to.voidNe(CDMatrix B, CDMatrix C)Element wise not equal to.voidOneWayANOVA(double[] dZ, int[] nDFModel, int[] nDFError)One-way analysis of variance (ANOVA).voidOuterProduct(CDVector v1, CDVector v2)Forms the outer product of two vectors and store the result in this.voidRand()Uniformly distributed random numbers.voidRow(int i, CDVector vRow)Return the i-th row of the matrix.voidSqr()Takes the power of two of each element.voidSqrt()Takes the square root of each element.doubleStd()Calc the standard diviation of the matrix.voidStdCol(CDVector vStd)Calc the standard deviation of each column into a vector.doubleSum()Calc the total sum of the matrix.voidSumCol(CDVector vSum)Calc the sum of each column into a vector.voidToFile(java.io.DataOutputStream fh)Writes the matrix to disk in binary format.voidToFile(java.lang.String sFilename)Writes the matrix to disk in binary format.voidToMatlab(java.lang.String sFilename, java.lang.String sName, java.lang.String sComment, boolean fAppend)Writes the matrix to disk in MatLab (.m) format.java.lang.StringToString()Returns a string representing the matrix.voidToVector(CDVector v, boolean rowWise)Converts this matrix to a vector, either by row (default) or column.doubleTrace()Calculates the trace - i.e. the sum of diagonal elements.voidTriL(CDMatrix matrix, int K)Extract lower triangular part of matrix.voidTriU(CDMatrix matrix, int K)Extract upper triangular part of matrix.voidTTest(int iCol1, int iCol2, double[] dZ, int[] nDF)Student's T-test.doubleVar()Calc the variance of the matrix.voidVarCol(CDVector vVar)Calc the variance of each column into a vector.- 
Methods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrixadd, add_into, Column, Determinant, Determinant, Dgelss, Dgesv, Dgesvd, Dgetrf, dispose, div, div_into, Dposv, Dsyev, EqDiff, EqProd, EqSum, equals, FreeBuffer, Invert, Inverted, IsSymmetric, lessThan, mult, mult, mult, mult_into, mult_into, NCols, neg, not_equals, NRows, Resize, Resize, Row, SetColumn, SetRow, SetSize, SetSize, sub, sub_into, Submatrix, Submatrix, Submatrix, Transpose, Transposed, VisCrossProduct, VisCrossProduct, VisDMatrixLeastSquares, VisDMatrixLeastSquares, VisDMatrixLeastSquares, VisDMatrixLeastSquares, VisDMatrixLLS, VisDMatrixSolve, VisDMatrixSolve, VisDMatrixSolveSPD, VisDMatrixSolveSPD, VisDMatrixSqrtInverse, VisDMatrixSqrtInverse, VisDMatrixSVD, VisDMatrixSVD, VisDMatrixSymmetricEigen, VisGaussJordanSolveDMatrix, VisOuterProduct
 
- 
 
- 
- 
- 
Constructor Detail- 
CDMatrixpublic CDMatrix() Constructors
 - 
CDMatrixpublic CDMatrix(int rows, int cols)
 - 
CDMatrixpublic CDMatrix(int rows, int cols, double[][] storage)
 - 
CDMatrixpublic CDMatrix(CDMatrix mat) 
 - 
CDMatrixpublic CDMatrix(CVisDMatrix mat) 
 
- 
 - 
Method Detail- 
assignpublic CDMatrix assign(CVisDMatrix mat) Assignment operator (CVisDMatrix).- Overrides:
- assignin class- CVisDMatrix
- Parameters:
- mat- Input matrix.
- Returns:
- This.
 
 - 
assignpublic CDMatrix assign(CDMatrix mat) Assignment operator (CDMatrix).- Parameters:
- mat- Input matrix.
- Returns:
- This.
 
 - 
assignpublic CDMatrix assign(double value) Assignment operator (double). Set all values equal to 'value'.- Overrides:
- assignin class- CVisDMatrix
- Parameters:
- value- Input double.
- Returns:
- This.
 
 - 
assignpublic CDMatrix assign(double[][] value) Assignment operator- Parameters:
- value- double matrix
- Returns:
- this.
 
 - 
SumColpublic void SumCol(CDVector vSum) Calc the sum of each column into a vector. The vector will be resized if it doesn't have the right length.- Parameters:
- vSum- Output vector.
 
 - 
MeanColpublic void MeanCol(CDVector vMean) Calc the mean of each column into a vector. The vector will be resized if it doesn't have the right length.- Parameters:
- vMean- Output vector.
 
 - 
VarColpublic void VarCol(CDVector vVar) Calc the variance of each column into a vector. The vector will be resized if it doesn't have the right length.- Parameters:
- vVar- Output vector.
 
 - 
StdColpublic void StdCol(CDVector vStd) Calc the standard deviation of each column into a vector. The vector will be resized if it doesn't have the right length.- Parameters:
- vStd- Output vector.
 
 - 
Sumpublic double Sum() Calc the total sum of the matrix.- Returns:
- The sum.
 
 - 
Meanpublic double Mean() Calcs the mean value of the matrix.- Returns:
- The mean value.
 
 - 
Varpublic double Var() Calc the variance of the matrix.- Returns:
- The variance value.
 
 - 
Stdpublic double Std() Calc the standard diviation of the matrix.- Returns:
- The standard diviation value.
 
 - 
OneWayANOVApublic void OneWayANOVA(double[] dZ, int[] nDFModel, int[] nDFError)One-way analysis of variance (ANOVA). Determination of the fluctuations observed in a sample, and their dependencies in the form of a one-way analysis of variance (ANOVA).- Parameters:
- dZ-
- nDFModel-
- nDFError-
 
 - 
TTestpublic void TTest(int iCol1, int iCol2, double[] dZ, int[] nDF)Student's T-test.- Parameters:
- iCol1-
- iCol2-
- dZ-
- nDF-
 
 - 
Rowpublic void Row(int i, CDVector vRow)Return the i-th row of the matrix. The vector will be resized if it doesn't have the right length. Notice that due to the row major nature of matrices, row read/writes are *much* faster than col read/writes. Alternatively, one could use the more costly CVisDVector CVisDMatrix::Row(int r) method. To set the i-th row use: void CVisDMatrix::SetRow(int r, const CVisDVector &v)- Parameters:
- i- The row number.
- vRow- Output vector;
 
 - 
Colpublic void Col(int i, CDVector vCol)Return the i-th column of the matrix. The vector will be resized if it doesn't have the right length.- Parameters:
- i- The column number.
- vCol- Output vector;
 
 - 
Diagpublic void Diag(CDVector vec) Make the matrix a diagonal matrix containing 'vec'. This function transforms the matrix into a diagonal matrix, with the values of 'vec' in the diagonal.- Parameters:
- vec- Vector to place in the diagonal.
 
 - 
ToStringpublic java.lang.String ToString() Returns a string representing the matrix.- Returns:
- A string.
 
 - 
CombVertpublic void CombVert(CVisDMatrix Top, CVisDMatrix Bottom) Composes the matrix of Top and Bottom (on top of each other).- Parameters:
- Top- Matrix to be placed in the top of this matrix.
- Bottom- Matrix to be placed in the bottom of this matrix.
 
 - 
ToMatlabpublic void ToMatlab(java.lang.String sFilename, java.lang.String sName, java.lang.String sComment, boolean fAppend)Writes the matrix to disk in MatLab (.m) format. To read the matrix into MatLab write e.g. 'my_matrix.m' at the MatLab prompt. Notice that this should be used for storage a (really) large matrices, due to the computational and i/o overhead induced by the simple MatLab text format. Also, remember that MatLab can't read (.m) files with lines longer than 4096 bytes. If no communication with MatLab is needed, but merely to/from disk functionality within a DIVA program, it is suggested to use the fast binary i/o methods ToFile() and FromFile().- Parameters:
- sFilename- Output file name. Should have the extension '.m'.
- sName- Name of destination matlab variable.
- sComment- Optional comment inside the file.
- fAppend- If true, the vector is appended to the file 'sFilename'.
 
 - 
Sqrtpublic void Sqrt() Takes the square root of each element.
 - 
Sqrpublic void Sqr() Takes the power of two of each element.
 - 
ElementMultiplypublic void ElementMultiply(CDMatrix matrix) Element-wise matrix multiply. Multiply each element in the matrix with the corresponding element of the input matrix.
 - 
ElementDividepublic void ElementDivide(CDMatrix matrix) Element-wise matrix division. Divide each element in the matrix with the corresponding element of the input matrix.
 - 
ToFilepublic void ToFile(java.lang.String sFilename) Writes the matrix to disk in binary format. The dimensions are saved as two doubles (!!?) (rows,cols) in the start.- Parameters:
- sFilename- Input file name.
 
 - 
ToFilepublic void ToFile(java.io.DataOutputStream fh) Writes the matrix to disk in binary format. The dimensions are saved as two doubles (!!?) (rows,cols) in the start. The matrix is written to the binary file 'fh' at the current position of the file pointer.- Parameters:
- fh- Open file handle.
 
 - 
FromFilepublic void FromFile(java.lang.String sFilename) Reads a matrix from disk in binary format, as written from ToFile(). The matrix is resizew if it doesn't fit the disk matrix.- Parameters:
- sFilename- Input file name.
 
 - 
FromFilepublic void FromFile(java.io.DataInputStream fh) Reads a matrix from disk in binary format (from the current position of the file pointer), as written from ToFile(). The matrix is resized if it doesn't fit the disk matrix.- Parameters:
- fh- Open file handle.
 
 - 
Kronpublic void Kron(CDMatrix mX, CDMatrix mY) Forms the Kronecker tensor product of two matrices. The result is placed in this.
 - 
Eyepublic void Eye() Converts the matrix in the identity matrix - i.e. zeros all-over except the ones in the diagonal.
 - 
TriUpublic void TriU(CDMatrix matrix, int K) Extract upper triangular part of matrix. Extracts the elements on and above the K-th diagonal. K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0 is below the main diagonal.
 - 
TriLpublic void TriL(CDMatrix matrix, int K) Extract lower triangular part of matrix. Extracts the elements on and below the K-th diagonal. K = 0 is the main diagonal, K > 0 is above the main diagonal and K < 0 is below the main diagonal.
 - 
Eqpublic void Eq(double B, CDMatrix C)Element wise equal to. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) == B C(i,j) = 0 else
 - 
Eqpublic void Eq(CDMatrix B, CDMatrix C) Element wise equal to. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) == B(i,j) C(i,j) = 0 else
 - 
Nepublic void Ne(double B, CDMatrix C)Element wise not equal to. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) != B C(i,j) = 0 else
 - 
Nepublic void Ne(CDMatrix B, CDMatrix C) Element wise not equal to. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) != B(i,j) C(i,j) = 0 else
 - 
Ltpublic void Lt(double B, CDMatrix C)Element wise less than. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) < B C(i,j) = 0 else
 - 
Ltpublic void Lt(CDMatrix B, CDMatrix C) Element wise less than. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) < B(i,j) C(i,j) = 0 else
 - 
Lepublic void Le(double B, CDMatrix C)Element wise less than or equal. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) <= B C(i,j) = 0 else
 - 
Lepublic void Le(CDMatrix B, CDMatrix C) Element wise less than or equal. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) <= B(i,j) C(i,j) = 0 else
 - 
Gtpublic void Gt(double B, CDMatrix C)Element wise greater than. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) > B C(i,j) = 0 else
 - 
Gtpublic void Gt(CDMatrix B, CDMatrix C) Element wise greater than. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) > B(i,j) C(i,j) = 0 else
 - 
Gepublic void Ge(double B, CDMatrix C)Element wise greater than or equal. Comparison of a matrix and a double. Compares each element in this matrix (A) with double B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) >= B C(i,j) = 0 else
 - 
Gepublic void Ge(CDMatrix B, CDMatrix C) Element wise greater than or equal. Comparison of two matrices. Compares each element in this matrix (A) with corresponding element in B. Result matrix C has elements with values 1 or 0. C(i,j) = 1 if A(i,j) <= B(i,j) C(i,j) = 0 else
 - 
Logpublic void Log() Takes the natural logarithm (base e=2.71..) of each matrix element.
 - 
FlipLRpublic void FlipLR() FlipLR modifies the matrix with row preserved and columns flipped in the left/right direction.
 - 
FlipUDpublic void FlipUD() Flip matrix in up/down direction. FlipUD(X) modifies the matrix with columns preserved and rows flipped in the up/down direction.
 - 
Randpublic void Rand() Uniformly distributed random numbers. Inserts uniformly distributed random numbers in the range [0;1].
 - 
OuterProductpublic void OuterProduct(CDVector v1, CDVector v2) Forms the outer product of two vectors and store the result in this. If the matrix does have the correct size, it will be resized.- Parameters:
- v1- Input vector.
- v2- Input vector.
 
 - 
Detpublic double Det() Calculates the determinant of a square matrix up to the 3rd order.- Returns:
- The determinant.
 
 - 
Tracepublic double Trace() Calculates the trace - i.e. the sum of diagonal elements.- Returns:
- The trace.
 
 - 
ToVectorpublic void ToVector(CDVector v, boolean rowWise) Converts this matrix to a vector, either by row (default) or column.- Parameters:
- v- Output vector
- rowWise- If true (default) matrix data is extracted row-wise. If false matrix data is extracted column-wise.
 
 
- 
 
-