[vtkusers] Crash using vtkMath::RandomSeed

Francois Bertel francois.bertel at kitware.com
Thu Jan 14 12:50:38 EST 2010


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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list