opale.matrix
Class BandMatrix

java.lang.Object
  |
  +--opale.matrix.BandMatrix
All Implemented Interfaces:
java.lang.Cloneable

public final class BandMatrix
extends java.lang.Object
implements java.lang.Cloneable

This class implements a band square matrix with real coefficients. The coefficients are stored in a one dimensional array such as : | 1 2 * * | 3 4 5 * | * 6 7 8 | * * 9 10 In this example size of band = 3.

Since:
Opale-Matrix 0.11

Constructor Summary
BandMatrix(int n, int b)
          Construct a matrix of zeros, of size n and band size b.
 
Method Summary
 BandMatrix add(BandMatrix A)
          Add an another matrix A to the current matrix.
 void add(int i, int j, double x)
          Add a real to a coefficient.
 java.lang.Object clone()
          Creates and return a copy of this object.
 BandMatrix copy()
          Make a copy of the current matrix.
 double get(int i, int j)
          Get a coefficient of the matrix.
 double[] getArrayCopy()
          Get a copy of array of matrix elements.
 double[] getInternalArray()
          Get the internal one-dimensional array.
 int getPosition(int i, int j)
          Get the position of the coefficient (i,j) in the internal one dimensional array.
 int getSize()
          Get the size.
 int getSizeOfBand()
          Get the band size.
static void main(java.lang.String[] arg)
           
 DVect mul(DVect x)
          Multiply the current matrix by a vector.
 void set(int i, int j, double x)
          Set a coefficient of the matrix.
 java.lang.String toString()
          Print the matrix.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BandMatrix

public BandMatrix(int n,
                  int b)
Construct a matrix of zeros, of size n and band size b.
Parameters:
int - n, row dimension.
int - b, band size.
Method Detail

getSize

public int getSize()
Get the size.
Returns:
int, the row dimension.

getSizeOfBand

public int getSizeOfBand()
Get the band size.
Returns:
int, the band size.

get

public double get(int i,
                  int j)
Get a coefficient of the matrix.
Parameters:
int - i, row index.
int - j, column index.
Returns:
double, coeff(i,j)

set

public void set(int i,
                int j,
                double x)
Set a coefficient of the matrix.
Parameters:
int - i, row index.
int - j, column index.
double - x, the value of coeff(i,j)

getPosition

public int getPosition(int i,
                       int j)
Get the position of the coefficient (i,j) in the internal one dimensional array.
Parameters:
int - i, row index.
int - j, column index.
Returns:
int x, the position of coeff(i,j)

copy

public BandMatrix copy()
Make a copy of the current matrix.
Returns:
Matrix, the copy

add

public BandMatrix add(BandMatrix A)
Add an another matrix A to the current matrix.
Parameters:
BandMatrix - A, an another matrix
Returns:
BandMatrix, the result in the current matrix

add

public void add(int i,
                int j,
                double x)
Add a real to a coefficient.
Parameters:
int - i, j, the position of the coefficient
double - the value to add

mul

public DVect mul(DVect x)
Multiply the current matrix by a vector.
Parameters:
DVect - x, a vector
DVect, - the result A*x

getInternalArray

public double[] getInternalArray()
Get the internal one-dimensional array.
Returns:
double[], Pointer to the array of matrix elements.

getArrayCopy

public double[] getArrayCopy()
Get a copy of array of matrix elements.
Returns:
double[], the array of matrix elements.

toString

public java.lang.String toString()
Print the matrix.
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Creates and return a copy of this object.
Overrides:
clone in class java.lang.Object
Returns:
Object a copy of this object.
Throws:
OutOfMemoryError - if not enough memory.
See Also:
Cloneable

main

public static void main(java.lang.String[] arg)