hephysics.matrix
Class SymmetricMatrix
- java.lang.Object
-
- hephysics.matrix.SymmetricMatrix
-
- All Implemented Interfaces:
- Matrix, MutableMatrix, java.io.Serializable
public class SymmetricMatrix extends java.lang.Object implements MutableMatrix, java.io.Serializable
A simple implementation of a symmetric matrix. A symmmetric matrix is a square matrix for whiche(i,j) == e(j,i).- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SymmetricMatrix(int size)Creates a new instance of SymmetricMatrix with all elements set to zero.SymmetricMatrix(int size, double[] initialValues, boolean isLower)Creates a new instance of SymmetricMatrix with the given initial values.SymmetricMatrix(Matrix mIn)Construct a SymmetricMatrix by copying an existing matrix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[]asPackedArray(boolean isLower)Returns the matrix as a packed arraydoubledet()doublediagonal(int index)Returns the diagonal element for the given row/columndoublee(int x, int y)Returns a specific elementintgetNColumns()Returns the number of columnsintgetNRows()Returns the number of rowsvoidincrementElement(int x, int y, double value)Increment a specific elementvoidinvert()Invert this matrix (into itself)voidsetElement(int x, int y, double value)Set a specific elementjava.lang.StringtoString()voidtranspose()Tranpose this matrix (into itself)
-
-
-
Constructor Detail
-
SymmetricMatrix
public SymmetricMatrix(int size)
Creates a new instance of SymmetricMatrix with all elements set to zero.- Parameters:
size- The rank of the matrix
-
SymmetricMatrix
public SymmetricMatrix(Matrix mIn)
Construct a SymmetricMatrix by copying an existing matrix. If the input matrix is a SymmetricMatrix it is copied exactly. Otherwise if the input matrix is square the lower left elements are copied If the matrix is not square an illegal argument exception is thrown.
-
SymmetricMatrix
public SymmetricMatrix(int size, double[] initialValues, boolean isLower)Creates a new instance of SymmetricMatrix with the given initial values.- Parameters:
size- The rank of the matrixinitialValues- The initial values for the matrixisLower- If true initial values must be m(0,0), m(1,0), m(1,1), ... otherwise m(0,0), m(0,1), m(0,2), ...
-
-
Method Detail
-
asPackedArray
public double[] asPackedArray(boolean isLower)
Returns the matrix as a packed array- Parameters:
isLower- if true array is packed m(0,0), m(1,0), m(1,1),... else m(0,0), m(0,1), m(0,2), ...
-
getNRows
public int getNRows()
Description copied from interface:MatrixReturns the number of rows
-
getNColumns
public int getNColumns()
Description copied from interface:MatrixReturns the number of columns- Specified by:
getNColumnsin interfaceMatrix
-
diagonal
public double diagonal(int index)
Returns the diagonal element for the given row/column
-
setElement
public void setElement(int x, int y, double value)Set a specific element- Specified by:
setElementin interfaceMutableMatrix
-
incrementElement
public void incrementElement(int x, int y, double value)Increment a specific element
-
det
public double det()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
invert
public void invert() throws MatrixOp.IndeterminateMatrixExceptionDescription copied from interface:MutableMatrixInvert this matrix (into itself)- Specified by:
invertin interfaceMutableMatrix- Throws:
MatrixOp.IndeterminateMatrixException- See Also:
MatrixOp.inverse(Matrix,MutableMatrix)
-
transpose
public void transpose()
Description copied from interface:MutableMatrixTranpose this matrix (into itself)- Specified by:
transposein interfaceMutableMatrix- See Also:
MatrixOp.transposed(Matrix,MutableMatrix)
-
-
DMelt 3.0 © DataMelt by jWork.ORG