maspack.matlab
Class MatlabSolver

java.lang.Object
  extended by maspack.matlab.MatlabSolver
All Implemented Interfaces:
DirectSolver

public class MatlabSolver
extends java.lang.Object
implements DirectSolver


Constructor Summary
MatlabSolver()
           
 
Method Summary
 void analyze(Matrix M, int size, int type)
          Performs prefactor analysis on a specified matrix.
 void analyzeAndFactor(Matrix M)
          Factors a matrix.
 void autoFactorAndSolve(VectorNd x, VectorNd b, int tolExp)
          Factors a previously analyzed matrix M and then solves the system
 void dispose()
          Releases all internal resources allocated by this solver.
 void factor()
          Factors a previously analyzed matrix.
 boolean hasAutoIterativeSolving()
          Returns true if this solver supports automatic iterative solving using a recent directly-factored matrix as a preconditioner.
 void incAll(int[] ar)
           
 void incIndices(double[] ar)
           
 void int2double(int[] ar, double[] dar)
           
 void printArray(double[] ar)
           
 void printArray(int[] ar)
           
 void printArray(java.lang.String name, double[] ar)
           
 void printArray(java.lang.String name, int[] ar)
           
 void printData(double[] rows, double[] cols, double[] vals)
           
 void printIdxs(double[] rows, double[] cols)
           
 void queryFullMatrix()
           
 void querySparseMatrix()
           
 void solve(double[] x, double[] b)
           
 void solve(VectorNd x, VectorNd b)
          Solves the system
 void test()
           
 void write(java.lang.String filename)
           
 void writeArray(IndentingPrintWriter pw, java.lang.String name, double[] ar)
           
 void writeArray(IndentingPrintWriter pw, java.lang.String name, int[] ar)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MatlabSolver

public MatlabSolver()
Method Detail

test

public void test()

analyze

public void analyze(Matrix M,
                    int size,
                    int type)
Description copied from interface: DirectSolver
Performs prefactor analysis on a specified matrix. The matrix reference is stored and used by later calls to factor(). If size is less than the actual matrix size, then the analysis is done on the principal submatrix of M defined by the first size rows and columns.

Specified by:
analyze in interface DirectSolver
Parameters:
M - matrix to analyze
size - size of the matrix to factor.
type - or-ed flags giving information about the matrix type. Typical flags are SYMMETRIC or POSITIVE_DEFINITE

factor

public void factor()
Description copied from interface: DirectSolver
Factors a previously analyzed matrix.

Specified by:
factor in interface DirectSolver

analyzeAndFactor

public void analyzeAndFactor(Matrix M)
Description copied from interface: DirectSolver
Factors a matrix. This is equivalent to the two calls
   analyze (M, M.rowSize(), 0)
   factor()
 

Specified by:
analyzeAndFactor in interface DirectSolver
Parameters:
M - matrix to factor

querySparseMatrix

public void querySparseMatrix()

queryFullMatrix

public void queryFullMatrix()

solve

public void solve(VectorNd x,
                  VectorNd b)
Description copied from interface: DirectSolver
Solves the system
  M x = b
 
where M was specified using previous calls to analyze or factor.

Specified by:
solve in interface DirectSolver
Parameters:
x - vector in which result is returned
b - right hand vector of matrix equation

autoFactorAndSolve

public void autoFactorAndSolve(VectorNd x,
                               VectorNd b,
                               int tolExp)
Description copied from interface: DirectSolver
Factors a previously analyzed matrix M and then solves the system
 M x = b
 
This is equivalent to
 factor()
 solve (x, b) 
 
but is included because it may be faster depending on the underlying implementation. If auto-iterative solving is available (as determined by hasAutoIterativeSolving), this method also allows the solver to automatically employ iterative solving using a recent direct factorization as a preconditioner. To enable auto-iterative solving, the argument tolExp should be set to a positive value giving the (negative) exponent of the desired relative residual.

Specified by:
autoFactorAndSolve in interface DirectSolver
Parameters:
x - vector in which result is returned
b - right hand vector of matrix equation
tolExp - if positive, enables auto-iterative solving with the specified value giving the (negative) exponent of the desired relative residual.

solve

public void solve(double[] x,
                  double[] b)

write

public void write(java.lang.String filename)

writeArray

public void writeArray(IndentingPrintWriter pw,
                       java.lang.String name,
                       double[] ar)

writeArray

public void writeArray(IndentingPrintWriter pw,
                       java.lang.String name,
                       int[] ar)

printData

public void printData(double[] rows,
                      double[] cols,
                      double[] vals)

printIdxs

public void printIdxs(double[] rows,
                      double[] cols)

printArray

public void printArray(java.lang.String name,
                       int[] ar)

printArray

public void printArray(int[] ar)

printArray

public void printArray(java.lang.String name,
                       double[] ar)

printArray

public void printArray(double[] ar)

int2double

public void int2double(int[] ar,
                       double[] dar)

incAll

public void incAll(int[] ar)

incIndices

public void incIndices(double[] ar)

hasAutoIterativeSolving

public boolean hasAutoIterativeSolving()
Returns true if this solver supports automatic iterative solving using a recent directly-factored matrix as a preconditioner. If this feature is available, it may be invoked using the autoFactorAndSolve method.

Specified by:
hasAutoIterativeSolving in interface DirectSolver
Returns:
true if auto-iterative solving is available

dispose

public void dispose()
Description copied from interface: DirectSolver
Releases all internal resources allocated by this solver.

Specified by:
dispose in interface DirectSolver