gov.sns.tools.math.r3
Class R3x3

java.lang.Object
  |
  +--gov.sns.tools.math.r3.R3x3
All Implemented Interfaces:
java.io.Serializable

public class R3x3
extends java.lang.Object
implements java.io.Serializable

Represents an element of R3x3, the set of real 3x3 matrices. The class a set of the usual matrix operations and linear transforms on R3 represented by the matrix.

See Also:
Matrix, R3, Serialized Form

Field Summary
static int DIM
          number of dimensions (DIM=3)
static int IND_X
          index of x position
static int IND_Y
          index of y position
static int IND_Z
          index of z position
 
Constructor Summary
R3x3()
          Creates a new instance of R3x3 initialized to zero.
R3x3(R3x3 matInit)
          Copy Constructor - create a deep copy of the target matrix.
R3x3(java.lang.String strTokens)
          Parsing Constructor - create a R3x3 instance and initialize it according to a token string of element values.
 
Method Summary
 R3x3 conjugateInv(R3x3 matPhi)
          Function for inverse conjugation of this matrix by the argument matrix.
 R3x3 conjugateTrans(R3x3 matPhi)
          Function for transpose conjugation of this matrix by the argument matrix.
 double det()
          Matrix determinant function.
 R3x3EigenDecomposition eigenDecomposition()
          Perform an eigenvalue decomposition of this matrix.
 boolean equals(java.lang.Object o)
          Return true if this object is equal to o, false otherwise.
 double getElem(int i, int j)
          Return matrix element value.
 int hashCode()
          "Borrowed" implementation from AffineTransform, since it is based on double attribute values.
static R3x3 identity()
          Create an identity matrix
 R3x3 inverse()
          Nondestructive inverse of this matrix.
 boolean isSymmetric()
          Check if matrix is symmetric.
static void main(java.lang.String[] arrArgs)
          Testing Driver
 R3x3 minus(R3x3 mat)
          Nondestructive matrix subtraction.
 void minusEquals(R3x3 mat)
          In-place matrix subtraction.
 double norm1()
          Return the l1 norm of this matrix.
 double norm2()
          Return the l2 norm of this matrix
 double normInf()
          Return the l-infinity norm of this matrix
static R3x3 parse(java.lang.String strTokens)
          Create a R3x3 instance and initialize it according to a token string of element values.
 R3x3 plus(R3x3 mat)
          Nondestructive matrix addition.
 void plusEquals(R3x3 mat)
          In-place matrix addition.
 void print(java.io.PrintWriter os)
          Print out the contents of the R3x3 in text format.
 void setElem(int i, int j, double s)
          Element assignment - assigns matrix element to the specified value
 void setSubMatrix(int i0, int i1, int j0, int j1, double[][] arrSub)
          Set a submatrix within the phase matrix.
 R3x3 times(double s)
          Nondestructive scalar multiplication.
 R3 times(R3 vec)
          Nondestructive Matrix-Vector multiplication.
 R3x3 times(R3x3 matRight)
          Matrix multiplication.
 void timesEquals(double s)
          In-place scalar multiplication.
 void timesEquals(R3x3 matRight)
          In-place matrix multiplication.
 java.lang.String toString()
          Convert the contents of the matrix to a string representation.
 R3x3 transpose()
          Nondestructive transpose of this matrix.
static R3x3 zero()
          Create a new instance of a zero matrix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IND_X

public static final int IND_X
index of x position

See Also:
Constant Field Values

IND_Y

public static final int IND_Y
index of y position

See Also:
Constant Field Values

IND_Z

public static final int IND_Z
index of z position

See Also:
Constant Field Values

DIM

public static final int DIM
number of dimensions (DIM=3)

See Also:
Constant Field Values
Constructor Detail

R3x3

public R3x3()
Creates a new instance of R3x3 initialized to zero.


R3x3

public R3x3(R3x3 matInit)
Copy Constructor - create a deep copy of the target matrix.

Parameters:
matInit - initial value

R3x3

public R3x3(java.lang.String strTokens)
     throws java.lang.IllegalArgumentException,
            java.lang.NumberFormatException
Parsing Constructor - create a R3x3 instance and initialize it according to a token string of element values. The token string argument is assumed to be one-dimensional and packed by column (ala FORTRAN).

Parameters:
strTokens - token vector of 7x7=49 numeric values
Throws:
java.lang.IllegalArgumentException - wrong number of token strings
java.lang.NumberFormatException - bad number format, unparseable
Method Detail

zero

public static R3x3 zero()
Create a new instance of a zero matrix.

Returns:
zero vector

identity

public static R3x3 identity()
Create an identity matrix

Returns:
identity matrix object

parse

public static R3x3 parse(java.lang.String strTokens)
                  throws java.lang.IllegalArgumentException,
                         java.lang.NumberFormatException
Create a R3x3 instance and initialize it according to a token string of element values. The token string argument is assumed to be one-dimensional and packed by column (ala FORTRAN).

Parameters:
strTokens - token vector of 3x3=9 numeric values
Throws:
java.lang.IllegalArgumentException - wrong number of token strings
java.lang.NumberFormatException - bad number format, unparseable

getElem

public double getElem(int i,
                      int j)
               throws java.lang.ArrayIndexOutOfBoundsException
Return matrix element value. Get matrix element value at specified index

Parameters:
i - row index
j - column index
Throws:
java.lang.ArrayIndexOutOfBoundsException - index must be in {0,1,2}

setElem

public void setElem(int i,
                    int j,
                    double s)
             throws java.lang.ArrayIndexOutOfBoundsException
Element assignment - assigns matrix element to the specified value

Parameters:
i - row index
j - column index
Throws:
java.lang.ArrayIndexOutOfBoundsException - index must be in {0,1,2}

setSubMatrix

public void setSubMatrix(int i0,
                         int i1,
                         int j0,
                         int j1,
                         double[][] arrSub)
                  throws java.lang.ArrayIndexOutOfBoundsException
Set a submatrix within the phase matrix.

Parameters:
i0 - row index of upper left block
i1 - row index of lower right block
j0 - column index of upper left block
j1 - column index of lower right block
arrSub - two-dimensional sub element array
Throws:
java.lang.ArrayIndexOutOfBoundsException - submatrix does not fit into 3x3 matrix

equals

public boolean equals(java.lang.Object o)
Return true if this object is equal to o, false otherwise.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
"Borrowed" implementation from AffineTransform, since it is based on double attribute values. Must implement hashCode to be consistent with equals as specified by contract of hashCode in Object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashCode for this object

isSymmetric

public boolean isSymmetric()
Check if matrix is symmetric.

Returns:
true if matrix is symmetric

det

public double det()
Matrix determinant function.

Returns:
det(this)

transpose

public R3x3 transpose()
Nondestructive transpose of this matrix.

Returns:
transposed matrix

inverse

public R3x3 inverse()
Nondestructive inverse of this matrix.

Returns:
the algebraic inverse of this matrix

eigenDecomposition

public R3x3EigenDecomposition eigenDecomposition()
Perform an eigenvalue decomposition of this matrix. If the matrix is symmetric it can be decomposed as A = R*D*R' where A is this matrix, R is an (special) orthogonal matrix in SO(3), and D is the diagonal matrix of eigenvales of A.

Returns:
eigen-system decomposition object for R3x3 matrix

plus

public R3x3 plus(R3x3 mat)
Nondestructive matrix addition.

Parameters:
mat - matrix to be added to this
Returns:
this + mat (elementwise)

plusEquals

public void plusEquals(R3x3 mat)
In-place matrix addition.

Parameters:
mat - matrix to be added to this (result replaces this)

minus

public R3x3 minus(R3x3 mat)
Nondestructive matrix subtraction.

Parameters:
mat - matrix to be subtracted from this
Returns:
this - mat (elementwise)

minusEquals

public void minusEquals(R3x3 mat)
In-place matrix subtraction.

Parameters:
mat - matrix to be subtracted from this (result replaces this)

times

public R3x3 times(double s)
Nondestructive scalar multiplication.

Parameters:
s - scalar value to multiply this matrix
Returns:
new matrix equal to s*this

timesEquals

public void timesEquals(double s)
In-place scalar multiplication.

Parameters:
s - scalar value to multiply this matrix (result replaces this)

times

public R3 times(R3 vec)
Nondestructive Matrix-Vector multiplication.

Returns:
this*vec

times

public R3x3 times(R3x3 matRight)
Matrix multiplication.

Parameters:
matRight - right operand of matrix multiplication operator
Returns:
this*matRight

timesEquals

public void timesEquals(R3x3 matRight)
In-place matrix multiplication.

Parameters:
matRight - right operand of matrix multiplication operator
Returns:
this*matRight

conjugateTrans

public R3x3 conjugateTrans(R3x3 matPhi)
Function for transpose conjugation of this matrix by the argument matrix. This method is nondestructive, return a new matrix.

Parameters:
matPhi - conjugating matrix (typically a tranfer matrix)
Returns:
matPhi*this*matPhi^T

conjugateInv

public R3x3 conjugateInv(R3x3 matPhi)
Function for inverse conjugation of this matrix by the argument matrix. This method is nondestructive, return a new matrix.

Parameters:
matPhi - conjugating matrix (typically a tranfer matrix)
Returns:
matPhi*this*matPhi^-1

norm1

public double norm1()
Return the l1 norm of this matrix.

Returns:
||M||_1 = Sum |m_ij|

norm2

public double norm2()
Return the l2 norm of this matrix

Returns:
||M||_2 = [ Sum (m_ij)^2 ]^1/2

normInf

public double normInf()
Return the l-infinity norm of this matrix

Returns:
||M||_inf = sup_ij |m_ij|

toString

public java.lang.String toString()
Convert the contents of the matrix to a string representation. The format is similar to that of Mathematica, e.g. { {a b }{c d } }

Overrides:
toString in class java.lang.Object
Returns:
string representation of the matrix

print

public void print(java.io.PrintWriter os)
Print out the contents of the R3x3 in text format.

Parameters:
os - output stream to receive text dump

main

public static void main(java.lang.String[] arrArgs)
Testing Driver