15 #define _USE_MATH_DEFINES
25 #define IS_NORM_0(c) (norm(c) <= FP_NORM_EPSILON)
26 #define IS_SAME(c1, c2) (IS_NORM_0((c1) - (c2)))
27 #define IS_OPPOSITE(c1, c2) (IS_NORM_0((c1) + (c2)))
30 #include <cuda_runtime.h>
33 #if (FPPOW < 5) && !defined(__arm__)
38 #define bitLenInt uint8_t
40 #define bitLenInt uint16_t
42 #define bitLenInt uint32_t
43 #elif (QBCAPPOW < 64) || !defined(__SIZEOF_INT128__)
44 #define bitLenInt uint64_t
46 #define bitLenInt unsigned __int128
50 #define bitCapIntOcl uint8_t
52 #define bitCapIntOcl uint16_t
54 #define bitCapIntOcl uint32_t
55 #elif (UINTPOW < 7) || !defined(__SIZEOF_INT128__)
56 #define bitCapIntOcl uint64_t
58 #define bitCapIntOcl unsigned __int128
62 #define bitCapInt uint32_t
63 #define QRACK_MAX_QUBITS 32
65 #define bitCapInt uint64_t
66 #define QRACK_MAX_QUBITS 64
67 #elif (QBCAPPOW < 8) && defined(__SIZEOF_INT128__)
68 #define bitCapInt unsigned __int128
69 #define QRACK_MAX_QUBITS 128
72 #define bitCapInt BigInteger
83 #if (CPP_STD >= 23) && __has_include(<stdfloat>)
86 #if defined(__STDCPP_FLOAT16_T__)
88 typedef float16_t
real1;
106 typedef double real1;
110 #if (CPP_STD >= 23) && __has_include(<stdfloat>)
113 #if defined(__STDCPP_FLOAT128_T__)
115 typedef float128_t
real1;
119 #include <boost/multiprecision/float128.hpp>
120 #include <quadmath.h>
122 typedef boost::multiprecision::float128
real1;
123 typedef boost::multiprecision::float128
real1_f;
133 typedef std::shared_ptr<complex>
BitOp;
143 class StateVectorSparse;
154 #define bitsInByte 8U
155 #define qrack_rand_gen std::mt19937_64
156 #define qrack_rand_gen_ptr std::shared_ptr<qrack_rand_gen>
157 #define QRACK_ALIGN_SIZE 64U
160 #define ZERO_R1_F 0.0f
161 #define QUARTER_R1_F 0.25f
162 #define HALF_R1_F 0.5f
163 #define ONE_R1_F 1.0f
165 #define ZERO_R1_F 0.0
166 #define QUARTER_R1_F 0.25
167 #define HALF_R1_F 0.5
171 #if (FPPOW > 4) || defined(__arm__)
172 #define QRACK_CONST constexpr
174 #define QRACK_CONST const
177 #define REAL1_DEFAULT_ARG -999.0f
182 #if (FPPOW < 5) || (FPPOW > 6)
188 #define QUARTER_R1 0.25f
193 #define QUARTER_R1 0.25
203 #define REAL1_EPSILON 1.7763568394002505e-15f
206 #define REAL1_EPSILON 6.310887241768095e-30
214 #include <cuda_fp16.h>
215 #define qCudaReal1 __half
216 #define qCudaReal2 __half2
217 #define qCudaReal4 __half2*
218 #define qCudaCmplx __half2
219 #define qCudaCmplx2 __half2*
220 #define qCudaReal1_f float
221 #define make_qCudaCmplx make_half2
222 #define ZERO_R1_CUDA ((qCudaReal1)0.0f)
223 #define REAL1_EPSILON_CUDA ((qCudaReal1)0.000000477f)
224 #define PI_R1_CUDA M_PI
226 #define qCudaReal1 float
227 #define qCudaReal2 float2
228 #define qCudaReal4 float4
229 #define qCudaCmplx float2
230 #define qCudaCmplx2 float4
231 #define qCudaReal1_f float
232 #define make_qCudaCmplx make_float2
233 #define make_qCudaCmplx2 make_float4
234 #define ZERO_R1_CUDA 0.0f
235 #define REAL1_EPSILON_CUDA REAL1_EPSILON
236 #define PI_R1_CUDA PI_R1
238 #define qCudaReal1 double
239 #define qCudaReal2 double2
240 #define qCudaReal4 double4
241 #define qCudaCmplx double2
242 #define qCudaCmplx2 double4
243 #define qCudaReal1_f double
244 #define make_qCudaCmplx make_double2
245 #define make_qCudaCmplx2 make_double4
246 #define ZERO_R1_CUDA 0.0
247 #define REAL1_EPSILON_CUDA REAL1_EPSILON
248 #define PI_R1_CUDA PI_R1
Abstract QEngine implementation, for all "Schroedinger method" engines.
Definition: qengine.hpp:31
Definition: statevector.hpp:72
Definition: statevector.hpp:38
Half-precision floating-point type.
Definition: half.hpp:2222
Main header file for half-precision functionality.
GLOSSARY: bitLenInt - "bit-length integer" - unsigned integer ID of qubit position in register bitCap...
Definition: complex16x2simd.hpp:25
QRACK_CONST real1_f FP_NORM_EPSILON_F
Definition: qrack_types.hpp:259
QRACK_CONST real1 SQRT1_2_R1
Definition: qrack_types.hpp:180
std::shared_ptr< QEngine > QEnginePtr
Definition: qrack_types.hpp:151
QRACK_CONST real1 SQRT2_R1
Definition: qrack_types.hpp:179
QRACK_CONST real1_f TRYDECOMPOSE_EPSILON
Definition: qrack_types.hpp:260
QRACK_CONST real1 HALF_R1
Definition: qrack_types.hpp:184
std::shared_ptr< complex > BitOp
Definition: qrack_types.hpp:133
std::function< bitCapIntOcl(const bitCapIntOcl &)> IncrementFunc
Definition: qrack_types.hpp:137
std::function< bitCapInt(const bitCapInt &)> BdtFunc
Definition: qrack_types.hpp:138
void U(quid sid, bitLenInt q, real1_f theta, real1_f phi, real1_f lambda)
(External API) 3-parameter unitary gate
Definition: wasm_api.cpp:1143
std::function< void(void)> DispatchFn
Definition: dispatchqueue.hpp:31
half_float::half real1
Definition: qrack_types.hpp:94
std::complex< real1 > complex
Definition: qrack_types.hpp:128
QRACK_CONST real1 FP_NORM_EPSILON
Definition: qrack_types.hpp:258
std::shared_ptr< StateVectorSparse > StateVectorSparsePtr
Definition: qrack_types.hpp:147
std::function< void(const bitCapInt &, const unsigned &cpu)> ParallelFuncBdt
Definition: qrack_types.hpp:139
QRACK_CONST real1 REAL1_EPSILON
Definition: qrack_types.hpp:200
QRACK_CONST complex ONE_CMPLX
Definition: qrack_types.hpp:252
QRACK_CONST real1 ONE_R1
Definition: qrack_types.hpp:185
QRACK_CONST real1 ZERO_R1
Definition: qrack_types.hpp:183
constexpr bitLenInt bitsInCap
Definition: qrack_types.hpp:131
float real1_f
Definition: qrack_types.hpp:95
std::shared_ptr< StateVectorArray > StateVectorArrayPtr
Definition: qrack_types.hpp:146
float real1_s
Definition: qrack_types.hpp:96
QRACK_CONST complex CMPLX_DEFAULT_ARG
Definition: qrack_types.hpp:257
std::function< void(const bitCapIntOcl &, const unsigned &cpu)> ParallelFunc
Definition: qrack_types.hpp:136
QRACK_CONST complex I_CMPLX
Definition: qrack_types.hpp:254
std::shared_ptr< StateVector > StateVectorPtr
Definition: qrack_types.hpp:143
QRACK_CONST complex HALF_I_HALF_CMPLX
Definition: qrack_types.hpp:255
QRACK_CONST complex ZERO_CMPLX
Definition: qrack_types.hpp:253
const double FIDELITY_MIN
Definition: qrack_types.hpp:261
QRACK_CONST real1 PI_R1
Definition: qrack_types.hpp:178
const bitCapInt ONE_BCI
Definition: qrack_types.hpp:129
const bitCapInt ZERO_BCI
Definition: qrack_types.hpp:130
QRACK_CONST complex HALF_NEG_I_HALF_CMPLX
Definition: qrack_types.hpp:256
half log(half arg)
Natural logarithm.
Definition: half.hpp:3318
#define REAL1_DEFAULT_ARG
Definition: qrack_types.hpp:177
#define QRACK_CONST
Definition: qrack_types.hpp:174
#define bitLenInt
Definition: qrack_types.hpp:38
#define bitCapInt
Definition: qrack_types.hpp:62
#define bitCapIntOcl
Definition: qrack_types.hpp:50
#define QRACK_MAX_QUBITS
Definition: qrack_types.hpp:63