[vtkusers] Crash using vtkMath::RandomSeed
Dean Inglis
dean.inglis at camris.ca
Thu Jan 14 12:17:57 EST 2010
Im using vtkMath::RandomSeed( long s ) to generate
a random sequence of numbers uniformly distributed between 0 and 1
(VTK latest CVS, static Release build , Win32 Vista, VSExpress 2005).
I get a crash when I run this simple command line app:
int main( int argc, char* argv[])
{
vtkMath::RandomSeed(123);
return EXIT_SUCCESS:
}
The documentation in vtkMath.h says
// Description:
// Initialize seed value. NOTE: Random() has the bad property that
// the first random number returned after RandomSeed() is called
// is proportional to the seed value! To help solve this, call
// RandomSeed() a few times inside seed. This doesn't ruin the
// repeatability of Random().
//
// DON'T USE Random(), RandomSeed(), GetSeed(), Gaussian()
// THIS IS STATIC SO THIS IS PRONE TO ERRORS (SPECIAL FOR REGRESSION
TESTS)
// THIS IS HERE FOR BACKWARD COMPATIBILITY ONLY.
// Instead, for a sequence of random numbers with a uniform distribution
// create a vtkMinimalStandardRandomSequence object.
// For a sequence of random numbers with a gaussian/normal distribution
// create a vtkBoxMuellerRandomSequence object.
static void RandomSeed(int s);
however, in vtkMath.cxx, RandomSeed just calls an internally maintained
vtkMinimalStandardRandomSequence:
void vtkMath::RandomSeed(int s)
{
vtkMath::Internal.Uniform->SetSeed(s);
}
any ideas what is going on here? Has anyone else experience this problem?
Dean
More information about the vtkusers
mailing list