maspack.matrix
Class SparseMatrixNd

java.lang.Object
  extended by maspack.matrix.MatrixBase
      extended by maspack.matrix.SparseMatrixBase
          extended by maspack.matrix.SparseMatrixNd
All Implemented Interfaces:
LinearTransformNd, Matrix, SparseMatrix

public class SparseMatrixNd
extends SparseMatrixBase
implements LinearTransformNd

Implements general sparse m x n matrices, along with most the commonly used operations associated with such matrices. A sparse matrix is implemented as a linked list of cells representing the explicit elements, with links running in both the row and column directions. In general, explicit elements are non-zero and non-explicit elements are zero, although zero-valued explicit elements may arise computationally.

Normally, these matrices can be resized, either explicitly through a call to setSize, or implicitly through operations that require the matrix size to be modified. However, specialized sub-classes (such as those implementing sub-matrices) may have a fixed size.


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
 
Constructor Summary
SparseMatrixNd(int numRows, int numCols)
          Creates a sparse matrix of a specific size, and initializes its elements to 0.
SparseMatrixNd(Matrix M)
          Creates a sparse matrix whose size and elements are the same as an existing Matrix.
SparseMatrixNd(SparseMatrixNd M)
          Creates a sparse matrix which is a copy of an existing one.
 
Method Summary
 void add(SparseMatrixNd M)
          Adds this matrix to M and places the result in this matrix.
 void add(SparseMatrixNd M1, SparseMatrixNd M2)
          Adds matrix M1 to M2 and places the result in this matrix.
 void addEntry(SparseMatrixCell cell, SparseMatrixCell rowPrev, SparseMatrixCell colPrev)
           
 void checkConsistency()
          Check that the internal structures of this matrix are consistent.
 int colSize()
          Number of columns in the matrix associated with this transformation.
 double get(int i, int j)
          Gets a single element of this matrix.
 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.
 SparseMatrixCell getCell(int i, int j)
           
 SparseMatrixCell getCol(int j)
           
 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.
 int getExplicitElements(double[] values)
          Returns the explicit element values in row-major order.
 SparseMatrixCell getRow(int i)
           
 boolean isFixedSize()
          Returns true if this matrix is of fixed size.
 void mul(SparseMatrixNd M)
          Multiplies this matrix by M and places the result in this matrix.
 void mul(SparseMatrixNd M1, SparseMatrixNd M2)
          Multiplies matrix M1 by M2 and places the result in this matrix.
 void mulTranspose(SparseMatrixNd M)
          Multiplies this matrix by the transpose of M and places the result in this matrix.
 void mulTransposeBoth(SparseMatrixNd M1, SparseMatrixNd M2)
          Multiplies the transpose of matrix M1 by the transpose of M2 and places the result in this matrix.
 void mulTransposeLeft(SparseMatrixNd M1, SparseMatrixNd M2)
          Multiplies the transpose of matrix M1 by M2 and places the result in this matrix.
 void mulTransposeRight(SparseMatrixNd M1, SparseMatrixNd M2)
          Multiplies matrix M1 by the transpose of M2 and places the result in this matrix.
 void negate()
          Negates this matrix in place.
 void negate(SparseMatrixNd M)
          Sets this matrix to the negative of M1.
 int numExplicitElements()
          Returns the number of explicit elements in this matrix.
 int numNonZeroVals(Matrix.Partition part, int nrows, int ncols)
          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.
 SparseMatrixCell prevColEntry(int i, int j)
           
 SparseMatrixCell prevRowEntry(int i, int j)
           
 void removeEntry(SparseMatrixCell cell, SparseMatrixCell rowPrev, SparseMatrixCell colPrev)
           
 int rowSize()
          Number of rows in the matrix associated with this transformation.
 void scale(double s)
          Scales the elements of this matrix by s.
 void scale(double s, SparseMatrixNd M)
          Scales the elements of matrix M1 by s and places the results in this matrix.
 void set(double[] values, int[] indices, int numValues)
          Sets the elements of this matrix from an array of doubles and a list of indices.
 void set(int i, int j, double value)
           
 void set(SparseMatrixNd M)
          Sets the size and values of this matrix to those of matrix M.
 void setDiagonal(double[] vals)
          Sets this matrix to a diagonal matrix whose diagonal elements are specified by an array.
 void setExplicitElements(double[] values)
          Sets the existing explicit element values, in row-major order.
 void setIdentity()
          Sets this matrix to the identity matrix.
 void setRandom()
          Sets some randomly selected elements of this matrix to random values.
 void setRandom(double lower, double upper, int numElements)
          Sets some randomly selected elements of this matrix to random values.
 void setRandom(double lower, double upper, int numElements, java.util.Random generator)
          Sets some randomly selected elements of this matrix to random values.
 void setSize(int numRows, int numCols)
          Sets the size of this matrix.
 void setSubMatrix(int baseRow, int baseCol, SparseMatrixNd Msrc)
          Sets a submatrix of this matrix.
 void setZero()
          Sets the elements of this matrix to zero.
 void setZero(int i, int j)
           
 void sub(SparseMatrixNd M)
          Subtracts this matrix from M1 and places the result in this matrix.
 void sub(SparseMatrixNd M1, SparseMatrixNd M2)
          Subtracts matrix M1 from M2 and places the result in this matrix.
 java.lang.String toString()
          Returns a String representation of this sparse matrix.
 java.lang.String toString(NumberFormat fmt)
          Returns a String representation of this sparse matrix.
 java.lang.String toString(java.lang.String fmtStr)
          Returns a String representation of this sparse matrix.
 void transpose()
          Replaces this matrix by its tranpose.
 void transpose(SparseMatrixNd M)
          Takes the transpose of matrix M and places the result in this matrix.
 
Methods inherited from class maspack.matrix.SparseMatrixBase
set, setCCSValues, setCRSValues, setRandom, setRandom
 
Methods inherited from class maspack.matrix.MatrixBase
containsNaN, determinant, epsilonEquals, equals, frobeniusNorm, get, get, getCCSIndices, getCCSValues, getColumn, getColumn, getColumn, getCRSIndices, getCRSValues, getDefaultFormat, getRow, getRow, getRow, getSize, getSubMatrix, hasNaN, idString, infinityNorm, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, oneNorm, scan, setCRSValues, setDefaultFormat, 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.LinearTransformNd
mul
 
Methods inherited from interface maspack.matrix.Matrix
determinant, epsilonEquals, equals, frobeniusNorm, get, getCCSIndices, getCCSValues, getColumn, getColumn, getColumn, getCRSIndices, getCRSValues, getRow, getRow, getRow, getSize, getSubMatrix, infinityNorm, isSymmetric, mul, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, numNonZeroVals, oneNorm, scan, trace, write, write, write
 

Constructor Detail

SparseMatrixNd

public SparseMatrixNd(int numRows,
                      int numCols)
Creates a sparse matrix of a specific size, and initializes its elements to 0. It is legal to create a matrix with zero rows and columns.

Parameters:
numRows - number of rows
numCols - number of columns
Throws:
ImproperSizeException - if numRows or numCols are negative

SparseMatrixNd

public SparseMatrixNd(Matrix M)
Creates a sparse matrix whose size and elements are the same as an existing Matrix.

Parameters:
M - matrix object to be copied.

SparseMatrixNd

public SparseMatrixNd(SparseMatrixNd M)
Creates a sparse matrix which is a copy of an existing one.

Parameters:
M - matrix object to be copied.
Method Detail

rowSize

public int rowSize()
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

colSize

public int colSize()
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

isFixedSize

public boolean isFixedSize()
Returns true if this matrix is of fixed size. The size of a SparseMatrixNd is normally not fixed, but the size of subclasses might be. A matrix not of fixed size can be resized dynamically, either explicitly using setSize, or implicitly when being used as a result for various matrix operations.

Specified by:
isFixedSize in interface Matrix
Overrides:
isFixedSize in class MatrixBase
Returns:
true if this matrix is of fixed size
See Also:
MatrixNd.setSize(int, int)

setSize

public void setSize(int numRows,
                    int numCols)
Sets the size of this matrix. This operation is only supported if isFixedSize returns false.

If a matrix is resized, then any previous element values which are still within the new matrix dimensions are preserved. Other (new) element values are undefined.

Specified by:
setSize in interface Matrix
Overrides:
setSize in class MatrixBase
Parameters:
numRows - new row size
numCols - new column size
Throws:
ImproperSizeException - if this matrix has an explicit internal buffer and that buffer is too small to support the requested size
java.lang.UnsupportedOperationException - if this matrix has fixed size
See Also:
isFixedSize()

get

public double get(int i,
                  int j)
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

getCell

public SparseMatrixCell getCell(int i,
                                int j)

getExplicitElements

public int getExplicitElements(double[] values)
Returns the explicit element values in row-major order. The values are placed into an array of doubles. It is assumed that i and j values of these elements are known.

Parameters:
values - collects the explicit element values
Returns:
number of explicit elements
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the array is not large enough to store all the values

setExplicitElements

public void setExplicitElements(double[] values)
Sets the existing explicit element values, in row-major order. New values are supplied by an array of doubles.

Parameters:
values - new values for the explicit elements
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the array is not large enough to provide all the values

numExplicitElements

public int numExplicitElements()
Returns the number of explicit elements in this matrix.

Returns:
number of explicit elements

set

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

setZero

public void setZero(int i,
                    int j)

set

public void set(double[] values,
                int[] indices,
                int numValues)
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
numValues - number of explicit values

addEntry

public void addEntry(SparseMatrixCell cell,
                     SparseMatrixCell rowPrev,
                     SparseMatrixCell colPrev)

removeEntry

public void removeEntry(SparseMatrixCell cell,
                        SparseMatrixCell rowPrev,
                        SparseMatrixCell colPrev)

prevColEntry

public SparseMatrixCell prevColEntry(int i,
                                     int j)

prevRowEntry

public SparseMatrixCell prevRowEntry(int i,
                                     int j)

set

public void set(SparseMatrixNd M)
Sets the size and values of this matrix to those of matrix M.

Parameters:
M - matrix tp be copied
Throws:
ImproperSizeException - if matrices have different sizes and this matrix cannot be resized accordingly

setIdentity

public void setIdentity()
Sets this matrix to the identity matrix. If this matrix matrix is not square, then element (i,j) is set to 1 if i and j are equal, and 0 otherwise.


setZero

public void setZero()
Sets the elements of this matrix to zero.


setDiagonal

public void setDiagonal(double[] vals)
Sets this matrix to a diagonal matrix whose diagonal elements are specified by an array.

Parameters:
vals - diagonal elements for this matrix
Throws:
ImproperSizeException - if the size of diag does not equal the minimum matrix dimension

setRandom

public void setRandom()
Sets some randomly selected elements of this matrix to random values. The number of selected elements is equal to the sum of the number of rows and columns, and the values are uniformly distributed in the range -0.5 (inclusive) to 0.5 (exclusive). Other elements are set to zero.


setRandom

public void setRandom(double lower,
                      double upper,
                      int numElements)
Sets some randomly selected elements of this matrix to random values. The number of selected elements is given by the argument numValues, and the values are uniformly distributed in in a specified range. Other elements are set to zero.

Parameters:
lower - lower random value (inclusive)
upper - upper random value (exclusive)
numElements - number of explicit elements to randomly select

setRandom

public void setRandom(double lower,
                      double upper,
                      int numElements,
                      java.util.Random generator)
Sets some randomly selected elements of this matrix to random values. The number of selected elements is given by the argument numValues, and the values are uniformly distributed in in a specified range. Other elements are set to zero. Random numbers are generated by a supplied random number generator.

Parameters:
lower - lower random value (inclusive)
upper - upper random value (exclusive)
numElements - number of explicit values to randomly select
generator - random number generator

mul

public void mul(SparseMatrixNd M)
Multiplies this matrix by M and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M - right-hand matrix
Throws:
ImproperSizeException - if this matrix and M do not conform, or if this matrix needs resizing but is of fixed size

mul

public void mul(SparseMatrixNd M1,
                SparseMatrixNd M2)
         throws ImproperSizeException
Multiplies matrix M1 by M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if matrices M1 and M2 do not comform, or if this matrix needs resizing but is of fixed size

mulTranspose

public void mulTranspose(SparseMatrixNd M)
Multiplies this matrix by the transpose of M and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M - right-hand matrix
Throws:
ImproperSizeException - if this matrix and the transpose of M do not conform, or if this matrix needs resizing but is of fixed size

mulTransposeRight

public void mulTransposeRight(SparseMatrixNd M1,
                              SparseMatrixNd M2)
                       throws ImproperSizeException
Multiplies matrix M1 by the transpose of M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if M1 and the transpose of M2 do not comform, or if this matrix needs resizing but is of fixed size

mulTransposeLeft

public void mulTransposeLeft(SparseMatrixNd M1,
                             SparseMatrixNd M2)
                      throws ImproperSizeException
Multiplies the transpose of matrix M1 by M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if the transpose of M1 and M2 do not comform, or if this matrix needs resizing but is of fixed size

mulTransposeBoth

public void mulTransposeBoth(SparseMatrixNd M1,
                             SparseMatrixNd M2)
                      throws ImproperSizeException
Multiplies the transpose of matrix M1 by the transpose of M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if the transpose of M1 and the transpose of M2 do not comform, or if this matrix needs resizing but is of fixed size

add

public void add(SparseMatrixNd M)
Adds this matrix to M and places the result in this matrix.

Parameters:
M - right-hand matrix
Throws:
ImproperSizeException - if this matrix and M have different sizes

add

public void add(SparseMatrixNd M1,
                SparseMatrixNd M2)
Adds matrix M1 to M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if matrices M1 and M2 have different sizes, or if this matrix needs resizing but is of fixed size

sub

public void sub(SparseMatrixNd M)
Subtracts this matrix from M1 and places the result in this matrix.

Parameters:
M - right-hand matrix
Throws:
ImproperSizeException - if this matrix and M have different sizes

sub

public void sub(SparseMatrixNd M1,
                SparseMatrixNd M2)
Subtracts matrix M1 from M2 and places the result in this matrix. This matrix is resized if necessary.

Parameters:
M1 - left-hand matrix
M2 - right-hand matrix
Throws:
ImproperSizeException - if matrices M1 and M2 have different sizes, or if this matrix needs resizing but is of fixed size

negate

public void negate()
Negates this matrix in place.


negate

public void negate(SparseMatrixNd M)
Sets this matrix to the negative of M1. This matrix is resized if necessary.

Parameters:
M - matrix to negate
Throws:
ImproperSizeException - if this matrix needs resizing but is of fixed size

scale

public void scale(double s,
                  SparseMatrixNd M)
           throws ImproperSizeException
Scales the elements of matrix M1 by s and places the results in this matrix. This matrix is resized if necessary.

Parameters:
s - scaling factor
M - matrix to be scaled
Throws:
ImproperSizeException - if this matrix needs resizing but is of fixed size

scale

public void scale(double s)
Scales the elements of this matrix by s.

Specified by:
scale in interface SparseMatrix
Parameters:
s - scaling factor

transpose

public void transpose()
Replaces this matrix by its tranpose. The matrix is resized if necessary.

Throws:
ImproperSizeException - if this matrix needs resizing but is of fixed size

transpose

public void transpose(SparseMatrixNd M)
               throws ImproperSizeException
Takes the transpose of matrix M and places the result in this matrix. The matrix is resized if necessary.

Parameters:
M - matrix to take the transpose of
Throws:
ImproperSizeException - if this matrix needs resizing but is of fixed size

toString

public java.lang.String toString()
Returns a String representation of this sparse matrix. Each explicit element is output in row-major order as a tuple ( i j value), one tuple per line. Elements which are not printed are zero.

Overrides:
toString in class MatrixBase
Returns:
String representation of this matrix
See Also:
MatrixBase.toString(String)

toString

public java.lang.String toString(java.lang.String fmtStr)
Returns a String representation of this sparse matrix. The output format is the same as that produced by toString, except that elements values are themselves formatted using a C printf style format string. For a description of the format string syntax, see NumberFormat.

Overrides:
toString in class MatrixBase
Parameters:
fmtStr - numeric format specification
Returns:
String representation of this matrix

toString

public java.lang.String toString(NumberFormat fmt)
Returns a String representation of this sparse matrix. The output format is the same as that produced by toString, except that elements values are themselves formatted using a C printf style as decribed by the parameter NumberFormat. When called numerous times, this routine can be more efficient than toString(String), because the NumberFormat does not need to be recreated each time from a specification string.

Specified by:
toString in interface Matrix
Overrides:
toString in class MatrixBase
Parameters:
fmt - numeric format
Returns:
String representation of this matrix

numNonZeroVals

public int numNonZeroVals(Matrix.Partition part,
                          int nrows,
                          int ncols)
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
nrows - number of rows delimiting the sub-matrix
ncols - number of columns delimiting the sub-matrix
Returns:
number of non-zero values

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. Indices are 1-based and supplied in row-major order. For a detailed decsription of the CRS format, see setCRSValues(). Some matrix types may place restrictions on the sub-matrix; for instance, a block-structured matrix may require that the sub-matrix be block aligned.

Specified by:
getCRSIndices in interface Matrix
Overrides:
getCRSIndices in class MatrixBase
Parameters:
colIdxs - returns the column indices of each non-zero element, in row-major order. This array must have a length equal at least to the number of non-zero elements.
rowOffs - returns the row start offsets into colIdxs, followed by nvals+1, where nvals is the number of non-zero elements in the sub-matrix. This array must have a length equal at least to nrows+1, where nrows is 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. Values are supplied in row-major order. For a detailed decsription of the CRS format, see setCRSValues(). Some matrix types may place restrictions on the sub-matrix; for instance, a block-structured matrix may require that the sub-matrix be block aligned.

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

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. Indices are 1-based and supplied in column-major order. For a detailed decsription of the CCS format, see setCCSValues(). Some matrix types may place restrictions on the sub-matrix; for instance, a block-structured matrix may require that the sub-matrix be block aligned.

Specified by:
getCCSIndices in interface Matrix
Overrides:
getCCSIndices in class MatrixBase
Parameters:
rowIdxs - returns the row indices of each non-zero element, in column-major order. This array must have a length equal at least to the number of non-zero elements.
colOffs - returns the column start offsets into rowIdxs, followed by nvals+1, where nvals is the number of non-zero elements in the sub-matrix. This array must have a length equal at least to ncol+1, where ncols is 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. Values are supplied in column-major order. For a detailed decsription of the CCS format, see setCCSValues(). Some matrix types may place restrictions on the sub-matrix; for instance, a block-structured matrix may require that the sub-matrix be block aligned.

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

setSubMatrix

public void setSubMatrix(int baseRow,
                         int baseCol,
                         SparseMatrixNd Msrc)
                  throws ImproperSizeException
Sets a submatrix of this matrix. The first row and column of the submatrix are given by baseRow and baseCol, and the new values are given by the matrix Msrc. The size of the submatrix is determined by the dimensions of Msrc.

Parameters:
baseRow - index of the first row of the submatrix
baseCol - index of the first column of the submatrix
Msrc - new values for the submatrix.
Throws:
ImproperSizeException - if baseRow or baseCol are negative, or if the submatrix exceeds the current matrix bounds

getRow

public SparseMatrixCell getRow(int i)

getCol

public SparseMatrixCell getCol(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