fhm.edu.fem.calc.objects.matrix
Class MatrixHull

java.lang.Object
  extended by fhm.edu.fem.calc.objects.matrix.MatrixHull
All Implemented Interfaces:
MathObject, Matrix
Direct Known Subclasses:
MatrixHullChain

public class MatrixHull
extends java.lang.Object
implements Matrix

Class Description: HullMatrix extends the basic matrix. It offers a hull-oriented memory management to safe memory. ONLY WORKS ON SYMMETRIC MATRICES

Author:
Thomas Woellert (thomas@woellert.net), Stefan Weissbach (weissbst@gmx.de)

Field Summary
protected  int[] diagPointer
           
protected  int difference
           
protected  ENVHullMatrix env
           
protected  int hullDiagElementIndex
           
protected static Logger localLogger
           
protected  java.lang.String name
           
protected  int prevHullDiagElementIndex
           
protected  int size
           
protected  int targetHullElementIndex
           
 
Constructor Summary
protected MatrixHull()
           
  MatrixHull(MatrixHull m)
          Copy Constructor
  MatrixHull(java.lang.String name, double[][] values)
          Matrix with the given name, filled with the given values
  MatrixHull(java.lang.String name, int size)
          Create a new HullMatrix with the size (x rows and x columns) (all fields are initialized with zeros)
 
Method Summary
 Matrix add(Matrix m)
          Add a given matrix to this matrix
 double[][] asArray()
          Convert all data in the matrix to a quadratic double array
 Matrix cholesky()
          Do the cholesky for this matrix
 java.lang.Object clone()
          Clone the matrix
 int[] getDiagPointer()
          Retrieve the diag pointer from the outside (used by the copy constructor)
 ENVHullMatrix getENV()
          Retrieve the ENVHullMatrix object from the outside (used by the copy constructor)
protected  int getFirstNonZeroIndexForRow(int row)
          Retrieve the first index in the given row where we have a valid value (means !
 java.lang.String getName()
          Retrieve the name of this matrix
 long getRequiredMemory()
          Retrieve the amount of required memory in this matrix (in byte)
 double getValue(int row, int column)
          Retrieve a value from the HullMatrix
 boolean isMainDiagonalNotZero()
          Test if the main diagonal of this matrix is not zero
 boolean isSymmetric()
          Test if the Matrix is symmetric
 Matrix mult(double multiplicator)
          Multiply all values in the matrix by the given value
 Matrix mult(Matrix m)
          Multiply this Matrix with the given Matrix (have to be the same size)
 Vector mult(Vector m)
          Multiply this Matrix with the given vector (have to be the same size)
 void setLineAndColumn(int index, double value)
          Set a whole column to the given value in the matrix at the given column number
 void setName(java.lang.String name)
          Set a new name for this matrix
 void setValue(int row, int column, double value)
          Set a value in the HullMatrix
 int size()
          Get the number of rows and columns in the matrix (square matrix only!)
 void storeLine(int lineNumber, double[] line)
          Store a whole line in the matrix at the given line number
 java.lang.String toString()
           
 java.lang.String toString(int number)
          Variable toString method
 Matrix transponate()
          Transponate the Matrix
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

diagPointer

protected int[] diagPointer

difference

protected int difference

env

protected ENVHullMatrix env

hullDiagElementIndex

protected int hullDiagElementIndex

localLogger

protected static Logger localLogger

name

protected java.lang.String name

prevHullDiagElementIndex

protected int prevHullDiagElementIndex

size

protected int size

targetHullElementIndex

protected int targetHullElementIndex
Constructor Detail

MatrixHull

protected MatrixHull()

MatrixHull

public MatrixHull(MatrixHull m)
Copy Constructor

Parameters:
m, - the hull matrix to copy

MatrixHull

public MatrixHull(java.lang.String name,
                  double[][] values)
Matrix with the given name, filled with the given values

Parameters:
name, - name
values, - quadratic

MatrixHull

public MatrixHull(java.lang.String name,
                  int size)
Create a new HullMatrix with the size (x rows and x columns) (all fields are initialized with zeros)

Parameters:
name, - the name of the matrix
size, - the number of rows and columns (square matrix only!)
Method Detail

add

public Matrix add(Matrix m)
Add a given matrix to this matrix

Specified by:
add in interface Matrix
Parameters:
m, - the matrix to add
Returns:
the new matrix, the original matrix is not changed

asArray

public double[][] asArray()
Convert all data in the matrix to a quadratic double array

Specified by:
asArray in interface Matrix
Returns:
double[][]

cholesky

public Matrix cholesky()
                throws CholeskyFailedException
Do the cholesky for this matrix

Specified by:
cholesky in interface Matrix
Returns:
the matrix L as result of the cholesky
Throws:
CholeskyFailedException

clone

public java.lang.Object clone()
Clone the matrix

Specified by:
clone in interface Matrix
Overrides:
clone in class java.lang.Object
Returns:
the cloned matrix

getDiagPointer

public int[] getDiagPointer()
Retrieve the diag pointer from the outside (used by the copy constructor)

Returns:
diagPointer, the diag pointer

getENV

public ENVHullMatrix getENV()
Retrieve the ENVHullMatrix object from the outside (used by the copy constructor)

Returns:
env, the env object

getFirstNonZeroIndexForRow

protected int getFirstNonZeroIndexForRow(int row)
                                  throws java.lang.IndexOutOfBoundsException
Retrieve the first index in the given row where we have a valid value (means != 0)

Parameters:
row, - the row index (starting at 1)
Returns:
the first index with a valid (means != 0) value
Throws:
java.lang.IndexOutOfBoundsException

getName

public java.lang.String getName()
Retrieve the name of this matrix

Specified by:
getName in interface Matrix
Returns:
the name

getRequiredMemory

public long getRequiredMemory()
Retrieve the amount of required memory in this matrix (in byte)

Specified by:
getRequiredMemory in interface Matrix
Returns:
the amount of required memory in byte

getValue

public double getValue(int row,
                       int column)
                throws java.lang.IndexOutOfBoundsException
Retrieve a value from the HullMatrix

Specified by:
getValue in interface Matrix
Parameters:
row, - the row index (starting at 1)
column, - the column index (starting at 1)
Returns:
the value at this position
Throws:
java.lang.IndexOutOfBoundsException

isMainDiagonalNotZero

public boolean isMainDiagonalNotZero()
Test if the main diagonal of this matrix is not zero

Specified by:
isMainDiagonalNotZero in interface Matrix
Returns:
true if it is not zero, false otherwise

isSymmetric

public boolean isSymmetric()
Test if the Matrix is symmetric

Specified by:
isSymmetric in interface Matrix
Returns:
false if it is not symmetric, true otherwise

mult

public Matrix mult(double multiplicator)
Multiply all values in the matrix by the given value

Specified by:
mult in interface Matrix
Parameters:
multiplicator, - the value to multiply the matrix with
Returns:
the new matrix, the original matrix is not changed

mult

public Matrix mult(Matrix m)
Multiply this Matrix with the given Matrix (have to be the same size)

Specified by:
mult in interface Matrix
Parameters:
m, - the matrix
Returns:
Matrix, the result matrix

mult

public Vector mult(Vector m)
Multiply this Matrix with the given vector (have to be the same size)

Specified by:
mult in interface Matrix
Parameters:
m, - the vector
Returns:
Vector, the result vector

setLineAndColumn

public void setLineAndColumn(int index,
                             double value)
Set a whole column to the given value in the matrix at the given column number

Specified by:
setLineAndColumn in interface Matrix
Parameters:
columnNumber, - where to store the column
value, - the sole value we want to fill the column with

setName

public void setName(java.lang.String name)
Set a new name for this matrix

Specified by:
setName in interface Matrix
Parameters:
name -

setValue

public void setValue(int row,
                     int column,
                     double value)
              throws java.lang.IndexOutOfBoundsException
Set a value in the HullMatrix

Specified by:
setValue in interface Matrix
Parameters:
row, - the row index (starting at 1)
column, - the column index (starting at 1)
value, - the value to set at the specified position in the matrix
Throws:
java.lang.IndexOutOfBoundsException

size

public int size()
Get the number of rows and columns in the matrix (square matrix only!)

Specified by:
size in interface Matrix
Returns:
the number of rows and columns

storeLine

public void storeLine(int lineNumber,
                      double[] line)
Store a whole line in the matrix at the given line number

Specified by:
storeLine in interface Matrix
Parameters:
lineNumber, - where to store the line
line, - the array holding the line's data

toString

public java.lang.String toString()
Specified by:
toString in interface Matrix
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int number)
Variable toString method

Specified by:
toString in interface Matrix
Parameters:
number, - the number of rows and columns to display (starting at the upper left)
Returns:
String

transponate

public Matrix transponate()
Transponate the Matrix

Specified by:
transponate in interface Matrix
Returns:
the new transponated Matrix