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

java.lang.Object
  extended by fhm.edu.fem.calc.objects.matrix.MatrixStandard
All Implemented Interfaces:
MathObject, Matrix

public class MatrixStandard
extends java.lang.Object
implements Matrix

Class Description: This class represents the matrix (we start at index 1 not 0 for both the rows and the columns)

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

Field Summary
protected  double[][] data
           
protected static Logger localLogger
           
protected  java.lang.String name
           
protected  int size
           
 
Constructor Summary
MatrixStandard(java.lang.String name, double[][] values)
          Matrix with the given name, filled with the given values
MatrixStandard(java.lang.String name, int size)
          Matrix 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
 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 matrix
 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 new value in the matrix
 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

data

protected double[][] data

localLogger

protected static Logger localLogger

name

protected java.lang.String name

size

protected int size
Constructor Detail

MatrixStandard

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

Parameters:
name, - name
values, - quadratic

MatrixStandard

public MatrixStandard(java.lang.String name,
                      int size)
Matrix 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

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 matrix

Specified by:
getValue in interface Matrix
Parameters:
row, - the row index
colum, - the column index
Returns:
the value
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 new value in the matrix

Specified by:
setValue in interface Matrix
Parameters:
row, - the row index
colum, - the column index
value, - the value to set
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