maspack.matrix
Class SparseBlockMatrix

java.lang.Object
  extended by maspack.matrix.MatrixBase
      extended by maspack.matrix.SparseMatrixBase
          extended by maspack.matrix.SparseBlockMatrix
All Implemented Interfaces:
java.lang.Cloneable, LinearTransformNd, Matrix, SparseMatrix, Clonable
Direct Known Subclasses:
SparseNumberedBlockMatrix

public class SparseBlockMatrix
extends SparseMatrixBase
implements Clonable

Implements a square sparse matrix composed of MatrixBlocks.


Nested Class Summary
static class SparseBlockMatrix.PrintFormat
           
 
Nested classes/interfaces inherited from interface maspack.matrix.Matrix
Matrix.Partition, Matrix.WriteFormat
 
Field Summary
static int warningLevel
           
 
Fields inherited from interface maspack.matrix.Matrix
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
 
Constructor Summary
SparseBlockMatrix()
           
SparseBlockMatrix(int[] rowColSizes)
           
SparseBlockMatrix(int[] rowSizes, int[] colSizes)
           
 
Method Summary
 int addBlock(int bi, int bj, MatrixBlock blk)
           
 void addCol(int size)
           
 void addCols(int[] sizes, int num)
           
 void addNumNonZerosByCol(int[] offsets, int idx, Matrix.Partition part, int numRows, int numCols)
           
 void addNumNonZerosByRow(int[] offsets, int idx, Matrix.Partition part)
           
 void addNumNonZerosByRow(int[] offsets, int idx, Matrix.Partition part, int numRows, int numCols)
           
 void addRow(int size)
           
 void addRows(int[] sizes, int num)
           
static SparseBlockMatrix buildKKTSystem(SparseBlockMatrix M, SparseBlockMatrix GT)
           
 void checkConsistency()
          Check that the internal structures of this matrix are consistent.
 SparseBlockMatrix clone()
          Creates a clone of this SparseBlockMatrix, along with clones of all the associated MatrixBlocks.
 int colSize()
          Number of columns in the matrix associated with this transformation.
 int colSize(int numBlkCols)
           
 SparseBlockMatrix createSubMatrix(int[] irows, int[] icols)
           
 SparseBlockMatrix createSubMatrix(int numBlockRows, int numBlockCols)
           
 boolean elementIsNonZero(int i, int j)
           
 MatrixBlock firstBlockInCol(int bj)
           
 MatrixBlock firstBlockInRow(int bi)
           
 double get(int i, int j)
          Gets a single element of this matrix.
 MatrixBlock getBlock(int bi, int bj)
           
 int getBlockCCSIndices(int[] rowIdxs, int rowOff, int[] offsets, Matrix.Partition part)
           
 int getBlockCCSIndices(int[] rowIdxs, int rowOff, int[] offsets, Matrix.Partition part, int numRows, int numCols)
           
 void getBlockCCSValues(double[] vals, int[] offsets, Matrix.Partition part)
           
 int getBlockCCSValues(double[] vals, int[] offsets, Matrix.Partition part, int numRows, int numCols)
           
 int getBlockCol(int j)
          Returns the block column index corresponding to an element column index.
 int getBlockColOffset(int bj)
           
 int getBlockColSize(int bj)
           
 int getBlockCRSIndices(int[] colIdxs, int colOff, int[] offsets, Matrix.Partition part)
           
 int getBlockCRSIndices(int[] colIdxs, int colOff, int[] offsets, Matrix.Partition part, int numRows, int numCols)
           
 int getBlockCRSValues(double[] vals, int[] offsets, Matrix.Partition part)
           
 int getBlockCRSValues(double[] vals, int[] offsets, Matrix.Partition part, int numRows, int numCols)
           
 java.lang.String getBlockPattern()
           
 int getBlockRow(int i)
          Returns the block row index corresponding to an element row index.
 int getBlockRowOffset(int bi)
           
 int getBlockRowSize(int bi)
           
 int getCCSIndices(int[] rowIdxs, int[] colOffs, Matrix.Partition part, int numRows, int numCols)
          Gets the compressed column storage (CCS) indices for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns.
 int getCCSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
          Gets the compressed column storage (CCS) values for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns.
 void getColumn(int j, double[] values)
          Copies a column of this matrix into an array of doubles.
 void getColumn(int j, double[] values, int off, int nrows)
           
static int[] getComp(int[] idxs, int size)
           
 int getCRSIndices(int[] colIdxs, int[] rowOffs, Matrix.Partition part, int numRows, int numCols)
          Gets the compressed row storage (CRS) indices for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns.
 int getCRSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
          Gets the compressed row storage (CRS) values for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns.
 MatrixBlock getElementBlock(int i, int j)
           
static int[] getRange(int idx, int numIdxs)
           
 void getRow(int i, double[] values)
          Copies a row of this matrix into an array of doubles.
 void getRow(int i, double[] values, int off)
          Copies a row of this matrix into an array of doubles, starting at a specified offset.
 SparseBlockMatrix getSubMatrix(int bi, int bj, int numBlkRows, int numBlkCols, SparseBlockMatrix dest)
          Ian TODO
 int getSubMatrixColSize(int[] icols)
           
 void getSubMatrixColumn(int j, double[] values, int off, int[] irows)
           
 void getSubMatrixRow(int i, double[] values, int off, int[] icols)
           
 int getSubMatrixRowSize(int[] irows)
           
 boolean isVerticallyLinked()
           
 void mulSubMatrixVec(double[] res, double[] vec, int[] irows, int[] icols)
           
 int numBlockCols()
           
 int numBlockRows()
           
 int numBlocks()
           
 int numNonZeroVals()
          Returns the number of non-zero values in this matrix object.
 int numNonZeroVals(Matrix.Partition part)
           
 int numNonZeroVals(Matrix.Partition part, int numRows, int numCols)
          Returns the number of non-zero values for a specified partition of a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns.
 void perturb(double tol)
           
 void printBlocks(java.io.PrintStream ps)
           
 void removeAllBlocks()
           
 MatrixBlock removeBlock(int bi, int bj)
           
 boolean removeBlock(MatrixBlock oldBlk)
           
 int rowSize()
          Number of rows in the matrix associated with this transformation.
 int rowSize(int numBlkRows)
           
 void scale(double s)
           
 void scanBlocks(ReaderTokenizer rtok)
          Sets the sizing and contents of the matrix to values read from a ReaderTokenizer.
 void set(double[] values, int[] indices, int nvals)
          Sets the elements of this matrix from an array of doubles and a list of indices.
 void set(int i, int j, double val)
           
 void set(Matrix M)
          Sets the size and values of this matrix to those of another matrix.
 void set(SparseBlockMatrix M)
          Sets this SparseBlockMatrix to a copy of another SparseBlockMatrix.
 void setColCapacity(int newCap)
           
 void setRandomValues()
          Sets the nonzero elements of this matrix to random values in the range -0.5 (inclusive) to 0.5 (exclusive).
 void setRandomValues(boolean symmetric)
          Sets the nonzero elements of this matrix to random values in the range -0.5 (inclusive) to 0.5 (exclusive).
 void setRandomValues(double lower, double upper, java.util.Random generator, boolean symmetric)
          Sets the nonzero elements of this matrix to random values in a specified range.
 void setRowCapacity(int newCap)
           
 void setSubMatrix(SparseBlockMatrix M, int[] irows, int[] icols)
           
 void setVerticallyLinked(boolean enable)
           
 void setZero()
           
 boolean structureEquals(SparseBlockMatrix M1)
          Returns true if the structure of this SparseBlockMatrix matches that of another.
 java.lang.String toString(java.lang.String fmtStr, int nrows, int ncols)
           
 boolean valueIsNonZero(int i, int j)
           
 void writeBlocks(java.io.PrintWriter pw)
           
 void writeBlocks(java.io.PrintWriter pw, NumberFormat fmt)
          Writes the contents of this matrix to a PrintWriter, using a sparse block structure.
 void zeroColumn(int j)
           
 void zeroRow(int i)
           
 
Methods inherited from class maspack.matrix.SparseMatrixBase
setCCSValues, setCRSValues, setRandom, setRandom
 
Methods inherited from class maspack.matrix.MatrixBase
containsNaN, determinant, epsilonEquals, equals, frobeniusNorm, get, get, getCCSIndices, getCCSValues, getColumn, getColumn, getCRSIndices, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, oneNorm, scan, setCRSValues, setDefaultFormat, setSize, toString, toString, toString, trace, write, write, write, write, write, writeToFile
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface maspack.matrix.Matrix
determinant, epsilonEquals, equals, frobeniusNorm, get, getCCSIndices, getCCSValues, getColumn, getColumn, getCRSIndices, getCRSValues, getRow, getSize, getSubMatrix, infinityNorm, isFixedSize, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, oneNorm, scan, setSize, toString, trace, write, write, write
 

Field Detail

warningLevel

public static int warningLevel
Constructor Detail

SparseBlockMatrix

public SparseBlockMatrix()

SparseBlockMatrix

public SparseBlockMatrix(int[] rowColSizes)

SparseBlockMatrix

public SparseBlockMatrix(int[] rowSizes,
                         int[] colSizes)
Method Detail

setRowCapacity

public void setRowCapacity(int newCap)

addRow

public void addRow(int size)

addRows

public void addRows(int[] sizes,
                    int num)

setColCapacity

public void setColCapacity(int newCap)

addCol

public void addCol(int size)

addCols

public void addCols(int[] sizes,
                    int num)

getBlockRowOffset

public int getBlockRowOffset(int bi)

getBlockRowSize

public int getBlockRowSize(int bi)

getBlockColOffset

public int getBlockColOffset(int bj)

getBlockColSize

public int getBlockColSize(int bj)

numBlocks

public int numBlocks()

addBlock

public int addBlock(int bi,
                    int bj,
                    MatrixBlock blk)

removeBlock

public boolean removeBlock(MatrixBlock oldBlk)

removeBlock

public MatrixBlock removeBlock(int bi,
                               int bj)

removeAllBlocks

public void removeAllBlocks()

getBlock

public MatrixBlock getBlock(int bi,
                            int bj)

firstBlockInRow

public MatrixBlock firstBlockInRow(int bi)

firstBlockInCol

public MatrixBlock firstBlockInCol(int bj)

rowSize

public int rowSize()
Description copied from class: MatrixBase
Number of rows in the matrix associated with this transformation. This will equal the size of the output vector in mul.

Specified by:
rowSize in interface LinearTransformNd
Specified by:
rowSize in interface Matrix
Specified by:
rowSize in class MatrixBase
Returns:
number of rows

rowSize

public int rowSize(int numBlkRows)

numBlockRows

public int numBlockRows()

numBlockCols

public int numBlockCols()

colSize

public int colSize(int numBlkCols)

colSize

public int colSize()
Description copied from class: MatrixBase
Number of columns in the matrix associated with this transformation. This will equal the size of the input vector in mul.

Specified by:
colSize in interface LinearTransformNd
Specified by:
colSize in interface Matrix
Specified by:
colSize in class MatrixBase
Returns:
number of columns

elementIsNonZero

public boolean elementIsNonZero(int i,
                                int j)

valueIsNonZero

public boolean valueIsNonZero(int i,
                              int j)

getElementBlock

public MatrixBlock getElementBlock(int i,
                                   int j)

get

public double get(int i,
                  int j)
Description copied from class: MatrixBase
Gets a single element of this matrix.

Specified by:
get in interface Matrix
Specified by:
get in class MatrixBase
Parameters:
i - element row index
j - element column index
Returns:
element value

set

public void set(int i,
                int j,
                double val)

set

public void set(double[] values,
                int[] indices,
                int nvals)
Description copied from interface: Matrix
Sets the elements of this matrix from an array of doubles and a list of indices. Each value should be associated with two (i,j) index values, which, for the k-th value, are given by indices[k*2] and indices[k*2+1], respectively. All non-specified elements are set to zero.

Specified by:
set in interface Matrix
Parameters:
values - explicit values for specific matrix locations
indices - i and j indices for each explicit value
nvals - number of explicit values

numNonZeroVals

public int numNonZeroVals()
Description copied from class: MatrixBase
Returns the number of non-zero values in this matrix object. For dense matrices, this will simply be the product of the number of rows times the number of columns.

Specified by:
numNonZeroVals in interface Matrix
Overrides:
numNonZeroVals in class MatrixBase
Returns:
number of non-zero values

numNonZeroVals

public int numNonZeroVals(Matrix.Partition part)

numNonZeroVals

public int numNonZeroVals(Matrix.Partition part,
                          int numRows,
                          int numCols)
Description copied from class: MatrixBase
Returns the number of non-zero values for a specified partition of a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns. If the matrix is dense and the partition is Full, then this will simply be the product of the number of rows times the number of columns.

Specified by:
numNonZeroVals in interface Matrix
Overrides:
numNonZeroVals in class MatrixBase
Parameters:
part - matrix parition to be examined
numRows - number of rows delimiting the sub-matrix
numCols - number of columns delimiting the sub-matrix
Returns:
number of non-zero values

setZero

public void setZero()

scale

public void scale(double s)
Specified by:
scale in interface SparseMatrix

getBlockRow

public int getBlockRow(int i)
Returns the block row index corresponding to an element row index.

Parameters:
i - element row index
Returns:
corresponding block row index, or -1 if the element index is out of range.

getBlockCol

public int getBlockCol(int j)
Returns the block column index corresponding to an element column index.

Parameters:
j - element column index
Returns:
corresponding block column index, or -1 if the element index is out of range.

getSubMatrix

public SparseBlockMatrix getSubMatrix(int bi,
                                      int bj,
                                      int numBlkRows,
                                      int numBlkCols,
                                      SparseBlockMatrix dest)
Ian TODO


getCRSIndices

public int getCRSIndices(int[] colIdxs,
                         int[] rowOffs,
                         Matrix.Partition part,
                         int numRows,
                         int numCols)
Gets the compressed row storage (CRS) indices for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns. The sub-matrix must be block-aligned. Indices are 0-based and the sub-matrix is traversed in row-major order.

Specified by:
getCRSIndices in interface Matrix
Overrides:
getCRSIndices in class MatrixBase
Parameters:
colIdxs - returns the column indices of each non-zero element. This array must have a length equal at least to the number of non-zero elements in the sub-matrix.
rowOffs - returns the offsets into colIdxs corresponding to the first non-zero element in each row. This array must have a length equal at least to the number of rows in the sub-matrix.
part - specifies what portion of the sub-matrix to store; must be either Full or UpperTriangular
numRows - number of rows delimiting the sub-matrix
numCols - number of columns delimiting the sub-matrix
Returns:
number of non-zero elements

getCRSValues

public int getCRSValues(double[] vals,
                        Matrix.Partition part,
                        int numRows,
                        int numCols)
Gets the compressed row storage (CRS) values for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns. The sub-matrix must be block-aligned, and it is traversed in row-major order.

Specified by:
getCRSValues in interface Matrix
Overrides:
getCRSValues in class MatrixBase
Parameters:
vals - returns the value of each non-zero element. This array must have a length equal at least to the number of non-zero elements in the sub-matrix.
part - specifies what portion of the sub-matrix to store; must be either Full or UpperTriangular
numRows - number of rows delimiting the sub-matrix
numCols - number of columns delimiting the sub-matrix
Returns:
number of non-zero elements

getBlockCRSIndices

public int getBlockCRSIndices(int[] colIdxs,
                              int colOff,
                              int[] offsets,
                              Matrix.Partition part)

getBlockCRSIndices

public int getBlockCRSIndices(int[] colIdxs,
                              int colOff,
                              int[] offsets,
                              Matrix.Partition part,
                              int numRows,
                              int numCols)

getBlockCRSValues

public int getBlockCRSValues(double[] vals,
                             int[] offsets,
                             Matrix.Partition part)

getBlockCRSValues

public int getBlockCRSValues(double[] vals,
                             int[] offsets,
                             Matrix.Partition part,
                             int numRows,
                             int numCols)

addNumNonZerosByRow

public void addNumNonZerosByRow(int[] offsets,
                                int idx,
                                Matrix.Partition part)

addNumNonZerosByRow

public void addNumNonZerosByRow(int[] offsets,
                                int idx,
                                Matrix.Partition part,
                                int numRows,
                                int numCols)

getCCSIndices

public int getCCSIndices(int[] rowIdxs,
                         int[] colOffs,
                         Matrix.Partition part,
                         int numRows,
                         int numCols)
Gets the compressed column storage (CCS) indices for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns. The sub-matrix must be block-aligned. Indices are 0-based and the sub-matrix is traversed in column-major order.

Specified by:
getCCSIndices in interface Matrix
Overrides:
getCCSIndices in class MatrixBase
Parameters:
rowIdxs - returns the row indices of each non-zero element. This array must have a length equal at least to the number of non-zero elements in the sub-matrix.
colOffs - returns the offsets into rowIdxs corresponding to the first non-zero element in each column. This array must have a length equal at least to the number of columns in the sub-matrix.
part - specifies what portion of the sub-matrix to store; must be either Full or LowerTriangular
numRows - number of rows delimiting the sub-matrix
numCols - number of columns delimiting the sub-matrix
Returns:
number of non-zero elements

getCCSValues

public int getCCSValues(double[] vals,
                        Matrix.Partition part,
                        int numRows,
                        int numCols)
Gets the compressed column storage (CCS) values for a principal sub-matrix of this matrix delimited by the first numRows rows and the first numCols columns. The sub-matrix must be block aligned and it is traversed in column-major order.

Specified by:
getCCSValues in interface Matrix
Overrides:
getCCSValues in class MatrixBase
Parameters:
vals - returns the value of each non-zero element. This array must have a length equal at least to the number of non-zero elements in the sub-matrix.
part - specifies what portion of the sub-matrix to store; must be either Full or LowerTriangular
numRows - number of rows delimiting the sub-matrix
numCols - number of columns delimiting the sub-matrix
Returns:
number of non-zero elements

getBlockCCSIndices

public int getBlockCCSIndices(int[] rowIdxs,
                              int rowOff,
                              int[] offsets,
                              Matrix.Partition part)

getBlockCCSIndices

public int getBlockCCSIndices(int[] rowIdxs,
                              int rowOff,
                              int[] offsets,
                              Matrix.Partition part,
                              int numRows,
                              int numCols)

getBlockCCSValues

public void getBlockCCSValues(double[] vals,
                              int[] offsets,
                              Matrix.Partition part)

getBlockCCSValues

public int getBlockCCSValues(double[] vals,
                             int[] offsets,
                             Matrix.Partition part,
                             int numRows,
                             int numCols)

addNumNonZerosByCol

public void addNumNonZerosByCol(int[] offsets,
                                int idx,
                                Matrix.Partition part,
                                int numRows,
                                int numCols)

toString

public java.lang.String toString(java.lang.String fmtStr,
                                 int nrows,
                                 int ncols)

getBlockPattern

public java.lang.String getBlockPattern()

printBlocks

public void printBlocks(java.io.PrintStream ps)

setRandomValues

public void setRandomValues()
Sets the nonzero elements of this matrix to random values in the range -0.5 (inclusive) to 0.5 (exclusive).


setRandomValues

public void setRandomValues(boolean symmetric)
Sets the nonzero elements of this matrix to random values in the range -0.5 (inclusive) to 0.5 (exclusive).

Parameters:
symmetric - if true, sets transposed values to the same value (ignored if the matrix is not square or does not have identical row and block sizes).

setRandomValues

public void setRandomValues(double lower,
                            double upper,
                            java.util.Random generator,
                            boolean symmetric)
Sets the nonzero elements of this matrix to random values in a specified range.

Parameters:
lower - lower random value (inclusive)
upper - upper random value (exclusive)
generator - random number generator
symmetric - if true, sets transposed values to the same value (ignored if the matrix is not square or does not have identical row and block sizes).

set

public void set(Matrix M)
Description copied from class: SparseMatrixBase
Sets the size and values of this matrix to those of another matrix.

Specified by:
set in interface Matrix
Overrides:
set in class SparseMatrixBase
Parameters:
M - matrix whose size and values are copied

set

public void set(SparseBlockMatrix M)
Sets this SparseBlockMatrix to a copy of another SparseBlockMatrix.

Parameters:
M - matrix to be copied

clone

public SparseBlockMatrix clone()
Creates a clone of this SparseBlockMatrix, along with clones of all the associated MatrixBlocks.

Specified by:
clone in interface Clonable
Overrides:
clone in class java.lang.Object

getRow

public void getRow(int i,
                   double[] values)
Description copied from class: MatrixBase
Copies a row of this matrix into an array of doubles.

Specified by:
getRow in interface Matrix
Overrides:
getRow in class MatrixBase
Parameters:
i - row index
values - array into which the row is copied

getRow

public void getRow(int i,
                   double[] values,
                   int off)
Description copied from class: MatrixBase
Copies a row of this matrix into an array of doubles, starting at a specified offset.

Specified by:
getRow in interface Matrix
Overrides:
getRow in class MatrixBase
Parameters:
i - row index
values - array into which the row is copied
off - offset in values where copying should begin

zeroRow

public void zeroRow(int i)

getColumn

public void getColumn(int j,
                      double[] values)
Description copied from class: MatrixBase
Copies a column of this matrix into an array of doubles.

Specified by:
getColumn in interface Matrix
Overrides:
getColumn in class MatrixBase
Parameters:
j - column index
values - array into which the column is copied

getColumn

public void getColumn(int j,
                      double[] values,
                      int off,
                      int nrows)

zeroColumn

public void zeroColumn(int j)

checkConsistency

public void checkConsistency()
Check that the internal structures of this matrix are consistent. Used for testing.

Specified by:
checkConsistency in interface Matrix

perturb

public void perturb(double tol)

setVerticallyLinked

public void setVerticallyLinked(boolean enable)

isVerticallyLinked

public boolean isVerticallyLinked()

buildKKTSystem

public static SparseBlockMatrix buildKKTSystem(SparseBlockMatrix M,
                                               SparseBlockMatrix GT)

createSubMatrix

public SparseBlockMatrix createSubMatrix(int numBlockRows,
                                         int numBlockCols)

createSubMatrix

public SparseBlockMatrix createSubMatrix(int[] irows,
                                         int[] icols)

setSubMatrix

public void setSubMatrix(SparseBlockMatrix M,
                         int[] irows,
                         int[] icols)

getSubMatrixRow

public void getSubMatrixRow(int i,
                            double[] values,
                            int off,
                            int[] icols)

getSubMatrixColumn

public void getSubMatrixColumn(int j,
                               double[] values,
                               int off,
                               int[] irows)

mulSubMatrixVec

public void mulSubMatrixVec(double[] res,
                            double[] vec,
                            int[] irows,
                            int[] icols)

getSubMatrixRowSize

public int getSubMatrixRowSize(int[] irows)

getSubMatrixColSize

public int getSubMatrixColSize(int[] icols)

getRange

public static int[] getRange(int idx,
                             int numIdxs)

getComp

public static int[] getComp(int[] idxs,
                            int size)

writeBlocks

public void writeBlocks(java.io.PrintWriter pw)
                 throws java.io.IOException
Throws:
java.io.IOException

writeBlocks

public void writeBlocks(java.io.PrintWriter pw,
                        NumberFormat fmt)
                 throws java.io.IOException
Writes the contents of this matrix to a PrintWriter, using a sparse block structure. The entire output is surrounded in square brackets [ ]. The opening bracket is then followed by two integer vectors, each contained within square brackets, giving the number of rows in each block row and the number of columns in each block column. This is then followed by the blocks, presented in row-major order, with each individual block written using the format
 [ bi bj nr nc
   xx xx xx
   xx xx xx
   xx xx xx
 ]
 
where bi and bj give the block row and column indices, nr and nc give the number of rows and columns in the block, and xx denotes the individual numeric values in dense format. The latter are formatted using a C printf style as described by the parameter NumberFormat.

Parameters:
pw - PrintWriter to write this matrix to
fmt - numeric format
Throws:
java.io.IOException

scanBlocks

public void scanBlocks(ReaderTokenizer rtok)
                throws java.io.IOException
Sets the sizing and contents of the matrix to values read from a ReaderTokenizer. The format is assumed to be the sparse block structure described for writeBlocks.

Parameters:
rtok - ReaderTokenizer from which values are read.
Throws:
java.io.IOException

structureEquals

public boolean structureEquals(SparseBlockMatrix M1)
Returns true if the structure of this SparseBlockMatrix matches that of another. This means that the matrices must match in terms of size, row and column blocks sizes, and block placement.

Parameters:
M1 - matrix to compare with
Returns:
false if the matrices have different structures.