Changeset 3601 in Sophya


Ignore:
Timestamp:
Apr 28, 2009, 5:23:19 PM (16 years ago)
Author:
cmv
Message:

adaptation de TsFunRan a RandomGeneratorInterface , cmv 28/04/2009

Location:
trunk/SophyaLib/NTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/Makefile

    r3600 r3601  
    11include ../BuildMgr/sophyamake.inc
    2 
     2 
    33all: $(SOPHYALIBP)libNTools.a
    44 
     
    694694  $(SOPHYAINCP)machdefs.h \
    695695  $(SOPHYAINCP)pexceptions.h \
    696   $(SOPHYAINCP)machdefs.h pemath.h
     696  $(SOPHYAINCP)machdefs.h \
     697  $(SOPHYAINCP)randr48.h \
     698  $(SOPHYAINCP)objfio.h \
     699  $(SOPHYAINCP)anydataobj.h \
     700  $(SOPHYAINCP)ppersist.h \
     701  $(SOPHYAINCP)pexceptions.h \
     702  $(SOPHYAINCP)gnumd5.h \
     703  $(SOPHYAINCP)ppfbinstream.h \
     704  $(SOPHYAINCP)rawstream.h \
     705  $(SOPHYAINCP)ppfnametag.h \
     706  $(SOPHYAINCP)ndatablock.h \
     707  $(SOPHYAINCP)randinterf.h tsfunran.h \
     708  $(SOPHYAINCP)histos.h \
     709  $(SOPHYAINCP)peida.h \
     710  $(SOPHYAINCP)utils.h \
     711  $(SOPHYAINCP)perrors.h \
     712  $(SOPHYAINCP)fmath.h \
     713  $(SOPHYAINCP)tvector.h \
     714  $(SOPHYAINCP)tmatrix.h \
     715  $(SOPHYAINCP)tarray.h \
     716  $(SOPHYAINCP)basarr.h \
     717  $(SOPHYAINCP)mutyv.h \
     718  $(SOPHYAINCP)timestamp.h \
     719  $(SOPHYAINCP)dvlist.h \
     720  $(SOPHYAINCP)utilarr.h \
     721  $(SOPHYAINCP)tmatrix_tsnl.h \
     722  $(SOPHYAINCP)tvector_tsnl.h \
     723  $(SOPHYAINCP)tvector.h \
     724  $(SOPHYAINCP)randinterf.h classfunc.h
    697725        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsfunran.cc
    698726 
  • trunk/SophyaLib/NTools/smakefile

    r3600 r3601  
    694694  $(SOPHYAINCP)machdefs.h \
    695695  $(SOPHYAINCP)pexceptions.h \
    696   $(SOPHYAINCP)machdefs.h pemath.h
     696  $(SOPHYAINCP)machdefs.h \
     697  $(SOPHYAINCP)randr48.h \
     698  $(SOPHYAINCP)objfio.h \
     699  $(SOPHYAINCP)anydataobj.h \
     700  $(SOPHYAINCP)ppersist.h \
     701  $(SOPHYAINCP)pexceptions.h \
     702  $(SOPHYAINCP)gnumd5.h \
     703  $(SOPHYAINCP)ppfbinstream.h \
     704  $(SOPHYAINCP)rawstream.h \
     705  $(SOPHYAINCP)ppfnametag.h \
     706  $(SOPHYAINCP)ndatablock.h \
     707  $(SOPHYAINCP)randinterf.h tsfunran.h \
     708  $(SOPHYAINCP)histos.h \
     709  $(SOPHYAINCP)peida.h \
     710  $(SOPHYAINCP)utils.h \
     711  $(SOPHYAINCP)perrors.h \
     712  $(SOPHYAINCP)fmath.h \
     713  $(SOPHYAINCP)tvector.h \
     714  $(SOPHYAINCP)tmatrix.h \
     715  $(SOPHYAINCP)tarray.h \
     716  $(SOPHYAINCP)basarr.h \
     717  $(SOPHYAINCP)mutyv.h \
     718  $(SOPHYAINCP)timestamp.h \
     719  $(SOPHYAINCP)dvlist.h \
     720  $(SOPHYAINCP)utilarr.h \
     721  $(SOPHYAINCP)tmatrix_tsnl.h \
     722  $(SOPHYAINCP)tvector_tsnl.h \
     723  $(SOPHYAINCP)tvector.h \
     724  $(SOPHYAINCP)randinterf.h classfunc.h
    697725        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  tsfunran.cc
    698726 
  • trunk/SophyaLib/NTools/tsfunran.cc

    r3600 r3601  
    11#include "sopnamsp.h"
    22#include "machdefs.h"
     3#include <iostream>
    34#include "pexceptions.h"
     5#include "randr48.h"
    46#include "tsfunran.h"
    5 #include <iostream>
    67
    78
     
    4344*/
    4445TsFunRan::TsFunRan(TsFunRan::Func f, r_8 xMin, r_8 xMax, int_4 nBin, bool pdf)
    45   : Histo(xMin,xMax,nBin)
     46  : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false)
    4647{
    4748 if(nBin<=1)
    4849   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    4950 for(int_4 i=0;i<nBin;i++) (*this)(i) = f(BinCenter(i));
    50  rg_ = new RandomGenerator(1,false);
     51 rg_ = new DR48RandGen();
    5152 create_DF(pdf);
    5253}
     
    5758*/
    5859TsFunRan::TsFunRan(ClassFunc& f, r_8 xMin, r_8 xMax, int_4 nBin, bool pdf)
    59   : Histo(xMin,xMax,nBin)
     60  : Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false)
    6061{
    6162 if(nBin<=1)
    6263   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    6364 for(int_4 i=0;i<nBin;i++) (*this)(i) = f(BinCenter(i));
    64  rg_ = new RandomGenerator(1,false);
     65 rg_ = new DR48RandGen();
    6566 create_DF(pdf);
    6667}
     
    7475*/
    7576TsFunRan::TsFunRan(r_8 *tab, int_4 nBin, bool pdf)
    76 : Histo(-0.5,nBin-0.5,nBin)
     77: Histo(-0.5,nBin-0.5,nBin), rg_(NULL), internal_rg_(false)
    7778{
    7879 if(nBin<=1)
    7980   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    8081 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab[i];
    81  rg_ = new RandomGenerator(1,false);
     82 rg_ = new DR48RandGen();
    8283 create_DF(pdf);
    8384}
     
    9293*/
    9394TsFunRan::TsFunRan(r_8 *tab, int_4 nBin, r_8 xMin, r_8 xMax, bool pdf)
    94 : Histo(xMin,xMax,nBin)
     95: Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false)
    9596{
    9697 if(nBin<=1)
    9798   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    9899 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab[i];
    99  rg_ = new RandomGenerator(1,false);
     100 rg_ = new DR48RandGen();
    100101 create_DF(pdf);
    101102}
     
    105106*/
    106107TsFunRan::TsFunRan(TVector<r_8>& tab, int_4 nBin, bool pdf)
    107 : Histo(-0.5,nBin-0.5,nBin)
     108: Histo(-0.5,nBin-0.5,nBin), rg_(NULL), internal_rg_(false)
    108109{
    109110 if(nBin<=1)
    110111   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    111112 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab(i);
    112  rg_ = new RandomGenerator(1,false);
     113 rg_ = new DR48RandGen();
    113114 create_DF(pdf);
    114115}
     
    118119*/
    119120TsFunRan::TsFunRan(TVector<r_8>& tab, int_4 nBin, r_8 xMin, r_8 xMax, bool pdf)
    120 : Histo(xMin,xMax,nBin)
     121: Histo(xMin,xMax,nBin), rg_(NULL), internal_rg_(false)
    121122{
    122123 if(nBin<=1)
    123124   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    124125 for(int_4 i=0;i<nBin;i++) (*this)(i) = tab(i);
    125  rg_ = new RandomGenerator(1,false);
     126 rg_ = new DR48RandGen();
    126127 create_DF(pdf);
    127128}
     
    134135*/
    135136TsFunRan::TsFunRan(Histo &h, bool pdf)
    136   : Histo(h)
     137  : Histo(h), rg_(NULL), internal_rg_(false)
    137138{
    138139 if(mBins<=1)
    139140   throw RangeCheckError("TsFunRan::TsFunRan less than 2 bins requested");
    140  rg_ = new RandomGenerator(1,false);
     141 rg_ = new DR48RandGen();
    141142 create_DF(pdf);
    142143}
     
    145146/*! Creator by copy */
    146147TsFunRan::TsFunRan(const TsFunRan& fh)
    147   : Histo(fh)
    148 {
    149   rg_ = new RandomGenerator(*fh.rg_);
     148  : Histo(fh), rg_(fh.rg_), internal_rg_(false)
     149{
    150150}
    151151
     
    153153/*! Creator by default */
    154154TsFunRan::TsFunRan(void)
    155 {
    156   rg_ = new RandomGenerator(1,false);
     155  : rg_(NULL), internal_rg_(false)
     156{
    157157}
    158158
     
    160160TsFunRan::~TsFunRan(void)
    161161{
    162   if(rg_!=NULL) delete rg_;
     162  if(rg_!=NULL && internal_rg_) delete rg_;
    163163}
    164164
     
    180180
    181181/********* Methode *********/
    182 void TsFunRan::SetRandomGenerator(RandomGenerator& rg)
    183 {
    184   if(rg_!=NULL) delete rg_;
    185   rg_ = new RandomGenerator(rg);
     182void TsFunRan::SetRandomGenerator(RandomGeneratorInterface* rg)
     183{
     184  if(rg_!=NULL && internal_rg_) delete rg_;
     185  rg_ = rg;
    186186}
    187187
  • trunk/SophyaLib/NTools/tsfunran.h

    r3600 r3601  
    1212#include "histos.h"
    1313#include "tvector.h"
    14 #include "stsrand.h"
     14#include "randinterf.h"
    1515#include "classfunc.h"
    1616
     
    3131  virtual ~TsFunRan(void);
    3232
    33   void SetRandomGenerator(RandomGenerator& rg);
     33  void SetRandomGenerator(RandomGeneratorInterface* rg);
    3434
    3535  int_4 BinRandom(void);
     
    3838protected:
    3939  void create_DF(bool pdf);
    40   RandomGenerator* rg_;
     40  RandomGeneratorInterface* rg_;
     41  bool internal_rg_;
    4142};
    4243
Note: See TracChangeset for help on using the changeset viewer.