static - no memory

From: Jan Malinowski <jmalinowski_at_uni.lodz.pl>
Date: Mon, 13 Oct 2008 11:59:19 +0200


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()
{
gROOT->Reset();
gStyle->SetOptStat(1110);

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