# MatCreateADA
Creates a matrix M=A^T D1 A + D2 where D1, D2 are diagonal 
## Synopsis
```
#include "petscmat.h"  
PetscErrorCode MatCreateADA(Mat mat, Vec d1, Vec d2, Mat *J)
```
Collective


## Input Parameters

- ***mat -*** matrix of arbitrary type
- ***d1 -*** A vector defining a diagonal matrix
- ***d2 -*** A vector defining a diagonal matrix



## Output Parameters

- ***J -*** New matrix whose operations are defined in terms of mat, D1, and D2.





## Note
The user provides the input data and is responsible for destroying
this data after matrix J has been destroyed.


## See Also
 `Mat`, `MatCreate()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/matrix/adamat.c.html#MatCreateADA">src/tao/matrix/adamat.c</A>


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


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