Nek5000
SEM for Incompressible NS
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
jl
gs_defs.h
Go to the documentation of this file.
1
#ifndef GS_DEFS_H
2
#define GS_DEFS_H
3
4
/* requires:
5
<limits.h>, <float.h> for GS_DEFINE_IDENTITIES()
6
"types.h" for gs_sint, gs_slong
7
*/
8
9
/*------------------------------------------------------------------------------
10
Monoid Definitions
11
12
Here are defined the domains and operations, each combination being a
13
commutative semigroup, as well as the identity element making each a
14
commutative monoid.
15
------------------------------------------------------------------------------*/
16
17
/* the supported domains */
18
#define GS_FOR_EACH_DOMAIN(macro) \
19
macro(double) \
20
macro(float ) \
21
macro(int ) \
22
macro(long ) \
23
WHEN_LONG_LONG(macro(long_long))
24
25
/* the supported ops */
26
#define GS_FOR_EACH_OP(T,macro) \
27
macro(T,add) \
28
macro(T,mul) \
29
macro(T,min) \
30
macro(T,max) \
31
macro(T,bpr)
32
33
#define GS_DO_add(a,b) a+=b
34
#define GS_DO_mul(a,b) a*=b
35
#define GS_DO_min(a,b) if(b<a) a=b
36
#define GS_DO_max(a,b) if(b>a) a=b
37
#define GS_DO_bpr(a,b) \
38
do if(b!=0) { uint a_ = a; uint b_ = b; \
39
if(a_==0) { a=b_; break; } \
40
for(;;) { if(a_<b_) b_>>=1; else if(b_<a_) a_>>=1; else break; } \
41
a = a_; \
42
} while(0)
43
44
/* the monoid identity elements */
45
#define GS_DEFINE_MONOID_ID(T,min,max) \
46
static const T gs_identity_##T[] = { 0, 1, max, min, 0 };
47
#define GS_DEFINE_IDENTITIES() \
48
GS_DEFINE_MONOID_ID(double, -DBL_MAX, DBL_MAX) \
49
GS_DEFINE_MONOID_ID(float , -FLT_MAX, FLT_MAX) \
50
GS_DEFINE_MONOID_ID(int , INT_MIN, INT_MAX) \
51
GS_DEFINE_MONOID_ID(long , LONG_MIN, LONG_MAX) \
52
WHEN_LONG_LONG(GS_DEFINE_MONOID_ID(long_long,LLONG_MIN,LLONG_MAX))
53
54
/*------------------------------------------------------------------------------
55
Enums and constants
56
------------------------------------------------------------------------------*/
57
58
/* domain enum */
59
#define LIST GS_FOR_EACH_DOMAIN(ITEM) gs_dom_n
60
#define ITEM(T) gs_##T,
61
typedef
enum
{
LIST
}
gs_dom
;
62
#undef ITEM
63
#undef LIST
64
65
#define gs_sint TYPE_LOCAL(gs_int,gs_long,gs_long_long)
66
#define gs_slong TYPE_GLOBAL(gs_int,gs_long,gs_long_long)
67
68
/* domain type size array */
69
#define GS_DOM_SIZE_ITEM(T) sizeof(T),
70
#define GS_DEFINE_DOM_SIZES() \
71
static const unsigned gs_dom_size[] = \
72
{ GS_FOR_EACH_DOMAIN(GS_DOM_SIZE_ITEM) 0 };
73
74
/* operation enum */
75
#define LIST GS_FOR_EACH_OP(T,ITEM) gs_op_n
76
#define ITEM(T,op) gs_##op,
77
typedef
enum
{
LIST
}
gs_op
;
78
#undef ITEM
79
#undef LIST
80
81
#endif
LIST
#define LIST
Definition:
gs_defs.h:75
gs_op
gs_op
Definition:
gs_defs.h:77
gs_dom
gs_dom
Definition:
gs_defs.h:61
Generated on Tue Jul 14 2015 10:52:58 for Nek5000 by
1.8.8