[petsc-users] Same random number

Hong Zhang hzhang at mcs.anl.gov
Wed Nov 20 09:52:55 CST 2013


Feng XING,

>
> I use Petsc random number generator. Every time I launch the code I get
> same random number, the code is like this:
>
>   PetscRandom rnd;
>   PetscRandomCreate(PETSC_COMM_WORLD,&rnd);
>   PetscRandomSetType(rnd,PETSCRAND);
>
>   PetscScalar r;
>   PetscRandomGetValue(rnd,&r);
>
> I would like to ask two questions. How could I get different random number?


You can use
PetscRandomSetSeed() and PetscRandomSeed().
See an example:
petsc/src/dm/impls/plex/examples/tests/ex6.c


> And what's the difference bewteen PETSCRAND and PETSCRAND48?
>

Two different random number generators, see
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscRandomType.html

Hong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131120/fbcccd45/attachment.html>


More information about the petsc-users mailing list