Qrack  9.0
General classical-emulating-quantum development framework
Namespaces | Macros
state.cpp File Reference
#include "qengine_cpu.hpp"
#include <chrono>
#include <thread>
Include dependency graph for state.cpp:

Namespaces

 Qrack
 

Macros

#define CHECK_ZERO_SKIP()
 
#define NORM_THRESH_KERNEL(fn1, fn2)
 Apply a 2x2 matrix to the state vector. More...
 
#define NORM_CALC_KERNEL(fn1, fn2)
 

Macro Definition Documentation

◆ CHECK_ZERO_SKIP

#define CHECK_ZERO_SKIP ( )
Value:
if (!stateVec) { \
return; \
}

◆ NORM_CALC_KERNEL

#define NORM_CALC_KERNEL (   fn1,
  fn2 
)
Value:
[&](const bitCapIntOcl& lcv, const unsigned& cpu) { \
complex qubit[2U]; \
\
const complex Y0 = stateVec->read(lcv + offset1); \
qubit[1U] = stateVec->read(lcv + offset2); \
\
qubit[0U] = fn1; \
qubit[1U] = fn2; \
\
rngNrm[cpu] = norm(qubit[0U]) + norm(qubit[1U]); \
\
stateVec->write2(lcv + offset1, qubit[0U], lcv + offset2, qubit[1U]); \
};
std::complex< half_float::half > complex
Definition: qrack_types.hpp:62
double norm(const complex2 &c)
Definition: complex16x2simd.hpp:101
MICROSOFT_QUANTUM_DECL void U(_In_ uintq sid, _In_ uintq q, _In_ double theta, _In_ double phi, _In_ double lambda)
(External API) 3-parameter unitary gate
Definition: pinvoke_api.cpp:1362
#define bitCapIntOcl
Definition: qrack_types.hpp:91

◆ NORM_THRESH_KERNEL

#define NORM_THRESH_KERNEL (   fn1,
  fn2 
)
Value:
[&](const bitCapIntOcl& lcv, const unsigned& cpu) { \
complex qubit[2U]; \
\
const complex Y0 = stateVec->read(lcv + offset1); \
qubit[1U] = stateVec->read(lcv + offset2); \
\
qubit[0U] = fn1; \
qubit[1U] = fn2; \
\
real1 dotMulRes = norm(qubit[0U]); \
if (dotMulRes < norm_thresh) { \
qubit[0U] = ZERO_CMPLX; \
} else { \
rngNrm[cpu] += dotMulRes; \
} \
\
dotMulRes = norm(qubit[1U]); \
if (dotMulRes < norm_thresh) { \
qubit[1U] = ZERO_CMPLX; \
} else { \
rngNrm[cpu] += dotMulRes; \
} \
stateVec->write2(lcv + offset1, qubit[0U], lcv + offset2, qubit[1U]); \
}
QRACK_CONST complex ZERO_CMPLX
Definition: qrack_types.hpp:240

Apply a 2x2 matrix to the state vector.

A fundamental operation used by almost all gates.