petsc-3.7.1 2016-05-15
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 Vec Many br

### Input Parameters

| x | - the vector Many br
| rctx | - the random number context, formed by PetscRandomCreate(), or NULL and Many brit will create one internally. Many br

### Output Parameter

x -the vector Many br

### Example of Usage

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

Many br

Many br

### See Also

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

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