Changeset 894 in Sophya for trunk/SophyaLib/TArray/utilarr.h
- Timestamp:
- Apr 12, 2000, 7:42:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/TArray/utilarr.h
r850 r894 13 13 /* Quelques utilitaires pour les tableaux (Array) */ 14 14 15 //! define a function of double which returns a double 15 16 typedef double (* Arr_DoubleFunctionOfX) (double x); 17 //! define a function of float which returns a float 16 18 typedef float (* Arr_FloatFunctionOfX) (float x); 17 19 20 ////////////////////////////////////////////////////////// 21 //! Class to generate a random sequence of values 18 22 class RandomSequence { 19 23 public: 20 enum { Gaussian = 0, Flat = 1 }; 24 //! to define the generator type 25 enum { 26 Gaussian = 0, //!< gaussian generator 27 Flat = 1 //!< Flat generator 28 }; 29 21 30 RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.); 22 31 double Rand(); 23 32 protected: 24 int typ_; 25 double mean_, sig_; 33 int typ_; //!< random generation type 34 double mean_, sig_; //!< generation parameters mean and sigma (if needed) 26 35 }; 27 36 28 37 38 ////////////////////////////////////////////////////////// 39 //! Class to generate a sequence of values 29 40 class Sequence { 30 41 public: 31 42 explicit Sequence (double start=0., double step=1., Arr_DoubleFunctionOfX f=NULL); 32 43 explicit Sequence (RandomSequence rseq); 44 45 //! return start value of the sequence 33 46 inline double & Start() { return start_; } 47 //! return step value of the sequence 34 48 inline double & Step() { return step_; } 35 49 double operator () (uint_4 k); 36 50 protected: 37 double start_, step_; 38 Arr_DoubleFunctionOfX myf_; 39 bool fgrseq_; 40 RandomSequence rseq_; 51 double start_; //!< start value of the sequence 52 double step_; //!< step value of the sequence 53 Arr_DoubleFunctionOfX myf_; //!< pointer to the sequence function 54 bool fgrseq_; //!< true if RandomSequence is used 55 RandomSequence rseq_; //!< RandomSequence 41 56 }; 42 57 58 ////////////////////////////////////////////////////////// 59 //! Class to define a range of indexes 43 60 class Range { 44 61 public: 45 62 explicit Range(uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4 step=1); 63 //! Return the start index 46 64 inline uint_4 & Start() { return start_; } 65 //! Return the last index 47 66 inline uint_4 & End() { return end_; } 67 //! Return the size 48 68 inline uint_4 & Size() { return size_; } 69 //! Return the step 49 70 inline uint_4 & Step() { return step_; } 50 71 protected: 51 uint_4 start_, end_, size_, step_ ; 72 uint_4 start_; //!< start index 73 uint_4 end_; //!< end index 74 uint_4 size_; //!< size 75 uint_4 step_; //!< step 52 76 }; 53 77 78 ////////////////////////////////////////////////////////// 79 //! Class to define an identity matrix 54 80 class IdentityMatrix { 55 81 public: 56 82 explicit IdentityMatrix(double diag=1., uint_4 n=0); 83 //! return the size of the identity matrix 57 84 inline uint_4 Size() { return size_; } 85 //! return the value of the diagonal elements 58 86 inline double Diag() { return diag_; } 59 87 protected: 60 uint_4 size_; 61 double diag_; 88 uint_4 size_; //!< size of the matrix 89 double diag_; //!< value of the diagonal elements 62 90 }; 63 91 … … 65 93 66 94 #endif 67
Note:
See TracChangeset
for help on using the changeset viewer.