[vtkusers] Crash using vtkMath::RandomSeed
Dean Inglis
dean.inglis at camris.ca
Thu Jan 14 15:47:29 EST 2010
Hi Francois,
instanitating and using a
vtkMinimalStandardRandomSequence
works fine so I concur with your suspicion re
a static vs shared build problem. No idea what
to do here though...
Dean
>It sounds like in static build the static protected member of vtkMath
>is not created:
>vtkMath.h has:
>class vtkMath
>{
>protected:
>static vtkMathInternal Internal;
>};
>vtkMath.cxx has the following line that should create the internal
>object and call its constructor:
>vtkMathInternal vtkMath::Internal;
>Any idea to solve this issue is welcome....
On Thu, Jan 14, 2010 at 12:17 PM, Dean Inglis <dean.inglis at camris.ca>
wrote:
> 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