hep.physics.matrix
Class MatrixOp

java.lang.Object
  extended by hep.physics.matrix.MatrixOp

public class MatrixOp
extends java.lang.Object

Simple operations on matrices

Author:
tonyj

Nested Class Summary
static class MatrixOp.IndeterminateMatrixException
           
static class MatrixOp.InvalidMatrixException
           
 
Method Summary
static Matrix add(Matrix a, Matrix b)
          Add two matrices together.
static Hep3Vector as3Vector(Matrix m)
          Convenience method to turn a 3 row column matrix into a vector.
static double det(Matrix mIn)
           
static Matrix getSubMatrix(Matrix m, int row, int col, int nrow, int ncol)
          Extract part of a matrix.
static Matrix inverse(Matrix m)
          Convenience method to invert a matrix in one step.
static void inverse(Matrix mIn, MutableMatrix mOut)
          Invert matrix mIn and write it to matrix mOut.
static Matrix mult(double c, Matrix m)
          Multiply a matrix by a scaler constant.
static Matrix mult(Matrix m1, Matrix m2)
           
static void setSubMatrix(MutableMatrix mat, Matrix sub, int row, int col)
          Fill in part of a matrix with the contents of another matrix.
static Matrix sub(Matrix a, Matrix b)
          Subtract matrix b from matrix a.
static java.lang.String toString(Matrix m)
           
static Matrix transposed(Matrix m)
          Returns the transpose of the matrix.
static void transposed(Matrix mIn, MutableMatrix mOut)
          Traspose matrix mIn and write it to matrix mOut.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

mult

public static Matrix mult(Matrix m1,
                          Matrix m2)

add

public static Matrix add(Matrix a,
                         Matrix b)
Add two matrices together. Matrices must have the same dimensions.

Parameters:
a - first matrix
b - 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 matrix
b - 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 matrix
m - 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 modified
sub - submatrix to be inserted
row - row where insertion is to take place
col - 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 submatrix
row - row where the submatrix is located
col - column where the submatrix is located
nrow - number of rows in the submatrix
ncol - 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


Copyright © 2000-2010 FreeHEP. All Rights Reserved.