visad.matrix
Class JamaMatrix

java.lang.Object
  extended by visad.ThingImpl
      extended by visad.DataImpl
          extended by visad.FunctionImpl
              extended by visad.FieldImpl
                  extended by visad.FlatField
                      extended by visad.matrix.JamaMatrix
All Implemented Interfaces:
Serializable, Cloneable, Data, Field, FlatFieldIface, Function, Thing

public class JamaMatrix
extends FlatField

JamaMatrix is a VisAD wrapper for JAMA matrices. This class requires the JAMA package.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class visad.DataImpl
DataImpl.Syncher
 
Field Summary
 
Fields inherited from class visad.FlatField
RangeCoordinateSystem, RangeCoordinateSystems, RangeUnits, TupleDimension
 
Fields inherited from interface visad.Data
ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE
 
Constructor Summary
JamaMatrix(double[][] entries)
          Construct a new JamaMatrix from the given matrix entries.
JamaMatrix(int rows, int cols)
          Construct a new JamaMatrix from the given matrix dimensions.
JamaMatrix(Object matrix)
          Construct a new JamaMatrix from the given JAMA Matrix.
JamaMatrix(Object matrix, CoordinateSystem range_coord_sys, CoordinateSystem[] range_coord_syses, Set[] range_sets, Unit[] units)
          Construct a new JamaMatrix from the specified JAMA Matrix, coordinate systems, range sets and units.
JamaMatrix(Object matrix, FunctionType type, Gridded2DSet domain_set)
          Construct a new JamaMatrix from the given JAMA Matrix, MathType and domain set.
JamaMatrix(Object matrix, FunctionType type, Gridded2DSet domain_set, CoordinateSystem range_coord_sys, CoordinateSystem[] range_coord_syses, Set[] range_sets, Unit[] units)
          Construct a new JamaMatrix from the specified JAMA Matrix, MathType, domain set, coordinate systems, range sets and units.
 
Method Summary
 JamaMatrix arrayLeftDivide(JamaMatrix B)
          Element-by-element left division, C = A.
 JamaMatrix arrayLeftDivideEquals(JamaMatrix B)
          Element-by-element left division in place, A = A.
 JamaMatrix arrayRightDivide(JamaMatrix B)
          Element-by-element right division, C = A.
 JamaMatrix arrayRightDivideEquals(JamaMatrix B)
          Element-by-element right division in place, A = A.
 JamaMatrix arrayTimes(JamaMatrix B)
          Element-by-element multiplication, C = A.
 JamaMatrix arrayTimesEquals(JamaMatrix B)
          Element-by-element multiplication in place, A = A.
 JamaCholeskyDecomposition chol()
           
 double cond()
          Matrix condition (2 norm).
static JamaMatrix convertToMatrix(FlatField field)
          Attempt to convert the given VisAD FlatField to a VisAD JamaMatrix Data object.
 double det()
          Matrix determinant.
 JamaEigenvalueDecomposition eig()
           
 double get(int i, int j)
          Get a single element.
 int getColumnDimension()
          Get column dimension.
 Object getMatrix()
          Return the associated JAMA Matrix object.
 JamaMatrix getMatrix(int[] r, int[] c)
          Get a submatrix.
 JamaMatrix getMatrix(int[] r, int j0, int j1)
          Get a submatrix.
 JamaMatrix getMatrix(int i0, int i1, int[] c)
          Get a submatrix.
 JamaMatrix getMatrix(int i0, int i1, int j0, int j1)
          Get a submatrix.
 int getRowDimension()
          Get row dimension.
static JamaMatrix identity(int m, int n)
          Generate identity matrix.
 JamaMatrix inverse()
          Matrix inverse or pseudoinverse.
 JamaLUDecomposition lu()
           
static void main(String[] args)
          Test the JamaMatrix class.
 JamaMatrix minus(JamaMatrix B)
          C = A - B
 JamaMatrix minusEquals(JamaMatrix B)
          A = A - B
 double norm1()
          One norm.
 double norm2()
          Two norm.
 double normF()
          Frobenius norm.
 double normInf()
          Infinity norm.
 JamaMatrix plus(JamaMatrix B)
          C = A + B
 JamaMatrix plusEquals(JamaMatrix B)
          A = A + B
 void print(int w, int d)
          Print the matrix to stdout.
 void print(NumberFormat format, int width)
          Print the matrix to stdout.
 void print(PrintWriter output, int w, int d)
          Print the matrix to the output stream.
 void print(PrintWriter output, NumberFormat format, int width)
          Print the matrix to the output stream.
 JamaQRDecomposition qr()
           
static JamaMatrix random(int m, int n)
          Generate matrix with random elements.
 int rank()
          Matrix rank.
static JamaMatrix read(BufferedReader input)
          Read a matrix from a stream.
 void set(int i, int j, double s)
          Set a single element.
 void setMatrix(double[][] entries)
          Set this matrix's samples to correspond to the given entries.
 void setMatrix(int[] r, int[] c, JamaMatrix X)
          Set a submatrix.
 void setMatrix(int[] r, int j0, int j1, JamaMatrix X)
          Set a submatrix.
 void setMatrix(int i0, int i1, int[] c, JamaMatrix X)
          Set a submatrix.
 void setMatrix(int i0, int i1, int j0, int j1, JamaMatrix X)
          Set a submatrix.
 void setMatrix(Object matrix)
          Set this matrix's samples to correspond to those of the given JAMA Matrix.
 JamaMatrix solve(JamaMatrix B)
          Solve A*X = B
 JamaMatrix solveTranspose(JamaMatrix B)
          Solve X*A = B, which is also A'*X' = B'
 JamaSingularValueDecomposition svd()
           
 JamaMatrix times(double s)
          Multiply a matrix by a scalar, C = s*A
 JamaMatrix times(JamaMatrix B)
          Linear algebraic matrix multiplication, A * B
 JamaMatrix timesEquals(double s)
          Multiply a matrix by a scalar in place, A = s*A
 double trace()
          Matrix trace.
 JamaMatrix transpose()
          Matrix transpose.
 JamaMatrix uminus()
          Unary minus.
 
Methods inherited from class visad.FlatField
adjustSamplingError, binary, clearMissing, clone, cloneDouble, cloneDouble, cloneFloat, cloneFloat, computeRanges, convertToField, derivative, derivative, derivative, derivative, derivative, equals, extract, extract, fillField, getDefaultRangeUnits, getFloats, getFloats, getRangeCoordinateSystem, getRangeCoordinateSystem, getRangeDimension, getRangeErrors, getRangeSets, getRangeUnits, getSample, getSample, getStringValues, getValues, getValues, getValues, grabBytes, isFlatField, isMissing, longString, makeField, makeField1, makeField2, makeRational, makeRational, nullRanges, pr, resample, resampleDouble, setRangeErrors, setSample, setSample, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, setSamples, toString, unary, unpackFloats, unpackFloats, unpackFloats, unpackOneFloatRangeComp, unpackOneFloatRangeComp, unpackOneRangeComp, unpackOneRangeComp, unpackValues, unpackValues, unpackValues
 
Methods inherited from class visad.FieldImpl
__getitem__, __len__, __setitem__, __setitem__, combine, combine, combine, combine, combine, domainEnumeration, domainFactor, domainFactor, domainMultiply, domainMultiply, domainMultiply, domainMultiply, extract, extract, getDomainCoordinateSystem, getDomainSet, getDomainUnits, getLength, setSample, setSample, setSample, setSamples
 
Methods inherited from class visad.FunctionImpl
__getitem__, __getitem__, evaluate, evaluate, evaluate, evaluate, getDomainDimension, resample
 
Methods inherited from class visad.DataImpl
__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary
 
Methods inherited from class visad.ThingImpl
addReference, removeReference
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface visad.Field
domainEnumeration, domainFactor, domainMultiply, domainMultiply, getDomainSet, getLength, setSample, setSample
 
Methods inherited from interface visad.Function
evaluate, evaluate, evaluate, evaluate, getDomainCoordinateSystem, getDomainDimension, getDomainUnits, resample
 
Methods inherited from interface visad.Data
abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary
 
Methods inherited from interface visad.Thing
addReference, removeReference
 

Constructor Detail

JamaMatrix

public JamaMatrix(int rows,
                  int cols)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the given matrix dimensions.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

JamaMatrix

public JamaMatrix(double[][] entries)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the given matrix entries.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

JamaMatrix

public JamaMatrix(Object matrix)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the given JAMA Matrix.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

JamaMatrix

public JamaMatrix(Object matrix,
                  FunctionType type,
                  Gridded2DSet domain_set)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the given JAMA Matrix, MathType and domain set.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

JamaMatrix

public JamaMatrix(Object matrix,
                  CoordinateSystem range_coord_sys,
                  CoordinateSystem[] range_coord_syses,
                  Set[] range_sets,
                  Unit[] units)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the specified JAMA Matrix, coordinate systems, range sets and units.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

JamaMatrix

public JamaMatrix(Object matrix,
                  FunctionType type,
                  Gridded2DSet domain_set,
                  CoordinateSystem range_coord_sys,
                  CoordinateSystem[] range_coord_syses,
                  Set[] range_sets,
                  Unit[] units)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Construct a new JamaMatrix from the specified JAMA Matrix, MathType, domain set, coordinate systems, range sets and units.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException
Method Detail

convertToMatrix

public static JamaMatrix convertToMatrix(FlatField field)
                                  throws VisADException,
                                         IllegalAccessException,
                                         InstantiationException,
                                         InvocationTargetException
Attempt to convert the given VisAD FlatField to a VisAD JamaMatrix Data object.

Returns:
The converted object, or null if it could not be converted
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

main

public static void main(String[] args)
                 throws VisADException,
                        RemoteException
Test the JamaMatrix class.

Throws:
VisADException
RemoteException

getMatrix

public Object getMatrix()
Return the associated JAMA Matrix object.


setMatrix

public void setMatrix(Object matrix)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set this matrix's samples to correspond to those of the given JAMA Matrix.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

setMatrix

public void setMatrix(double[][] entries)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set this matrix's samples to correspond to the given entries.

Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getRowDimension

public int getRowDimension()
                    throws VisADException,
                           IllegalAccessException,
                           InstantiationException,
                           InvocationTargetException
Get row dimension.

Returns:
The number of rows
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getColumnDimension

public int getColumnDimension()
                       throws VisADException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
Get column dimension.

Returns:
The number of columns
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

get

public double get(int i,
                  int j)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Get a single element.

Parameters:
i - Row index
j - Column index
Returns:
A(i,j)
Throws:
ArrayIndexOutOfBoundsException
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getMatrix

public JamaMatrix getMatrix(int i0,
                            int i1,
                            int j0,
                            int j1)
                     throws VisADException,
                            IllegalAccessException,
                            InstantiationException,
                            InvocationTargetException
Get a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
Returns:
A(i0:i1,j0:j1)
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getMatrix

public JamaMatrix getMatrix(int[] r,
                            int[] c)
                     throws VisADException,
                            IllegalAccessException,
                            InstantiationException,
                            InvocationTargetException
Get a submatrix.

Parameters:
r - Array of row indices
c - Array of column indices
Returns:
A(r(:),c(:))
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getMatrix

public JamaMatrix getMatrix(int i0,
                            int i1,
                            int[] c)
                     throws VisADException,
                            IllegalAccessException,
                            InstantiationException,
                            InvocationTargetException
Get a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
c - Array of column indices
Returns:
A(i0:i1,c(:))
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

getMatrix

public JamaMatrix getMatrix(int[] r,
                            int j0,
                            int j1)
                     throws VisADException,
                            IllegalAccessException,
                            InstantiationException,
                            InvocationTargetException
Get a submatrix.

Parameters:
r - Array of row indices
j0 - Initial column index
j1 - Final column index
Returns:
A(r(:),j0:j1)
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

set

public void set(int i,
                int j,
                double s)
         throws VisADException,
                IllegalAccessException,
                InstantiationException,
                InvocationTargetException
Set a single element.

Parameters:
i - Row index
j - Column index
s - A(i,j)
Throws:
ArrayIndexOutOfBoundsException
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

setMatrix

public void setMatrix(int i0,
                      int i1,
                      int j0,
                      int j1,
                      JamaMatrix X)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
j0 - Initial column index
j1 - Final column index
X - A(i0:i1,j0:j1)
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

setMatrix

public void setMatrix(int[] r,
                      int[] c,
                      JamaMatrix X)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set a submatrix.

Parameters:
r - Array of row indices
c - Array of column indices
X - A(r(:),c(:))
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

setMatrix

public void setMatrix(int[] r,
                      int j0,
                      int j1,
                      JamaMatrix X)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set a submatrix.

Parameters:
r - Array of row indices
j0 - Initial column index
j1 - Final column index
X - A(r(:),j0:j1)
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

setMatrix

public void setMatrix(int i0,
                      int i1,
                      int[] c,
                      JamaMatrix X)
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Set a submatrix.

Parameters:
i0 - Initial row index
i1 - Final row index
c - Array of column indices
X - A(i0:i1,c(:))
Throws:
ArrayIndexOutOfBoundsException - Submatrix indices
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

transpose

public JamaMatrix transpose()
                     throws VisADException,
                            IllegalAccessException,
                            InstantiationException,
                            InvocationTargetException
Matrix transpose.

Returns:
A'
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

norm1

public double norm1()
             throws VisADException,
                    IllegalAccessException,
                    InstantiationException,
                    InvocationTargetException
One norm.

Returns:
maximum column sum
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

norm2

public double norm2()
             throws VisADException,
                    IllegalAccessException,
                    InstantiationException,
                    InvocationTargetException
Two norm.

Returns:
maximum singular value
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

normInf

public double normInf()
               throws VisADException,
                      IllegalAccessException,
                      InstantiationException,
                      InvocationTargetException
Infinity norm.

Returns:
maximum row sum
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

normF

public double normF()
             throws VisADException,
                    IllegalAccessException,
                    InstantiationException,
                    InvocationTargetException
Frobenius norm.

Returns:
sqrt of sum of squares of all elements
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

uminus

public JamaMatrix uminus()
                  throws VisADException,
                         IllegalAccessException,
                         InstantiationException,
                         InvocationTargetException
Unary minus.

Returns:
-A
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

plus

public JamaMatrix plus(JamaMatrix B)
                throws VisADException,
                       IllegalAccessException,
                       InstantiationException,
                       InvocationTargetException
C = A + B

Parameters:
B - another matrix
Returns:
A + B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

plusEquals

public JamaMatrix plusEquals(JamaMatrix B)
                      throws VisADException,
                             IllegalAccessException,
                             InstantiationException,
                             InvocationTargetException
A = A + B

Parameters:
B - another matrix
Returns:
A + B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

minus

public JamaMatrix minus(JamaMatrix B)
                 throws VisADException,
                        IllegalAccessException,
                        InstantiationException,
                        InvocationTargetException
C = A - B

Parameters:
B - another matrix
Returns:
A - B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

minusEquals

public JamaMatrix minusEquals(JamaMatrix B)
                       throws VisADException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
A = A - B

Parameters:
B - another matrix
Returns:
A - B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayTimes

public JamaMatrix arrayTimes(JamaMatrix B)
                      throws VisADException,
                             IllegalAccessException,
                             InstantiationException,
                             InvocationTargetException
Element-by-element multiplication, C = A.*B

Parameters:
B - another matrix
Returns:
A.*B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayTimesEquals

public JamaMatrix arrayTimesEquals(JamaMatrix B)
                            throws VisADException,
                                   IllegalAccessException,
                                   InstantiationException,
                                   InvocationTargetException
Element-by-element multiplication in place, A = A.*B

Parameters:
B - another matrix
Returns:
A.*B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayRightDivide

public JamaMatrix arrayRightDivide(JamaMatrix B)
                            throws VisADException,
                                   IllegalAccessException,
                                   InstantiationException,
                                   InvocationTargetException
Element-by-element right division, C = A./B

Parameters:
B - another matrix
Returns:
A./B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayRightDivideEquals

public JamaMatrix arrayRightDivideEquals(JamaMatrix B)
                                  throws VisADException,
                                         IllegalAccessException,
                                         InstantiationException,
                                         InvocationTargetException
Element-by-element right division in place, A = A./B

Parameters:
B - another matrix
Returns:
A./B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayLeftDivide

public JamaMatrix arrayLeftDivide(JamaMatrix B)
                           throws VisADException,
                                  IllegalAccessException,
                                  InstantiationException,
                                  InvocationTargetException
Element-by-element left division, C = A.\B

Parameters:
B - another matrix
Returns:
A.\B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

arrayLeftDivideEquals

public JamaMatrix arrayLeftDivideEquals(JamaMatrix B)
                                 throws VisADException,
                                        IllegalAccessException,
                                        InstantiationException,
                                        InvocationTargetException
Element-by-element left division in place, A = A.\B

Parameters:
B - another matrix
Returns:
A.\B
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

times

public JamaMatrix times(double s)
                 throws VisADException,
                        IllegalAccessException,
                        InstantiationException,
                        InvocationTargetException
Multiply a matrix by a scalar, C = s*A

Parameters:
s - scalar
Returns:
s*A
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

timesEquals

public JamaMatrix timesEquals(double s)
                       throws VisADException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
Multiply a matrix by a scalar in place, A = s*A

Parameters:
s - scalar
Returns:
replace A by s*A
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

times

public JamaMatrix times(JamaMatrix B)
                 throws VisADException,
                        IllegalAccessException,
                        InstantiationException,
                        InvocationTargetException
Linear algebraic matrix multiplication, A * B

Parameters:
B - another matrix
Returns:
Matrix product, A * B
Throws:
IllegalArgumentException - Matrix inner dimensions must agree
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

solve

public JamaMatrix solve(JamaMatrix B)
                 throws VisADException,
                        IllegalAccessException,
                        InstantiationException,
                        InvocationTargetException
Solve A*X = B

Parameters:
B - right hand side
Returns:
solution if A is square, least squares solution otherwise
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

solveTranspose

public JamaMatrix solveTranspose(JamaMatrix B)
                          throws VisADException,
                                 IllegalAccessException,
                                 InstantiationException,
                                 InvocationTargetException
Solve X*A = B, which is also A'*X' = B'

Parameters:
B - right hand side
Returns:
solution if A is square, least squares solution otherwise
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

inverse

public JamaMatrix inverse()
                   throws VisADException,
                          IllegalAccessException,
                          InstantiationException,
                          InvocationTargetException
Matrix inverse or pseudoinverse.

Returns:
inverse(A) if A is square, pseudoinverse otherwise
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

det

public double det()
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Matrix determinant.

Returns:
determinant
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

rank

public int rank()
         throws VisADException,
                IllegalAccessException,
                InstantiationException,
                InvocationTargetException
Matrix rank.

Returns:
effective numerical rank, obtained from SVD
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

cond

public double cond()
            throws VisADException,
                   IllegalAccessException,
                   InstantiationException,
                   InvocationTargetException
Matrix condition (2 norm).

Returns:
ratio of largest to smallest singular value
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

trace

public double trace()
             throws VisADException,
                    IllegalAccessException,
                    InstantiationException,
                    InvocationTargetException
Matrix trace.

Returns:
sum of the diagonal elements
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

random

public static JamaMatrix random(int m,
                                int n)
                         throws VisADException,
                                IllegalAccessException,
                                InstantiationException,
                                InvocationTargetException
Generate matrix with random elements.

Parameters:
m - Number of rows
n - Number of colums
Returns:
An m-by-n matrix with uniformly distributed random elements
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

identity

public static JamaMatrix identity(int m,
                                  int n)
                           throws VisADException,
                                  IllegalAccessException,
                                  InstantiationException,
                                  InvocationTargetException
Generate identity matrix.

Parameters:
m - Number of rows
n - Number of colums
Returns:
An m-by-n matrix with ones on the diagonal and zeros elsewhere
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

print

public void print(int w,
                  int d)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Print the matrix to stdout. Line the elements up in columns with a Fortran-like 'Fw.d' style format

Parameters:
w - Column width
d - Number of digits after the decimal
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

print

public void print(PrintWriter output,
                  int w,
                  int d)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Print the matrix to the output stream. Line the elements up in columns with a Fortran-like 'Fw.d' style format.

Parameters:
output - Output stream
w - Column width
d - Number of digits after the decimal
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

print

public void print(NumberFormat format,
                  int width)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Print the matrix to stdout. Line the elements up in columns. Use the format object, and right justify within columns of width characters.

Parameters:
format - Formatting object for individual elements
width - Field width for each column
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

print

public void print(PrintWriter output,
                  NumberFormat format,
                  int width)
           throws VisADException,
                  IllegalAccessException,
                  InstantiationException,
                  InvocationTargetException
Print the matrix to the output stream. Line the elements up in columns. Use the format object, and right justify within columns of width characters.

Parameters:
output - the output stream
format - A formatting object to format the matrix elements
width - Column width
Throws:
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

read

public static JamaMatrix read(BufferedReader input)
                       throws IOException,
                              VisADException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
Read a matrix from a stream. The format is the same the print method, so printed matrices can be read back in. Elements are separated by whitespace, all the elements for each row appear on a single line, the last row is followed by a blank line.

Parameters:
input - the input stream
Throws:
IOException
VisADException
IllegalAccessException
InstantiationException
InvocationTargetException

chol

public JamaCholeskyDecomposition chol()
                               throws VisADException,
                                      RemoteException,
                                      IllegalAccessException,
                                      InstantiationException,
                                      InvocationTargetException
Throws:
VisADException
RemoteException
IllegalAccessException
InstantiationException
InvocationTargetException

eig

public JamaEigenvalueDecomposition eig()
                                throws VisADException,
                                       RemoteException,
                                       IllegalAccessException,
                                       InstantiationException,
                                       InvocationTargetException
Throws:
VisADException
RemoteException
IllegalAccessException
InstantiationException
InvocationTargetException

lu

public JamaLUDecomposition lu()
                       throws VisADException,
                              RemoteException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
Throws:
VisADException
RemoteException
IllegalAccessException
InstantiationException
InvocationTargetException

qr

public JamaQRDecomposition qr()
                       throws VisADException,
                              RemoteException,
                              IllegalAccessException,
                              InstantiationException,
                              InvocationTargetException
Throws:
VisADException
RemoteException
IllegalAccessException
InstantiationException
InvocationTargetException

svd

public JamaSingularValueDecomposition svd()
                                   throws VisADException,
                                          RemoteException,
                                          IllegalAccessException,
                                          InstantiationException,
                                          InvocationTargetException
Throws:
VisADException
RemoteException
IllegalAccessException
InstantiationException
InvocationTargetException