:orphan:
# TaoSetResidualWeights
Give weights for the residual values. A vector can be used if only diagonal terms are used, otherwise a matrix can be give. If this function is not provided, or if `sigma_v` and `vals` are both `NULL`, then the identity matrix will be used for weights. 
## Synopsis
```
#include "petsctao.h" 
PetscErrorCode TaoSetResidualWeights(Tao tao, Vec sigma_v, PetscInt n, PetscInt *rows, PetscInt *cols, PetscReal *vals)
```
Collective


## Input Parameters

- ***tao -*** the `Tao` context
- ***sigma_v -*** vector of weights (diagonal terms only)
- ***n       -*** the number of weights (if using off-diagonal)
- ***rows    -*** index list of rows for `sigma_v`
- ***cols    -*** index list of columns for `sigma_v`
- ***vals -*** array of weights





## Note
Either `sigma_v` or `vals` should be `NULL`


## See Also
 [](ch_tao), `Tao`, `TaoSetResidualRoutine()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/interface/taosolver_fg.c.html#TaoSetResidualWeights">src/tao/interface/taosolver_fg.c</A>


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


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