Skip to main content
`Ctrl`+`K`

# MatDiagonalScale

Scales a matrix on the left and right by diagonal matrices that are stored as vectors. Either of the two scaling matrices can be `NULL`.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatDiagonalScale(Mat mat, Vec l, Vec r)

Collective

## Input Parameters

- mat - the matrix to be scaled

- l - the left scaling vector (or `NULL`)

- r - the right scaling vector (or `NULL`)

## Note

`MatDiagonalScale()` computes \(A = LAR\), where L = a diagonal matrix (stored as a vector), R = a diagonal matrix (stored as a vector) The L scales the rows of the matrix, the R scales the columns of the matrix.

## See Also

Matrices, `Mat`, `MatScale()`, `MatShift()`, `MatDiagonalSet()`

## Level

intermediate

## Location

src/mat/interface/matrix.c

## Examples

src/tao/pde_constrained/tutorials/elliptic.c
src/tao/unconstrained/tutorials/burgers_spectral.c
src/tao/unconstrained/tutorials/spectraladjointassimilation.c
src/snes/tutorials/ex70.c
src/tao/pde_constrained/tutorials/parabolic.c
src/tao/pde_constrained/tutorials/hyperbolic.c
src/ts/tutorials/ex50.c

## Implementations

MatDiagonalScale_MPIAIJ() in src/mat/impls/aij/mpi/mpiaij.c
MatDiagonalScale_SeqAIJ() in src/mat/impls/aij/seq/aij.c
MatDiagonalScale_SeqAIJKokkos() in src/mat/impls/aij/seq/kokkos/aijkok.kokkos.cxx
MatDiagonalScale_MPIBAIJ() in src/mat/impls/baij/mpi/mpibaij.c
MatDiagonalScale_SeqBAIJ() in src/mat/impls/baij/seq/baij2.c
MatDiagonalScale_SeqBAIJMKL() in src/mat/impls/baij/seq/baijmkl/baijmkl.c
MatDiagonalScale_MPIDense() in src/mat/impls/dense/mpi/mpidense.c
MatDiagonalScale_SeqDense() in src/mat/impls/dense/seq/dense.c
MatDiagonalScale_Diagonal() in src/mat/impls/diagonal/diagonal.c
MatDiagonalScale_Elemental() in src/mat/impls/elemental/matelem.cxx
MatDiagonalScale_IS() in src/mat/impls/is/matis.c
MatDiagonalScale_Nest() in src/mat/impls/nest/matnest.c
MatDiagonalScale_MPISBAIJ() in src/mat/impls/sbaij/mpi/mpisbaij.c
MatDiagonalScale_SeqSBAIJ() in src/mat/impls/sbaij/seq/sbaij2.c
MatDiagonalScale_ScaLAPACK() in src/mat/impls/scalapack/matscalapack.c
MatDiagonalScale_MPISELL() in src/mat/impls/sell/mpi/mpisell.c
MatDiagonalScale_SeqSELL() in src/mat/impls/sell/seq/sell.c
MatDiagonalScale_Shell() in src/mat/impls/shell/shell.c
MatDiagonalScale_SubMatrix() in src/mat/impls/submat/submat.c

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