Class MjSparseMatrix
java.lang.Object
gov.nih.mipav.view.renderer.J3D.surfaceview.brainflattenerview.MjSparseMatrix
Sparse matrix implemented with a hash map. All undefined entries are zero.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed to reference a single element in the matrix. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MjSparseMatrix.IndexInstantiate once instead of each time a value key (Index) is needed.private HashMapMapping of Index(row,col).private static final floatDOCUMENT ME! -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static floatdot(int iSize, float[] afU, float[] afV) conjugate gradient methods.floatgetElement(int iRow, int iCol) Get the element value at the specified row,col.iterator()Return iterator to non-zero elements in the matrix.private voidmultiply(int iSize, float[] afX, float[] afProd) DOCUMENT ME!voidsetElement(int iRow, int iCol, float fValue) Set the element value at the specified row,col.intsize()return number of non-zero entries in the matrix.(package private) booleansolveSymmetricCG(int iSize, float[] afB, float[] afX) Conjugate gradient method for sparse, symmetric matrices.private static voidupdateP(int iSize, float[] afP, float fBeta, float[] afR) DOCUMENT ME!private static voidupdateR(int iSize, float[] afR, float fAlpha, float[] afW) DOCUMENT ME!private static voidupdateX(int iSize, float[] afX, float fAlpha, float[] afP) DOCUMENT ME!
-
Field Details
-
ms_fTolerance
private static final float ms_fToleranceDOCUMENT ME!- See Also:
-
m_kIndexKeyTmp
Instantiate once instead of each time a value key (Index) is needed. -
m_kMap
Mapping of Index(row,col).
-
-
Constructor Details
-
MjSparseMatrix
public MjSparseMatrix()Matrix of undefined dimensions. Initially all elements are zero.
-
-
Method Details
-
getElement
public float getElement(int iRow, int iCol) Get the element value at the specified row,col.- Parameters:
iRow- DOCUMENT ME!iCol- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
iterator
Return iterator to non-zero elements in the matrix. Each entry in the iterator is of Map.Entry type where the key is of Index type and the value is of Float type.- Returns:
- DOCUMENT ME!
-
setElement
public void setElement(int iRow, int iCol, float fValue) Set the element value at the specified row,col.- Parameters:
iRow- DOCUMENT ME!iCol- DOCUMENT ME!fValue- DOCUMENT ME!
-
size
public int size()return number of non-zero entries in the matrix.- Returns:
- DOCUMENT ME!
-
solveSymmetricCG
boolean solveSymmetricCG(int iSize, float[] afB, float[] afX) Conjugate gradient method for sparse, symmetric matrices. Input: The nonzero entries of the symmetrix matrix A are stored in a map whose keys are pairs (i,j) and whose values are real numbers. The pair (i,j) is the location of the value in the array. Only one of (i,j) and (j,i) should be stored since A is symmetric. The code assumes this is how you set up A. The column vector B is stored as an array of contiguous valuess. If B itself is sparse, another solver can be implemented which uses a map to store B. Output: B[iSize] is the solution x to Ax = B- Parameters:
iSize- DOCUMENT ME!afB- DOCUMENT ME!afX- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
dot
private static float dot(int iSize, float[] afU, float[] afV) conjugate gradient methods.- Parameters:
iSize- DOCUMENT ME!afU- DOCUMENT ME!afV- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
updateP
private static void updateP(int iSize, float[] afP, float fBeta, float[] afR) DOCUMENT ME!- Parameters:
iSize- DOCUMENT ME!afP- DOCUMENT ME!fBeta- DOCUMENT ME!afR- DOCUMENT ME!
-
updateR
private static void updateR(int iSize, float[] afR, float fAlpha, float[] afW) DOCUMENT ME!- Parameters:
iSize- DOCUMENT ME!afR- DOCUMENT ME!fAlpha- DOCUMENT ME!afW- DOCUMENT ME!
-
updateX
private static void updateX(int iSize, float[] afX, float fAlpha, float[] afP) DOCUMENT ME!- Parameters:
iSize- DOCUMENT ME!afX- DOCUMENT ME!fAlpha- DOCUMENT ME!afP- DOCUMENT ME!
-
multiply
private void multiply(int iSize, float[] afX, float[] afProd) DOCUMENT ME!- Parameters:
iSize- DOCUMENT ME!afX- DOCUMENT ME!afProd- DOCUMENT ME!
-