<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Feng XING,</span><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
I use Petsc random number generator. Every time I launch the code I get same random number, the code is like this:<br>
<br>
  PetscRandom rnd;<br>
  PetscRandomCreate(PETSC_COMM_<u></u>WORLD,&rnd);<br>
  PetscRandomSetType(rnd,<u></u>PETSCRAND);<br>
<br>
  PetscScalar r;<br>
  PetscRandomGetValue(rnd,&r);<br>
<br>
I would like to ask two questions. How could I get different random number?</blockquote><div> </div><div style>You can use </div><div style>PetscRandomSetSeed() and PetscRandomSeed().<br></div><div style>See an example:</div>
<div style>petsc/src/dm/impls/plex/examples/tests/ex6.c<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
And what's the difference bewteen PETSCRAND and PETSCRAND48?<br></blockquote><div> </div><div style>Two different random number generators, see</div><div style><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscRandomType.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscRandomType.html</a><br>
</div><div style><br></div><div style>Hong </div></div><br></div></div></div>