# MatSOR
Computes relaxation (SOR, Gauss-Seidel) sweeps. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatSOR(Mat mat, Vec b, PetscReal omega, MatSORType flag, PetscReal shift, PetscInt its, PetscInt lits, Vec x)
```
Neighbor-wise Collective on mat


## Input Parameters

- ***mat -*** the matrix
- ***b -*** the right hand side
- ***omega -*** the relaxation factor
- ***flag -*** flag indicating the type of SOR (see below)
- ***shift -*** diagonal shift
- ***its -*** the number of iterations
- ***lits -*** the number of local iterations



## Output Parameter

- ***x -*** the solution (can contain an initial guess, use option `SOR_ZERO_INITIAL_GUESS` to indicate no guess)



## SOR Flags

- ***`SOR_FORWARD_SWEEP` -*** forward SOR
- ***`SOR_BACKWARD_SWEEP` -*** backward SOR
- ***`SOR_SYMMETRIC_SWEEP` -*** SSOR (symmetric SOR)
- ***`SOR_LOCAL_FORWARD_SWEEP` -*** local forward SOR
- ***`SOR_LOCAL_BACKWARD_SWEEP` -*** local forward SOR
- ***`SOR_LOCAL_SYMMETRIC_SWEEP` -*** local SSOR
- ***`SOR_EISENSTAT` -*** SOR with Eisenstat trick
- ***`SOR_APPLY_UPPER`, `SOR_APPLY_LOWER` -*** applies
upper/lower triangular part of matrix to
vector (with omega)
- ***`SOR_ZERO_INITIAL_GUESS` -*** zero initial guess



## Notes
`SOR_LOCAL_FORWARD_SWEEP`, `SOR_LOCAL_BACKWARD_SWEEP`, and
`SOR_LOCAL_SYMMETRIC_SWEEP` perform separate independent smoothings
on each processor.

Application programmers will not generally use `MatSOR()` directly,
but instead will employ the `KSP`/`PC` interface.

For `MATBAIJ`, `MATSBAIJ`, and `MATAIJ` matrices with Inodes this does a block SOR smoothing, otherwise it does a pointwise smoothing

Most users should employ the `KSP` interface for linear solvers
instead of working directly with matrix algebra routines such as this.
See, e.g., `KSPCreate()`.

Vectors x and b CANNOT be the same


## Notes for Advanced Users
The flags are implemented as bitwise inclusive or operations.
For example, use (`SOR_ZERO_INITIAL_GUESS` | `SOR_SYMMETRIC_SWEEP`)
to specify a zero initial guess for SSOR.


## Developer Note
We should add block SOR support for `MATAIJ` matrices with block size set to great than one and no inodes




## See Also
 `Mat`, `MatMult()`, `KSP`, `PC`, `MatGetFactor()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/interface/matrix.c.html#MatSOR">src/mat/interface/matrix.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/pde_constrained/tutorials/hyperbolic.c.html">src/tao/pde_constrained/tutorials/hyperbolic.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/pde_constrained/tutorials/parabolic.c.html">src/tao/pde_constrained/tutorials/parabolic.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/mpi/mpiaij.c.html#MatSOR_MPIAIJ">MatSOR_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aij.c.html#MatSOR_SeqAIJ">MatSOR_SeqAIJ in src/mat/impls/aij/seq/aij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/aij/seq/aijsell/aijsell.c.html#MatSOR_SeqAIJSELL">MatSOR_SeqAIJSELL in src/mat/impls/aij/seq/aijsell/aijsell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/mpi/mpibaij.c.html#MatSOR_MPIBAIJ">MatSOR_MPIBAIJ in src/mat/impls/baij/mpi/mpibaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/baij/seq/baij.c.html#MatSOR_SeqBAIJ">MatSOR_SeqBAIJ in src/mat/impls/baij/seq/baij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/blockmat/seq/blockmat.c.html#MatSOR_BlockMat">MatSOR_BlockMat in src/mat/impls/blockmat/seq/blockmat.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/cdiagonal/cdiagonal.c.html#MatSOR_ConstantDiagonal">MatSOR_ConstantDiagonal in src/mat/impls/cdiagonal/cdiagonal.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/dense/seq/dense.c.html#MatSOR_SeqDense">MatSOR_SeqDense in src/mat/impls/dense/seq/dense.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/kaij/kaij.c.html#MatSOR_SeqKAIJ">MatSOR_SeqKAIJ in src/mat/impls/kaij/kaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sbaij/mpi/mpisbaij.c.html#MatSOR_MPISBAIJ">MatSOR_MPISBAIJ in src/mat/impls/sbaij/mpi/mpisbaij.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sbaij/seq/relax.h.html#MatSOR_SeqSBAIJ">MatSOR_SeqSBAIJ in src/mat/impls/sbaij/seq/relax.h</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/mpi/mpisell.c.html#MatSOR_MPISELL">MatSOR_MPISELL in src/mat/impls/sell/mpi/mpisell.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/sell/seq/sell.c.html#MatSOR_SeqSELL">MatSOR_SeqSELL in src/mat/impls/sell/seq/sell.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/interface/matrix.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
