22 #define isinf !_finite    32 static inline void stop();
    36 template <
typename T> 
static inline T 
ran1(); 
    38 template <
typename T> 
static inline T 
ran1b(); 
    44 static void sort(
int* irOut, T* prOut,
int beg, 
int end);
    46 static void quick_sort(
int* irOut, T* prOut,
const int beg, 
const int end, 
const bool incr);
    49 T 
power(
const T x, 
const T y);
    61    return sqr<T>(
static_cast<T
>(x));
    74 static inline void stop() {
    75    printf(
"Appuyez sur une touche pour continuer\n");
    80 template <
typename T> 
static inline T 
ran1() {
    81    const int IA=16807,IM=2147483647,IQ=127773,IR=2836,NTAB=32;
    82    const int NDIV=(1+(IM-1)/NTAB);
    83    const T EPS=3.0e-16,AM=1.0/IM,RNMX=(1.0-EPS);
    89    if (seed <= 0 || !iy) {
    90       if (-seed < 1) seed=1;
    92       for (j=NTAB+7;j>=0;j--) {
    94          seed=IA*(seed-k*IQ)-IR*k;
    95          if (seed < 0) seed += IM;
    96          if (j < NTAB) iv[j] = 
seed;
   101    seed=IA*(seed-k*IQ)-IR*k;
   102    if (seed < 0) seed += IM;
   106    if ((temp=AM*iy) > RNMX) 
return RNMX;
   112    return static_cast<T
>(rand())/RAND_MAX;
   116 template <
typename T>
   118    static bool iset = 
true;
   124          v1 = 2.0*ran1<T>()-1.0;
   125          v2 = 2.0*ran1<T>()-1.0;
   127       } 
while (rsq >= 1.0 || rsq == 0.0);
   128       fac = sqrt(-2.0*log(rsq)/rsq);
   140 template <
typename T>
   141 static void sort(
int* irOut, T* prOut,
int beg, 
int end) {
   143    if (end <= beg) 
return;
   145    for (i = beg+1; i<=end; ++i) {
   146       if (irOut[i] < irOut[pivot]) {
   150             irOut[i]=irOut[pivot];
   151             prOut[i]=prOut[pivot];
   155             int tmp = irOut[pivot+1];
   156             T tmpd = prOut[pivot+1];
   157             irOut[pivot+1]=irOut[pivot];
   158             prOut[pivot+1]=prOut[pivot];
   159             irOut[pivot]=irOut[i];
   160             prOut[pivot]=prOut[i];
   167    sort(irOut,prOut,beg,pivot-1);
   168    sort(irOut,prOut,pivot+1,end);
   170 template <
typename T>
   171 static void quick_sort(
int* irOut, T* prOut,
const int beg, 
const int end, 
const bool incr) {
   172    if (end <= beg) 
return;
   175       const T val_pivot=prOut[pivot];
   176       const int key_pivot=irOut[pivot];
   177       for (
int i = beg+1; i<=end; ++i) {
   178          if (prOut[i] < val_pivot) {
   179             prOut[pivot]=prOut[i];
   180             irOut[pivot]=irOut[i];
   181             prOut[i]=prOut[++pivot];
   182             irOut[i]=irOut[pivot];
   183             prOut[pivot]=val_pivot;
   184             irOut[pivot]=key_pivot;
   188       const T val_pivot=prOut[pivot];
   189       const int key_pivot=irOut[pivot];
   190       for (
int i = beg+1; i<=end; ++i) {
   191          if (prOut[i] > val_pivot) {
   192             prOut[pivot]=prOut[i];
   193             irOut[pivot]=irOut[i];
   194             prOut[i]=prOut[++pivot];
   195             irOut[i]=irOut[pivot];
   196             prOut[pivot]=val_pivot;
   197             irOut[pivot]=key_pivot;
   208 inline double power(
const double x, 
const double y) {
   212 inline float power(
const float x, 
const float y) {
   218 inline double abs(
const double x) {
   222 inline float abs(
const float x) {
   228 inline double sqr(
const double x) {
   232 inline float sqr(
const float x) {
   267    NUM_THREADS = (numThreads == -1) ? 
MIN(
MAX_THREADS,omp_get_num_procs()) : numThreads;
   270    omp_set_num_threads(NUM_THREADS);
 
T sqr(const T x)
template version of the fabs function 
static void sort(int *irOut, T *prOut, int beg, int end)
static void stop()
a useful debugging function 
Contains various variables and class timer. 
T abs(const T x)
template version of the fabs function 
static void quick_sort(int *irOut, T *prOut, const int beg, const int end, const bool incr)
static int seed
seed for random number generation 
static T normalDistrib()
random sampling from the normal distribution 
static int init_omp(const int numThreads)
T power(const T x, const T y)
template version of the power function 
static T ran1()
first random number generator from Numerical Recipe 
static T ran1b()
standard random number generator