petsc-3.7.1 2016-05-15
Report Typos and Errors

# MatConvert

Converts a matrix to another matrix, either of the same or different type.

### Synopsis

    #include "petscmat.h"
    PetscErrorCode MatConvert(Mat mat, MatType newtype,MatReuse reuse,Mat *M)

Collective on Mat Many br

### Input Parameters

| mat | - the matrix Many br
| newtype | - new matrix type. Use MATSAME to create a new matrix of the Many brsame type as the original matrix. Many br
| reuse | - denotes if the destination matrix is to be created or reused. Many brUse MAT_INPLACE_MATRIX for inplace conversion, otherwise use Many brMAT_INITIAL_MATRIX or MAT_REUSE_MATRIX. Many br

### Output Parameter

M -pointer to place new matrix Many br

### Notes

MatConvert() first creates a new matrix and then copies the data from Many brthe first matrix. A related routine is MatCopy(), which copies the matrix Many brentries of one matrix to another already existing matrix context. Many br

Cannot be used to convert a sequential matrix to parallel or parallel to sequential, Many brthe MPI communicator of the generated matrix is always the same as the communicator Many brof the input matrix. Many br

Many br

### See Also

MatCopy(), MatDuplicate()

Level:intermediate
Location:src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex6f.F.html
src/snes/examples/tutorials/ex28.c.html