maspack.matrix
Interface MatrixBlock

All Superinterfaces:
Clonable, java.lang.Cloneable, DenseMatrix, LinearTransformNd, Matrix
All Known Implementing Classes:
FrameBlock, Matrix1x1Block, Matrix1x3Block, Matrix1x6Block, Matrix2x2Block, Matrix2x3Block, Matrix2x6Block, Matrix3x1Block, Matrix3x2Block, Matrix3x3Block, Matrix3x3DiagBlock, Matrix3x4Block, Matrix3x6Block, Matrix4x3Block, Matrix6dBlock, Matrix6x1Block, Matrix6x2Block, Matrix6x3Block, MatrixBlockBase, MatrixNdBlock, SpatialInertia

public interface MatrixBlock
extends DenseMatrix, Clonable

An extension to matrix that supports inclusion in a block matrix.


Nested Class Summary
 
Nested classes/interfaces inherited from interface maspack.matrix.Matrix
Matrix.Partition, Matrix.WriteFormat
 
Field Summary
 
Fields inherited from interface maspack.matrix.Matrix
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
 
Method Summary
 void add(Matrix M)
          Adds the contents of a Matrix to this matrix block.
 void addNumNonZerosByCol(int[] offsets, int idx, Matrix.Partition part)
          Adds the number of non-zero entries in each column of this block matrix to the current values stored in the array offsets, starting at the location specified by idx.
 void addNumNonZerosByRow(int[] offsets, int idx, Matrix.Partition part)
          Adds the number of non-zero entries in each row of this block matrix to the current values stored in the array offsets, starting at the location specified by idx.
 MatrixBlock clone()
          Creates a clone of this MatrixBlock, which duplicates the size, storage capacity, and values.
 MatrixBlock down()
          Returns the next matrix block in a block matrix column.
 int getBlockCCSIndices(int[] rowIdxs, int rowOff, int[] offsets, Matrix.Partition part)
           
 int getBlockCCSValues(double[] vals, int[] offsets, Matrix.Partition part)
          Stores the values of non-zero entries for this matrix block.
 int getBlockCol()
          Gets the number of the block column of this matrix block within a SparseBlockMatrix.
 int getBlockCRSIndices(int[] colIdxs, int colOff, int[] offsets, Matrix.Partition part)
          Stores the column indices of the non-zero entries for this matrix block.
 int getBlockCRSValues(double[] vals, int[] offsets, Matrix.Partition part)
          Stores the values of non-zero entries for this matrix block.
 int getBlockNumber()
          Gets the number of this block within a SparseBlockMatrix.
 int getBlockRow()
          Gets the number of the block row of this matrix block within a SparseBlockMatrix.
 void mulAdd(double[] y, int yIdx, double[] x, int xidx)
          Pre-multiplies a column vector by this matrix block and adds the result to a set of existing values.
 void mulTransposeAdd(double[] y, int yIdx, double[] x, int xidx)
          Post-multiplies a row vector by this matrix block and adds the result to a set of existing values.
 MatrixBlock next()
          Returns the next matrix block in a block matrix row.
 void scale(double s)
          Scales the elements of this matrix block by a scale factor.
 void scaledAdd(double s, Matrix M)
          Adds the scaled contents of a Matrix to this matrix block.
 void setBlockCol(int blkCol)
          Sets the number of the block column of this matrix block within a SparseBlockMatrix.
 void setBlockNumber(int num)
          Sets the number of this block within a SparseBlockMatrix.
 void setBlockRow(int blkRow)
          Sets the number of the block row of this matrix block within a SparseBlockMatrix.
 void setDown(MatrixBlock blk)
          Sets the next matrix block in a block matrix column.
 void setNext(MatrixBlock blk)
          Sets the next matrix block in a block matrix row.
 void setZero()
          Sets the contents of this matrix block to zero.
 void sub(Matrix M)
          Subtract the contents of a Matrix from this matrix block.
 boolean valueIsNonZero(int i, int j)
          Returns true if the value at the specified location is structurally non-zero.
 
Methods inherited from interface maspack.matrix.DenseMatrix
set, set, set, setColumn, setColumn, setRow, setRow, setSubMatrix
 
Methods inherited from interface maspack.matrix.Matrix
checkConsistency, colSize, determinant, epsilonEquals, equals, frobeniusNorm, get, get, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getColumn, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getRow, getRow, getRow, getSize, getSubMatrix, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, numNonZeroVals, oneNorm, rowSize, scan, set, set, setCCSValues, setCRSValues, setSize, toString, trace, write, write, write
 

Method Detail

down

MatrixBlock down()
Returns the next matrix block in a block matrix column.

Returns:
next matrix block in a column

setDown

void setDown(MatrixBlock blk)
Sets the next matrix block in a block matrix column. Reserved for use by maspack.matrix.

Parameters:
blk - next matrix block in a column

next

MatrixBlock next()
Returns the next matrix block in a block matrix row.

Returns:
next matrix block in a row

setNext

void setNext(MatrixBlock blk)
Sets the next matrix block in a block matrix row. Reserved for use by maspack.matrix.

Parameters:
blk - next matrix block in a row

setZero

void setZero()
Sets the contents of this matrix block to zero.


scale

void scale(double s)
Scales the elements of this matrix block by a scale factor.

Parameters:
s - scaling factor

add

void add(Matrix M)
Adds the contents of a Matrix to this matrix block.

Parameters:
M - matrix to add
Throws:
ImproperSizeException - if the matrix sizes do not conform

scaledAdd

void scaledAdd(double s,
               Matrix M)
Adds the scaled contents of a Matrix to this matrix block.

Parameters:
s - scaling factor
M - matrix to add
Throws:
ImproperSizeException - if the matrix sizes do not conform

sub

void sub(Matrix M)
Subtract the contents of a Matrix from this matrix block.

Parameters:
M - matrix to subtract
Throws:
ImproperSizeException - if the matrix sizes do not conform

getBlockCol

int getBlockCol()
Gets the number of the block column of this matrix block within a SparseBlockMatrix.

Returns:
block column number for this block

getBlockRow

int getBlockRow()
Gets the number of the block row of this matrix block within a SparseBlockMatrix.

Returns:
block row number for this block

setBlockCol

void setBlockCol(int blkCol)
Sets the number of the block column of this matrix block within a SparseBlockMatrix. Use of this method is reserved to maspack.matrix.

Parameters:
blkCol - column number for this block

setBlockRow

void setBlockRow(int blkRow)
Sets the number of the block row of this matrix block within a SparseBlockMatrix. Use of this method is reserved to maspack.matrix.

Parameters:
blkRow - row number for this block

getBlockNumber

int getBlockNumber()
Gets the number of this block within a SparseBlockMatrix. Block numbers are used for fast access. If the block does not belong to a SparseBlockMatrix, then -1 is returned.

Returns:
number for this block

setBlockNumber

void setBlockNumber(int num)
Sets the number of this block within a SparseBlockMatrix. Use of this method is reserved to maspack.matrix.

Parameters:
num - number for this block

mulAdd

void mulAdd(double[] y,
            int yIdx,
            double[] x,
            int xidx)
Pre-multiplies a column vector by this matrix block and adds the result to a set of existing values. The column vector values are supplied by the argument x, starting at location xIdx, and the result is added to values in y, starting at location yIdx.

Parameters:
y - accumulates resulting values
yIdx - starting index for accumulating values
x - supplies column vector values
xidx - starting index for column vector values

mulTransposeAdd

void mulTransposeAdd(double[] y,
                     int yIdx,
                     double[] x,
                     int xidx)
Post-multiplies a row vector by this matrix block and adds the result to a set of existing values. The row vector values are supplied by the argument x, starting at location xIdx, and the result is added to values in y, starting at location yIdx.

Parameters:
y - accumulates resulting values
yIdx - starting index for accumulating values
x - supplies row vector values
xidx - starting index for row vector values

getBlockCRSIndices

int getBlockCRSIndices(int[] colIdxs,
                       int colOff,
                       int[] offsets,
                       Matrix.Partition part)
Stores the column indices of the non-zero entries for this matrix block. The indices for each row i are stored contiguously within the array colIdxs, starting at a location given by offsets[i]. Indices are 0-based. Upon return, offsets[i] should be incremented by the number of non-zero values in row i.

Parameters:
colIdxs - stores column indices of non-zero entries
colOff - starting column index for the first column of this block
offsets - offsets within colIdxs for storing each row's indices; upon return, should be incremented by the number of non-zero entries in each row.
part - specifies whether to store column indices for the entire block or a specified sub-portion.
Returns:
number of non-zero entries

getBlockCRSValues

int getBlockCRSValues(double[] vals,
                      int[] offsets,
                      Matrix.Partition part)
Stores the values of non-zero entries for this matrix block. The values for each row i are stored contiguously within the array vals, starting at a location given by offsets[i]. Upon return, offsets[i] should be incremented by the number of non-zero values in row i.

Parameters:
vals - stores values of non-zero entries
offsets - offsets within vals for storing each row's values; upon return, should be incremented by the number of non-zero entries in each row.
part - specifies whether to store the entire block or a specified sub-portion.
Returns:
number of non-zero entries

addNumNonZerosByRow

void addNumNonZerosByRow(int[] offsets,
                         int idx,
                         Matrix.Partition part)
Adds the number of non-zero entries in each row of this block matrix to the current values stored in the array offsets, starting at the location specified by idx.

Parameters:
offsets - values to be incremented by the number of non-zero entries in each row
idx - starting location within offsets
part - specifies whether to consider the entire block or a specified sub-portion.

getBlockCCSIndices

int getBlockCCSIndices(int[] rowIdxs,
                       int rowOff,
                       int[] offsets,
                       Matrix.Partition part)
Parameters:
rowIdxs - stores row indices of non-zero entries
rowOff - starting row index for the first row of this block
offsets - offsets within rowIdxs for storing each column's indices; upon return, should be incremented by the number of non-zero entries in each column.
part - specifies whether to store row indices for the entire block or a specified sub-portion.
Returns:
number of non-zero entries

getBlockCCSValues

int getBlockCCSValues(double[] vals,
                      int[] offsets,
                      Matrix.Partition part)
Stores the values of non-zero entries for this matrix block. The values for each column j are stored contiguously within the array vals, starting at a location given by offsets[j]. Upon return, offsets[j] should be incremented by the number of non-zero values in column j.

Parameters:
vals - stores values of non-zero entries
offsets - offsets within vals for storing each columns's values; upon return, should be incremented by the number of non-zero entries in each column.
part - specifies whether to store the entire block or a specified sub-portion.
Returns:
number of non-zero entries

addNumNonZerosByCol

void addNumNonZerosByCol(int[] offsets,
                         int idx,
                         Matrix.Partition part)
Adds the number of non-zero entries in each column of this block matrix to the current values stored in the array offsets, starting at the location specified by idx.

Parameters:
offsets - values to be incremented by the number of non-zero entries in each column
idx - starting location within offsets
part - specifies whether to consider the entire block or a specified sub-portion.

valueIsNonZero

boolean valueIsNonZero(int i,
                       int j)
Returns true if the value at the specified location is structurally non-zero. For dense blocks, this methid will always return true.

Parameters:
i - row index
j - column index
Returns:
true if the value at (i,j) is structurally non-zero

clone

MatrixBlock clone()
Creates a clone of this MatrixBlock, which duplicates the size, storage capacity, and values.

Specified by:
clone in interface Clonable
Returns:
clone of this MatrixBlock