maspack.matrix
Class Matrix3x3DiagBlock

java.lang.Object
  extended by maspack.matrix.MatrixBase
      extended by maspack.matrix.DenseMatrixBase
          extended by maspack.matrix.Matrix3dBase
              extended by maspack.matrix.Matrix3d
                  extended by maspack.matrix.Matrix3x3Block
                      extended by maspack.matrix.Matrix3x3DiagBlock
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DenseMatrix, LinearTransformNd, Matrix, MatrixBlock, Clonable

public class Matrix3x3DiagBlock
extends Matrix3x3Block

Implements a 3 x 3 matrix block using a single Matrix3d object.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface maspack.matrix.Matrix
Matrix.Partition, Matrix.WriteFormat
 
Field Summary
 
Fields inherited from class maspack.matrix.Matrix3d
IDENTITY, ZERO
 
Fields inherited from class maspack.matrix.Matrix3dBase
m00, m01, m02, m10, m11, m12, m20, m21, m22
 
Fields inherited from interface maspack.matrix.Matrix
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC
 
Constructor Summary
Matrix3x3DiagBlock()
          Creates a new Matrix3x3DiagBlock.
Matrix3x3DiagBlock(double m00, double m11, double m22)
          Creates a new Matrix3x3DiagBlock with specufied diagnonal elements.
 
Method Summary
 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.
 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 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.
 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.
 int numNonZeroVals()
          Returns the number of non-zero values in this matrix object.
 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 set(double m00, double m11, double m22)
           
 void set(int i, int j, double val)
          Sets a single element of this matrix.
 boolean valueIsNonZero(int i, int j)
          Returns true if the value at the specified location is structurally non-zero.
 
Methods inherited from class maspack.matrix.Matrix3x3Block
add, clone, down, getBlockCol, getBlockNumber, getBlockRow, next, scaledAdd, setBlockCol, setBlockNumber, setBlockRow, setDown, setNext, sub
 
Methods inherited from class maspack.matrix.Matrix3d
add, add, addOuterProduct, addOuterProduct, addScaledOuterProduct, crossProduct, crossProduct, factorQR, fastInvert, inverseTransform, inverseTransform, invert, invert, main, mul, mul, mulDiagonalLeft, mulDiagonalLeft, mulDiagonalRight, mulDiagonalRight, mulInverse, mulInverseBoth, mulInverseLeft, mulInverseRight, mulTranspose, mulTransposeBoth, mulTransposeLeft, mulTransposeRight, negate, outerProduct, permuteColumns, permuteColumns, permuteRows, permuteRows, scale, scale, scaledAdd, scaledAdd, scaledAdd, set, setColumns, setDiagonal, setDiagonal, setDiagonal, setRandom, setRandom, setRandom, setRows, setSkewSymmetric, setSymmetric, setZero, sub, sub, transform, transform, transpose
 
Methods inherited from class maspack.matrix.Matrix3dBase
colSize, determinant, epsilonEquals, equals, factorQR, frobeniusNorm, get, get, getColumn, getColumn, getColumn, getRow, getRow, getRow, infinityNorm, isIdentity, mul, mul, mul, mulAdd, mulInverse, mulInverse, mulInverseTranspose, mulInverseTranspose, mulTranspose, mulTranspose, mulTransposeAdd, negate, oneNorm, orthogonalDeterminant, rowSize, set, set, set, setColumn, setColumn, setIdentity, setRow, setRow, trace, transpose
 
Methods inherited from class maspack.matrix.DenseMatrixBase
add, checkConsistency, set, set, set, setCCSValues, setColumn, setCRSValues, setRow, setSubMatrix
 
Methods inherited from class maspack.matrix.MatrixBase
containsNaN, epsilonEquals, equals, get, getCCSIndices, getCCSIndices, getCCSValues, getCCSValues, getColumn, getCRSIndices, getCRSIndices, getCRSValues, getCRSValues, getDefaultFormat, getRow, getSize, getSubMatrix, hasNaN, idString, isFixedSize, isSymmetric, mul, mul, mulAdd, mulAdd, mulAdd, mulTranspose, mulTranspose, mulTranspose, mulTransposeAdd, mulTransposeAdd, mulTransposeAdd, scan, setCRSValues, setDefaultFormat, setSize, toString, toString, toString, 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.MatrixBlock
scale, setZero
 
Methods inherited from interface maspack.matrix.DenseMatrix
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, oneNorm, rowSize, scan, set, set, setCCSValues, setCRSValues, setSize, toString, trace, write, write, write
 

Constructor Detail

Matrix3x3DiagBlock

public Matrix3x3DiagBlock()
Creates a new Matrix3x3DiagBlock.


Matrix3x3DiagBlock

public Matrix3x3DiagBlock(double m00,
                          double m11,
                          double m22)
Creates a new Matrix3x3DiagBlock with specufied diagnonal elements.

Method Detail

set

public void set(double m00,
                double m11,
                double m22)

set

public void set(int i,
                int j,
                double val)
Description copied from class: Matrix3dBase
Sets a single element of this matrix.

Specified by:
set in interface DenseMatrix
Overrides:
set in class Matrix3dBase
Parameters:
i - element row index
j - element column index
val - element value

valueIsNonZero

public 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.

Specified by:
valueIsNonZero in interface MatrixBlock
Overrides:
valueIsNonZero in class Matrix3x3Block
Parameters:
i - row index
j - column index
Returns:
true if the value at (i,j) is structurally non-zero

numNonZeroVals

public int numNonZeroVals()
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,
                          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. 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

mulAdd

public 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.

Specified by:
mulAdd in interface MatrixBlock
Overrides:
mulAdd in class Matrix3x3Block
Parameters:
y - accumulates resulting values
yIdx - starting index for accumulating values
x - supplies column vector values
xIdx - starting index for column vector values

mulTransposeAdd

public 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.

Specified by:
mulTransposeAdd in interface MatrixBlock
Overrides:
mulTransposeAdd in class Matrix3x3Block
Parameters:
y - accumulates resulting values
yIdx - starting index for accumulating values
x - supplies row vector values
xIdx - starting index for row vector values

getBlockCRSIndices

public 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.

Specified by:
getBlockCRSIndices in interface MatrixBlock
Overrides:
getBlockCRSIndices in class Matrix3x3Block
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

addNumNonZerosByRow

public 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.

Specified by:
addNumNonZerosByRow in interface MatrixBlock
Overrides:
addNumNonZerosByRow in class Matrix3x3Block
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

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

Specified by:
getBlockCCSIndices in interface MatrixBlock
Overrides:
getBlockCCSIndices in class Matrix3x3Block
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

addNumNonZerosByCol

public 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.

Specified by:
addNumNonZerosByCol in interface MatrixBlock
Overrides:
addNumNonZerosByCol in class Matrix3x3Block
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.

getBlockCRSValues

public 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.

Specified by:
getBlockCRSValues in interface MatrixBlock
Overrides:
getBlockCRSValues in class Matrix3x3Block
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

getBlockCCSValues

public 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.

Specified by:
getBlockCCSValues in interface MatrixBlock
Overrides:
getBlockCCSValues in class Matrix3x3Block
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