ignore local files (projects, R history...)
[valse.git] / pkg / src / sources / utils.h
1 #ifndef valse_utils_H
2 #define valse_utils_H
3
4 //#include <stdint.h>
5
6 /********
7 * Types
8 *******/
9
10 typedef double Real;
11 //typedef uint32_t UInt;
12 //typedef int32_t Int;
13
14 /*******************
15 * tune parallelism
16 *******************/
17
18 // Number of OpenMP threads
19 #define OMP_NUM_THREADS 8
20
21 // CHUNK_SIZE = number of lambda values to be treated sequentially by a single core
22 #define CHUNK_SIZE 1
23
24 /*******************************
25 * Matrix and arrays indexation
26 *******************************/
27
28 // Matrix Index ; TODO? ncol unused
29 #define mi(i,j,nrow,ncol)\
30 j*nrow + i
31
32 // Array Index ; TODO? d3 unused
33 #define ai(i,j,k,d1,d2,d3)\
34 k*d1*d2 + j*d1 + i
35
36 // Array4 Index ; TODO? ...
37 #define ai4(i,j,k,m,d1,d2,d3,d4)\
38 m*d1*d2*d3 + k*d1*d2 + j*d1 + i
39
40 /*************************
41 * Array copy & "zeroing"
42 ************************/
43
44 // Fill an array with zeros
45 #define zeroArray(array, size)\
46 {\
47 for (int u=0; u<size; u++)\
48 array[u] = 0;\
49 }
50
51 // Copy an 1D array
52 #define copyArray(array, copy, size)\
53 {\
54 for (int u=0; u<size; u++)\
55 copy[u] = array[u];\
56 }
57
58 #endif