Pass R CMD check --as-cran
[valse.git] / pkg / src / utils.h
CommitLineData
228ee602 1#ifndef valse_utils_H
2#define valse_utils_H
3
4//#include <stdint.h>
5
6/********
7 * Types
8 *******/
9
10typedef double Real;
11//typedef uint32_t UInt;
12//typedef int32_t Int;
13
14/*******************************
15 * Matrix and arrays indexation
16 *******************************/
17
18// Matrix Index ; TODO? ncol unused
19#define mi(i,j,nrow,ncol)\
20 j*nrow + i
21
22// Array Index ; TODO? d3 unused
23#define ai(i,j,k,d1,d2,d3)\
24 k*d1*d2 + j*d1 + i
25
26// Array4 Index ; TODO? ...
27#define ai4(i,j,k,m,d1,d2,d3,d4)\
28 m*d1*d2*d3 + k*d1*d2 + j*d1 + i
29
30/*************************
31 * Array copy & "zeroing"
32 ************************/
33
34// Fill an array with zeros
35#define zeroArray(array, size)\
36{\
37 for (int u=0; u<size; u++)\
38 array[u] = 0;\
39}
40
41// Copy an 1D array
42#define copyArray(array, copy, size)\
43{\
44 for (int u=0; u<size; u++)\
45 copy[u] = array[u];\
46}
47
48#endif