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

Input Parameters#

  • Y - the matrices

  • a - the PetscScalar

Notes#

If Y is a rectangular matrix, the shift is done on the main diagonal Y_{ii} of the matrix (https://en.wikipedia.org/wiki/Main_diagonal)

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). No operation is performed when a is zero.

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

See Also#

MatDiagonalSet(), MatScale(), MatDiagonalScale()

Level#

intermediate

Location#

src/mat/utils/axpy.c

Examples#

src/ksp/ksp/tutorials/ex1.c.html
src/ksp/ksp/tutorials/ex27.c.html
src/ksp/ksp/tutorials/ex79.c.html
src/ksp/ksp/tutorials/ex81.c.html
src/ksp/ksp/tutorials/ex82.c.html
src/snes/tutorials/ex20.c.html
src/ts/tutorials/ex16fwd.c.html
src/ts/tutorials/ex20fwd.c.html
src/ts/tutorials/ex3.c.html
src/tao/constrained/tutorials/tomographyADMM.c.html
src/tao/pde_constrained/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_ConstantDiagonal in src/mat/impls/cdiagonal/cdiagonal.c
MatShift_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatShift_MPIDenseCUDA in src/mat/impls/dense/mpi/mpidense.c
MatShift_MPIDenseHIP in src/mat/impls/dense/mpi/mpidense.c
MatShift_SeqDenseCUDA in src/mat/impls/dense/seq/cuda/densecuda.cu
MatShift_SeqDense in src/mat/impls/dense/seq/dense.c
MatShift_SeqDenseHIP in src/mat/impls/dense/seq/hip/densehip.hip.c
MatShift_IS in src/mat/impls/is/matis.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_ScaLAPACK in src/mat/impls/scalapack/matscalapack.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
MatShift_SubMatrix in src/mat/impls/submat/submat.c


Edit on GitLab

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