18 #include <emmintrin.h>
19 #include <immintrin.h>
20 #include <smmintrin.h>
27 static const __m256d
SIGNMASK = _mm256_set_pd(-0.0, -0.0, -0.0, -0.0);
37 inline complex2(
const std::complex<double>& cm1,
const std::complex<double>& cm2)
39 c2 = _mm256_set_pd(cm2.imag(), cm2.real(), cm1.imag(), cm1.real());
41 inline complex2(
const double& r1,
const double& i1,
const double& r2,
const double& i2)
43 c2 = _mm256_set_pd(i2, r2, i1, r1);
45 inline std::complex<double>
c(
const size_t& i)
const {
return complex(
f[i << 1U],
f[(i << 1U) + 1U]); }
49 c2 = _mm256_add_pd(
c2, other.
c2);
55 c2 = _mm256_sub_pd(
c2, other.
c2);
62 return _mm256_fmadd_pd(_mm256_shuffle_pd(
c2,
c2, 5),
63 _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, other.
c2), other.
c2, 15),
64 _mm256_mul_pd(
c2, _mm256_shuffle_pd(other.
c2, other.
c2, 0)));
66 return _mm256_add_pd(_mm256_mul_pd(_mm256_shuffle_pd(
c2,
c2, 5),
67 _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, other.
c2), other.
c2, 15)),
68 _mm256_mul_pd(
c2, _mm256_shuffle_pd(other.
c2, other.
c2, 0)));
75 c2 = _mm256_fmadd_pd(_mm256_shuffle_pd(
c2,
c2, 5),
76 _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, other.
c2), other.
c2, 15),
77 _mm256_mul_pd(
c2, _mm256_shuffle_pd(other.
c2, other.
c2, 0)));
79 c2 = _mm256_add_pd(_mm256_mul_pd(_mm256_shuffle_pd(
c2,
c2, 5),
80 _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, other.
c2), other.
c2, 15)),
81 _mm256_mul_pd(
c2, _mm256_shuffle_pd(other.
c2, other.
c2, 0)));
89 c2 = _mm256_mul_pd(
c2, _mm256_set1_pd(rhs));
98 const __m256d dupeLo = _mm256_permute2f128_pd(qubit.
c2, qubit.
c2, 0);
99 const __m256d dupeHi = _mm256_permute2f128_pd(qubit.
c2, qubit.
c2, 17);
102 return _mm256_add_pd(
103 _mm256_fmadd_pd(mtrxCol1Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeLo), dupeLo, 15),
104 _mm256_mul_pd(mtrxCol1.
c2, _mm256_shuffle_pd(dupeLo, dupeLo, 0))),
105 _mm256_fmadd_pd(mtrxCol2Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeHi), dupeHi, 15),
106 _mm256_mul_pd(mtrxCol2.
c2, _mm256_shuffle_pd(dupeHi, dupeHi, 0))));
108 return _mm256_add_pd(
109 _mm256_add_pd(_mm256_mul_pd(mtrxCol1Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeLo), dupeLo, 15)),
110 _mm256_mul_pd(mtrxCol1.
c2, _mm256_shuffle_pd(dupeLo, dupeLo, 0))),
111 _mm256_add_pd(_mm256_mul_pd(mtrxCol2Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeHi), dupeHi, 15)),
112 _mm256_mul_pd(mtrxCol2.
c2, _mm256_shuffle_pd(dupeHi, dupeHi, 0))));
118 return matrixMul(mtrxCol1, mtrxCol2, mtrxCol1Shuff, mtrxCol2Shuff, qubit) * nrm;
125 const __m256d sq = _mm256_mul_pd(c.
c2, c.
c2);
126 const __m256d sum = _mm256_hadd_pd(sq, sq);
127 return _mm_cvtsd_f64(_mm_add_pd(_mm256_castpd256_pd128(sum), _mm256_extractf128_pd(sum, 1)));
GLOSSARY: bitLenInt - "bit-length integer" - unsigned integer ID of qubit position in register bitCap...
Definition: complex16x2simd.hpp:25
static const __m256d SIGNMASK
Definition: complex16x2simd.hpp:27
std::complex< real1 > complex
Definition: qrack_types.hpp:136
double norm(const complex2 &c)
Definition: complex16x2simd.hpp:122
complex2 matrixMul(const complex2 &mtrxCol1, const complex2 &mtrxCol2, const complex2 &mtrxCol1Shuff, const complex2 &mtrxCol2Shuff, const complex2 &qubit)
Definition: complex16x2simd.hpp:95
complex2 mtrxColShuff(const complex2 &mtrxCol)
Definition: complex16x2simd.hpp:94
complex2 operator*(const double &lhs, const complex2 &rhs)
Definition: complex16x2simd.hpp:120
SIMD implementation of the double precision complex vector type of 2 complex numbers,...
Definition: complex16x2simd.hpp:30
complex2 operator*(const complex2 &other) const
Definition: complex16x2simd.hpp:58
complex2(const complex2 &cm2)
Definition: complex16x2simd.hpp:36
double f[4]
Definition: complex16x2simd.hpp:32
complex2 operator*(const double &rhs) const
Definition: complex16x2simd.hpp:85
__m256d c2
Definition: complex16x2simd.hpp:31
complex2 operator*=(const complex2 &other)
Definition: complex16x2simd.hpp:71
complex2()
Definition: complex16x2simd.hpp:34
complex2(const std::complex< double > &cm1, const std::complex< double > &cm2)
Definition: complex16x2simd.hpp:37
complex2 operator-(const complex2 &other) const
Definition: complex16x2simd.hpp:52
complex2(const double &r1, const double &i1, const double &r2, const double &i2)
Definition: complex16x2simd.hpp:41
complex2 operator*=(const double &rhs)
Definition: complex16x2simd.hpp:87
complex2(const __m256d &cm2)
Definition: complex16x2simd.hpp:35
complex2 operator+=(const complex2 &other)
Definition: complex16x2simd.hpp:47
complex2 operator-() const
Definition: complex16x2simd.hpp:86
std::complex< double > c(const size_t &i) const
Definition: complex16x2simd.hpp:45
complex2 operator+(const complex2 &other) const
Definition: complex16x2simd.hpp:46
complex2 operator-=(const complex2 &other)
Definition: complex16x2simd.hpp:53