|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.MatrixBase
public abstract class MatrixBase
Base implementation of Matrix
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface maspack.matrix.Matrix |
---|
Matrix.Partition, Matrix.WriteFormat |
Field Summary |
---|
Fields inherited from interface maspack.matrix.Matrix |
---|
INDEFINITE, POSITIVE_DEFINITE, SPD, SYMMETRIC |
Constructor Summary | |
---|---|
MatrixBase()
|
Method Summary | |
---|---|
abstract int |
colSize()
Number of columns in the matrix associated with this transformation. |
boolean |
containsNaN()
Returns true if any element of this matrix is not a number. |
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. |
void |
get(double[] values)
Copies the elements of this matrix into an array of doubles. |
void |
get(double[][] values)
Copies the elements of this matrix into a 2-dimensional array of doubles. |
abstract double |
get(int i,
int j)
Gets a single element of 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 sub-matrix of this matrix delimited by the first numRows
rows and the first numCols columns. |
int |
getCCSValues(double[] vals,
Matrix.Partition part)
Gets the compressed column storage (CCS) values for this matrix, in column-major order. |
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)
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,
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 sub-matrix of this matrix delimited by the first numRows rows and the
first numCols columns. |
int |
getCRSValues(double[] vals,
Matrix.Partition part)
Gets the compressed row storage (CRS) values for this matrix, in row-major order. |
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. |
static java.lang.String |
getDefaultFormat()
Returns the default format string used in toString . |
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. |
boolean |
hasNaN()
Returns true if one or more elements of this matrix is NaN. |
java.lang.String |
idString()
|
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 tolerance. |
void |
mul(VectorNd vr,
VectorNd v1)
Applies this transformation to vector v1 and returns the result in 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 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. |
double |
oneNorm()
Returns the 1 norm of this matrix. |
abstract int |
rowSize()
Number of rows in the matrix associated with this transformation. |
void |
scan(ReaderTokenizer rtok)
Sets the contents of this matrix to values read from a ReaderTokenizer. |
void |
setCRSValues(double[] vals,
int[] colIdxs,
int[] rowOffs)
Sets the contents of this matrix given a set of values in compressed row storage (CRS). |
static void |
setDefaultFormat(java.lang.String fmtStr)
Sets the default format string used in toString . |
void |
setSize(int numRows,
int numCols)
Sets the size of this matrix. |
java.lang.String |
toString()
Returns a String representation of this matrix, using the default format returned by getDefaultFormat . |
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 sub-matrix of this matrix delimited by the first numRows rows and the first numCols
columns. |
void |
write(java.io.PrintWriter pw,
java.lang.String msg,
Matrix.WriteFormat wfmt)
Writes the contents of this matrix to a PrintWriter. |
java.io.PrintWriter |
write(java.lang.String fileName,
java.lang.String msg,
Matrix.WriteFormat wfmt)
Writes the contents of this matrix to a specified file, and returns the PrintWriter that was created to do the writing. |
void |
writeToFile(java.lang.String fileName,
java.lang.String fmtStr)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface maspack.matrix.Matrix |
---|
checkConsistency, set, set, setCCSValues, setCRSValues |
Constructor Detail |
---|
public MatrixBase()
Method Detail |
---|
public static void setDefaultFormat(java.lang.String fmtStr)
toString
. For
a description of the format string syntax, see NumberFormat
.
fmtStr
- new format string
java.lang.IllegalArgumentException
- if the format string is invalidgetDefaultFormat()
public static java.lang.String getDefaultFormat()
toString
. If
unset, this string is "%g". For a description of the format string syntax,
see NumberFormat
.
public abstract int rowSize()
mul
.
rowSize
in interface LinearTransformNd
rowSize
in interface Matrix
public abstract int colSize()
mul
.
colSize
in interface LinearTransformNd
colSize
in interface Matrix
public abstract double get(int i, int j)
get
in interface Matrix
i
- element row indexj
- element column index
public void get(double[] values)
(i,j)
is
stored at location i*colSize()+j
.
get
in interface Matrix
values
- array into which values are copiedpublic void get(double[][] values)
values
- array into which values are copied
java.lang.IllegalArgumentException
- values
has inconsistent row sizes
ImproperSizeException
- dimensions of values
do not match the size of this matrixpublic void getColumn(int j, double[] values)
getColumn
in interface Matrix
j
- column indexvalues
- array into which the column is copiedpublic void getColumn(int j, double[] values, int off)
getColumn
in interface Matrix
j
- column indexvalues
- array into which the column is copiedoff
- offset in values where copying should beginpublic void getRow(int i, double[] values)
getRow
in interface Matrix
i
- row indexvalues
- array into which the row is copiedpublic void getRow(int i, double[] values, int off)
getRow
in interface Matrix
i
- row indexvalues
- array into which the row is copiedoff
- offset in values where copying should beginpublic void getColumn(int j, Vector v)
Vector
.
getColumn
in interface Matrix
j
- column indexv
- vector into which the column is copiedpublic void getRow(int i, Vector v)
Vector
.
getRow
in interface Matrix
i
- row indexv
- vector into which the row is copiedpublic boolean isFixedSize()
setSize
, or implicitly when used as a result for various
matrix operations.
isFixedSize
in interface Matrix
Matrix.setSize(int, int)
public void setSize(int numRows, int numCols)
isFixedSize
returns false.
setSize
in interface Matrix
numRows
- new row sizenumCols
- new column sizeMatrix.isFixedSize()
public double determinant() throws ImproperSizeException
determinant
in interface Matrix
ImproperSizeException
- if the matrix is not squarepublic double trace() throws ImproperSizeException
trace
in interface Matrix
ImproperSizeException
- if the matrix is not squarepublic boolean epsilonEquals(Matrix M1, double epsilon)
M1
within a prescribed tolerance epsilon
.
epsilonEquals
in interface Matrix
M1
- matrix to compare withepsilon
- comparison tolerance
public boolean equals(Matrix M1)
M1
.
equals
in interface Matrix
M1
- matrix to compare with
public double oneNorm()
oneNorm
in interface Matrix
public double infinityNorm()
infinityNorm
in interface Matrix
public double frobeniusNorm()
frobeniusNorm
in interface Matrix
public java.lang.String toString()
getDefaultFormat
.
toString
in class java.lang.Object
toString(String)
public java.lang.String idString()
public java.lang.String toString(java.lang.String fmtStr)
printf
style format string. For a
description of the format string syntax, see NumberFormat
. Note that when called numerous
times, toString(NumberFormat)
will be more
efficient because the NumberFormat
will
not need to be recreated each time from a specification string.
fmtStr
- numeric format specification
public java.lang.String toString(NumberFormat fmt)
printf
style format as decribed by the
parameter NumberFormat
.
toString
in interface Matrix
fmt
- numeric format
public void writeToFile(java.lang.String fileName, java.lang.String fmtStr)
public java.io.PrintWriter write(java.lang.String fileName, java.lang.String msg, Matrix.WriteFormat wfmt) throws java.io.IOException
fileName
- Path name for the file to writtenmsg
- Optional message - if not null
, is printed on
a separate line preceeding the matrix information.wfmt
- specifies the matrix output format
java.io.IOException
public void write(java.io.PrintWriter pw, java.lang.String msg, Matrix.WriteFormat wfmt) throws java.io.IOException
pw
- PrintWriter to write the matrix tomsg
- Optional message - if not null
, is printed on
a separate line preceeding the matrix information.wfmt
- specifies the matrix output format
java.io.IOException
public void write(java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
printf
style as
described by the parameter NumberFormat
.
write
in interface Matrix
pw
- PrintWriter to write this matrix tofmt
- numeric format
java.io.IOException
public 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
.
write
in interface Matrix
pw
- PrintWriter to write this matrix tofmt
- numeric formatwfmt
- specifies the general output format
java.io.IOException
public 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
.
write
in interface Matrix
pw
- PrintWriter to write this matrix tofmt
- numeric formatwfmt
- specifies the general output formatnumRows
- number of rows delimiting the sub-matrixnumCols
- number of columns delimiting the sub-matrix
java.io.IOException
public void scan(ReaderTokenizer rtok) throws java.io.IOException
For the dense format, the input should consist of a sequence of numbers,
arranged in row-major 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.
scan
in interface Matrix
rtok
- Tokenizer from which matrix values are read. Number parsing should be
enabled
java.io.IOException
public boolean containsNaN()
public void mul(VectorNd vr, VectorNd v1)
mul
in interface LinearTransformNd
mul
in interface Matrix
vr
- vector in which result is returnedv1
- vector to transformpublic 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:nr-1][0:nc-1] v1The vector vr is resized if it is not sufficiently large.
mul
in interface Matrix
vr
- result vectorv1
- vector to multiply bynr
- number of initial rows of this matrix to usenc
- number of initial columns of this matrix to usepublic 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+nr-1][c0:c0+nc-1] v1The vector vr is resized if it is not sufficiently large.
mul
in interface Matrix
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 submatrixpublic void mulAdd(VectorNd vr, VectorNd v1)
vr += M v1
mulAdd
in interface Matrix
vr
- result vectorv1
- vector to multiply bypublic 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:nr-1][0:nc-1] v1
mulAdd
in interface Matrix
vr
- result vectorv1
- vector to multiply bynr
- number of initial rows of this matrix to usenc
- number of initial columns of this matrix to usepublic 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+nr-1][c0:c0+nc-1] v1
mulAdd
in interface Matrix
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 submatrixpublic void mulTranspose(VectorNd vr, VectorNd v1)
vr = v1 MThe vector vr is resized if it is not sufficiently large.
mulTranspose
in interface Matrix
vr
- result vectorv1
- vector to multiply bypublic void 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:nc-1][0:nr-1]The vector vr is resized if it is not sufficiently large.
mulTranspose
in interface Matrix
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 usepublic 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+nc-1][r0:r0+nr-1]The vector vr is resized if it is not sufficiently large.
mulTranspose
in interface Matrix
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 submatrixpublic void mulTransposeAdd(VectorNd vr, VectorNd v1)
vr += v1 M
mulTransposeAdd
in interface Matrix
vr
- result vectorv1
- vector to multiply bypublic void 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:nc-1][0:nr-1]
mulTransposeAdd
in interface Matrix
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 usepublic 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+nc-1][r0:r0+nr-1]
mulTransposeAdd
in interface Matrix
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 submatrixpublic boolean hasNaN()
public int getCRSIndices(int[] colIdxs, int[] rowOffs, Matrix.Partition part)
setCRSValues()
.
getCRSIndices
in interface Matrix
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. 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
public int getCRSIndices(int[] colIdxs, int[] rowOffs, Matrix.Partition part, int numRows, int numCols)
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.
getCRSIndices
in interface Matrix
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-matrixnumCols
- number of columns delimiting the sub-matrix
public int getCRSValues(double[] vals, Matrix.Partition part)
setCRSValues()
.
getCRSValues
in interface Matrix
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.part
- specifies what portion of the matrix to store; must be either
Full
or
UpperTriangular
public int getCRSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
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.
getCRSValues
in interface Matrix
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-matrixnumCols
- number of columns delimiting the sub-matrix
public void setCRSValues(double[] vals, int[] colIdxs, int[] rowOffs)
vals
- non-zero element valuescolIdxs
- column indices for each non-zero elementrowOffs
- location within vals
( and colIdxs
)
corresponding to the first non-zero element in each rowpublic int getCCSIndices(int[] rowIdxs, int[] colOffs, Matrix.Partition part)
setCCSValues()
.
getCCSIndices
in interface Matrix
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. 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
public int getCCSIndices(int[] rowIdxs, int[] colOffs, Matrix.Partition part, int numRows, int numCols)
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.
getCCSIndices
in interface Matrix
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-matrixnumCols
- number of columns delimiting the sub-matrix
public int getCCSValues(double[] vals, Matrix.Partition part)
setCCSValues()
.
getCCSValues
in interface Matrix
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.part
- specifies what portion of the matrix to store; must be either
Full
or
LowerTriangular
public int getCCSValues(double[] vals, Matrix.Partition part, int numRows, int numCols)
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.
getCCSValues
in interface Matrix
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-matrixnumCols
- number of columns delimiting the sub-matrix
public 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
.
getSubMatrix
in interface Matrix
baseRow
- first row of the submatrixbaseCol
- first column of the submatrixMdest
- destination for submatrix values
ImproperSizeException
- 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)
public boolean isSymmetric(double tol)
isSymmetric
in interface Matrix
tol
- tolerance for checking equality of off-diagonal elementspublic int numNonZeroVals()
numNonZeroVals
in interface Matrix
public 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.
numNonZeroVals
in interface Matrix
part
- matrix parition to be examinednumRows
- number of rows delimiting the sub-matrixnumCols
- number of columns delimiting the sub-matrix
public java.lang.String getSize()
getSize
in interface Matrix
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |