22#include "quest/include/modes.h"
23#include "quest/include/precision.h"
31typedef FLOAT_TYPE qreal;
32typedef INDEX_TYPE qindex;
45 typedef std::complex<FLOAT_TYPE> qcomp;
56 #if (FLOAT_PRECISION == 1)
57 typedef _Fcomplex qcomp;
59 #elif (FLOAT_PRECISION == 2)
60 typedef _Dcomplex qcomp;
62 #elif (FLOAT_PRECISION == 4)
63 typedef _Lcomplex qcomp;
69 typedef FLOAT_TYPE _Complex qcomp;
91static inline qcomp
getQcomp(qreal re, qreal im) {
93 #if defined(__cplusplus)
96 #elif defined(_MSC_VER)
97 return (qcomp) {re, im};
119 using namespace std::complex_literals;
127 static inline qcomp
operator ""_i(
long double y) {
128 return qcomp(0,
static_cast<qreal
>(y));
131 static inline qcomp
operator ""_i(
unsigned long long int y) {
132 return qcomp(0,
static_cast<qreal
>(y));
167 #ifndef DEFINE_ARITHMETIC_OVERLOADS
168 #define DEFINE_ARITHMETIC_OVERLOADS 1
171 #if DEFINE_ARITHMETIC_OVERLOADS
174 #define COMP_TO_QCOMP(a) \
176 static_cast<qreal>(std::real(a)), \
177 static_cast<qreal>(std::imag(a)))
179 #define REAL_TO_QCOMP(b) \
180 qcomp(static_cast<qreal>(b), 0)
183 #define DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL(op, compprec, realtype) \
184 static inline qcomp operator op (const std::complex<compprec>& a, const realtype& b) { \
190 static inline qcomp operator op (const realtype& b, const std::complex<compprec>& a) { \
196 static inline std::complex<compprec>& operator op##= (std::complex<compprec>& a, const realtype& b) { \
202 #define DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, realtype) \
203 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL(+, compprec, realtype) \
204 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL(-, compprec, realtype) \
205 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL(*, compprec, realtype) \
206 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL(/, compprec, realtype)
209 #define DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_INTEGER(compprec) \
210 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, int) \
211 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, long int) \
212 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, long long int) \
213 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, unsigned) \
214 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, long unsigned) \
215 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(compprec, long long unsigned)
218 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_INTEGER(
float)
219 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_INTEGER(
double)
220 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_INTEGER(
long double)
223 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
float,
double)
224 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
float,
long double)
225 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
double,
long double)
226 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
double,
float)
227 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
long double,
float)
228 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL(
long double,
double)
231 #define DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX(op, precA, precB) \
232 static inline qcomp operator op (const std::complex<precA>& a, const std::complex<precB>& b) { \
240 #define DEFINE_SINGLE_DIRECTION_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(precA, precB) \
241 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX(+, precA, precB) \
242 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX(-, precA, precB) \
243 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX(*, precA, precB) \
244 DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX(/, precA, precB)
246 #define DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(precA, precB) \
247 DEFINE_SINGLE_DIRECTION_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(precA, precB) \
248 DEFINE_SINGLE_DIRECTION_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(precB, precA)
251 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(
float,
double)
252 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(
float,
long double)
253 DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX(
double,
long double)
258 #undef DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_REAL
259 #undef DEFINE_OPERATOR_BETWEEN_COMPLEX_AND_COMPLEX
260 #undef DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_REAL
261 #undef DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_INTEGER
262 #undef DEFINE_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX
263 #undef DEFINE_SINGLE_DIRECTION_ARITHMETIC_BETWEEN_COMPLEX_AND_COMPLEX
289 extern "C" void reportStr(
const char* str);
297 extern "C" void reportScalar(
const char* label, qcomp num);
322 void _reportScalar_real(
const char* label, qreal num);
326 #define reportScalar(label, num) \
328 qcomp : reportScalar, \
329 qreal : _reportScalar_real, \
330 default : _reportScalar_real \
void reportStr(const char *str)
static qcomp getQcomp(qreal re, qreal im)
void reportScalar(const char *label, qcomp num)