Class CDMatrix
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrix
gov.nih.mipav.view.renderer.WildMagic.AAM.CDMatrix
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 invalid input: '&' 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 Summary
FieldsFields inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrix
eftData, eftDims, eftEnd, eftName, FieldType, m_data, m_fExternalStorage, m_nCols, m_nRows, s_fVerboseOutput -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassign(double value) Assignment operator (double).assign(double[][] value) Assignment operatorAssignment operator (CDMatrix).assign(CVisDMatrix mat) Assignment operator (CVisDMatrix).voidReturn 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.voidMake the matrix a diagonal matrix containing 'vec'.voidElementDivide(CDMatrix matrix) Element-wise matrix division.voidElementMultiply(CDMatrix matrix) Element-wise matrix multiply.voidElement wise equal to.voidElement 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.voidReads a matrix from disk in binary format (from the current position of the file pointer), as written from ToFile().voidReads a matrix from disk in binary format, as written from ToFile().voidElement wise greater than or equal.voidElement wise greater than or equal.voidElement wise greater than.voidElement wise greater than.voidForms the Kronecker tensor product of two matrices.voidElement wise less than or equal.voidElement wise less than or equal.voidLog()Takes the natural logarithm (base e=2.71..) of each matrix element.voidElement wise less than.voidElement wise less than.doubleMean()Calcs the mean value of the matrix.voidCalc the mean of each column into a vector.voidElement wise not equal to.voidElement 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.voidReturn 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.voidCalc the standard deviation of each column into a vector.doubleSum()Calc the total sum of the matrix.voidCalc the sum of each column into a vector.voidWrites the matrix to disk in binary format.voidWrites the matrix to disk in binary format.voidWrites the matrix to disk in MatLab (.m) format.ToString()Returns a string representing the matrix.voidConverts this matrix to a vector, either by row (default) or column.doubleTrace()Calculates the trace - i.e. the sum of diagonal elements.voidExtract lower triangular part of matrix.voidExtract 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.voidCalc the variance of each column into a vector.Methods inherited from class gov.nih.mipav.view.renderer.WildMagic.AAM.CVisDMatrix
add, 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
-
Field Details
-
RAND_MAX
public static int RAND_MAX
-
-
Constructor Details
-
CDMatrix
public CDMatrix()Constructors -
CDMatrix
public CDMatrix(int rows, int cols) -
CDMatrix
public CDMatrix(int rows, int cols, double[][] storage) -
CDMatrix
-
CDMatrix
-
-
Method Details
-
assign
Assignment operator (CVisDMatrix).- Overrides:
assignin classCVisDMatrix- Parameters:
mat- Input matrix.- Returns:
- This.
-
assign
Assignment operator (CDMatrix).- Parameters:
mat- Input matrix.- Returns:
- This.
-
assign
Assignment operator (double). Set all values equal to 'value'.- Overrides:
assignin classCVisDMatrix- Parameters:
value- Input double.- Returns:
- This.
-
assign
Assignment operator- Parameters:
value- double matrix- Returns:
- this.
-
SumCol
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.
-
MeanCol
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.
-
VarCol
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.
-
StdCol
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.
-
Sum
public double Sum()Calc the total sum of the matrix.- Returns:
- The sum.
-
Mean
public double Mean()Calcs the mean value of the matrix.- Returns:
- The mean value.
-
Var
public double Var()Calc the variance of the matrix.- Returns:
- The variance value.
-
Std
public double Std()Calc the standard diviation of the matrix.- Returns:
- The standard diviation value.
-
OneWayANOVA
public 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-
-
TTest
public void TTest(int iCol1, int iCol2, double[] dZ, int[] nDF) Student's T-test.- Parameters:
iCol1-iCol2-dZ-nDF-
-
Row
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 invalid input: '&v')- Parameters:
i- The row number.vRow- Output vector;
-
Col
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;
-
Diag
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.
-
ToString
Returns a string representing the matrix.- Returns:
- A string.
-
CombVert
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.
-
ToMatlab
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'.
-
Sqrt
public void Sqrt()Takes the square root of each element. -
Sqr
public void Sqr()Takes the power of two of each element. -
ElementMultiply
Element-wise matrix multiply. Multiply each element in the matrix with the corresponding element of the input matrix. -
ElementDivide
Element-wise matrix division. Divide each element in the matrix with the corresponding element of the input matrix. -
ToFile
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.
-
ToFile
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.
-
FromFile
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.
-
FromFile
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.
-
Kron
Forms the Kronecker tensor product of two matrices. The result is placed in this. -
Eye
public void Eye()Converts the matrix in the identity matrix - i.e. zeros all-over except the ones in the diagonal. -
TriU
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 invalid input: '<' 0 is below the main diagonal. -
TriL
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 invalid input: '<' 0 is below the main diagonal. -
Eq
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 -
Eq
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 -
Ne
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 -
Ne
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 -
Lt
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) invalid input: '<' B C(i,j) = 0 else -
Lt
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) invalid input: '<' B(i,j) C(i,j) = 0 else -
Le
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) invalid input: '<'= B C(i,j) = 0 else -
Le
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) invalid input: '<'= B(i,j) C(i,j) = 0 else -
Gt
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 -
Gt
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 -
Ge
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 -
Ge
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) invalid input: '<'= B(i,j) C(i,j) = 0 else -
Log
public void Log()Takes the natural logarithm (base e=2.71..) of each matrix element. -
FlipLR
public void FlipLR()FlipLR modifies the matrix with row preserved and columns flipped in the left/right direction. -
FlipUD
public void FlipUD()Flip matrix in up/down direction. FlipUD(X) modifies the matrix with columns preserved and rows flipped in the up/down direction. -
Rand
public void Rand()Uniformly distributed random numbers. Inserts uniformly distributed random numbers in the range [0;1]. -
OuterProduct
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.
-
Det
public double Det()Calculates the determinant of a square matrix up to the 3rd order.- Returns:
- The determinant.
-
Trace
public double Trace()Calculates the trace - i.e. the sum of diagonal elements.- Returns:
- The trace.
-
ToVector
Converts this matrix to a vector, either by row (default) or column.- Parameters:
v- Output vectorrowWise- If true (default) matrix data is extracted row-wise. If false matrix data is extracted column-wise.
-