|
Boost : |
From: SourceForge.net (noreply_at_[hidden])
Date: 2005-02-02 19:08:26
Bugs item #1115124, was opened at 2005-02-02 16:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1115124&group_id=7586
Category: random
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Morgan (toth21)
Assigned to: Jens Maurer (jmaurer)
Summary: Diff in state of mersenne_twister gen between GCC3.41 & CW9
Initial Comment:
I have found a bug with the mersenne_twister random
number generator class, where results when calling for a
random number vary between codewarrior 9.0 and gcc
3.4.1 with boost 1.31.0.
A simple example is shown below:
#include <boost/random/mersenne_twister.hpp>
//for mt11213b
typedef boost::mt11213b base_generator_type;
class foo
{
public:
foo(const base_generator_type gen):m_gen(gen)
{}
~foo(void) {}
rand_type operator() ( void )
{
const float x = m_gen();
return x;
}
private:
base_generator_type m_gen;
}
int main(void)
{
base_generator_type gen( (uint32_t) 2000);
//seed is not important
foo f(gen);
cout << "Random result is " << f() << endl;
}
The resulting numbers will be different between
codewarrior 9.0 running on windows (xp or 2000) and
gcc 3.4.1 running on Suse linux 7.3.(Hope that is enough
info).
I tracked the cause of the bug down to class
initialization. In the case of CW9.0, the compiler when
constructing a foo, will use a mersenne_twister copy
ctor when initializing m_gen, while in the case of
gcc 3.4.1 it will choose the following in the .hpp file
template<class Generator>
explicit mersenne_twister(Generator & gen) { seed
(gen); }
therefore using the provided generator as a seed to the
new generator rather than just copying its state, even
though no template parameter is provided.
Anyways I will leave it up to the more informed to decide
which is more desirable/proper; however, this is a fairly
nasty bug at the moment as you can not reproduce
results between these two platforms when using this
random number generator for your random numbers.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1115124&group_id=7586
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk