ru.sscc.matrix
Class SymBandedMatrix

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

public class SymBandedMatrix
extends RealMatrix

Performs operations upon a Symmetric Banded Matrix. A banded matrix is stored in the container by its upper half values. Exactly, if n*n-matrix has k upper non-zero diagonals then the matrix container will contain (k+1)*n entries. The value (k+1) is called here the half width. The ordering of the matrix values in the container is the following: (k+1) upper diagonal entries of the first row beginning from the diagonal entry, (k+1) upper diagonal entries of the second row, and so on. If upper diagonal entries number in a row is less than (k+1) (this sitiation appears in last k matrix rows), the missing entries may have arbitrary values.

A special case of a matrix, a Toeplitz matrix, is also implemented. A Toeplitz matrix contains identical entires along any main diagonal. To store it only (k+1) entries are needed. You can expand a Toeplitz matrix to non-Toeplitz one using the expand operation.

See Also:
Serialized Form

Field Summary
 int halfWidth
          A number of nonempty diagonals in upper half of matrix (the main diagonal is also counted).
 
Fields inherited from class ru.sscc.matrix.RealMatrix
entries, nColumns, nRows
 
Constructor Summary
SymBandedMatrix(int size, int halfWidth, boolean toeplitz)
          Construct an object with a clear double[] type matrix container.
SymBandedMatrix(RealContainer entries, int size, int halfWidth, 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 expand()
          Expands Toeplitz matrix to non-Toeplitz type (enlarges the matrix container and fills it by corresponding values).
 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.
 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(boolean toeplitz)
          Allows to use the matrix in algebraic operations again and resets toeplitz tag to new value.
 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

halfWidth

public final int halfWidth
A number of nonempty diagonals in upper half of matrix (the main diagonal is also counted).
Constructor Detail

SymBandedMatrix

public SymBandedMatrix(int size,
                       int halfWidth,
                       boolean toeplitz)
Construct an object with a clear double[] type matrix container.
Parameters:
size - a matrix dimension
halfWidth - a width of matrix's half-band (k+1)
toeplitz - is true for Toeplitz matrix

SymBandedMatrix

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

isToeplitz

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

reuse

public void reuse(boolean toeplitz)
Allows to use the matrix in algebraic operations again and resets toeplitz tag to new value.

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

expand

public void expand()
Expands Toeplitz matrix to non-Toeplitz type (enlarges the matrix container and fills it by corresponding values). The expansion is processed in place if the container size is sufficient for it. Does nothing when the matrix isn't Toeplitz's. Throws the IllegalStateException if the matrix is nonalgebraic.

multiply

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

multiplyT

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