EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
def.h
Go to the documentation of this file.
1 #ifndef DEF_H
2 #define DEF_H
3 
4 #include <stdlib.h>
5 #include <assert.h>
6 #include <math.h>
7 
12 #ifndef M_PI
13 #define M_PI 3.14159265358979323846
14 #endif
15 #define PI M_PI
16 //3.14159265358979323846
17 #define orthTol 1e-14
18 
19 #define CHKERR(ierr) assert(!(ierr))
20 //#define CHKREQ(ierr) { if (ierr) { return (ierr); } }
21 
22 #define Malloc(base, nmem, type) { \
23  size_t nbytes = (nmem) * sizeof(type); \
24  (base) = (type*) malloc(nbytes); \
25  if ((base) == NULL) { \
26  fprintf(stdout, "EVSL Error: out of memory [%zu bytes asked]\n", nbytes); \
27  fprintf(stdout, "Malloc at FILE %s, LINE %d, nmem %zu\n", __FILE__, __LINE__, (size_t) nmem); \
28  exit(-1); \
29  } \
30 }
31 
32 #define Calloc(base, nmem, type) { \
33  size_t nbytes = (nmem) * sizeof(type); \
34  (base) = (type*) calloc((nmem), sizeof(type)); \
35  if ((base) == NULL) { \
36  fprintf(stdout, "EVSL Error: out of memory [%zu bytes asked]\n", nbytes); \
37  fprintf(stdout, "Calloc at FILE %s, LINE %d, nmem %zu\n", __FILE__, __LINE__, (size_t) nmem); \
38  exit(-1); \
39  } \
40 }
41 
42 #define Realloc(base, nmem, type) {\
43  size_t nbytes = (nmem) * sizeof(type); \
44  (base) = (type*) realloc((base), nbytes); \
45  if ((base) == NULL && nbytes > 0) { \
46  fprintf(stdout, "EVSL Error: out of memory [%zu bytes asked]\n", nbytes); \
47  fprintf(stdout, "Realloc at FILE %s, LINE %d, nmem %zu\n", __FILE__, __LINE__, (size_t) nmem); \
48  exit(-1); \
49  } \
50 }
51 
56 #define max(a, b) ((a) > (b) ? (a) : (b))
57 
62 #define min(a, b) ((a) < (b) ? (a) : (b))
63 
66 #define EVSLFORT(name) name ## _f90_
67 
70 #define NGS_MAX 2
71 
73 #define EVSL_Int int
74 #define EVSL_Unsigned unsigned
75 
76 #endif