Changeset 850 in Sophya for trunk/SophyaLib/TArray/utilarr.cc
- Timestamp:
- Apr 10, 2000, 2:57:45 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/utilarr.cc
r813 r850 4 4 #include "machdefs.h" 5 5 #include "utilarr.h" 6 #include "srandgen.h" 6 7 7 8 // Classe utilitaires 9 10 RandomSequence::RandomSequence(int typ, double m, double s) 11 { 12 typ_ = (typ == Flat) ? Flat : Gaussian; 13 mean_ = m; 14 sig_ = s; 15 } 16 17 double RandomSequence::Rand() 18 { 19 if (typ_ == Flat) 20 return(drandpm1()*sig_ + mean_); 21 else return(GauRnd(mean_, sig_)); 22 } 23 24 8 25 Sequence::Sequence(double start, double step, Arr_DoubleFunctionOfX f) 26 : rseq_(RandomSequence::Gaussian) 9 27 { 10 28 start_ = start; 11 29 step_ = step; 12 30 myf_ = f; 31 fgrseq_ = false; 32 } 33 34 Sequence::Sequence(RandomSequence rseq) 35 { 36 start_ = 0.; 37 step_ = 1.; 38 myf_ = NULL; 39 rseq_ = rseq; 40 fgrseq_ = true; 13 41 } 14 42 15 43 double Sequence::operator () (uint_4 k) 16 44 { 17 double x = start_+(double)k*step_; 18 if (myf_) return(myf_(x)); 19 return x; 45 if (fgrseq_) return(rseq_.Rand()); 46 else { 47 double x = start_+(double)k*step_; 48 if (myf_) return(myf_(x)); 49 else return x; 50 } 20 51 } 21 52
Note:
See TracChangeset
for help on using the changeset viewer.