escript
Revision_Unversioneddirectory
Main Page
Namespaces
Classes
Files
File List
File Members
esysUtils
src
index.h
Go to the documentation of this file.
1
2
/*****************************************************************************
3
*
4
* Copyright (c) 2003-2016 by The University of Queensland
5
* http://www.uq.edu.au
6
*
7
* Primary Business: Queensland, Australia
8
* Licensed under the Apache License, version 2.0
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12
* Development 2012-2013 by School of Earth Sciences
13
* Development from 2014 by Centre for Geoscience Computing (GeoComp)
14
*
15
*****************************************************************************/
16
17
18
#ifndef INC_ESYS_INDEX
19
#define INC_ESYS_INDEX
20
21
/************************************************************************************/
22
23
/* Macros for array indexing */
24
25
/************************************************************************************/
26
27
/************************************************************************************/
28
29
/* some useful functions: */
30
31
#include <limits.h>
32
33
34
#define FALSE 0
35
#define TRUE 1
36
#define UNKNOWN -1
37
#define DBLE(_x_) (double)(_x_)
38
#define INDEX1(_X1_) (_X1_)
39
#define INDEX2(_X1_,_X2_,_N1_) ((_X1_)+(_N1_)*(_X2_))
40
#define INDEX3(_X1_,_X2_,_X3_,_N1_,_N2_) ((_X1_)+(_N1_)*INDEX2(_X2_,_X3_,_N2_))
41
#define INDEX4(_X1_,_X2_,_X3_,_X4_,_N1_,_N2_,_N3_) ((_X1_)+(_N1_)*INDEX3(_X2_,_X3_,_X4_,_N2_,_N3_))
42
#define INDEX5(_X1_,_X2_,_X3_,_X4_,_X5_,_N1_,_N2_,_N3_,_N4_) ((_X1_)+(_N1_)*INDEX4(_X2_,_X3_,_X4_,_X5_,_N2_,_N3_,_N4_))
43
#define INDEX6(_X1_,_X2_,_X3_,_X4_,_X5_,_X6_,_N1_,_N2_,_N3_,_N4_,_N5_) ((_X1_)+(_N1_)*INDEX5(_X2_,_X3_,_X4_,_X5_,_X6_,_N2_,_N3_,_N4_,_N5_))
44
45
#define MAX(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg1_) : (_arg2_))
46
#define MAX3(_arg1_,_arg2_,_arg3_) MAX(_arg1_,MAX(_arg2_,_arg3_))
47
#define MIN(_arg1_,_arg2_) ((_arg1_)>(_arg2_) ? (_arg2_) : (_arg1_))
48
#define MIN3(_arg1_,_arg2_,_arg3_) MIN(_arg1_,MIN(_arg2_,_arg3_))
49
#define ABS(_arg_) MAX((_arg_),-(_arg_))
50
#define SIGN(_arg_) ((_arg_)>0 ? 1 : ((_arg_)<0 ? -1 : 0 ))
51
#define SAMESIGN(_arg1_, _arg2_) ( ( ( (_arg1_)>=0 ) && ( (_arg2_)>=0 ) ) || ( ((_arg1_)<=0 ) && ( (_arg2_)<=0 ) ) )
52
#define SWAP(_a0_,_a1_,_type_) { \
53
_type_ s; \
54
s=(_a0_); \
55
_a0_= (_a1_); \
56
_a1_=s; \
57
}
58
#define XNOR(_a0_,_a1_) ( ( (_a0_) && (_a1_) ) || ( !(_a0_) && !(_a1_) ) )
59
60
#define INDEX_T_MAX INT_MAX
61
#define INDEX_T_MIN -INT_MAX
62
63
#endif
Generated on Sat Oct 8 2016 15:12:59 for escript by
1.8.11