public interface Matrix extends LinearTransformNd
setSize
for resizing, which can be used
unless the matrix size is fixed (which can be determined using isFixedSize
).
This interface does not support operations such as multiplication or
addition. The reason for this is that specific implementations may have a
specialized structure which could be compromised by arbitrary operations. For
instance, if an implementing class represents orthogonal matrices, then it
does not make sense for that class to allow an add
operation.
Similarly, for an implementation representing symmetric matrices, any
muliplication methods should not be open to general matrices.
Of course, it is possible to corrupt any special implementation structure
using the set
methods provided in this base class, but it was
felt that not including such routines would be overly restrictive. It is
therefore up to the user to safeguard implementation integrity against misuse
of the set
methods.
Note that indices for matrix elements, rows, and columns are zerobased. The
range of valid indices for a matrix of size m X n is
[0, ... , m1]
and [0, ... , n1]
.
Modifier and Type  Interface and Description 

static class 
Matrix.Partition
Describes different partitions of a matrix object.

static class 
Matrix.WriteFormat
Describes the general format for writing matrix values.

Modifier and Type  Field and Description 

static int 
INDEFINITE
Identifies a matrix as regular indefinite.

static int 
POSITIVE_DEFINITE
Identifies a matrix as positive definite.

static int 
SPD
Identifies a matrix as symmetric positive definite.

static int 
SYMMETRIC
Identifies a matrix as symmetric.

Modifier and Type  Method and Description 

void 
checkConsistency()
Check that the internal structures of this matrix are consistent.

int 
colSize()
Returns the number of columns in this matrix.

double 
determinant()
Returns the determinant of this matrix, which must be square

boolean 
epsilonEquals(Matrix M1,
double epsilon)
Returns true if the elements of this matrix equal those of matrix
M1 within a prescribed tolerance epsilon . 
boolean 
equals(Matrix M1)
Returns true if the elements of this matrix exactly equal those of matrix
M1 . 
double 
frobeniusNorm()
Returns the Frobenius norm of this matrix.

double 
frobeniusNormSquared()
Returns the squared Frobenius norm of this matrix.

void 
get(double[] values)
Copies the elements of this matrix into an array of doubles.

double 
get(int i,
int j)
Gets a single element of this matrix.

int 
getCCSIndices(int[] rowIdxs,
int[] colOffs)
Gets the compressed column storage (CCS) indices for this matrix.

int 
getCCSIndices(int[] rowIdxs,
int[] colOffs,
Matrix.Partition part)
Gets the compressed column storage (CCS) indices for 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
submatrix of this matrix delimited by the first
numRows
rows and the first numCols columns. 
int 
getCCSValues(double[] vals)
Gets the compressed column storage (CCS) values for this matrix, in
columnmajor order.

int 
getCCSValues(double[] vals,
Matrix.Partition part)
Gets the compressed column storage (CCS) values for this matrix, in
columnmajor order.

int 
getCCSValues(double[] vals,
Matrix.Partition part,
int numRows,
int numCols)
Gets the compressed column storage (CCS) values for a principal
submatrix 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)
Copies a column of this matrix into an array of doubles, starting at a
specified offset.

void 
getColumn(int j,
Vector v)
Copies a column of this matrix into a
Vector . 
int 
getCRSIndices(int[] colIdxs,
int[] rowOffs)
Gets the compressed row storage (CRS) indices for this matrix.

int 
getCRSIndices(int[] colIdxs,
int[] rowOffs,
Matrix.Partition part)
Gets the compressed row storage (CRS) indices for this matrix.

int 
getCRSIndices(int[] colIdxs,
int[] rowOffs,
Matrix.Partition part,
int numRows,
int numCols)
Gets the compressed row storage (CRS) indices for a principal submatrix
of this matrix delimited by the first
numRows rows and the
first numCols columns. 
int 
getCRSValues(double[] vals)
Gets the compressed row storage (CRS) values for this matrix, in
rowmajor order.

int 
getCRSValues(double[] vals,
Matrix.Partition part)
Gets the compressed row storage (CRS) values for this matrix, in
rowmajor order.

int 
getCRSValues(double[] vals,
Matrix.Partition part,
int numRows,
int numCols)
Gets the compressed row storage (CRS) values for a principal submatrix
of this matrix delimited by the first
numRows rows and the
first numCols columns. 
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.

void 
getRow(int i,
Vector v)
Copies a row of this matrix into a
Vector . 
java.lang.String 
getSize()
Returns a string indicating the size of this matrix.

void 
getSubMatrix(int baseRow,
int baseCol,
DenseMatrix Mdest)
Gets a submatrix of this matrix object.

double 
infinityNorm()
Returns the infinity norm of this matrix.

boolean 
isFixedSize()
Returns true if this matrix is of fixed size.

boolean 
isSymmetric(double tol)
Returns true if this matrix is symmetric within a given absolute
tolerance.

double 
maxNorm()
Returns the maxnorm of this matrix.

void 
mul(VectorNd vr,
VectorNd v1)
Multiplies this matrix by the column vector v1 and places the result in
the vector vr.

void 
mul(VectorNd vr,
VectorNd v1,
int nr,
int nc)
Multiplies a submatrix of this matrix by the column vector
v1
and places the result in the vector vr . 
void 
mul(VectorNd vr,
VectorNd v1,
int r0,
int nr,
int c0,
int nc)
Multiplies a submatrix of this matrix by the column vector
v1
and places the result in the vector vr . 
void 
mulAdd(VectorNd vr,
VectorNd v1)
Multiplies this matrix by the column vector v1 and adds the result to
the vector vr.

void 
mulAdd(VectorNd vr,
VectorNd v1,
int nr,
int nc)
Multiplies a submatrix of this matrix by the column vector
v1
and adds the result to the vector vr . 
void 
mulAdd(VectorNd vr,
VectorNd v1,
int r0,
int nr,
int c0,
int nc)
Multiplies a submatrix of this matrix by the column vector
v1
and adds the result to the vector vr . 
void 
mulTranspose(VectorNd vr,
VectorNd v1)
Multiplies the transpose of this matrix by the vector v1 and places the
result in vr.

void 
mulTranspose(VectorNd vr,
VectorNd v1,
int nr,
int nc)
Multiplies a submatrix of the transpose of this matrix by the column
vector
v1 and places the result in the vector
vr . 
void 
mulTranspose(VectorNd vr,
VectorNd v1,
int r0,
int nr,
int c0,
int nc)
Multiplies a submatrix of the transpose of this matrix by the column
vector
v1 and places the result in the vector
vr . 
void 
mulTransposeAdd(VectorNd vr,
VectorNd v1)
Multiplies the transpose of this matrix by the vector v1 and adds the
result to vr.

void 
mulTransposeAdd(VectorNd vr,
VectorNd v1,
int nr,
int nc)
Multiplies a submatrix of the transpose of this matrix by the column
vector
v1 and adds the result to the vector
vr . 
void 
mulTransposeAdd(VectorNd vr,
VectorNd v1,
int r0,
int nr,
int c0,
int nc)
Multiplies a submatrix of the transpose of this matrix by the column
vector
v1 and adds the result to the vector vr . 
int 
numNonZeroVals()
Returns the number of nonzero values in this matrix object.

int 
numNonZeroVals(Matrix.Partition part,
int numRows,
int numCols)
Returns the number of nonzero values for a specified partition of a
principal submatrix of this matrix delimited by the first
numRows rows and the first numCols columns. 
double 
oneNorm()
Returns the 1 norm of this matrix.

int 
rowSize()
Returns the number of rows in this matrix.

void 
scan(ReaderTokenizer rtok)
Sets the contents of this matrix to values read from a ReaderTokenizer.

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(Matrix M)
Sets the size and values of this matrix to those of another matrix.

void 
setCCSValues(double[] vals,
int[] rowIdxs,
int[] colOffs,
int nvals,
int ncols,
Matrix.Partition part)
Sets the contents of this matrix given a set of values in compressed
column storage (CCS).

void 
setCRSValues(double[] vals,
int[] colIdxs,
int[] rowOffs,
int nvals,
int nrows,
Matrix.Partition part)
Sets the contents of this matrix given a set of values in compressed row
storage (CRS).

void 
setSize(int numRows,
int numCols)
Sets the size of this matrix.

java.lang.String 
toString(NumberFormat fmt)
Returns a String representation of this matrix, in which each element is
formatted using a C
printf style format as decribed by the
parameter NumberFormat . 
java.lang.String 
toString(java.lang.String fmtStr)
Returns a String representation of this matrix, in which each element is
formatted using a C
printf style format string. 
double 
trace()
Returns the trace of this matrix, which must be square

void 
write(java.io.PrintWriter pw,
NumberFormat fmt)
Writes the contents of this matrix to a PrintWriter.

void 
write(java.io.PrintWriter pw,
NumberFormat fmt,
Matrix.WriteFormat wfmt)
Writes the contents of this matrix to a PrintWriter.

void 
write(java.io.PrintWriter pw,
NumberFormat fmt,
Matrix.WriteFormat wfmt,
int numRows,
int numCols)
Writes the contents of a principal submatrix of this matrix delimited by
the first
numRows rows and the first numCols
columns. 
static final int INDEFINITE
static final int SYMMETRIC
static final int POSITIVE_DEFINITE
static final int SPD
int rowSize()
rowSize
in interface LinearTransformNd
int colSize()
colSize
in interface LinearTransformNd
double get(int i, int j)
i
 element row indexj
 element column indexvoid get(double[] values)
(i,j)
is
stored at location i*colSize()+j
.values
 array into which values are copiedvoid getColumn(int j, double[] values)
j
 column indexvalues
 array into which the column is copiedvoid getColumn(int j, double[] values, int off)
j
 column indexvalues
 array into which the column is copiedoff
 offset in values where copying should beginvoid getRow(int i, double[] values)
i
 row indexvalues
 array into which the row is copiedvoid getRow(int i, double[] values, int off)
i
 row indexvalues
 array into which the row is copiedoff
 offset in values where copying should beginvoid getColumn(int j, Vector v)
Vector
.j
 column indexv
 vector into which the column is copiedImproperSizeException
 vector's size not equal to the number of matrix rows and the vector cannot
be resizedvoid getRow(int i, Vector v)
Vector
.i
 row indexv
 vector into which the row is copiedImproperSizeException
 vector's size not equal to the number of matrix columns and the vector
cannot be resizedvoid set(Matrix M)
M
 matrix whose size and values are copiedImproperSizeException
 matrices have different sizes and this matrix cannot be resized
accordinglyboolean isFixedSize()
setSize
, or implicitly when used as a result for various
matrix operations.setSize(int, int)
void setSize(int numRows, int numCols)
isFixedSize
returns false.numRows
 new row sizenumCols
 new column sizejava.lang.UnsupportedOperationException
 if this operation is not supportedisFixedSize()
double determinant()
ImproperSizeException
 if the matrix is not squaredouble trace()
ImproperSizeException
 if the matrix is not squareboolean epsilonEquals(Matrix M1, double epsilon)
M1
within a prescribed tolerance epsilon
.M1
 matrix to compare withepsilon
 comparison toleranceboolean equals(Matrix M1)
M1
.M1
 matrix to compare withdouble oneNorm()
double infinityNorm()
double frobeniusNorm()
double frobeniusNormSquared()
double maxNorm()
void write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style as
described by the parameter NumberFormat
.pw
 PrintWriter to write this matrix tofmt
 numeric formatjava.io.IOException
void write(java.io.PrintWriter pw, NumberFormat fmt, Matrix.WriteFormat wfmt) throws java.io.IOException
wfmt
, while the values themselves
are formatted using a C printf
style as decribed by the
parameter NumberFormat
.pw
 PrintWriter to write this matrix tofmt
 numeric formatwfmt
 specifies the general output formatjava.io.IOException
void write(java.io.PrintWriter pw, NumberFormat fmt, Matrix.WriteFormat wfmt, int numRows, int numCols) throws java.io.IOException
numRows
rows and the first numCols
columns. The overall write format is specified by wfmt
,
while the values themselves are formatted using a C printf
style as decribed by the parameter NumberFormat
.pw
 PrintWriter to write this matrix tofmt
 numeric formatwfmt
 specifies the general output formatnumRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixjava.io.IOException
void scan(ReaderTokenizer rtok) throws java.io.IOException
For the dense format, the input should consist of a sequence of numbers,
arranged in rowmajor order, separated by white space, and optionally
surrounded by square brackets [ ]
.
If the input is not surrounded by square brackets, then the number of
values should equal the current number of elements in this matrix, as
defined by the product of rowSize
and
colSize
.
If the input is surrounded by square brackets, then the matrix dimensions are determined by the input itself: rows should be separated by either semicolons or a newline, the number of values in each row should be the same, and rows are read until a closing square bracket is detected. The resulting input should either match this matrix's dimensions, or this matrix should be resizable to accomodate those dimensions. For example,
[ 1.2 4 5 6 3.1 0 ]defines a 2 x 3 matrix.
For the sparse format, the input should be surrounded by square brackets,
and each element value is specified as a triple ( i j value )
,
enclosed in parentheses. No particular ordering is required for the i or j
indices, and unspecified elements are set to zero. The entire set of
elements should be surrounded by square brackets. For example,
[ ( 0 0 1.2 ) ( 0 1 4 ) ( 0 2 5 ) ( 1 0 6 ) ( 1 1 3.1) ]defines that same 2 x 3 matrix given in the previous example.
rtok
 Tokenizer from which matrix values are read. Number parsing should be
enabledImproperSizeException
 if this matrix has a fixed size which is incompatible with the input, or
if the sizes of the specified rows are inconsistentjava.io.IOException
void mul(VectorNd vr, VectorNd v1)
vr = M v1The vector vr is resized if it is not sufficiently large.
mul
in interface LinearTransformNd
vr
 result vectorv1
 vector to multiply byImproperSizeException
 if the size of v1 does not equal the number of columns of this matrix.void mul(VectorNd vr, VectorNd v1, int nr, int nc)
v1
and places the result in the vector vr
. The
submatrix is defined by the first nr
rows and
nc
columns of this matrix. If M represents this matrix, this
is equivalent to computing
vr = M[0:nr1][0:nc1] v1The vector vr is resized if it is not sufficiently large.
vr
 result vectorv1
 vector to multiply bynr
 number of initial rows of this matrix to usenc
 number of initial columns of this matrix to useImproperSizeException
 if the size of v1 is less than nc
, or if nr
or nc
exceed the dimensions of this matrix.void mul(VectorNd vr, VectorNd v1, int r0, int nr, int c0, int nc)
v1
and places the result in the vector vr
. The submatrix
is defined by the nr
rows and nc
columns of
this matrix starting at r0
and c0
,
respectively. If M represents this matrix, this is equivalent to
computing
vr = M[r0:r0+nr1][c0:c0+nc1] v1The vector vr is resized if it is not sufficiently large.
vr
 result vectorv1
 vector to multiply byr0
 initial row of the submatrixnr
 number of rows in the submatrixc0
 initial column of the submatrixnc
 number of columns in the submatrixImproperSizeException
 if the size of v1 is less than nc
, or
if nr
or nc
exceed the dimensions of this matrix.void mulAdd(VectorNd vr, VectorNd v1)
vr += M v1
vr
 result vectorv1
 vector to multiply byImproperSizeException
 if the size of v1 does not equal the number of columns of this matrix,
or if the size of vr does not equal the number of rows.void mulAdd(VectorNd vr, VectorNd v1, int nr, int nc)
v1
and adds the result to the vector vr
. The submatrix
is defined by the first nr
rows and nc
columns
of this matrix. If M represents this matrix, this is equivalent to
computing
vr += M[0:nr1][0:nc1] v1
vr
 result vectorv1
 vector to multiply bynr
 number of initial rows of this matrix to usenc
 number of initial columns of this matrix to useImproperSizeException
 if the size of v1 is less than nc
,
if the size of vr is less than nr
, or
if nr
or nc
exceed the dimensions of this matrix.void mulAdd(VectorNd vr, VectorNd v1, int r0, int nr, int c0, int nc)
v1
and adds the result to the vector vr
. The submatrix
is defined by the nr
rows and nc
columns of
this matrix starting at r0
and c0
,
respectively. If M represents this matrix, this is equivalent to
computing
vr += M[r0:r0+nr1][c0:c0+nc1] v1
vr
 result vectorv1
 vector to multiply byr0
 initial row of the submatrixnr
 number of rows in the submatrixc0
 initial column of the submatrixnc
 number of columns in the submatrixImproperSizeException
 if the size of v1 is less than nc
,
if the size of vr is less than nr
, or
if nr
or nc
exceed the dimensions of this matrix.void mulTranspose(VectorNd vr, VectorNd v1)
vr = v1 MThe vector vr is resized if it is not sufficiently large.
vr
 result vectorv1
 vector to multiply byImproperSizeException
 if the size of v1 does not equal the number of rows of this matrixvoid mulTranspose(VectorNd vr, VectorNd v1, int nr, int nc)
v1
and places the result in the vector
vr
. The submatrix is defined by the first nr
rows and nc
columns of the transpose of this matrix. If M
represents this matrix, this is equivalent to computing
vr = v1 M[0:nc1][0:nr1]The vector vr is resized if it is not sufficiently large.
vr
 result vectorv1
 vector to multiply bynr
 number of initial rows of the transpose of this matrix to usenc
 number of initial columns of the transpose of this matrix to useImproperSizeException
 if the size of v1 is less than nc
,
or if nr
or nc
exceed the dimensions of this matrix.void mulTranspose(VectorNd vr, VectorNd v1, int r0, int nr, int c0, int nc)
v1
and places the result in the vector
vr
. The submatrix is defined by the nr
rows
and nc
columns of the transpose of this matrix starting at
r0
and c0
, respectively. If M represents this
matrix, this is equivalent to
vr = v1 M[c0:c0+nc1][r0:r0+nr1]The vector vr is resized if it is not sufficiently large.
vr
 result vectorv1
 vector to multiply byr0
 initial row of the submatrixnr
 number of rows in the submatrixc0
 initial column of the submatrixnc
 number of columns in the submatrixImproperSizeException
 if the size of v1 is less than nc
,
or if nr
or nc
exceed the dimensions of this matrix.void mulTransposeAdd(VectorNd vr, VectorNd v1)
vr += v1 M
vr
 result vectorv1
 vector to multiply byImproperSizeException
 if the size of v1 does not equal the number of rows of this matrixvoid mulTransposeAdd(VectorNd vr, VectorNd v1, int nr, int nc)
v1
and adds the result to the vector
vr
. The submatrix is defined by the first nr
rows and nc
columns of the transpose of this matrix. If M
represents this matrix, this is equivalent to computing
vr += v1 M[0:nc1][0:nr1]
vr
 result vectorv1
 vector to multiply bynr
 number of initial rows of the transpose of this matrix to usenc
 number of initial columns of the transpose of this matrix to useImproperSizeException
 if the size of v1 is less than nc
,
or if nr
or nc
exceed the dimensions of this matrix.void mulTransposeAdd(VectorNd vr, VectorNd v1, int r0, int nr, int c0, int nc)
v1
and adds the result to the vector vr
.
The submatrix is defined by the nr
rows and nc
columns of the transpose of this matrix starting at r0
and
c0
, respectively. If M represents this matrix, this is
equivalent to
vr += v1 M[c0:c0+nc1][r0:r0+nr1]
vr
 result vectorv1
 vector to multiply byr0
 initial row of the submatrixnr
 number of rows in the submatrixc0
 initial column of the submatrixnc
 number of columns in the submatrixImproperSizeException
 if the size of v1 is less than nc
,
or if nr
or nc
exceed the dimensions of this matrix.void set(double[] values, int[] indices, int numValues)
indices[k*2]
and
indices[k*2+1]
, respectively. All nonspecified elements
are set to zero.values
 explicit values for specific matrix locationsindices
 i and j indices for each explicit valuenumValues
 number of explicit valuesint getCRSIndices(int[] colIdxs, int[] rowOffs)
getCRSIndices(int[],int[],Partition)
with the Partition set to
Full
. For a detailed detailed decsription of the CRS format,
see setCRSValues()
.colIdxs
 returns the column indices of each nonzero element,
in rowmajor order. This array must have a length equal
at least to the number of nonzero elements.rowOffs
 returns the row start offsets into
colIdxs
, followed by nvals+1, where nvals is the number of
nonzero elements. This array must have a length equal at least to
nrows+1, where nrows is the number of rows in this matrix.int getCRSIndices(int[] colIdxs, int[] rowOffs, Matrix.Partition part)
setCRSValues()
.colIdxs
 returns the column indices of each nonzero element,
in rowmajor order. This array must have a length equal
at least to the number of nonzero elements.rowOffs
 returns the row start offsets into
colIdxs
, followed by nvals+1, where nvals is the number of
nonzero elements. This array must have a length equal at least to
nrows+1, where nrows is the number of rows in this matrix.part
 specifies what portion of the matrix to store; must be either
Full
or
UpperTriangular
int getCRSIndices(int[] colIdxs, int[] rowOffs, Matrix.Partition part, int numRows, int numCols)
numRows
rows and the
first numCols
columns. Indices are 1based and supplied in
rowmajor order. For a detailed decsription of the CRS format, see setCRSValues()
. Some matrix types may place restrictions
on the submatrix; for instance, a blockstructured matrix may require
that the submatrix be block aligned.colIdxs
 returns the column indices of each nonzero element,
in rowmajor order. This array must have a length equal
at least to the number of nonzero elements.rowOffs
 returns the row start offsets into colIdxs
,
followed by nvals+1, where nvals is the number of nonzero elements in
the submatrix. This array must have a length equal at least to nrows+1,
where nrows is the number of rows in the submatrix.part
 specifies what portion of the submatrix to store; must be either
Full
or
UpperTriangular
numRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixint getCRSValues(double[] vals)
getCRSValues(double[],Partition)
with
the Partition set to Full
. For a detailed decsription of the
CRS format, see setCRSValues()
.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements.int getCRSValues(double[] vals, Matrix.Partition part)
setCRSValues()
.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements.part
 specifies what portion of the matrix to store; must be either
Full
or
UpperTriangular
int getCRSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
numRows
rows and the
first numCols
columns. Values are supplied in rowmajor
order. For a detailed decsription of the CRS format, see setCRSValues()
. Some matrix types may place restrictions
on the submatrix; for instance, a blockstructured matrix may require
that the submatrix be block aligned.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements in the submatrix.part
 specifies what portion of the submatrix to store; must be either
Full
or
UpperTriangular
numRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixvoid setCRSValues(double[] vals, int[] colIdxs, int[] rowOffs, int nvals, int nrows, Matrix.Partition part)
part
specifies what portion of
the matrix is supplied. If it is Full
, then the
entire matrix is supplied. If it is Matrix.Partition.UpperTriangular
,
then only the upper triangular part is assumed to be supplied, and the
lower triangular part is set from its transpose (matrix bounds
permitting). For Partition.UpperTriangular, supplied entries which are
not upper triangular will either be ignored or generate an exception.
All specified data must fit within the current matrix bounds; the matrix is not resized.
CRS data takes the form of three arrays:
vals
and
colIdxs
corresponding to the first nonzero element in each
row. All values are 1based, so that first offset value is
1, the second offset value is n+1, where n is the number of nonzero
elements in the first row, etc. The final value is set to nvals+1, where
nvals is the number of nonzero elements in the matrix.vals
 nonzero element values. This array must have a length equal at
least to nvals
.colIdxs
 column indices for each nonzero element.
This array must have a length equal at
least to nvals
.rowOffs
 row start offsets into vals
and
colIdxs
. This array must have a length equal at least to
nrows+1, where nrows is the number of rows in this matrix.nvals
 number of nonzero valuesnrows
 number of specified rows. Indicates the maximum value of
rowOffs
that will be used; will not resize matrix.part
 must be either Full
or
UpperTriangular
.int getCCSIndices(int[] rowIdxs, int[] colOffs)
getCCSIndices(int[],int[],Partition)
with the Partition set to
Full
. For a detailed decsription of the CCS format, see
setCCSValues()
.rowIdxs
 returns the row indices of each nonzero element,
in columnmajor order. This array must have a length equal
at least to the number of nonzero elements.colOffs
 returns the column start offsets into
rowIdxs
, followed by nvals+1, where nvals is the number of
nonzero elements. This array must have a length equal at least to
ncols+1, where ncols is the number of columns in this matrix.int getCCSIndices(int[] rowIdxs, int[] colOffs, Matrix.Partition part)
setCCSValues()
.rowIdxs
 returns the row indices of each nonzero element,
in columnmajor order. This array must have a length equal
at least to the number of nonzero elements.colOffs
 returns the column start offsets into
rowIdxs
, followed by nvals+1, where nvals is the number of
nonzero elements. This array must have a length equal at least to
ncols+1, where ncols is the number of columns in this matrix.part
 specifies what portion of the matrix to store; must be either
Full
or
LowerTriangular
int getCCSIndices(int[] rowIdxs, int[] colOffs, Matrix.Partition part, int numRows, int numCols)
numRows
rows and the first numCols
columns. Indices are 1based and
supplied in columnmajor order. For a detailed decsription of the CCS
format, see setCCSValues()
. Some matrix types may
place restrictions on the submatrix; for instance, a blockstructured
matrix may require that the submatrix be block aligned.rowIdxs
 returns the row indices of each nonzero element,
in columnmajor order. This array must have a length equal
at least to the number of nonzero elements.colOffs
 returns the column start offsets into rowIdxs
,
followed by nvals+1, where nvals is the number of nonzero elements in
the submatrix. This array must have a length equal at least to ncol+1,
where ncols is the number of columns in the submatrix.part
 specifies what portion of the submatrix to store; must be either
Full
or
LowerTriangular
numRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixint getCCSValues(double[] vals)
getCCSValues(double[],Partition)
with
the Partition set to Full
. For a detailed decsription of the
CCS format, see setCCSValues()
.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements.int getCCSValues(double[] vals, Matrix.Partition part)
setCCSValues()
.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements.part
 specifies what portion of the matrix to store; must be either
Full
or
LowerTriangular
int getCCSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
numRows
rows and the first numCols
columns. Values are supplied in
columnmajor order. For a detailed decsription of the CCS format, see
setCCSValues()
. Some matrix types may place
restrictions on the submatrix; for instance, a blockstructured matrix
may require that the submatrix be block aligned.vals
 returns the value of each nonzero element. This array must have a length
equal at least to the number of nonzero elements in the submatrix.part
 specifies what portion of the submatrix to store; must be either
Full
or
LowerTriangular
numRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixvoid setCCSValues(double[] vals, int[] rowIdxs, int[] colOffs, int nvals, int ncols, Matrix.Partition part)
part
specifies what
portion of the matrix is supplied. If it is Full
,
then the entire matrix is supplied. If it is Matrix.Partition.LowerTriangular
, then only the lower triangular part is
assumed to be supplied, and the upper triangular part is set from its
transpose (matrix bounds permitting). For Partition.LowerTriangular,
supplied entries which are not lower triangular will either be ignored or
generate an exception.
All specified data must fit within the current matrix bounds; the matrix is not resized.
CCCS data takes the form of three arrays:
vals
and
colIdxs
corresponding to the first nonzero element in each
column. All values are 1based, so that first offset value is 1, the
second offset value is n+1, where n is the number of nonzero elements in
the first column, etc. The final value is set to nvals+1, where nvals is
the number of nonzero elements in the matrix.vals
 nonzero element values. This array must have a length equal at
least to nvals
.rowIdxs
 row indices for each nonzero element.
This array must have a length equal at
least to nvals
.colOffs
 column start offsets into vals
and
rowIdxs
. This array must have a length equal at least to
ncols+1, where ncols is the number of columns in this matrix.nvals
 number of nonzero valuesncols
 number of specified columns. Indicates the maximum value of
colOffs
that will be used; will not resize matrix.part
 must be either Full
or
LowerTriangular
.void getSubMatrix(int baseRow, int baseCol, DenseMatrix Mdest) throws ImproperSizeException
baseRow
and baseCol
,
and the values are written into the matrix object Mdest
.
The size of the submatrix is determined by the dimensions of
Mdest
.baseRow
 first row of the submatrixbaseCol
 first column of the submatrixMdest
 destination for submatrix valuesImproperSizeException
 if baseRow
or baseCol
are negative, or if
the submatrix exceeds the current matrix bounds.MatrixNd.copySubMatrix(int, int, int, int, maspack.matrix.Matrix, int, int)
boolean isSymmetric(double tol)
tol
 absolute tolerance for checking equality of offdiagonal elementsint numNonZeroVals()
int numNonZeroVals(Matrix.Partition part, int numRows, int numCols)
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.part
 matrix parition to be examinednumRows
 number of rows delimiting the submatrixnumCols
 number of columns delimiting the submatrixjava.lang.String toString(java.lang.String fmtStr)
printf
style format string. The
exact format for this string is described in the documentation for
NumberFormat.set(String)
{NumberFormat.set(String)}.fmtStr
 numeric printf style format stringNumberFormat
java.lang.String toString(NumberFormat fmt)
printf
style format as decribed by the
parameter NumberFormat
.fmt
 numeric formatjava.lang.String getSize()
void checkConsistency()
java.lang.IllegalStateException
 if the matrix structure is inconsistent.