Mat Interface
This page describes an interface that is efficiently implemented for both Array, SparseMatrixCSC, and Petscmat. In some cases, Base functions are extended with new methods, in other cases new functions are defined for the supported matrix types. Using these functions allows some amount of generic programming.
PETSc2.PetscMat — Method.Constructor
Inputs
mglobal: first dimension global size (or PETSC_DECIDE)
nglobal: second dimension global size (or PETSC_DECIDE)
format: matrix format
comm: MPI communicator
Keyword Arguments
mlocal: first dimension local size (or PETSC_DECIDE)
nlocal: second dimension local size (or PETSC_DECIDE)
PETSc2.PetscDestroy — Method.PetscDestroy for AbstractMatrix. No-op
PETSc2.PetscView — Function.Print a non-Petsc matrix to a given IO (a Julia IO, not a Petsc IO)
Inputs
A: the matrix
f: an IO, default STDOUT
PETSc2.assembly_begin — Method.Begin matrix assembly for PetscMat. No-op for Julia matrices
Inputs
mat: AbstractMatrix
flag: type of matrix assembly (see
MatAssemblyBegin
PETSc2.assembly_end — Method.PETSc2.diagonal_shift! — Method.Adds the specified value to the diagonal of the matrix
Inputs
A: the matrix
a: the value
PETSc2.fill_zero! — Method.Fill the matrix with zeros. The sparsity pattern of the matrix (if applicable) should be defined before this function is called
Inputs
A: AbstractMatrix
PETSc2.get_values1! — Method.Method for AbstractMatrix
PETSc2.get_values1! — Method.Like set_values1!, but retrieves values. See that function for the meanings of the arguments. Note that Petsc does not support getting values for the non-local block of the matrix
Inputs
mat: a matrix, can be a Petsc matrix or a julia matrix
Inputs/Outputs
idxm
idxn
vals
Aliasing restrictions: idxm and idxn cannot alias
PETSc2.local_indices — Method.Returns the rows owned by this process (1-based)
Inputs
A: a matrix
Outputs
rng: a UnitRange
PETSc2.set_values1! — Function.1-based indexing for both regular and Pets matrices. Note that Petsc treats arrays at being row-major, so it is recommened to set MatSetOption(mat, MAT_ROW_ORIENTED, PETSC_FALSE) before using this function.
Inputs
flag: INSERT_VALUES or ADD_VALUES. Note that the first one result in non-deterministic behavior in parallel (in the general case)
vals: the values, must be length(idxm) x length(idxn)
Inputs/Outputs
mat: a matrix, can be a Petsc matrix or a julia matrix
idxm: the row numbers
idxn: the column numbers
Note that idxm and idxn are listed as input/outputs because they may be modified by this function, however when the function returns they will have the same values as on entry. This is needed to accomodate the fact that Petsc uses 1 based indexing internally.
This function is optimized for PetscMat and SparseMatrixCSC
Aliasing restriction: idxm and idxn cannot alias
PETSc2.set_values1! — Method.Method for AbstractMatrix
PETSc2.set_values1! — Method.Method for SparseMatrixCSC
PETSc2.size_global — Method.Global size of matrix, same as size_local() for serial matrices
Inputs
A: AbstractMatrix
PETSc2.size_local — Method.Size of local part of matrix
Inputs
A: AbstractMatrix
Base.LinAlg.A_mul_B! — Method.Computes b = A*x
Base.LinAlg.At_mul_B! — Method.Computes b = A.'*x
Base.LinAlg.norm — Method.Norm for Petsc matrices, 1, 2, and infinity norms supported
Base.LinAlg.scale! — Method.scale! for Petsc matrix
Base.LinAlg.vecnorm — Method.Frobenius norm, consistent with Julias interface