petsc-3.10.5 2019-03-28
Report Typos and Errors

# MatSetRandom

Sets all components of a matrix to random numbers. For sparse matrices that have been preallocated it randomly selects appropriate locations

### Synopsis

    #include "petscmat.h"
    PetscErrorCode MatSetRandom(Mat x,PetscRandom rctx)

Logically Collective on Mat

### Input Parameters

| x | - the matrix
| rctx | - the random number context, formed by PetscRandomCreate(), or NULL and it will create one internally.

### Output Parameter

x -the matrix

### Example of Usage

         PetscRandomCreate(PETSC_COMM_WORLD,&rctx);
         MatSetRandom(x,rctx);
         PetscRandomDestroy(rctx);

### See Also

MatZeroEntries(), MatSetValues(), PetscRandomCreate(), PetscRandomDestroy()

### Level

intermediate

### Location

src/mat/interface/matrix.c

### Implementations

MatSetRandom_MPIAIJ in src/mat/impls/aij/mpi/mpiaij.c
MatSetRandom_SeqAIJ in src/mat/impls/aij/seq/aij.c
MatSetRandom_MPIDense in src/mat/impls/dense/mpi/mpidense.c
MatSetRandom_SeqDense in src/mat/impls/dense/seq/dense.c
MatSetRandom_Nest in src/mat/impls/nest/matnest.c
MatSetRandom_MPISELL in src/mat/impls/sell/mpi/mpisell.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages