ru.sscc.matrix
Class RectBandedMatrix

java.lang.Object
  |
  +--ru.sscc.matrix.RealMatrix
        |
        +--ru.sscc.matrix.RectBandedMatrix

public class RectBandedMatrix
extends RealMatrix

Performs operations upon a Rectangular Banded Matrix. If n is a matrix rows number and k is a band width then the implemented matrix has dimensions n*(n+k-1). The band ocupies the diagonal starting from the matrix upper left corner and also (k-1) diagonals upper it. The representation of the matrix in the container is the following: k entries of the first row (from the left to the right), k entries of the second row, and so on.

A special case of a matrix, a Toeplitz matrix, is also implemented. A Toeplitz matrix contains identical entries along any main diagonal. To store it, only k entries are needed.

See Also:
Serialized Form

Field Summary
 int bandWidth
          The width of band
 
Fields inherited from class ru.sscc.matrix.RealMatrix
entries, nColumns, nRows
 
Constructor Summary
RectBandedMatrix(int size, int bandWidth, boolean toeplitz)
          Constructs an object with a clear matrix double[] type container.
RectBandedMatrix(RealContainer entries, int size, int bandWidth, boolean toeplitz)
          Constructs an instance based on a user's real data container.
 
Method Summary
 double add(int i, int j, double value)
          Adds the value of a matrix entry at the position (i,j).
 void compose(double a, double b, SymBandedMatrix A, RealVector P, SymBandedMatrix B)
          Calculates a linear combination of two matrices by the formula a*A+b*H*P*H'.
 double get(int i, int j)
          Gets a value of a matrix entry at the position (i,j).
 boolean isToeplitz()
          Tests the matrix to be Toeplitz's one.
 double mul(int i, int j, double value)
          Multiplies a matrix entry at the position (i,j) by a value.
 void multiply(RealVector source, RealVector target)
          Multiplies the matrix by a column-vector.
 void multiplyT(RealVector source, RealVector target)
          Multiplies the transposed matrix by a column-vector.
 void reuse()
          Allows to use the matrix in algebraic operations again.
 double set(int i, int j, double value)
          Sets the value of a matrix entry at the position (i,j).
 
Methods inherited from class ru.sscc.matrix.RealMatrix
clone, columnsNumber, ensureAlgebraic, ensureDimensions, ensureDimensions, ensureSquareMatrix, getContainer, lock, multiplyNN, multiplyNT, multiplyTN, multiplyTT, relativeAccuracy, rowsNumber, unlock
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bandWidth

public final int bandWidth
The width of band
Constructor Detail

RectBandedMatrix

public RectBandedMatrix(int size,
                        int bandWidth,
                        boolean toeplitz)
Constructs an object with a clear matrix double[] type container.
Parameters:
size - a matrix dimension
bandWidth - a matrix band width
toeplitz - is true for Toeplitz matrix

RectBandedMatrix

public RectBandedMatrix(RealContainer entries,
                        int size,
                        int bandWidth,
                        boolean toeplitz)
Constructs an instance based on a user's real data container.
Parameters:
entries - an upper half-band container
size - a matrix dimension
bandWidth - a matrix band width
toeplitz - is true for Toeplitz matrix
Method Detail

isToeplitz

public final boolean isToeplitz()
Tests the matrix to be Toeplitz's one.
Returns:
the matrix toeplitznees tag

reuse

public void reuse()
Allows to use the matrix in algebraic operations again.

get

public double get(int i,
                  int j)
Gets a value of a matrix entry at the position (i,j).
Overrides:
get in class RealMatrix
Parameters:
i - a zero based row number
j - a zero based column number
Returns:
an entry value at the required position

set

public double set(int i,
                  int j,
                  double value)
Sets the value of a matrix entry at the position (i,j).
Overrides:
set in class RealMatrix
Parameters:
i - a zero based row number
j - a zero based column number
value - a value to set
Returns:
the set value

add

public double add(int i,
                  int j,
                  double value)
Adds the value of a matrix entry at the position (i,j).
Overrides:
add in class RealMatrix
Parameters:
i - a zero based row number
j - a zero based column number
value - a value to set
Returns:
the addition result

mul

public double mul(int i,
                  int j,
                  double value)
Multiplies a matrix entry at the position (i,j) by a value.
Overrides:
mul in class RealMatrix
Parameters:
i - a zero based row number
j - a zero based column number
value - a value to set
Returns:
the multiplication result

multiply

public void multiply(RealVector source,
                     RealVector target)
Multiplies the matrix by a column-vector.
Overrides:
multiply in class RealMatrix
Parameters:
source - a source vector to multiply
target - a target vector to write the result

multiplyT

public void multiplyT(RealVector source,
                      RealVector target)
Multiplies the transposed matrix by a column-vector.
Overrides:
multiplyT in class RealMatrix
Parameters:
source - a source vector to multiply
target - a target vector to write the result

compose

public void compose(double a,
                    double b,
                    SymBandedMatrix A,
                    RealVector P,
                    SymBandedMatrix B)
Calculates a linear combination of two matrices by the formula a*A+b*H*P*H'. Here a and b are scalar multipliers, A is a symmetric banded matrix, H is a rectangular banded matrix (contents of this object), P is a weight diagonal matrix. Rows numbers for all matrices must be identical. On contrary IllegalArgumentException will be thrown.
Parameters:
a - a multiplier
b - a multiplier
A - a source symmetric banded matrix
P - a weight vector containing values of a diagonal matrix P (null means calculation without weights)
B - a target symmetric banded matrix (may be the same as A) having the same rows number and half-band width not less than half-band width of A and band width of this matrix. In other words the following should be true: B.halfWidth >= max (A.halfWidth, this.bandWidth). If this inequality is broken, the IllegalArgumentException is thrown.