templates_on.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /* If BASE is undefined we use function names like gsl_name()
  2. and assume that we are using doubles.
  3. If BASE is defined we used function names like gsl_BASE_name()
  4. and use BASE as the base datatype */
  5. #if defined(BASE_GSL_COMPLEX_LONG)
  6. #define BASE gsl_complex_long_double
  7. #define SHORT complex_long_double
  8. #define SHORT_REAL long_double
  9. #define ATOMIC long double
  10. #define USES_LONGDOUBLE 1
  11. #define MULTIPLICITY 2
  12. #define FP 1
  13. #define IN_FORMAT "%Lg"
  14. #define OUT_FORMAT "%Lg"
  15. #define ATOMIC_IO ATOMIC
  16. #define ZERO {{0.0L,0.0L}}
  17. #define ONE {{1.0L,0.0L}}
  18. #define BASE_EPSILON GSL_DBL_EPSILON
  19. #elif defined(BASE_GSL_COMPLEX)
  20. #define BASE gsl_complex
  21. #define SHORT complex
  22. #define SHORT_REAL
  23. #define ATOMIC double
  24. #define MULTIPLICITY 2
  25. #define FP 1
  26. #define IN_FORMAT "%lg"
  27. #define OUT_FORMAT "%g"
  28. #define ATOMIC_IO ATOMIC
  29. #define ZERO {{0.0,0.0}}
  30. #define ONE {{1.0,0.0}}
  31. #define BASE_EPSILON GSL_DBL_EPSILON
  32. #elif defined(BASE_GSL_COMPLEX_FLOAT)
  33. #define BASE gsl_complex_float
  34. #define SHORT complex_float
  35. #define SHORT_REAL float
  36. #define ATOMIC float
  37. #define MULTIPLICITY 2
  38. #define FP 1
  39. #define IN_FORMAT "%g"
  40. #define OUT_FORMAT "%g"
  41. #define ATOMIC_IO ATOMIC
  42. #define ZERO {{0.0F,0.0F}}
  43. #define ONE {{1.0F,0.0F}}
  44. #define BASE_EPSILON GSL_FLT_EPSILON
  45. #elif defined(BASE_LONG_DOUBLE)
  46. #define BASE long double
  47. #define SHORT long_double
  48. #define ATOMIC long double
  49. #define USES_LONGDOUBLE 1
  50. #define MULTIPLICITY 1
  51. #define FP 1
  52. #define IN_FORMAT "%Lg"
  53. #define OUT_FORMAT "%Lg"
  54. #define ATOMIC_IO ATOMIC
  55. #define ZERO 0.0L
  56. #define ONE 1.0L
  57. #define BASE_EPSILON GSL_DBL_EPSILON
  58. #elif defined(BASE_DOUBLE)
  59. #define BASE double
  60. #define SHORT
  61. #define ATOMIC double
  62. #define MULTIPLICITY 1
  63. #define FP 1
  64. #define IN_FORMAT "%lg"
  65. #define OUT_FORMAT "%g"
  66. #define ATOMIC_IO ATOMIC
  67. #define ZERO 0.0
  68. #define ONE 1.0
  69. #define BASE_EPSILON GSL_DBL_EPSILON
  70. #elif defined(BASE_FLOAT)
  71. #define BASE float
  72. #define SHORT float
  73. #define ATOMIC float
  74. #define MULTIPLICITY 1
  75. #define FP 1
  76. #define IN_FORMAT "%g"
  77. #define OUT_FORMAT "%g"
  78. #define ATOMIC_IO ATOMIC
  79. #define ZERO 0.0F
  80. #define ONE 1.0F
  81. #define BASE_EPSILON GSL_FLT_EPSILON
  82. #elif defined(BASE_ULONG)
  83. #define BASE unsigned long
  84. #define SHORT ulong
  85. #define ATOMIC unsigned long
  86. #define MULTIPLICITY 1
  87. #define IN_FORMAT "%lu"
  88. #define OUT_FORMAT "%lu"
  89. #define ATOMIC_IO ATOMIC
  90. #define ZERO 0UL
  91. #define ONE 1UL
  92. #define UNSIGNED 1
  93. #elif defined(BASE_LONG)
  94. #define BASE long
  95. #define SHORT long
  96. #define ATOMIC long
  97. #define MULTIPLICITY 1
  98. #define IN_FORMAT "%ld"
  99. #define OUT_FORMAT "%ld"
  100. #define ATOMIC_IO ATOMIC
  101. #define ZERO 0L
  102. #define ONE 1L
  103. #elif defined(BASE_UINT)
  104. #define BASE unsigned int
  105. #define SHORT uint
  106. #define ATOMIC unsigned int
  107. #define MULTIPLICITY 1
  108. #define IN_FORMAT "%u"
  109. #define OUT_FORMAT "%u"
  110. #define ATOMIC_IO ATOMIC
  111. #define ZERO 0U
  112. #define ONE 1U
  113. #define UNSIGNED 1
  114. #elif defined(BASE_INT)
  115. #define BASE int
  116. #define SHORT int
  117. #define ATOMIC int
  118. #define MULTIPLICITY 1
  119. #define IN_FORMAT "%d"
  120. #define OUT_FORMAT "%d"
  121. #define ATOMIC_IO ATOMIC
  122. #define ZERO 0
  123. #define ONE 1
  124. #elif defined(BASE_USHORT)
  125. #define BASE unsigned short
  126. #define SHORT ushort
  127. #define ATOMIC unsigned short
  128. #define MULTIPLICITY 1
  129. #define IN_FORMAT "%hu"
  130. #define OUT_FORMAT "%hu"
  131. #define ATOMIC_IO ATOMIC
  132. #define ZERO 0U
  133. #define ONE 1U
  134. #define UNSIGNED 1
  135. #elif defined(BASE_SHORT)
  136. #define BASE short
  137. #define SHORT short
  138. #define ATOMIC short
  139. #define MULTIPLICITY 1
  140. #define IN_FORMAT "%hd"
  141. #define OUT_FORMAT "%hd"
  142. #define ATOMIC_IO ATOMIC
  143. #define ZERO 0
  144. #define ONE 1
  145. #elif defined(BASE_UCHAR)
  146. #define BASE unsigned char
  147. #define SHORT uchar
  148. #define ATOMIC unsigned char
  149. #define MULTIPLICITY 1
  150. #define IN_FORMAT "%u"
  151. #define OUT_FORMAT "%u"
  152. #define ATOMIC_IO unsigned int
  153. #define ZERO 0U
  154. #define ONE 1U
  155. #define UNSIGNED 1
  156. #elif defined(BASE_CHAR)
  157. #define BASE char
  158. #define SHORT char
  159. #define ATOMIC char
  160. #define MULTIPLICITY 1
  161. #define IN_FORMAT "%d"
  162. #define OUT_FORMAT "%d"
  163. #define ATOMIC_IO int
  164. #define ZERO 0
  165. #define ONE 1
  166. #ifdef __CHAR_UNSIGNED__
  167. #define UNSIGNED 1
  168. #endif
  169. #else
  170. #error unknown BASE_ directive in source.h
  171. #endif
  172. #define CONCAT2x(a,b) a ## _ ## b
  173. #define CONCAT2(a,b) CONCAT2x(a,b)
  174. #define CONCAT3x(a,b,c) a ## _ ## b ## _ ## c
  175. #define CONCAT3(a,b,c) CONCAT3x(a,b,c)
  176. #define CONCAT4x(a,b,c,d) a ## _ ## b ## _ ## c ## _ ## d
  177. #define CONCAT4(a,b,c,d) CONCAT4x(a,b,c,d)
  178. #ifndef USE_QUALIFIER
  179. #define QUALIFIER
  180. #endif
  181. #ifdef USE_QUALIFIER
  182. #if defined(BASE_DOUBLE)
  183. #define FUNCTION(dir,name) CONCAT3(dir,QUALIFIER,name)
  184. #define TYPE(dir) dir
  185. #define VIEW(dir,name) CONCAT2(dir,name)
  186. #define QUALIFIED_TYPE(dir) QUALIFIER dir
  187. #define QUALIFIED_VIEW(dir,name) CONCAT3(dir,QUALIFIER,name)
  188. #else
  189. #define FUNCTION(a,c) CONCAT4(a,SHORT,QUALIFIER,c)
  190. #define TYPE(dir) CONCAT2(dir,SHORT)
  191. #define VIEW(dir,name) CONCAT3(dir,SHORT,name)
  192. #define QUALIFIED_TYPE(dir) QUALIFIER CONCAT2(dir,SHORT)
  193. #define QUALIFIED_VIEW(dir,name) CONCAT4(dir,SHORT,QUALIFIER,name)
  194. #endif
  195. #if defined(BASE_GSL_COMPLEX)
  196. #define REAL_TYPE(dir) dir
  197. #define REAL_VIEW(dir,name) CONCAT2(dir,name)
  198. #define QUALIFIED_REAL_TYPE(dir) QUALIFIER dir
  199. #define QUALIFIED_REAL_VIEW(dir,name) CONCAT3(dir,QUALIFIER,name)
  200. #else
  201. #define REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
  202. #define REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
  203. #define QUALIFIED_REAL_TYPE(dir) QUALIFIER CONCAT2(dir,SHORT_REAL)
  204. #define QUALIFIED_REAL_VIEW(dir,name) CONCAT4(dir,SHORT_REAL,QUALIFIER,name)
  205. #endif
  206. #else
  207. #if defined(BASE_DOUBLE)
  208. #define FUNCTION(dir,name) CONCAT2(dir,name)
  209. #define TYPE(dir) dir
  210. #define VIEW(dir,name) CONCAT2(dir,name)
  211. #define QUALIFIED_TYPE(dir) TYPE(dir)
  212. #define QUALIFIED_VIEW(dir,name) CONCAT2(dir,name)
  213. #else
  214. #define FUNCTION(a,c) CONCAT3(a,SHORT,c)
  215. #define TYPE(dir) CONCAT2(dir,SHORT)
  216. #define VIEW(dir,name) CONCAT3(dir,SHORT,name)
  217. #define QUALIFIED_TYPE(dir) TYPE(dir)
  218. #define QUALIFIED_VIEW(dir,name) CONCAT3(dir,SHORT,name)
  219. #endif
  220. #if defined(BASE_GSL_COMPLEX)
  221. #define REAL_TYPE(dir) dir
  222. #define REAL_VIEW(dir,name) CONCAT2(dir,name)
  223. #define QUALIFIED_REAL_TYPE(dir) dir
  224. #define QUALIFIED_REAL_VIEW(dir,name) CONCAT2(dir,name)
  225. #else
  226. #define REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
  227. #define REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
  228. #define QUALIFIED_REAL_TYPE(dir) CONCAT2(dir,SHORT_REAL)
  229. #define QUALIFIED_REAL_VIEW(dir,name) CONCAT3(dir,SHORT_REAL,name)
  230. #endif
  231. #endif
  232. #define STRING(x) #x
  233. #define EXPAND(x) STRING(x)
  234. #define NAME(x) EXPAND(TYPE(x))