Dear Rooters,
the function Rnd() (below) good work at many compilers. I have the problem with static, and maybe const, in root macro (root ver. 5.18). I received the error: "No memory for static..."
It is not much important problem for me. I may to do it at other way. But this error give some discomfort at work.
Best regards,
Jan Malinowski
//===============================================================/* Random number generator */
//===============================================================
double Rnd() {
const unsigned long a=397204094; const unsigned long b=0; const unsigned long c=2147483647;
static unsigned long x1;
static unsigned long x2=1.0;
double R;
x1=x2;
x2=(a*x1 + b) % c;
R=double(x2)/double(c);
return R;
}
//---------------------------------------------------------------int main()
TCanvas* c1 = new TCanvas("c1","RNG",1,1,800,600); TH1D* hist = new TH1D("hist","hrng", 50, 0.0, 1.0);
for(int i=0; i<10; ++i)
{
double x=Rnd();
hist->Fill(x);
}
hist->SetTitle("Xmax distr.;Xmax;dN/dXmax");
hist->Draw(); // it mean "HIST";
c1->Update();
}
//===============================================================Received on Mon Oct 13 2008 - 11:47:01 CEST
This archive was generated by hypermail 2.2.0 : Mon Oct 13 2008 - 17:50:02 CEST