petsc-3.9.4 2018-09-11
Report Typos and Errors

MatShift

Computes Y = Y + a I, where a is a PetscScalar and I is the identity matrix.

Synopsis

#include "petscmat.h"  
PetscErrorCode  MatShift(Mat Y,PetscScalar a)
Neighbor-wise Collective on Mat

Input Parameters

Y - the matrices
a - the PetscScalar

Notes: If the matrix Y is missing some diagonal entries this routine can be very slow. To make it fast one should initially fill the matrix so that all diagonal entries have a value (with a value of zero for those locations that would not have an entry).

To form Y = Y + diag(V) use MatDiagonalSet()

Developers Note: If the local "diagonal part" of the matrix Y has no entries then the local diagonal part is preallocated with 1 nonzero per row for the to be added values. This allows for fast shifting of an empty matrix.

Keywords

matrix, add, shift

See Also

MatDiagonalSet(), MatScale(), MatDiagonalScale()

Level

intermediate

Location

src/mat/utils/axpy.c

Examples

src/mat/examples/tutorials/ex9.c.html
src/ts/examples/tutorials/ex3.c.html
src/tao/pde_constrained/examples/tutorials/parabolic.c.html
src/tao/pde_constrained/examples/tutorials/hyperbolic.c.html

Implementations

MatShift_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatShift_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatShift_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c
MatShift_SeqBAIJ in src/mat/impls/baij/seq/baij.c
MatShift_IS in src/mat/impls/is/matis.c
MatShift_MFFD in src/mat/impls/mffd/mffd.c
MatShift_Nest in src/mat/impls/nest/matnest.c
MatShift_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c
MatShift_SeqSBAIJ in src/mat/impls/sbaij/seq/sbaij.c
MatShift_MPISELL in src/mat/impls/sell/mpi/mpisell.c
MatShift_SeqSELL in src/mat/impls/sell/seq/sell.c
MatShift_Shell in src/mat/impls/shell/shell.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages