Mat Interface

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

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)

source

PetscDestroy for AbstractMatrix. No-op

source
PETSc2.PetscViewFunction.

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

source

Begin matrix assembly for PetscMat. No-op for Julia matrices

Inputs

source

Counterpart of assembly_end

Inputs

  • mat: AbstractMatrix

  • flg: type of matrix assembly

source

Adds the specified value to the diagonal of the matrix

Inputs

  • A: the matrix

  • a: the value

source
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

source

Method for AbstractMatrix

source

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

source

Returns the rows owned by this process (1-based)

Inputs

  • A: a matrix

Outputs

  • rng: a UnitRange

source
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

source

Method for AbstractMatrix

source

Method for SparseMatrixCSC

source
PETSc2.size_globalMethod.

Global size of matrix, same as size_local() for serial matrices

Inputs

  • A: AbstractMatrix

source
PETSc2.size_localMethod.

Size of local part of matrix

Inputs

  • A: AbstractMatrix

source

Computes b = A*x

source

Computes b = A.'*x

source
Base.LinAlg.normMethod.

Norm for Petsc matrices, 1, 2, and infinity norms supported

source
Base.LinAlg.scale!Method.

scale! for Petsc matrix

source

Frobenius norm, consistent with Julias interface

source