FairRoot/PandaRoot
Classes | Macros | Functions | Variables
ranlxd.cxx File Reference
#include <limits.h>
#include <float.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  vec_t
 
struct  dble_vec_t
 

Macros

#define RANLXD_C
 
#define BASE   0x1000000
 
#define MASK   0xffffff
 
#define STEP(pi, pj)
 

Functions

static void error (int no)
 
static void update (void)
 
static void define_constants (void)
 
void rlxd_init (int level, int seed)
 
void ranlxd (double r[], int n)
 
int rlxd_size (void)
 
void rlxd_get (int state[])
 
void rlxd_reset (int state[])
 

Variables

static int init =0
 
static int pr
 
static int prm
 
static int ir
 
static int jr
 
static int is
 
static int is_old
 
static int next [96]
 
static double one_bit
 
static vec_t carry
 
union {
   dble_vec_t   vec [12]
 
   int   num [96]
 
x
 

Macro Definition Documentation

#define BASE   0x1000000

Definition at line 361 of file ranlxd.cxx.

#define MASK   0xffffff

Definition at line 362 of file ranlxd.cxx.

#define RANLXD_C

Definition at line 41 of file ranlxd.cxx.

#define STEP (   pi,
  pj 
)

Definition at line 384 of file ranlxd.cxx.

Referenced by update().

Function Documentation

static void define_constants ( void  )
static

Definition at line 486 of file ranlxd.cxx.

Referenced by rlxd_init(), and rlxd_reset().

487 {
488  int k;
489 
490  one_bit=ldexp(1.0,-24);
491 
492  for (k=0;k<96;k++)
493  {
494  next[k]=(k+1)%96;
495  if ((k%4)==3)
496  next[k]=(k+5)%96;
497  }
498 }
static double one_bit
Definition: ranlxd.cxx:375
static int next[96]
Definition: ranlxd.cxx:374
static void error ( int  no)
static

Definition at line 419 of file ranlxd.cxx.

References exit(), and printf().

Referenced by RhoCandidate::Correlation(), PndTrkTracking2::EliminateSpuriousSZ_bis(), PndTrkTracking2::EliminateSpuriousSZ_ter(), KFParticleBaseSIMD::GetMomentum(), KFParticleBaseSIMD::GetPt(), PndLmdSensorAligner::readPairsFromBinary(), RKTrackRep::RKutta(), rlxd_get(), rlxd_init(), and rlxd_reset().

420 {
421  switch(no)
422  {
423  case 0:
424  printf("Error in rlxd_init\n");
425  printf("Arithmetic on this machine is not suitable for ranlxd\n");
426  break;
427  case 1:
428  printf("Error in subroutine rlxd_init\n");
429  printf("Bad choice of luxury level (should be 1 or 2)\n");
430  break;
431  case 2:
432  printf("Error in subroutine rlxd_init\n");
433  printf("Bad choice of seed (should be between 1 and 2^31-1)\n");
434  break;
435  case 3:
436  printf("Error in rlxd_get\n");
437  printf("Undefined state (ranlxd is not initialized)\n");
438  break;
439  case 4:
440  printf("Error in rlxd_reset\n");
441  printf("Arithmetic on this machine is not suitable for ranlxd\n");
442  break;
443  case 5:
444  printf("Error in rlxd_reset\n");
445  printf("Unexpected input data\n");
446  break;
447  }
448  printf("Program aborted\n");
449  exit(0);
450 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
exit(0)
void ranlxd ( double  r[],
int  n 
)

Definition at line 571 of file ranlxd.cxx.

References is, n, rlxd_init(), update(), and x.

Referenced by mzrnd().

572 {
573  int k;
574 
575  if (init==0)
576  rlxd_init(1,1);
577 
578  for (k=0;k<n;k++)
579  {
580  is=next[is];
581  if (is==is_old)
582  update();
583  r[k]=one_bit*((double)(x.num[is+4])+one_bit*(double)(x.num[is]));
584  }
585 }
void rlxd_init(int level, int seed)
Definition: ranlxd.cxx:501
double r
Definition: RiemannTest.C:14
static double one_bit
Definition: ranlxd.cxx:375
static void update(void)
Definition: ranlxd.cxx:453
int n
static int init
Definition: ranlxd.cxx:374
static int is
Definition: ranlxd.cxx:374
Double_t x
static int is_old
Definition: ranlxd.cxx:374
static int next[96]
Definition: ranlxd.cxx:374
void rlxd_get ( int  state[])

Definition at line 594 of file ranlxd.cxx.

References vec_t::c1, vec_t::c2, vec_t::c3, vec_t::c4, error(), pr, rlxd_size(), and x.

595 {
596  int k;
597 
598  if (init==0)
599  error(3);
600 
601  state[0]=rlxd_size();
602 
603  for (k=0;k<96;k++)
604  state[k+1]=x.num[k];
605 
606  state[97]=carry.c1;
607  state[98]=carry.c2;
608  state[99]=carry.c3;
609  state[100]=carry.c4;
610 
611  state[101]=pr;
612  state[102]=ir;
613  state[103]=jr;
614  state[104]=is;
615 }
static int jr
Definition: ranlxd.cxx:374
int c2
Definition: ranlxd.cxx:366
int c4
Definition: ranlxd.cxx:366
static void error(int no)
Definition: ranlxd.cxx:419
static int init
Definition: ranlxd.cxx:374
int c3
Definition: ranlxd.cxx:366
int c1
Definition: ranlxd.cxx:366
int rlxd_size(void)
Definition: ranlxd.cxx:588
static int is
Definition: ranlxd.cxx:374
Double_t x
static vec_t carry
Definition: ranlxd.cxx:376
static int pr
Definition: ranlxd.cxx:374
static int ir
Definition: ranlxd.cxx:374
void rlxd_init ( int  level,
int  seed 
)

Definition at line 501 of file ranlxd.cxx.

References vec_t::c1, vec_t::c2, vec_t::c3, vec_t::c4, define_constants(), error(), i, pr, seed, and x.

Referenced by mz_pp_to_leplep_vandewi_init(), mz_pp_to_pipi_vandewi_init(), and ranlxd().

502 {
503  int i,k,l;
504  int ibit,jbit,xbit[31];
505  int ix,iy;
506 
507  if ((INT_MAX<2147483647)||(FLT_RADIX!=2)||(FLT_MANT_DIG<24)||
508  (DBL_MANT_DIG<48))
509  error(0);
510 
512 
513  if (level==1)
514  pr=202;
515  else if (level==2)
516  pr=397;
517  else
518  error(1);
519 
520  i=seed;
521 
522  for (k=0;k<31;k++)
523  {
524  xbit[k]=i%2;
525  i/=2;
526  }
527 
528  if ((seed<=0)||(i!=0))
529  error(2);
530 
531  ibit=0;
532  jbit=18;
533 
534  for (i=0;i<4;i++)
535  {
536  for (k=0;k<24;k++)
537  {
538  ix=0;
539 
540  for (l=0;l<24;l++)
541  {
542  iy=xbit[ibit];
543  ix=2*ix+iy;
544 
545  xbit[ibit]=(xbit[ibit]+xbit[jbit])%2;
546  ibit=(ibit+1)%31;
547  jbit=(jbit+1)%31;
548  }
549 
550  if ((k%4)!=i)
551  ix=16777215-ix;
552 
553  x.num[4*k+i]=ix;
554  }
555  }
556 
557  carry.c1=0;
558  carry.c2=0;
559  carry.c3=0;
560  carry.c4=0;
561 
562  ir=0;
563  jr=7;
564  is=91;
565  is_old=0;
566  prm=pr%12;
567  init=1;
568 }
static int jr
Definition: ranlxd.cxx:374
static int prm
Definition: ranlxd.cxx:374
Int_t i
Definition: run_full.C:25
int c2
Definition: ranlxd.cxx:366
int c4
Definition: ranlxd.cxx:366
static void error(int no)
Definition: ranlxd.cxx:419
static int init
Definition: ranlxd.cxx:374
int c3
Definition: ranlxd.cxx:366
unsigned int seed
int c1
Definition: ranlxd.cxx:366
static void define_constants(void)
Definition: ranlxd.cxx:486
static int is
Definition: ranlxd.cxx:374
Double_t x
static int is_old
Definition: ranlxd.cxx:374
static vec_t carry
Definition: ranlxd.cxx:376
static int pr
Definition: ranlxd.cxx:374
static int ir
Definition: ranlxd.cxx:374
void rlxd_reset ( int  state[])

Definition at line 618 of file ranlxd.cxx.

References vec_t::c1, vec_t::c2, vec_t::c3, vec_t::c4, define_constants(), error(), ir, pr, rlxd_size(), and x.

619 {
620  int k;
621 
622  if ((INT_MAX<2147483647)||(FLT_RADIX!=2)||(FLT_MANT_DIG<24)||
623  (DBL_MANT_DIG<48))
624  error(4);
625 
627 
628  if (state[0]!=rlxd_size())
629  error(5);
630 
631  for (k=0;k<96;k++)
632  {
633  if ((state[k+1]<0)||(state[k+1]>=167777216))
634  error(5);
635 
636  x.num[k]=state[k+1];
637  }
638 
639  if (((state[97]!=0)&&(state[97]!=1))||
640  ((state[98]!=0)&&(state[98]!=1))||
641  ((state[99]!=0)&&(state[99]!=1))||
642  ((state[100]!=0)&&(state[100]!=1)))
643  error(5);
644 
645  carry.c1=state[97];
646  carry.c2=state[98];
647  carry.c3=state[99];
648  carry.c4=state[100];
649 
650  pr=state[101];
651  ir=state[102];
652  jr=state[103];
653  is=state[104];
654  is_old=8*ir;
655  prm=pr%12;
656  init=1;
657 
658  if (((pr!=202)&&(pr!=397))||
659  (ir<0)||(ir>11)||(jr<0)||(jr>11)||(jr!=((ir+7)%12))||
660  (is<0)||(is>91))
661  error(5);
662 }
static int jr
Definition: ranlxd.cxx:374
static int prm
Definition: ranlxd.cxx:374
int c2
Definition: ranlxd.cxx:366
int c4
Definition: ranlxd.cxx:366
static void error(int no)
Definition: ranlxd.cxx:419
static int init
Definition: ranlxd.cxx:374
int c3
Definition: ranlxd.cxx:366
int c1
Definition: ranlxd.cxx:366
static void define_constants(void)
Definition: ranlxd.cxx:486
int rlxd_size(void)
Definition: ranlxd.cxx:588
static int is
Definition: ranlxd.cxx:374
Double_t x
static int is_old
Definition: ranlxd.cxx:374
static vec_t carry
Definition: ranlxd.cxx:376
static int pr
Definition: ranlxd.cxx:374
static int ir
Definition: ranlxd.cxx:374
int rlxd_size ( void  )

Definition at line 588 of file ranlxd.cxx.

Referenced by rlxd_get(), and rlxd_reset().

589 {
590  return(105);
591 }
static void update ( void  )
static

Definition at line 453 of file ranlxd.cxx.

References d, ir, is, jr, pi, pr, prm, STEP, and x.

Referenced by Photospp::PH_HEPEVT_Interface::get(), GFKalman::processHit(), and ranlxd().

454 {
455  int k,kmax,d;
456  dble_vec_t *pmin,*pmax,*pi,*pj;
457 
458  kmax=pr;
459  pmin=&x.vec[0];
460  pmax=pmin+12;
461  pi=&x.vec[ir];
462  pj=&x.vec[jr];
463 
464  for (k=0;k<kmax;k++)
465  {
466  STEP(pi,pj);
467  pi+=1;
468  pj+=1;
469  if (pi==pmax)
470  pi=pmin;
471  if (pj==pmax)
472  pj=pmin;
473  }
474 
475  ir+=prm;
476  jr+=prm;
477  if (ir>=12)
478  ir-=12;
479  if (jr>=12)
480  jr-=12;
481  is=8*ir;
482  is_old=is;
483 }
static int jr
Definition: ranlxd.cxx:374
#define STEP(pi, pj)
Definition: ranlxd.cxx:384
static int prm
Definition: ranlxd.cxx:374
TObjArray * d
#define pi
Definition: createSTT.C:60
static int is
Definition: ranlxd.cxx:374
Double_t x
static int is_old
Definition: ranlxd.cxx:374
static int pr
Definition: ranlxd.cxx:374
static int ir
Definition: ranlxd.cxx:374

Variable Documentation

vec_t carry
static

Definition at line 376 of file ranlxd.cxx.

int init =0
static
int ir
static
int is
static
int is_old
static

Definition at line 374 of file ranlxd.cxx.

int jr
static

Definition at line 374 of file ranlxd.cxx.

Referenced by update().

int next[96]
static
int num[96]
double one_bit
static

Definition at line 375 of file ranlxd.cxx.

int pr
static

Definition at line 374 of file ranlxd.cxx.

Referenced by ana_dsdsj_full(), rlxd_get(), rlxd_init(), rlxd_reset(), and update().

int prm
static

Definition at line 374 of file ranlxd.cxx.

Referenced by fitsb(), and update().

dble_vec_t vec[12]
union { ... } x