spis.Util.Matrix
Class Matrix

java.lang.Object
  extended byspis.Util.Matrix.Matrix
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DiagMatrix, DirMatrix, SparseMatrix

public abstract class Matrix
extends java.lang.Object
implements java.io.Serializable

Class Name : Matrix
Project ref : SPIS project
File name : Matrix.java
File type : class
Copyright : ONERA, 2 Av. E. Belin, 31055 Toulouse cedex, France http://www.onecert.fr
Status : under development
Creation : 25/08/2003
Modification :

Description : generic Matrix class
For now, it is used to store R anc C matrices of SC circuit, but matrices are also used for solvers, with somewhat different constraints. Before actually implemening this class it must be checked whether those matrix classes could not be used

Versions and anomalies correction :

Version numberAuthor (name, e-mail) Corrections/Modifications
0.1 JF Roussel, roussel@onecert.frCreation


Version:
0.1
Author:
JF Roussel
See Also:
Serialized Form

Field Summary
private  int dim1
          first matrix dimension
private  int dim2
          second matrix dimension
 
Constructor Summary
Matrix(int d1, int d2)
          Default constructor
 
Method Summary
abstract  Matrix buildLineNormalised()
          Generates and returns a matrix built from this matrix by normalising each of its lines: Mij -> Mij / (sum_k Mik).
abstract  Matrix buildTranspose()
          Generates and returns the transpose of this matrix Should return a matrix of subtype identical to this matrix.
 void doubleVectMult(double[] x, double[] y)
          Multyplies by a vector (x) and returns y = matrix x, but with the vectors (badly) typed as double[]: to be avoided!
 int getDim1()
          Returns first matrix dimension.
 int getDim2()
          Returns second matrix dimension.
abstract  float[][] getValues()
          Returns a 2D array representing the matrix
abstract  void incrementValue(int i, int j, float incr)
          Increments the element (i,j) of the matrix of the value incr.
 void linearSystemSolve(FloatScalTable y, FloatScalTable x)
          Solves the linear system matrix x = y, and returns x.
abstract  Matrix matMult(Matrix m)
          Multyplies by another matrix m and returns (this_matrix . m).
abstract  void matMult(Matrix m, Matrix result)
          Multyplies by another matrix m and returns (this_matrix . m) in result.
protected  void setDim1(int dim1)
           
protected  void setDim2(int dim2)
           
abstract  void setValue(int i, int j, float val)
          Sets the element (i,j) of the matrix to the value val.
abstract  void vectMult(FloatScalTable x, FloatScalTable y)
          Multyplies by a vector (x) and returns y = matrix x.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dim1

private int dim1
first matrix dimension


dim2

private int dim2
second matrix dimension

Constructor Detail

Matrix

public Matrix(int d1,
              int d2)
Default constructor

Method Detail

setDim1

protected void setDim1(int dim1)
Parameters:
dim1 - The dim1 to set.

setDim2

protected void setDim2(int dim2)
Parameters:
dim2 - The dim2 to set.

linearSystemSolve

public void linearSystemSolve(FloatScalTable y,
                              FloatScalTable x)
Solves the linear system matrix x = y, and returns x.


doubleVectMult

public void doubleVectMult(double[] x,
                           double[] y)
Multyplies by a vector (x) and returns y = matrix x, but with the vectors (badly) typed as double[]: to be avoided! This was only written to be addressed by PoissonSolve.ConjugateGradientSolve which deals with double[] vectors, like lapack.


vectMult

public abstract void vectMult(FloatScalTable x,
                              FloatScalTable y)
Multyplies by a vector (x) and returns y = matrix x.


matMult

public abstract void matMult(Matrix m,
                             Matrix result)
Multyplies by another matrix m and returns (this_matrix . m) in result. The result matrix must of course be allocated (null forbidden), hence its sub type is dynamically determined by the subtype of the passed matrix (not all of them may sometimes be supported => RuntimeException).

Parameters:
m -
result - The result: this . m (remaining of the subtype of the Matrix argument)

matMult

public abstract Matrix matMult(Matrix m)
Multyplies by another matrix m and returns (this_matrix . m). The result matrix is course allocated during the process, hence its sub type is the preferred subtype of the matrix that performs the operation, this.

Parameters:
m -
Returns:
The result: this . m, as the preferred subtype of this matrix subtype

buildTranspose

public abstract Matrix buildTranspose()
Generates and returns the transpose of this matrix Should return a matrix of subtype identical to this matrix.


buildLineNormalised

public abstract Matrix buildLineNormalised()
Generates and returns a matrix built from this matrix by normalising each of its lines: Mij -> Mij / (sum_k Mik). Should return a matrix of subtype identical to this matrix.


incrementValue

public abstract void incrementValue(int i,
                                    int j,
                                    float incr)
Increments the element (i,j) of the matrix of the value incr. Only partially supported by derived classes: only diagonal term for a DiagMatrix, and only values already present in the matrix structure for a SparseMatrix

Parameters:
i -
j -

setValue

public abstract void setValue(int i,
                              int j,
                              float val)
Sets the element (i,j) of the matrix to the value val. Only partially supported by derived classes: only diagonal term for a DiagMatrix, and only values already present in the matrix structure for a SparseMatrix

Parameters:
i -
j -
val -

getValues

public abstract float[][] getValues()
Returns a 2D array representing the matrix


getDim1

public int getDim1()
Returns first matrix dimension.


getDim2

public int getDim2()
Returns second matrix dimension.