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 arraydouble
det()
double
diagonal(int index)
Returns the diagonal element for the given row/columndouble
e(int x, int y)
Returns a specific elementint
getNColumns()
Returns the number of columnsint
getNRows()
Returns the number of rowsvoid
incrementElement(int x, int y, double value)
Increment a specific elementvoid
invert()
Invert this matrix (into itself)void
setElement(int x, int y, double value)
Set a specific elementjava.lang.String
toString()
void
transpose()
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:Matrix
Returns the number of rows
-
getNColumns
public int getNColumns()
Description copied from interface:Matrix
Returns the number of columns- Specified by:
getNColumns
in 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:
setElement
in 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:
toString
in classjava.lang.Object
-
invert
public void invert() throws MatrixOp.IndeterminateMatrixException
Description copied from interface:MutableMatrix
Invert this matrix (into itself)- Specified by:
invert
in interfaceMutableMatrix
- Throws:
MatrixOp.IndeterminateMatrixException
- See Also:
MatrixOp.inverse(Matrix,MutableMatrix)
-
transpose
public void transpose()
Description copied from interface:MutableMatrix
Tranpose this matrix (into itself)- Specified by:
transpose
in interfaceMutableMatrix
- See Also:
MatrixOp.transposed(Matrix,MutableMatrix)
-
-
DMelt 3.0 © DataMelt by jWork.ORG