[785] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Utility classes for template numerical arrays
|
---|
| 3 | // R. Ansari, C.Magneville 03/2000
|
---|
| 4 |
|
---|
| 5 | #ifndef UtilArray_SEEN
|
---|
| 6 | #define UtilArray_SEEN
|
---|
| 7 |
|
---|
| 8 | #include "machdefs.h"
|
---|
| 9 | #include <stdlib.h>
|
---|
| 10 |
|
---|
| 11 | namespace SOPHYA {
|
---|
| 12 |
|
---|
| 13 | /* Quelques utilitaires pour les tableaux (Array) */
|
---|
| 14 |
|
---|
| 15 | typedef double (* Arr_DoubleFunctionOfX) (double x);
|
---|
| 16 | typedef float (* Arr_FloatFunctionOfX) (float x);
|
---|
| 17 |
|
---|
[850] | 18 | class RandomSequence {
|
---|
| 19 | public:
|
---|
| 20 | enum { Gaussian = 0, Flat = 1 };
|
---|
| 21 | RandomSequence(int typ = RandomSequence::Gaussian, double m=0., double s=1.);
|
---|
| 22 | double Rand();
|
---|
| 23 | protected:
|
---|
| 24 | int typ_;
|
---|
| 25 | double mean_, sig_;
|
---|
| 26 | };
|
---|
| 27 |
|
---|
| 28 |
|
---|
[785] | 29 | class Sequence {
|
---|
| 30 | public:
|
---|
[804] | 31 | explicit Sequence (double start=0., double step=1., Arr_DoubleFunctionOfX f=NULL);
|
---|
[850] | 32 | explicit Sequence (RandomSequence rseq);
|
---|
[785] | 33 | inline double & Start() { return start_; }
|
---|
| 34 | inline double & Step() { return step_; }
|
---|
| 35 | double operator () (uint_4 k);
|
---|
| 36 | protected:
|
---|
| 37 | double start_, step_;
|
---|
| 38 | Arr_DoubleFunctionOfX myf_;
|
---|
[850] | 39 | bool fgrseq_;
|
---|
| 40 | RandomSequence rseq_;
|
---|
[785] | 41 | };
|
---|
| 42 |
|
---|
| 43 | class Range {
|
---|
| 44 | public:
|
---|
[813] | 45 | explicit Range(uint_4 start=0, uint_4 end=0, uint_4 size=1, uint_4 step=1);
|
---|
[785] | 46 | inline uint_4 & Start() { return start_; }
|
---|
[813] | 47 | inline uint_4 & End() { return end_; }
|
---|
| 48 | inline uint_4 & Size() { return size_; }
|
---|
| 49 | inline uint_4 & Step() { return step_; }
|
---|
[785] | 50 | protected:
|
---|
[813] | 51 | uint_4 start_, end_, size_, step_ ;
|
---|
[785] | 52 | };
|
---|
| 53 |
|
---|
[804] | 54 | class IdentityMatrix {
|
---|
| 55 | public:
|
---|
| 56 | explicit IdentityMatrix(double diag=1., uint_4 n=0);
|
---|
| 57 | inline uint_4 Size() { return size_; }
|
---|
| 58 | inline double Diag() { return diag_; }
|
---|
| 59 | protected:
|
---|
| 60 | uint_4 size_;
|
---|
| 61 | double diag_;
|
---|
| 62 | };
|
---|
| 63 |
|
---|
[785] | 64 | } // Fin du namespace
|
---|
| 65 |
|
---|
| 66 | #endif
|
---|
| 67 |
|
---|