org.jscience.physics.nuclear.kinematics.math
Class Matrix

java.lang.Object
  extended by org.jscience.physics.nuclear.kinematics.math.Matrix

public class Matrix
extends java.lang.Object

DOCUMENT ME!


Field Summary
 int columns
          DOCUMENT ME!
 double[][] element
          DOCUMENT ME!
 int rows
          DOCUMENT ME!
 
Constructor Summary
Matrix(double d)
          Creates a new Matrix object.
Matrix(double x, Matrix m, char code)
          Creates a new Matrix object.
Matrix(int r, int c)
          Creates a new Matrix object.
Matrix(int r, int c, char code)
          Creates a new Matrix object.
Matrix(int r, int c, double fill)
          Creates a new Matrix object.
Matrix(Matrix m)
          Creates a new Matrix object.
Matrix(Matrix m1, Matrix m2, char code)
          Create a matrix by adding, subtracting, multiplying or solving a linear...
Matrix(java.lang.String s)
          Creates a new Matrix object.
 
Method Summary
 double average()
          DOCUMENT ME!
 java.util.List genp()
          returns the LU decomposition of a matrix using the Gauss transform.
 java.util.List gepp()
          Returns the LU decomposition of a matrix using the Gauss transform.
 double leig(double p)
          Elementary QR method method to find the spectral radius of a positive valued matrix.
 Matrix lr(int iter)
          Very basic LR eigenvalue method (no pivot) for illustration only.
 double max()
          DOCUMENT ME!
 double norm()
          DOCUMENT ME!
 Matrix order()
          DOCUMENT ME!
 Matrix permute(int a1, int a2, char c)
          DOCUMENT ME!
 Matrix Q()
          DOCUMENT ME!
 java.util.List qr()
          DOCUMENT ME!
 Matrix qreig(int iter)
          Super basic QR eigenvalue method (example use only) Since this method uses the Householder-QR, it is O(n^3) and not too efficient.
 Matrix R()
          DOCUMENT ME!
 void rowMultiply(int row, double factor)
          DOCUMENT ME!
 Matrix sort()
          DOCUMENT ME!
 Matrix sub(int r1, int r2, int c1, int c2)
          DOCUMENT ME!
 double sum()
          DOCUMENT ME!
 double sumSquares()
          DOCUMENT ME!
 java.util.List toHess()
          Makes the matrix upper Hessenberg via Householder rotations
 java.lang.String toString(int d)
          DOCUMENT ME!
 java.lang.String toStringUL(int d)
          DOCUMENT ME!
 Matrix transpose()
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rows

public int rows
DOCUMENT ME!


columns

public int columns
DOCUMENT ME!


element

public double[][] element
DOCUMENT ME!

Constructor Detail

Matrix

public Matrix(int r,
              int c)
Creates a new Matrix object.

Parameters:
r - DOCUMENT ME!
c - DOCUMENT ME!

Matrix

public Matrix(double d)
Creates a new Matrix object.

Parameters:
d - DOCUMENT ME!

Matrix

public Matrix(Matrix m1,
              Matrix m2,
              char code)
Create a matrix by adding, subtracting, multiplying or solving a linear...

Parameters:
m1 - left matrix
m2 - right matrix
code - '+' for add, '-' for subtract, '*' for multiply, '\\' for solving by decomposition

Matrix

public Matrix(double x,
              Matrix m,
              char code)
Creates a new Matrix object.

Parameters:
x - DOCUMENT ME!
m - DOCUMENT ME!
code - DOCUMENT ME!

Matrix

public Matrix(int r,
              int c,
              double fill)
Creates a new Matrix object.

Parameters:
r - DOCUMENT ME!
c - DOCUMENT ME!
fill - DOCUMENT ME!

Matrix

public Matrix(Matrix m)
Creates a new Matrix object.

Parameters:
m - DOCUMENT ME!

Matrix

public Matrix(int r,
              int c,
              char code)
Creates a new Matrix object.

Parameters:
r - DOCUMENT ME!
c - DOCUMENT ME!
code - DOCUMENT ME!

Matrix

public Matrix(java.lang.String s)
Creates a new Matrix object.

Parameters:
s - DOCUMENT ME!
Method Detail

transpose

public Matrix transpose()
DOCUMENT ME!

Returns:
DOCUMENT ME!

sub

public Matrix sub(int r1,
                  int r2,
                  int c1,
                  int c2)
DOCUMENT ME!

Parameters:
r1 - DOCUMENT ME!
r2 - DOCUMENT ME!
c1 - DOCUMENT ME!
c2 - DOCUMENT ME!
Returns:
DOCUMENT ME!

permute

public Matrix permute(int a1,
                      int a2,
                      char c)
DOCUMENT ME!

Parameters:
a1 - index of row or column to swap
a2 - index of row or column to swap
c - 'c' if swapping columns, 'r' if swapping rows
Returns:
a copy the original matrix with a pair of rows or columns swapped

norm

public double norm()
DOCUMENT ME!

Returns:
DOCUMENT ME!

max

public double max()
DOCUMENT ME!

Returns:
DOCUMENT ME!

sum

public double sum()
DOCUMENT ME!

Returns:
DOCUMENT ME!

average

public double average()
DOCUMENT ME!

Returns:
DOCUMENT ME!

sumSquares

public double sumSquares()
DOCUMENT ME!

Returns:
DOCUMENT ME!

Q

public Matrix Q()
DOCUMENT ME!

Returns:
DOCUMENT ME!

R

public Matrix R()
DOCUMENT ME!

Returns:
DOCUMENT ME!

qr

public java.util.List qr()
DOCUMENT ME!

Returns:
the QR-decomposition of this matrix object using Householder rotations, without column pivoting

toHess

public java.util.List toHess()
Makes the matrix upper Hessenberg via Householder rotations

Returns:
P, H, s.t. P' this P = H and H is upper Hessenberg and P' P = I.

genp

public java.util.List genp()
returns the LU decomposition of a matrix using the Gauss transform. This algorithm returns 3 matrices as follows: [P, L, U] such that LU = PA. This algorithm performs no pivoting other than to assure that the matrix is non-singular. As such, it is practical only from a pedagogical standpoint. Written 3-March, 1997.

Returns:
the LU decomposition of a matrix

gepp

public java.util.List gepp()
Returns the LU decomposition of a matrix using the Gauss transform. This algorithm returns 3 matrices as follows: [P, L, U] such that LU = PA. This algorithm performs partial pivoting. Written 3-March, 1997 by Bryan Lewis

Returns:
the LU decomposition of a matrix

lr

public Matrix lr(int iter)
Very basic LR eigenvalue method (no pivot) for illustration only.

Parameters:
iter - number of iterations
Returns:
?

qreig

public Matrix qreig(int iter)
Super basic QR eigenvalue method (example use only) Since this method uses the Householder-QR, it is O(n^3) and not too efficient. I will also implement a QR-givens method for Hessenberg or 3-diagonal matrices.

Parameters:
iter -
Returns:

leig

public double leig(double p)
Elementary QR method method to find the spectral radius of a positive valued matrix.

Parameters:
p - precision desired. For example, if A is a Matrix of positive real numbers, then A.leig(0.01) returns the largest eigenvalue to at least two digits of accuracy.
Returns:
the spectral radius of a positive valued matrix

toString

public java.lang.String toString(int d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!
Returns:
DOCUMENT ME!

toStringUL

public java.lang.String toStringUL(int d)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!
Returns:
DOCUMENT ME!

sort

public Matrix sort()
DOCUMENT ME!

Returns:
DOCUMENT ME!

order

public Matrix order()
DOCUMENT ME!

Returns:
DOCUMENT ME!

rowMultiply

public void rowMultiply(int row,
                        double factor)
DOCUMENT ME!

Parameters:
row - DOCUMENT ME!
factor - DOCUMENT ME!