![]() |
Blitz Bugs : |
From: Alex Dicks (alex.dicks_at_[hidden])
Date: 2002-04-26 19:21:49
I found a problem attempting to compile the random number example
program. The problem lies within the header file "random/mt.h".
Within "class MersenneTwister", you have the following typedefs and
data members:
typedef std::vector<twist_int> State;
typedef State::iterator Iter;
State S;
Iter I;
There are numerous places where you attempt to do something similar to
this:
I = &S[N];
However, this does not work under g++ 3.0.2. I believe that writing
this sort of thing is non standard. It assumes that you can assign a
pointer to twist_int to an Iter. Vector iterators do not have to be
implemented as raw pointers to the contained type.
I think that you ought to have written:
I = S.begin() + N;
Here is a diff patch for you which lets the example program compile
and run. I don't think I have changed any of the semantics, but you
ought to check. (Cut the rows of dollar signs.)
$$$$$$$$$$$$$$$$
98c98
< I = &S[N];
--- > I = S.begin() + N; 135c135 < Iter s = &S[0]; --- > Iter s = S.begin(); 153c153 < Iter p0 = &S[0]; --- > Iter p0 = S.begin(); 157c157 < for (Iter pf_end = &S[N-PF]; p0 != pf_end; ++p0, ++pM) --- > for (Iter pf_end = (S.begin() + N - PF); p0 != pf_end; ++p0, ++pM) 160c160 < for (Iter s_end = &S[N-1]; p0 != s_end; ++p0, ++pM) --- > for (Iter s_end = (S.begin() + N - 1); p0 != s_end; ++p0, ++pM) 164c164 < I = &S[0]; --- > I = S.begin(); $$$$$$$$$$$$$$$$ Hope this helps you. _______________________________________________ Blitz-bugs mailing list Blitz-bugs_at_[hidden] http://www.oonumerics.org/mailman/listinfo.cgi/blitz-bugs