hep.physics.matrix
Class MatrixOp
- java.lang.Object
-
- hep.physics.matrix.MatrixOp
-
public class MatrixOp extends java.lang.ObjectSimple operations on matrices
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classMatrixOp.IndeterminateMatrixExceptionstatic classMatrixOp.InvalidMatrixException
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static Matrixadd(Matrix a, Matrix b)Add two matrices together.static Hep3Vectoras3Vector(Matrix m)Convenience method to turn a 3 row column matrix into a vector.static doubledet(Matrix mIn)static MatrixgetSubMatrix(Matrix m, int row, int col, int nrow, int ncol)Extract part of a matrix.static Matrixinverse(Matrix m)Convenience method to invert a matrix in one step.static voidinverse(Matrix mIn, MutableMatrix mOut)Invert matrix mIn and write it to matrix mOut.static Matrixmult(double c, Matrix m)Multiply a matrix by a scaler constant.static Matrixmult(Matrix m1, Matrix m2)static voidsetSubMatrix(MutableMatrix mat, Matrix sub, int row, int col)Fill in part of a matrix with the contents of another matrix.static Matrixsub(Matrix a, Matrix b)Subtract matrix b from matrix a.static java.lang.StringtoString(Matrix m)static Matrixtransposed(Matrix m)Returns the transpose of the matrix.static voidtransposed(Matrix mIn, MutableMatrix mOut)Traspose matrix mIn and write it to matrix mOut.
-
-
-
Method Detail
-
inverse
public static void inverse(Matrix mIn, MutableMatrix mOut) throws MatrixOp.InvalidMatrixException
Invert matrix mIn and write it to matrix mOut. This method allows both arguments to be the same, e.g.inverse(this,this);This method currently only supports square matrices.- Throws:
MatrixOp.InvalidMatrixException
-
inverse
public static Matrix inverse(Matrix m)
Convenience method to invert a matrix in one step.- Parameters:
m- matrix to be inverted. This remains unchanged by this operation- Returns:
- inverted matrix
-
toString
public static java.lang.String toString(Matrix m)
-
det
public static double det(Matrix mIn)
-
transposed
public static void transposed(Matrix mIn, MutableMatrix mOut)
Traspose matrix mIn and write it to matrix mOut. For a square matrix this method allows both arguments to be the same, e.g.transposed(this,this);
-
transposed
public static Matrix transposed(Matrix m)
Returns the transpose of the matrix.- Parameters:
m- matrix to be transposed- Returns:
- transposed matrix
-
add
public static Matrix add(Matrix a, Matrix b)
Add two matrices together. Matrices must have the same dimensions.- Parameters:
a- first matrixb- second matrix- Returns:
- sum of the two matrices
-
sub
public static Matrix sub(Matrix a, Matrix b)
Subtract matrix b from matrix a. Matrices must have the same dimensions.- Parameters:
a- starting matrixb- matrix to be subtracted- Returns:
- difference (a - b)
-
mult
public static Matrix mult(double c, Matrix m)
Multiply a matrix by a scaler constant.- Parameters:
c- constant that will mutliply the matrixm- matrix to be scaled- Returns:
- scaled matrix (c * m)
-
setSubMatrix
public static void setSubMatrix(MutableMatrix mat, Matrix sub, int row, int col)
Fill in part of a matrix with the contents of another matrix.- Parameters:
mat- matrix to be modifiedsub- submatrix to be insertedrow- row where insertion is to take placecol- column where insertion is to take place
-
getSubMatrix
public static Matrix getSubMatrix(Matrix m, int row, int col, int nrow, int ncol)
Extract part of a matrix.- Parameters:
m- matrix containing the desired submatrixrow- row where the submatrix is locatedcol- column where the submatrix is locatednrow- number of rows in the submatrixncol- number of columns in the submatrix- Returns:
- submatrix
-
as3Vector
public static Hep3Vector as3Vector(Matrix m)
Convenience method to turn a 3 row column matrix into a vector.- Parameters:
m- column matrix- Returns:
- vector containing contents of column matrix
-
-
DMelt 3.0 © DataMelt by jWork.ORG