de.jtem.jpetsc
Class Mat

java.lang.Object
  extended by de.jtem.jpetsc.PrimitivNative
      extended by de.jtem.jpetsc.Native
          extended by de.jtem.jpetsc.Mat

public class Mat
extends Native


Nested Class Summary
static class Mat.CreateCompositeResult
          Result class for createComposite(int, int)
static class Mat.GetInertiaResult
          Result class for getInertia()
static class Mat.GetLocalSizeResult
          Result class for getLocalSize()
static class Mat.GetOwnershipRangeResult
          Result class for getOwnershipRange()
static class Mat.GetSizeResult
          Result class for getSize()
static class Mat.GetVecsResult
          Result class for getVecs()
static class Mat.IsHermitianKnownResult
          Result class for isHermitianKnown()
static class Mat.IsSymmetricKnownResult
          Result class for isSymmetricKnown()
static class Mat.StashGetInfoResult
          Result class for stashGetInfo()
 
Field Summary
 
Fields inherited from class de.jtem.jpetsc.PrimitivNative
destroyNative
 
Constructor Summary
Mat(int m, int n)
           
 
Method Summary
 void add(int i, int j, double val)
           
 void appendOptionsPrefix(java.lang.String prefix)
          Appends to the prefix used for searching for all
Mat options in the database.
 void assemble()
          abbreviation to: assemblyBegin(MatAssemblyType.FINAL_ASSEMBLY); assemblyEnd(MatAssemblyType.FINAL_ASSEMBLY);
 boolean assembled()
          Indicates if a matrix has been assembled and is ready for
use; for example, in matrix-vector product.
 void assemblyBegin(MatAssemblyType type)
          Begins assembling the matrix.
 void assemblyEnd(MatAssemblyType type)
          Completes assembling the matrix.
 void aXPY(double a, Mat X, MatStructure str)
          Computes Y = a*X + Y.
 void aYPX(double a, Mat X, MatStructure str)
          Computes Y = a*Y + X.
 void compositeAddMat(Mat smat)
          add another matrix to a composite matrix
 void compositeMerge()
          Given a composite matrix, replaces it with a "regular" matrix
by summing all the matrices inside the composite matrix.
 void compress()
          Tries to store the matrix in as little space as
possible.
 Mat computeExplicitOperator()
          Computes the explicit matrix
 void conjugate()
          replaces the matrix values with their complex conjugates
 void copy(Mat B, MatStructure str)
          Copys a matrix to another matrix.
static Mat create(int comm)
          Creates a matrix where the type is determined
from either a call to MatSetType() or from the options database
with a call to MatSetFromOptions().
static Mat createBlockMat(int comm, int m, int n, int bs, int nz, int[] nnz)
          Creates a new matrix based sparse Mat storage
static Mat.CreateCompositeResult createComposite(int comm, int nmat)
          Creates a matrix as the sum of zero or more matrices
 Mat createLRC(Mat U, Mat V)
          Creates a new matrix object that behaves like A + U*V'
static Mat createMFFD(int comm, int m, int n, int M, int N)
          Creates a matrix-free matrix.
static Mat createMPIAIJ(int comm, int m, int n, int M, int N, int d_nz, int[] d_nnz, int o_nz, int[] o_nnz)
          Creates a sparse parallel matrix in AIJ format
(the default parallel PETSc format).
static Mat createMPIAIJWithArrays(int comm, int m, int n, int M, int N, int[] i, int[] j, double[] a)
          creates a MPI AIJ matrix using arrays that contain in standard
CSR format the local rows.
static Mat createMPIAIJWithSplitArrays(int comm, int m, int n, int M, int N, int[] i, int[] j, double[] a, int[] oi, int[] oj, double[] oa)
          creates a MPI AIJ matrix using arrays that contain the "diagonal"
and "off-diagonal" part of the matrix in CSR format.
static Mat createMPIBAIJ(int comm, int bs, int m, int n, int M, int N, int d_nz, int[] d_nnz, int o_nz, int[] o_nnz)
          Creates a sparse parallel matrix in block AIJ format
(block compressed row).
static Mat createMPIDense(int comm, int m, int n, int M, int N, double[] data)
          Creates a sparse parallel matrix in dense format.
static Mat createMPISBAIJ(int comm, int bs, int m, int n, int M, int N, int d_nz, int[] d_nnz, int o_nz, int[] o_nnz)
          Creates a sparse parallel matrix in symmetric block AIJ format
(block compressed row).
 Mat createNormal()
          Creates a new matrix object that behaves like A'*A.
static Mat createSeqAIJ(int m, int n, int nz, int[] nnz)
          Creates a sparse matrix in AIJ (compressed row) format
(the default parallel PETSc format).
static Mat createSeqAIJWithArrays(int m, int n, int[] i, int[] j, double[] a)
          Creates an sequential AIJ matrix using matrix elements (in CSR format)
provided by the user.
static Mat createSeqBAIJ(int bs, int m, int n, int nz, int[] nnz)
          Creates a sparse matrix in block AIJ (block
compressed row) format.
static Mat createSeqBAIJWithArrays(int bs, int m, int n, int[] i, int[] j, double[] a)
          Creates an sequential BAIJ matrix using matrix elements
(upper triangular entries in CSR format) provided by the user.
static Mat createSeqCRL(int m, int n, int nz, int[] nnz)
          Creates a sparse matrix of type SEQCRL.
static Mat createSeqDense(int m, int n, double[] data)
          Creates a sequential dense matrix that
is stored in column major order (the usual Fortran 77 manner).
static Mat createSeqSBAIJWithArrays(int bs, int m, int n, int[] i, int[] j, double[] a)
          Creates an sequential SBAIJ matrix using matrix elements
(upper triangular entries in CSR format) provided by the user.
 Mat denseGetLocalMatrix()
          For a MATMPIDENSE or MATSEQDENSE matrix returns the sequential
matrix that represents the operator.
 double det()
          Run a very simple algorithm to calculate the determinant of the matrix.
 void diagonalScale(Vec l, Vec r)
          Scales a matrix on the left and right by diagonal
matrices that are stored as vectors.
 void diagonalSet(Vec D, InsertMode i)
          Computes Y = Y + D, where D is a diagonal matrix
that is represented as a vector.
 Mat duplicate(MatDuplicateOption op)
          Duplicates a matrix including the non-zero structure.
 boolean equal(Mat B)
          Compares two matrices.
 boolean equals(java.lang.Object obj)
           
 void flush()
          abbreviation to: assemblyBegin(MatAssemblyType.FLUSH_ASSEMBLY); assemblyEnd(MatAssemblyType.FLUSH_ASSEMBLY);
 int getBlockSize()
          Returns the matrix block size; useful especially for the
block row and block diagonal formats.
 void getColumnVector(Vec yy, int c)
          Gets the values from a given column of a matrix.
 void getDiagonal(Vec v)
          Gets the diagonal of a matrix.
 Mat.GetInertiaResult getInertia()
          Gets the inertia from a factored matrix
 Mat.GetLocalSizeResult getLocalSize()
          Returns the number of rows and columns in a matrix
stored locally.
 Mat.GetOwnershipRangeResult getOwnershipRange()
          Returns the range of matrix rows owned by
this processor, assuming that the matrix is laid out with the first
n1 rows on the first processor, the next n2 rows on the second, etc.
 void getRowMax(Vec v, int[] idx)
          Gets the maximum value (of the real part) of each
row of the matrix
 void getRowMaxAbs(Vec v, int[] idx)
          Gets the maximum value (in absolute value) of each
row of the matrix
 void getRowMin(Vec v, int[] idx)
          Gets the minimum value (of the real part) of each
row of the matrix
 void getRowSum(Vec v)
          Gets the sum of each row of the matrix
 void getRowUpperTriangular()
          Sets a flag to enable calls to MatGetRow() for matrix in MATSBAIJ format.
 Mat.GetSizeResult getSize()
          Returns the numbers of rows and columns in a matrix.
 java.lang.String getType()
          Gets the matrix type as a string from the matrix object.
 double getValue(int i, int j)
          native (faster) abbreviation for getValues(1, new int[]{i}, 1, new int[]{j}, ret)
 void getValues(int m, int[] idxm, int n, int[] idxn, double[] v)
          Gets a block of values from a matrix.
 Mat.GetVecsResult getVecs()
          Get vector(s) compatible with the matrix, i.e. with the same
parallel layout
 void imaginaryPart()
          Moves the imaginary part of the matrix to the real part and zeros the imaginary part
 void insert(int i, int j, double val)
           
 void interpolate(Vec x, Vec y)
          y = A*x or A'*x depending on the shape of
the matrix
 void interpolateAdd(Vec x, Vec y, Vec w)
          w = y + A*x or A'*x depending on the shape of
the matrix
 Mat iSGetLocalMat()
          Gets the local matrix stored inside a MATIS matrix.
 boolean isHermitian()
          Test whether a matrix is Hermitian, i.e. it is the complex conjugate of its transpose.
 Mat.IsHermitianKnownResult isHermitianKnown()
          Checks the flag on the matrix to see if it is hermitian.
 boolean isStructurallySymmetric()
          Test whether a matrix is structurally symmetric
 boolean isSymmetric(double tol)
          Test whether a matrix is symmetric
 Mat.IsSymmetricKnownResult isSymmetricKnown()
          Checks the flag on the matrix to see if it is symmetric.
static Mat loadMat(java.lang.String outtype)
          Loads a matrix that has been stored in binary format
with MatView().
 void matMultNumeric(Mat B, Mat C)
          Performs the numeric matrix-matrix product.
 Mat matMultSymbolic(Mat B, double fill)
          Performs construction, preallocation, and computes the ij structure
of the matrix-matrix product C=A*B.
 void mFFDDSSetUmin(double umin)
          Sets the "umin" parameter used by the
PETSc routine for computing the differencing parameter, h, which is used
for matrix-free Jacobian-vector products.
 double mFFDGetH()
          Gets the last value that was used as the differencing
parameter.
 void mFFDResetHHistory()
          Resets the counter to zero to begin
collecting a new set of differencing histories.
 void mFFDSetBase(Vec U, Vec F)
          Sets the vector U at which matrix vector products of the
Jacobian are computed
 void mFFDSetFromOptions()
          Sets the MatMFFD options from the command line
parameter.
 void mFFDSetFunctionError(double error_rel)
          Sets the error_rel for the approximation of
matrix-vector products using finite differences.
 void mFFDSetHHistory(double[] histroy, int nhistory)
          Sets an array to collect a history of the
differencing values (h) computed for the matrix-free product.
 void mFFDSetPeriod(int period)
          Sets how often h is recomputed, by default it is everytime
 void mFFDWPSetComputeNormU(boolean flag)
          Sets whether it computes the ||U|| used by the WP
PETSc routine for computing h.
 void mPIBAIJSetHashTableFactor(double fact)
          Sets the factor required to compute the size of the HashTable.
 void mult(Vec x, Vec y)
          Computes the matrix-vector product, y = Ax.
 void multAdd(Vec v1, Vec v2, Vec v3)
          Computes v3 = v2 + A * v1.
 boolean multAddEqual(Mat B, int n)
          Compares matrix-vector products of two matrices.
 void multConstrained(Vec x, Vec y)
          The inner multiplication routine for a
constrained matrix P^T A P.
 boolean multEqual(Mat B, int n)
          Compares matrix-vector products of two matrices.
 void multTranspose(Vec x, Vec y)
          Computes matrix transpose times a vector.
 void multTransposeAdd(Vec v1, Vec v2, Vec v3)
          Computes v3 = v2 + A' * v1.
 boolean multTransposeAddEqual(Mat B, int n)
          Compares matrix-vector products of two matrices.
 void multTransposeConstrained(Vec x, Vec y)
          The inner multiplication routine for a
constrained matrix P^T A^T P.
 boolean multTransposeEqual(Mat B, int n)
          Compares matrix-vector products of two matrices.
protected  void nativeCreate()
           
 double norm(NormType type)
          Calculates various norms of a matrix.
 void ptAPNumeric(Mat P, Mat C)
          Computes the matrix projection C = P^T * A * P
 void realPart()
          Zeros out the imaginary part of the matrix
 void restoreRowUpperTriangular()
          Disable calls to MatGetRow() for matrix in MATSBAIJ format.
 void restrict(Vec x, Vec y)
          y = A*x or A'*x
 void retrieveValues()
          Retrieves the copy of the matrix values; this allows, for
example, reuse of the linear part of a Jacobian, while recomputing the
nonlinear portion.
 void scale(double a)
          Scales all elements of a matrix by a given number.
 void seqAIJSetColumnIndices(int[] indices)
          Set the column indices for all the rows
in the matrix.
 void seqBAIJInvertBlockDiagonal()
          Inverts the block diagonal entries.
 void seqBAIJSetColumnIndices(int[] indices)
          Set the column indices for all the rows
in the matrix.
 void seqDenseSetLDA(int lda)
          Declare the leading dimension of the user-provided array
 void setBlockSize(int bs)
          Sets the matrix block size; for many matrix types you
cannot use this and MUST set the blocksize when you preallocate the matrix
Not Collective
 void setFromOptions()
          Creates a matrix where the type is determined
from the options database.
 void setOptionsPrefix(java.lang.String prefix)
          Sets the prefix used for searching for all
Mat options in the database.
 void setSizes(int m, int n)
          Sets the local and global sizes, and checks to determine compatibility
 void setSizes(int m, int n, int M, int N)
          Sets the local and global sizes, and checks to determine compatibility
 void setStencil(int dim, int[] dims, int[] starts, int dof)
          Sets the grid information for setting values into a matrix via
MatSetValuesStencil()
Not Collective
 void setToGenericMat(java.lang.Object mat, java.lang.String getMethodName, int[][] nzColIndices)
           
 void setType(java.lang.String matype)
          Builds matrix object for a particular matrix type
 void setUp()
          Sets up the internal matrix data structures for the later use.
 void setValue(int i, int j, double val, InsertMode mode)
          native (faster) abbreviation for setValues(1, new int[]{i}, 1, new int[]{j}, new double[]{val})
 void setValues(int m, int[] idxm, int n, int[] idxn, double[] v, InsertMode addv)
          Inserts or adds a block of values into a matrix.
 void setValuesBlocked(int m, int[] idxm, int n, int[] idxn, double[] v, InsertMode addv)
          Inserts or adds a block of values into a matrix.
 void setValuesBlockedLocal(int nrow, int[] irow, int ncol, int[] icol, double[] y, InsertMode addv)
          Inserts or adds values into certain locations of a matrix,
using a local ordering of the nodes a block at a time.
 void setValuesLocal(int nrow, int[] irow, int ncol, int[] icol, double[] y, InsertMode addv)
          Inserts or adds values into certain locations of a matrix,
using a local ordering of the nodes.
 void setValuesRow(int row, double[] v)
          Inserts a row (block row for BAIJ matrices) of nonzero
values into a matrix
Not Collective
 void setValuesRowLocal(int row, double[] v)
          Inserts a row (block row for BAIJ matrices) of nonzero
values into a matrix
Not Collective
 void shift(double a)
          Computes Y = Y + a I, where a is a PetscScalar and I is the identity matrix.
 Mat.StashGetInfoResult stashGetInfo()
          Gets how many values are currently in the vector stash, i.e. need
to be communicated to other processors during the MatAssemblyBegin/End() process
Not collective
 void stashSetInitialSize(int size, int bsize)
          sets the sizes of the matrix stash, that is
used during the assembly process to store values that belong to
other processors.
 void storeValues()
          Stashes a copy of the matrix values; this allows, for
example, reuse of the linear part of a Jacobian, while recomputing the
nonlinear portion.
 java.lang.String toString()
           
 Mat transpose()
          Computes an in-place or out-of-place transpose of a matrix.
 void view()
          Visualizes a matrix object.
 void zeroEntries()
          Zeros all entries of a matrix.
 void zeroRows(int numRows, int[] rows, double diag)
          Zeros all entries (except possibly the main diagonal)
of a set of rows of a matrix.
 void zeroRowsLocal(int numRows, int[] rows, double diag)
          Zeros all entries (except possibly the main diagonal)
of a set of rows of a matrix; using local numbering of rows.
 
Methods inherited from class de.jtem.jpetsc.PrimitivNative
finalize, getNativeObjectToString, load
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mat

public Mat(int m,
           int n)
Method Detail

nativeCreate

protected void nativeCreate()
Specified by:
nativeCreate in class Native

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class PrimitivNative

getValue

public double getValue(int i,
                       int j)
native (faster) abbreviation for getValues(1, new int[]{i}, 1, new int[]{j}, ret)

See Also:
getValues(int, int[], int, int[], double[])

setValue

public void setValue(int i,
                     int j,
                     double val,
                     InsertMode mode)
native (faster) abbreviation for setValues(1, new int[]{i}, 1, new int[]{j}, new double[]{val})

See Also:
setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

add

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

insert

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

assemble

public void assemble()
abbreviation to:
assemblyBegin(MatAssemblyType.FINAL_ASSEMBLY);
assemblyEnd(MatAssemblyType.FINAL_ASSEMBLY);

See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType)

flush

public void flush()
abbreviation to:
assemblyBegin(MatAssemblyType.FLUSH_ASSEMBLY);
assemblyEnd(MatAssemblyType.FLUSH_ASSEMBLY);

See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType)

setSizes

public void setSizes(int m,
                     int n)
Sets the local and global sizes, and checks to determine compatibility

Parameters:
n - number of local columns (or PETSC_DECIDE)
m - number of local rows (or PETSC_DECIDE)
See Also:
getSize()

det

public double det()
Run a very simple algorithm to calculate the determinant of the matrix. Implemented in Java and not part of PETSc. It is neither efficient nor sparse aware! So don't use it for real live problems at all.


setToGenericMat

public void setToGenericMat(java.lang.Object mat,
                            java.lang.String getMethodName,
                            int[][] nzColIndices)
                     throws java.lang.SecurityException,
                            java.lang.NoSuchMethodException,
                            java.lang.IllegalArgumentException,
                            java.lang.IllegalAccessException,
                            java.lang.reflect.InvocationTargetException
Throws:
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

mFFDSetFromOptions

public void mFFDSetFromOptions()
Sets the MatMFFD options from the command line
parameter.

See Also:
#createSNESMF, mFFDSetHHistory(double[], int), mFFDResetHHistory(), #mFFDKSPMonitor

createMFFD

public static Mat createMFFD(int comm,
                             int m,
                             int n,
                             int M,
                             int N)
Creates a matrix-free matrix. See also MatCreateSNESMF()

Parameters:
comm - MPI communicator
m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
This value should be the same as the local size used in creating the
y vector for the matrix-vector product y = Ax.
n - This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have
calculated if N is given) For square matrices n is almost always m.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
Returns:
the matrix-free matrix
See Also:
destroy(), mFFDSetFunctionError(double), #mFFDDefaultSetUmin, #mFFDSetFunction, mFFDSetHHistory(double[], int), mFFDResetHHistory(), #createSNESMF, mFFDGetH(), #mFFDKSPMonitor, #mFFDRegisterDynamic, #mFFDComputeJacobian

mFFDGetH

public double mFFDGetH()
Gets the last value that was used as the differencing
parameter.
Not Collective

Returns:
the differencing step size
See Also:
#createSNESMF, mFFDSetHHistory(double[], int), createMFFD(int, int, int, int, int), #MATMFFD, mFFDResetHHistory(), #mFFDKSPMonitor

mFFDSetPeriod

public void mFFDSetPeriod(int period)
Sets how often h is recomputed, by default it is everytime

Parameters:
period - 1 for everytime, 2 for every second etc
See Also:
#createSNESMF, mFFDGetH(), mFFDSetHHistory(double[], int), mFFDResetHHistory(), #mFFDKSPMonitor

mFFDSetFunctionError

public void mFFDSetFunctionError(double error_rel)
Sets the error_rel for the approximation of
matrix-vector products using finite differences.

Parameters:
error_rel - relative error (should be set to the square root of
the relative error in the function evaluations)
See Also:
#createSNESMF, mFFDGetH(), createMFFD(int, int, int, int, int), #MATMFFD, mFFDSetHHistory(double[], int), mFFDResetHHistory(), #mFFDKSPMonitor

mFFDSetHHistory

public void mFFDSetHHistory(double[] histroy,
                            int nhistory)
Sets an array to collect a history of the
differencing values (h) computed for the matrix-free product.

Parameters:
histroy - space to hold the history
nhistory - number of entries in history, if more entries are generated than
nhistory, then the later ones are discarded
See Also:
mFFDGetH(), #createSNESMF, mFFDResetHHistory(), #mFFDKSPMonitor, mFFDSetFunctionError(double)

mFFDResetHHistory

public void mFFDResetHHistory()
Resets the counter to zero to begin
collecting a new set of differencing histories.

See Also:
mFFDGetH(), #createSNESMF, mFFDSetHHistory(double[], int), #mFFDKSPMonitor, mFFDSetFunctionError(double)

mFFDSetBase

public void mFFDSetBase(Vec U,
                        Vec F)
Sets the vector U at which matrix vector products of the
Jacobian are computed

Parameters:
U - the vector
F - vector that contains F(u) if it has been already computed

mFFDDSSetUmin

public void mFFDDSSetUmin(double umin)
Sets the "umin" parameter used by the
PETSc routine for computing the differencing parameter, h, which is used
for matrix-free Jacobian-vector products.

Parameters:
umin - the parameter
See Also:
mFFDSetFunctionError(double), #createSNESMF

mFFDWPSetComputeNormU

public void mFFDWPSetComputeNormU(boolean flag)
Sets whether it computes the ||U|| used by the WP
PETSc routine for computing h. With any Krylov solver this need only
be computed during the first iteration and kept for later.

Parameters:
flag - PETSC_TRUE causes it to compute ||U||, PETSC_FALSE uses the previous value
See Also:
mFFDSetFunctionError(double), #createSNESMF

createLRC

public Mat createLRC(Mat U,
                     Mat V)
Creates a new matrix object that behaves like A + U*V'

Parameters:
U - two dense rectangular (tall and skinny) matrices
V - two dense rectangular (tall and skinny) matrices
Returns:
the matrix that represents A + U*V'

iSGetLocalMat

public Mat iSGetLocalMat()
Gets the local matrix stored inside a MATIS matrix.

Returns:
the local matrix usually MATSEQAIJ
See Also:
#MATIS

createComposite

public static Mat.CreateCompositeResult createComposite(int comm,
                                                        int nmat)
Creates a matrix as the sum of zero or more matrices

Parameters:
comm - MPI communicator
nmat - number of matrices to put in
Returns:
Mat.CreateCompositeResult
See Also:
destroy(), mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), compositeAddMat(de.jtem.jpetsc.Mat), compositeMerge()

compositeAddMat

public void compositeAddMat(Mat smat)
add another matrix to a composite matrix

Parameters:
smat - the partial matrix
See Also:
createComposite(int, int)

compositeMerge

public void compositeMerge()
Given a composite matrix, replaces it with a "regular" matrix
by summing all the matrices inside the composite matrix.

See Also:
destroy(), mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), compositeAddMat(de.jtem.jpetsc.Mat), createComposite(int, int), #MATCOMPOSITE

createNormal

public Mat createNormal()
Creates a new matrix object that behaves like A'*A.

Returns:
the matrix that represents A'*A

seqBAIJInvertBlockDiagonal

public void seqBAIJInvertBlockDiagonal()
Inverts the block diagonal entries.


seqBAIJSetColumnIndices

public void seqBAIJSetColumnIndices(int[] indices)
Set the column indices for all the rows
in the matrix.

Parameters:
indices - the column indices

createSeqBAIJ

public static Mat createSeqBAIJ(int bs,
                                int m,
                                int n,
                                int nz,
                                int[] nnz)
Creates a sparse matrix in block AIJ (block
compressed row) format. For good matrix assembly performance the
user should preallocate the matrix storage by setting the parameter nz
(or the array nnz). By setting these parameters accurately, performance
during matrix assembly can be increased by more than a factor of 50.

Parameters:
bs - size of block
m - number of rows
n - number of columns
nz - number of nonzero blocks per block row (same for all rows)
nnz - array containing the number of nonzero blocks in the various block rows
(possibly different for each block row) or PETSC_NULL
Returns:
the matrix
See Also:
create(int), createSeqAIJ(int, int, int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[])

createSeqBAIJWithArrays

public static Mat createSeqBAIJWithArrays(int bs,
                                          int m,
                                          int n,
                                          int[] i,
                                          int[] j,
                                          double[] a)
Creates an sequential BAIJ matrix using matrix elements
(upper triangular entries in CSR format) provided by the user.

Parameters:
bs - size of block
m - number of rows
n - number of columns
i - row indices
j - column indices
a - matrix values
Returns:
the matrix
See Also:
create(int), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), createSeqBAIJ(int, int, int, int, int[])

createMPIBAIJ

public static Mat createMPIBAIJ(int comm,
                                int bs,
                                int m,
                                int n,
                                int M,
                                int N,
                                int d_nz,
                                int[] d_nnz,
                                int o_nz,
                                int[] o_nnz)
Creates a sparse parallel matrix in block AIJ format
(block compressed row). For good matrix assembly performance
the user should preallocate the matrix storage by setting the parameters
d_nz (or d_nnz) and o_nz (or o_nnz). By setting these parameters accurately,
performance can be increased by more than a factor of 50.

Parameters:
comm - MPI communicator
bs - size of blockk
m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
This value should be the same as the local size used in creating the
y vector for the matrix-vector product y = Ax.
n - number of local columns (or PETSC_DECIDE to have calculated if N is given)
This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
d_nz - number of nonzero blocks per block row in diagonal portion of local
submatrix (same for all local rows)
d_nnz - array containing the number of nonzero blocks in the various block rows
of the in diagonal portion of the local (possibly different for each block
row) or PETSC_NULL. You must leave room for the diagonal entry even if it is zero.
o_nz - number of nonzero blocks per block row in the off-diagonal portion of local
submatrix (same for all local rows).
o_nnz - array containing the number of nonzero blocks in the various block rows of the
off-diagonal portion of the local submatrix (possibly different for
each block row) or PETSC_NULL.
Returns:
the matrix
See Also:
create(int), createSeqBAIJ(int, int, int, int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #mPIBAIJSetPreallocation, #mPIBAIJSetPreallocationCSR

mPIBAIJSetHashTableFactor

public void mPIBAIJSetHashTableFactor(double fact)
Sets the factor required to compute the size of the HashTable.

Parameters:
fact - factor
Collective on Mat
See Also:
#setOption

createSeqSBAIJWithArrays

public static Mat createSeqSBAIJWithArrays(int bs,
                                           int m,
                                           int n,
                                           int[] i,
                                           int[] j,
                                           double[] a)
Creates an sequential SBAIJ matrix using matrix elements
(upper triangular entries in CSR format) provided by the user.

Parameters:
bs - size of block
m - number of rows
n - number of columns
i - row indices
j - column indices
a - matrix values
Returns:
the matrix
See Also:
create(int), createMPISBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #createSeqSBAIJ

createMPISBAIJ

public static Mat createMPISBAIJ(int comm,
                                 int bs,
                                 int m,
                                 int n,
                                 int M,
                                 int N,
                                 int d_nz,
                                 int[] d_nnz,
                                 int o_nz,
                                 int[] o_nnz)
Creates a sparse parallel matrix in symmetric block AIJ format
(block compressed row). For good matrix assembly performance
the user should preallocate the matrix storage by setting the parameters
d_nz (or d_nnz) and o_nz (or o_nnz). By setting these parameters accurately,
performance can be increased by more than a factor of 50.

Parameters:
comm - MPI communicator
bs - size of blockk
m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
This value should be the same as the local size used in creating the
y vector for the matrix-vector product y = Ax.
n - number of local columns (or PETSC_DECIDE to have calculated if N is given)
This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
d_nz - number of block nonzeros per block row in diagonal portion of local
submatrix (same for all local rows)
d_nnz - array containing the number of block nonzeros in the various block rows
in the upper triangular portion of the in diagonal portion of the local
(possibly different for each block block row) or PETSC_NULL.
You must leave room for the diagonal entry even if it is zero.
o_nz - number of block nonzeros per block row in the off-diagonal portion of local
submatrix (same for all local rows).
o_nnz - array containing the number of nonzeros in the various block rows of the
off-diagonal portion of the local submatrix (possibly different for
each block row) or PETSC_NULL.
Returns:
the matrix
See Also:
create(int), #createSeqSBAIJ, setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[])

seqAIJSetColumnIndices

public void seqAIJSetColumnIndices(int[] indices)
Set the column indices for all the rows
in the matrix.

Parameters:
indices - the column indices

storeValues

public void storeValues()
Stashes a copy of the matrix values; this allows, for
example, reuse of the linear part of a Jacobian, while recomputing the
nonlinear portion.
Collect on Mat

See Also:
retrieveValues()

retrieveValues

public void retrieveValues()
Retrieves the copy of the matrix values; this allows, for
example, reuse of the linear part of a Jacobian, while recomputing the
nonlinear portion.
Collect on Mat

See Also:
storeValues()

createSeqAIJ

public static Mat createSeqAIJ(int m,
                               int n,
                               int nz,
                               int[] nnz)
Creates a sparse matrix in AIJ (compressed row) format
(the default parallel PETSc format). For good matrix assembly performance
the user should preallocate the matrix storage by setting the parameter nz
(or the array nnz). By setting these parameters accurately, performance
during matrix assembly can be increased by more than a factor of 50.

Parameters:
m - number of rows
n - number of columns
nz - number of nonzeros per row (same for all rows)
nnz - array containing the number of nonzeros in the various rows
(possibly different for each row) or PETSC_NULL
Returns:
the matrix
See Also:
create(int), createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), seqAIJSetColumnIndices(int[]), createSeqAIJWithArrays(int, int, int[], int[], double[])

createSeqAIJWithArrays

public static Mat createSeqAIJWithArrays(int m,
                                         int n,
                                         int[] i,
                                         int[] j,
                                         double[] a)
Creates an sequential AIJ matrix using matrix elements (in CSR format)
provided by the user.

Parameters:
m - number of rows
n - number of columns
i - row indices
j - column indices
a - matrix values
Returns:
the matrix
See Also:
create(int), createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), createSeqAIJ(int, int, int, int[]), createMPIAIJWithArrays(int, int, int, int, int, int[], int[], double[]), #mPIAIJSetPreallocationCSR

createSeqCRL

public static Mat createSeqCRL(int m,
                               int n,
                               int nz,
                               int[] nnz)
Creates a sparse matrix of type SEQCRL.
This type inherits from AIJ, but stores some additional
information that is used to allow better vectorization of
the matrix-vector product. At the cost of increased storage, the AIJ formatted
matrix can be copied to a format in which pieces of the matrix are
stored in ELLPACK format, allowing the vectorized matrix multiply
routine to use stride-1 memory accesses. As with the AIJ type, it is
important to preallocate matrix storage in order to get good assembly
performance.

Parameters:
m - number of rows
n - number of columns
nz - number of nonzeros per row (same for all rows)
nnz - array containing the number of nonzeros in the various rows
(possibly different for each row) or PETSC_NULL
Returns:
the matrix
See Also:
create(int), #createMPICSRPERM, setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

createMPIAIJWithArrays

public static Mat createMPIAIJWithArrays(int comm,
                                         int m,
                                         int n,
                                         int M,
                                         int N,
                                         int[] i,
                                         int[] j,
                                         double[] a)
creates a MPI AIJ matrix using arrays that contain in standard
CSR format the local rows.

Parameters:
comm - MPI communicator
m - number of local rows (Cannot be PETSC_DECIDE)
n - This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have
calculated if N is given) For square matrices n is almost always m.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
i - row indices
j - column indices
a - matrix values
Returns:
the matrix
See Also:
create(int), createSeqAIJ(int, int, int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #mPIAIJSetPreallocation, #mPIAIJSetPreallocationCSR, #MPIAIJ, createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), createMPIAIJWithSplitArrays(int, int, int, int, int, int[], int[], double[], int[], int[], double[])

createMPIAIJ

public static Mat createMPIAIJ(int comm,
                               int m,
                               int n,
                               int M,
                               int N,
                               int d_nz,
                               int[] d_nnz,
                               int o_nz,
                               int[] o_nnz)
Creates a sparse parallel matrix in AIJ format
(the default parallel PETSc format). For good matrix assembly performance
the user should preallocate the matrix storage by setting the parameters
d_nz (or d_nnz) and o_nz (or o_nnz). By setting these parameters accurately,
performance can be increased by more than a factor of 50.

Parameters:
comm - MPI communicator
m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
This value should be the same as the local size used in creating the
y vector for the matrix-vector product y = Ax.
n - This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have
calculated if N is given) For square matrices n is almost always m.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
d_nz - number of nonzeros per row in DIAGONAL portion of local submatrix
(same value is used for all local rows)
d_nnz - array containing the number of nonzeros in the various rows of the
DIAGONAL portion of the local submatrix (possibly different for each row)
or PETSC_NULL, if d_nz is used to specify the nonzero structure.
The size of this array is equal to the number of local rows, i.e 'm'.
You must leave room for the diagonal entry even if it is zero.
o_nz - number of nonzeros per row in the OFF-DIAGONAL portion of local
submatrix (same value is used for all local rows).
o_nnz - array containing the number of nonzeros in the various rows of the
OFF-DIAGONAL portion of the local submatrix (possibly different for
each row) or PETSC_NULL, if o_nz is used to specify the nonzero
structure. The size of this array is equal to the number
of local rows, i.e 'm'.
Returns:
the matrix
See Also:
create(int), createSeqAIJ(int, int, int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #mPIAIJSetPreallocation, #mPIAIJSetPreallocationCSR, #MPIAIJ, createMPIAIJWithArrays(int, int, int, int, int, int[], int[], double[])

createMPIAIJWithSplitArrays

public static Mat createMPIAIJWithSplitArrays(int comm,
                                              int m,
                                              int n,
                                              int M,
                                              int N,
                                              int[] i,
                                              int[] j,
                                              double[] a,
                                              int[] oi,
                                              int[] oj,
                                              double[] oa)
creates a MPI AIJ matrix using arrays that contain the "diagonal"
and "off-diagonal" part of the matrix in CSR format.

Parameters:
comm - MPI communicator
m - number of local rows (Cannot be PETSC_DECIDE)
n - This value should be the same as the local size used in creating the
x vector for the matrix-vector product y = Ax. (or PETSC_DECIDE to have
calculated if N is given) For square matrices n is almost always m.
M - number of global rows (or PETSC_DETERMINE to have calculated if m is given)
N - number of global columns (or PETSC_DETERMINE to have calculated if n is given)
i - row indices for "diagonal" portion of matrix
j - column indices
a - matrix values
oi - row indices for "off-diagonal" portion of matrix
oj - column indices
oa - matrix values
Returns:
the matrix
See Also:
create(int), createSeqAIJ(int, int, int, int[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #mPIAIJSetPreallocation, #mPIAIJSetPreallocationCSR, #MPIAIJ, createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), createMPIAIJWithArrays(int, int, int, int, int, int[], int[], double[])

createSeqDense

public static Mat createSeqDense(int m,
                                 int n,
                                 double[] data)
Creates a sequential dense matrix that
is stored in column major order (the usual Fortran 77 manner). Many
of the matrix operations use the BLAS and LAPACK routines.

Parameters:
m - number of rows
n - number of columns
data - optional location of matrix data. Set data=PETSC_NULL for PETSc
to control all matrix memory allocation.
Returns:
the matrix
See Also:
create(int), createMPIDense(int, int, int, int, int, double[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

seqDenseSetLDA

public void seqDenseSetLDA(int lda)
Declare the leading dimension of the user-provided array

Parameters:
lda - the leading dimension
See Also:
create(int), createSeqDense(int, int, double[]), #seqDenseSetPreallocation, #setMaximumSize

denseGetLocalMatrix

public Mat denseGetLocalMatrix()
For a MATMPIDENSE or MATSEQDENSE matrix returns the sequential
matrix that represents the operator. For sequential matrices it returns itself.

Returns:
the inner matrix

createMPIDense

public static Mat createMPIDense(int comm,
                                 int m,
                                 int n,
                                 int M,
                                 int N,
                                 double[] data)
Creates a sparse parallel matrix in dense format.

Parameters:
comm - MPI communicator
m - number of local rows (or PETSC_DECIDE to have calculated if M is given)
n - number of local columns (or PETSC_DECIDE to have calculated if N is given)
M - number of global rows (or PETSC_DECIDE to have calculated if m is given)
N - number of global columns (or PETSC_DECIDE to have calculated if n is given)
data - optional location of matrix data. Set data=PETSC_NULL (PETSC_NULL_SCALAR for Fortran users) for PETSc
to control all matrix memory allocation.
Returns:
the matrix
See Also:
create(int), createSeqDense(int, int, double[]), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

createBlockMat

public static Mat createBlockMat(int comm,
                                 int m,
                                 int n,
                                 int bs,
                                 int nz,
                                 int[] nnz)
Creates a new matrix based sparse Mat storage

Parameters:
comm - MPI communicator
m - number of rows
n - number of columns
bs - size of each submatrix
nz - expected maximum number of nonzero blocks in row (use PETSC_DEFAULT if not known)
nnz - expected number of nonzers per block row if known (use PETSC_NULL otherwise)
Returns:
the matrix
See Also:
#MATBLOCKMAT

getColumnVector

public void getColumnVector(Vec yy,
                            int c)
Gets the values from a given column of a matrix.
Not Collective

Parameters:
yy - the vector
c - the column requested (in global numbering)
See Also:
#getRow, getDiagonal(de.jtem.jpetsc.Vec)

create

public static Mat create(int comm)
Creates a matrix where the type is determined
from either a call to MatSetType() or from the options database
with a call to MatSetFromOptions(). The default matrix type is
AIJ, using the routines MatCreateSeqAIJ() or MatCreateMPIAIJ()
if you do not set a type in the options database. If you never
call MatSetType() or MatSetFromOptions() it will generate an
error when you try to use the matrix.

Parameters:
comm - MPI communicator
Returns:
the matrix
See Also:
createSeqAIJ(int, int, int, int[]), createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), #createSeqBDiag, #createMPIBDiag, createSeqDense(int, int, double[]), createMPIDense(int, int, int, int, int, double[]), #createMPIRowbs, createSeqBAIJ(int, int, int, int, int[]), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #createSeqSBAIJ, createMPISBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #convert

setSizes

public void setSizes(int m,
                     int n,
                     int M,
                     int N)
Sets the local and global sizes, and checks to determine compatibility

Parameters:
m - number of local rows (or PETSC_DECIDE)
n - number of local columns (or PETSC_DECIDE)
M - number of global rows (or PETSC_DETERMINE)
N - number of global columns (or PETSC_DETERMINE)
See Also:
getSize(), #PetscSplitOwnership

setFromOptions

public void setFromOptions()
Creates a matrix where the type is determined
from the options database. Generates a parallel MPI matrix if the
communicator has more than one processor. The default matrix type is
AIJ, using the routines MatCreateSeqAIJ() and MatCreateMPIAIJ() if
you do not select a type in the options database.

See Also:
createSeqAIJ(int, int, int, int[]), createMPIAIJ(int, int, int, int, int, int, int[], int, int[]), #createSeqBDiag, #createMPIBDiag, createSeqDense(int, int, double[]), createMPIDense(int, int, int, int, int, double[]), #createMPIRowbs, createSeqBAIJ(int, int, int, int, int[]), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #createSeqSBAIJ, createMPISBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #convert

aXPY

public void aXPY(double a,
                 Mat X,
                 MatStructure str)
Computes Y = a*X + Y.

Parameters:
a - the scalar multiplier
X - the first matrix
str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN
or SUBSET_NONZERO_PATTERN (nonzeros of X is a subset of Y's)
See Also:
aYPX(double, de.jtem.jpetsc.Mat, de.jtem.jpetsc.MatStructure)

shift

public void shift(double a)
Computes Y = Y + a I, where a is a PetscScalar and I is the identity matrix.

Parameters:
a - the PetscScalar
See Also:
diagonalSet(de.jtem.jpetsc.Vec, de.jtem.jpetsc.InsertMode)

diagonalSet

public void diagonalSet(Vec D,
                        InsertMode i)
Computes Y = Y + D, where D is a diagonal matrix
that is represented as a vector. Or Y[i,i] = D[i] if InsertMode is
INSERT_VALUES.

Parameters:
D - the diagonal matrix, represented as a vector
i - INSERT_VALUES or ADD_VALUES
Collective on Mat and Vec
See Also:
shift(double)

aYPX

public void aYPX(double a,
                 Mat X,
                 MatStructure str)
Computes Y = a*Y + X.

Parameters:
a - the PetscScalar multiplier
X - the second matrix
str - either SAME_NONZERO_PATTERN, DIFFERENT_NONZERO_PATTERN or SUBSET_NONZERO_PATTERN
See Also:
aXPY(double, de.jtem.jpetsc.Mat, de.jtem.jpetsc.MatStructure)

computeExplicitOperator

public Mat computeExplicitOperator()
Computes the explicit matrix

Returns:
the explict preconditioned operator

loadMat

public static Mat loadMat(java.lang.String outtype)
Loads a matrix that has been stored in binary format
with MatView(). The matrix format is determined from the options database.
Generates a parallel MPI matrix if the communicator has more than one
processor. The default matrix type is AIJ.

Parameters:
outtype - type of matrix desired, for example MATSEQAIJ,
MATMPIROWBS, etc. See types in petsc/include/petscmat.h.
Returns:
new matrix
See Also:
#PetscViewerBinaryOpen, view(), #VecLoad

multEqual

public boolean multEqual(Mat B,
                         int n)
Compares matrix-vector products of two matrices.

Parameters:
B - the second matrix
n - number of random vectors to be tested
Returns:
PETSC_TRUE if the products are equal; PETSC_FALSE otherwise.

multAddEqual

public boolean multAddEqual(Mat B,
                            int n)
Compares matrix-vector products of two matrices.

Parameters:
B - the second matrix
n - number of random vectors to be tested
Returns:
PETSC_TRUE if the products are equal; PETSC_FALSE otherwise.

multTransposeEqual

public boolean multTransposeEqual(Mat B,
                                  int n)
Compares matrix-vector products of two matrices.

Parameters:
B - the second matrix
n - number of random vectors to be tested
Returns:
PETSC_TRUE if the products are equal; PETSC_FALSE otherwise.

multTransposeAddEqual

public boolean multTransposeAddEqual(Mat B,
                                     int n)
Compares matrix-vector products of two matrices.

Parameters:
B - the second matrix
n - number of random vectors to be tested
Returns:
PETSC_TRUE if the products are equal; PETSC_FALSE otherwise.

setType

public void setType(java.lang.String matype)
Builds matrix object for a particular matrix type

Parameters:
matype - matrix type
See Also:
#PCSetType, #VecSetType, create(int), #type, Mat(int, int)

getType

public java.lang.String getType()
Gets the matrix type as a string from the matrix object.
Not Collective

Returns:
name of matrix type
See Also:
setType(java.lang.String)

realPart

public void realPart()
Zeros out the imaginary part of the matrix

See Also:
imaginaryPart()

imaginaryPart

public void imaginaryPart()
Moves the imaginary part of the matrix to the real part and zeros the imaginary part

See Also:
realPart()

conjugate

public void conjugate()
replaces the matrix values with their complex conjugates

See Also:
#VecConjugate

getRowUpperTriangular

public void getRowUpperTriangular()
Sets a flag to enable calls to MatGetRow() for matrix in MATSBAIJ format.
You should call MatRestoreRowUpperTriangular() after calling MatGetRow/MatRestoreRow() to disable the flag.
Not Collective

See Also:
#restoreRowRowUpperTriangular

restoreRowUpperTriangular

public void restoreRowUpperTriangular()
Disable calls to MatGetRow() for matrix in MATSBAIJ format.
Not Collective

See Also:
getRowUpperTriangular()

setOptionsPrefix

public void setOptionsPrefix(java.lang.String prefix)
Sets the prefix used for searching for all
Mat options in the database.

Parameters:
prefix - the prefix to prepend to all option names
See Also:
setFromOptions()

appendOptionsPrefix

public void appendOptionsPrefix(java.lang.String prefix)
Appends to the prefix used for searching for all
Mat options in the database.

Parameters:
prefix - the prefix to prepend to all option names
See Also:
#getOptionsPrefix

setUp

public void setUp()
Sets up the internal matrix data structures for the later use.

See Also:
create(int), destroy()

view

public void view()
Visualizes a matrix object.

See Also:
#PetscViewerSetFormat, #PetscViewerASCIIOpen, #PetscViewerDrawOpen, #PetscViewerSocketOpen, #PetscViewerBinaryOpen, PrimitivNative.load(java.lang.String)

setValues

public void setValues(int m,
                      int[] idxm,
                      int n,
                      int[] idxn,
                      double[] v,
                      InsertMode addv)
Inserts or adds a block of values into a matrix.
These values may be cached, so MatAssemblyBegin() and MatAssemblyEnd()
MUST be called after all calls to MatSetValues() have been completed.
Not Collective

Parameters:
m - the number of rows and their global indices
idxm - the number of rows and their global indices
n - the number of columns and their global indices
idxn - the number of columns and their global indices
v - a logically two-dimensional array of values
addv - either ADD_VALUES or INSERT_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
#setOption, assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValuesBlocked(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #InsertMode, #INSERTVALUES, #ADDVALUES

setValuesRowLocal

public void setValuesRowLocal(int row,
                              double[] v)
Inserts a row (block row for BAIJ matrices) of nonzero
values into a matrix
Not Collective

Parameters:
row - the (block) row to set
v - a logically two-dimensional array of values
See Also:
#setOption, assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValuesBlocked(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #InsertMode, #INSERTVALUES, #ADDVALUES, setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesRow(int, double[]), #setLocalToGlobalMapping

setValuesRow

public void setValuesRow(int row,
                         double[] v)
Inserts a row (block row for BAIJ matrices) of nonzero
values into a matrix
Not Collective

Parameters:
row - the (block) row to set
v - a logically two-dimensional array of values
See Also:
#setOption, assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValuesBlocked(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #InsertMode, #INSERTVALUES, #ADDVALUES, setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

setStencil

public void setStencil(int dim,
                       int[] dims,
                       int[] starts,
                       int dof)
Sets the grid information for setting values into a matrix via
MatSetValuesStencil()
Not Collective

Parameters:
dim - dimension of the grid 1, 2, or 3
dims - number of grid points in x, y, and z direction, including ghost points on your processor
starts - starting point of ghost nodes on your processor in x, y, and z direction
dof - number of degrees of freedom per node
Inspired by the structured grid interface to the HYPRE package
(www.llnl.gov/CASC/hyper)
For matrices generated with DAGetMatrix() this routine is automatically called and so not needed by the
user.
See Also:
#setOption, assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValuesBlocked(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #setValuesBlockedStencil, #setValuesStencil

setValuesBlocked

public void setValuesBlocked(int m,
                             int[] idxm,
                             int n,
                             int[] idxn,
                             double[] v,
                             InsertMode addv)
Inserts or adds a block of values into a matrix.
Not Collective

Parameters:
m - the number of block rows and their global block indices
idxm - the number of block rows and their global block indices
n - the number of block columns and their global block indices
idxn - the number of block columns and their global block indices
v - a logically two-dimensional array of values
addv - either ADD_VALUES or INSERT_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
#setOption, assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), setValuesBlockedLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

getValues

public void getValues(int m,
                      int[] idxm,
                      int n,
                      int[] idxn,
                      double[] v)
Gets a block of values from a matrix.
Not Collective; currently only returns a local block

Parameters:
m - the number of rows and their global indices
idxm - the number of rows and their global indices
n - the number of columns and their global indices
idxn - the number of columns and their global indices
v - a logically two-dimensional array for storing the values
See Also:
#getRow, #getSubMatrices, setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

setValuesLocal

public void setValuesLocal(int nrow,
                           int[] irow,
                           int ncol,
                           int[] icol,
                           double[] y,
                           InsertMode addv)
Inserts or adds values into certain locations of a matrix,
using a local ordering of the nodes.
Not Collective

Parameters:
nrow - number of rows and their local indices
irow - number of rows and their local indices
ncol - number of columns and their local indices
icol - number of columns and their local indices
y - a logically two-dimensional array of values
addv - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMapping, #setValueLocal

setValuesBlockedLocal

public void setValuesBlockedLocal(int nrow,
                                  int[] irow,
                                  int ncol,
                                  int[] icol,
                                  double[] y,
                                  InsertMode addv)
Inserts or adds values into certain locations of a matrix,
using a local ordering of the nodes a block at a time.
Not Collective

Parameters:
nrow - number of rows and their local indices
irow - number of rows and their local indices
ncol - number of columns and their local indices
icol - number of columns and their local indices
y - a logically two-dimensional array of values
addv - either INSERT_VALUES or ADD_VALUES, where
ADD_VALUES adds values to any existing entries, and
INSERT_VALUES replaces existing entries with new values
See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValuesLocal(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #setLocalToGlobalMappingBlock, setValuesBlocked(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode)

mult

public void mult(Vec x,
                 Vec y)
Computes the matrix-vector product, y = Ax.

Parameters:
x - the vector to be multiplied
y -
See Also:
multTranspose(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

multTranspose

public void multTranspose(Vec x,
                          Vec y)
Computes matrix transpose times a vector.

Parameters:
x - the vector to be multilplied
y -
See Also:
mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

multAdd

public void multAdd(Vec v1,
                    Vec v2,
                    Vec v3)
Computes v3 = v2 + A * v1.

Parameters:
v1 - the vectors
v2 - the vectors
v3 -
See Also:
multTranspose(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

multTransposeAdd

public void multTransposeAdd(Vec v1,
                             Vec v2,
                             Vec v3)
Computes v3 = v2 + A' * v1.

Parameters:
v1 - the vectors
v2 - the vectors
v3 -
See Also:
multTranspose(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

multConstrained

public void multConstrained(Vec x,
                            Vec y)
The inner multiplication routine for a
constrained matrix P^T A P.

Parameters:
x - the vector to be multilplied
y -
See Also:
mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), #multTrans, multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), #multTransAdd

multTransposeConstrained

public void multTransposeConstrained(Vec x,
                                     Vec y)
The inner multiplication routine for a
constrained matrix P^T A^T P.

Parameters:
x - the vector to be multilplied
y -
See Also:
mult(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), #multTrans, multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), #multTransAdd

copy

public void copy(Mat B,
                 MatStructure str)
Copys a matrix to another matrix.

Parameters:
B -
str - SAME_NONZERO_PATTERN or DIFFERENT_NONZERO_PATTERN
See Also:
#convert, duplicate(de.jtem.jpetsc.MatDuplicateOption)

duplicate

public Mat duplicate(MatDuplicateOption op)
Duplicates a matrix including the non-zero structure.

Parameters:
op - either MAT_DO_NOT_COPY_VALUES or MAT_COPY_VALUES, cause it to copy nonzero
values as well or not
Returns:
pointer to place new matrix
See Also:
copy(de.jtem.jpetsc.Mat, de.jtem.jpetsc.MatStructure), #convert

getDiagonal

public void getDiagonal(Vec v)
Gets the diagonal of a matrix.

Parameters:
v - the vector for storing the diagonal
See Also:
#getRow, #getSubMatrices, #getSubmatrix, getRowMaxAbs(de.jtem.jpetsc.Vec, int[])

getRowMin

public void getRowMin(Vec v,
                      int[] idx)
Gets the minimum value (of the real part) of each
row of the matrix

Parameters:
v -
idx -
See Also:
getDiagonal(de.jtem.jpetsc.Vec), #getSubMatrices, #getSubmatrix, getRowMaxAbs(de.jtem.jpetsc.Vec, int[]), getRowMax(de.jtem.jpetsc.Vec, int[])

getRowMax

public void getRowMax(Vec v,
                      int[] idx)
Gets the maximum value (of the real part) of each
row of the matrix

Parameters:
v -
idx -
See Also:
getDiagonal(de.jtem.jpetsc.Vec), #getSubMatrices, #getSubmatrix, getRowMaxAbs(de.jtem.jpetsc.Vec, int[]), getRowMin(de.jtem.jpetsc.Vec, int[])

getRowMaxAbs

public void getRowMaxAbs(Vec v,
                         int[] idx)
Gets the maximum value (in absolute value) of each
row of the matrix

Parameters:
v -
idx -
See Also:
getDiagonal(de.jtem.jpetsc.Vec), #getSubMatrices, #getSubmatrix, getRowMax(de.jtem.jpetsc.Vec, int[]), getRowMin(de.jtem.jpetsc.Vec, int[])

getRowSum

public void getRowSum(Vec v)
Gets the sum of each row of the matrix

Parameters:
v -
See Also:
getDiagonal(de.jtem.jpetsc.Vec), #getSubMatrices, #getSubmatrix, getRowMax(de.jtem.jpetsc.Vec, int[]), getRowMin(de.jtem.jpetsc.Vec, int[])

transpose

public Mat transpose()
Computes an in-place or out-of-place transpose of a matrix.

Returns:
the transpose
See Also:
multTranspose(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), #isTranspose

equal

public boolean equal(Mat B)
Compares two matrices.

Parameters:
B - the second matrix
Returns:
PETSC_TRUE if the matrices are equal; PETSC_FALSE otherwise.

diagonalScale

public void diagonalScale(Vec l,
                          Vec r)
Scales a matrix on the left and right by diagonal
matrices that are stored as vectors. Either of the two scaling
matrices can be PETSC_NULL.

Parameters:
l - the left scaling vector (or PETSC_NULL)
r - the right scaling vector (or PETSC_NULL)
See Also:
scale(double)

scale

public void scale(double a)
Scales all elements of a matrix by a given number.

Parameters:
a - the scaling value
See Also:
diagonalScale(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

norm

public double norm(NormType type)
Calculates various norms of a matrix.

Parameters:
type - the type of norm, NORM_1, NORM_FROBENIUS, NORM_INFINITY
Returns:
the resulting norm

assemblyBegin

public void assemblyBegin(MatAssemblyType type)
Begins assembling the matrix. This routine should
be called after completing all calls to MatSetValues().

Parameters:
type - type of assembly, either MAT_FLUSH_ASSEMBLY or MAT_FINAL_ASSEMBLY
See Also:
assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), assembled()

assembled

public boolean assembled()
Indicates if a matrix has been assembled and is ready for
use; for example, in matrix-vector product.

Returns:
PETSC_TRUE or PETSC_FALSE
See Also:
assemblyEnd(de.jtem.jpetsc.MatAssemblyType), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), assemblyBegin(de.jtem.jpetsc.MatAssemblyType)

assemblyEnd

public void assemblyEnd(MatAssemblyType type)
Completes assembling the matrix. This routine should
be called after MatAssemblyBegin().

Parameters:
type - type of assembly, either MAT_FLUSH_ASSEMBLY or MAT_FINAL_ASSEMBLY
See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), setValues(int, int[], int, int[], double[], de.jtem.jpetsc.InsertMode), #PetscDrawOpenX, view(), assembled(), #PetscViewerSocketOpen

compress

public void compress()
Tries to store the matrix in as little space as
possible. May fail if memory is already fully used, since it
tries to allocate new space.


zeroEntries

public void zeroEntries()
Zeros all entries of a matrix. For sparse matrices
this routine retains the old nonzero structure.

See Also:
zeroRows(int, int[], double)

zeroRows

public void zeroRows(int numRows,
                     int[] rows,
                     double diag)
Zeros all entries (except possibly the main diagonal)
of a set of rows of a matrix.

Parameters:
numRows - the number of rows to remove
rows - the global row indices
diag - value put in all diagonals of eliminated rows
See Also:
#zeroRowsIS, zeroEntries(), zeroRowsLocal(int, int[], double), #setOption

zeroRowsLocal

public void zeroRowsLocal(int numRows,
                          int[] rows,
                          double diag)
Zeros all entries (except possibly the main diagonal)
of a set of rows of a matrix; using local numbering of rows.

Parameters:
numRows - the number of rows to remove
rows - the global row indices
diag - value put in all diagonals of eliminated rows
See Also:
zeroRows(int, int[], double), #zeroRowsLocalIS, zeroEntries(), zeroRows(int, int[], double), #setLocalToGlobalMapping

getSize

public Mat.GetSizeResult getSize()
Returns the numbers of rows and columns in a matrix.
Not Collective

Returns:
Mat.GetSizeResult
See Also:
getLocalSize()

getLocalSize

public Mat.GetLocalSizeResult getLocalSize()
Returns the number of rows and columns in a matrix
stored locally. This information may be implementation dependent, so
use with care.
Not Collective

Returns:
Mat.GetLocalSizeResult
See Also:
getSize()

getOwnershipRange

public Mat.GetOwnershipRangeResult getOwnershipRange()
Returns the range of matrix rows owned by
this processor, assuming that the matrix is laid out with the first
n1 rows on the first processor, the next n2 rows on the second, etc.
For certain parallel layouts this range may not be well defined.
Not Collective

Returns:
Mat.GetOwnershipRangeResult
See Also:
#getOwnershipRanges

getBlockSize

public int getBlockSize()
Returns the matrix block size; useful especially for the
block row and block diagonal formats.
Not Collective

Returns:
block size
See Also:
createSeqBAIJ(int, int, int, int, int[]), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #createSeqBDiag, #createMPIBDiag

setBlockSize

public void setBlockSize(int bs)
Sets the matrix block size; for many matrix types you
cannot use this and MUST set the blocksize when you preallocate the matrix
Not Collective

Parameters:
bs - block size
See Also:
createSeqBAIJ(int, int, int, int, int[]), createMPIBAIJ(int, int, int, int, int, int, int, int[], int, int[]), #createSeqBDiag, #createMPIBDiag, getBlockSize()

stashSetInitialSize

public void stashSetInitialSize(int size,
                                int bsize)
sets the sizes of the matrix stash, that is
used during the assembly process to store values that belong to
other processors.
Not Collective

Parameters:
size - the initial size of the stash.
bsize - the initial size of the block-stash(if used).

interpolateAdd

public void interpolateAdd(Vec x,
                           Vec y,
                           Vec w)
w = y + A*x or A'*x depending on the shape of
the matrix

Parameters:
x - the vectors
y - the vectors
w - where the result is stored
See Also:
multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), restrict(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

interpolate

public void interpolate(Vec x,
                        Vec y)
y = A*x or A'*x depending on the shape of
the matrix

Parameters:
x - the vectors
y - the vectors
See Also:
multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), restrict(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

restrict

public void restrict(Vec x,
                     Vec y)
y = A*x or A'*x

Parameters:
x - the vectors
y - the vectors
See Also:
multAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), multTransposeAdd(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec), interpolate(de.jtem.jpetsc.Vec, de.jtem.jpetsc.Vec)

getInertia

public Mat.GetInertiaResult getInertia()
Gets the inertia from a factored matrix

Returns:
Mat.GetInertiaResult

isSymmetric

public boolean isSymmetric(double tol)
Test whether a matrix is symmetric

Parameters:
tol - difference between value and its transpose less than this amount counts as equal (use 0.0 for exact transpose)
Returns:
the result
See Also:
transpose(), #isTranspose, isHermitian(), isStructurallySymmetric(), #setOption, isSymmetricKnown()

isSymmetricKnown

public Mat.IsSymmetricKnownResult isSymmetricKnown()
Checks the flag on the matrix to see if it is symmetric.

Returns:
Mat.IsSymmetricKnownResult
See Also:
transpose(), #isTranspose, isHermitian(), isStructurallySymmetric(), #setOption, isSymmetric(double)

isHermitianKnown

public Mat.IsHermitianKnownResult isHermitianKnown()
Checks the flag on the matrix to see if it is hermitian.

Returns:
Mat.IsHermitianKnownResult
See Also:
transpose(), #isTranspose, isHermitian(), isStructurallySymmetric(), #setOption, isSymmetric(double)

isStructurallySymmetric

public boolean isStructurallySymmetric()
Test whether a matrix is structurally symmetric

Returns:
the result
See Also:
transpose(), #isTranspose, isHermitian(), isSymmetric(double), #setOption

isHermitian

public boolean isHermitian()
Test whether a matrix is Hermitian, i.e. it is the complex conjugate of its transpose.

Returns:
the result
See Also:
transpose(), #isTranspose, isSymmetric(double), isStructurallySymmetric(), #setOption

stashGetInfo

public Mat.StashGetInfoResult stashGetInfo()
Gets how many values are currently in the vector stash, i.e. need
to be communicated to other processors during the MatAssemblyBegin/End() process
Not collective

Returns:
Mat.StashGetInfoResult
See Also:
assemblyBegin(de.jtem.jpetsc.MatAssemblyType), assemblyEnd(de.jtem.jpetsc.MatAssemblyType), Mat(int, int), stashSetInitialSize(int, int)

getVecs

public Mat.GetVecsResult getVecs()
Get vector(s) compatible with the matrix, i.e. with the same
parallel layout

Returns:
Mat.GetVecsResult
See Also:
create(int)

ptAPNumeric

public void ptAPNumeric(Mat P,
                        Mat C)
Computes the matrix projection C = P^T * A * P

Parameters:
P - the projection matrix
C -
See Also:
#ptAP, #ptAPSymbolic, matMultNumeric(de.jtem.jpetsc.Mat, de.jtem.jpetsc.Mat)

matMultSymbolic

public Mat matMultSymbolic(Mat B,
                           double fill)
Performs construction, preallocation, and computes the ij structure
of the matrix-matrix product C=A*B. Call this routine before calling MatMatMultNumeric().

Parameters:
B - the right matrix
fill - expected fill as ratio of nnz(C)/(nnz(A) + nnz(B))
Returns:
the matrix containing the ij structure of product matrix
See Also:
#matMult, matMultNumeric(de.jtem.jpetsc.Mat, de.jtem.jpetsc.Mat)

matMultNumeric

public void matMultNumeric(Mat B,
                           Mat C)
Performs the numeric matrix-matrix product.
Call this routine after first calling MatMatMultSymbolic().

Parameters:
B - the right matrix
C -
See Also:
#matMult, matMultSymbolic(de.jtem.jpetsc.Mat, double)