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);
60 return _mm256_add_pd(_mm256_mul_pd(_mm256_shuffle_pd(
c2,
c2, 5),
61 _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, other.
c2), other.
c2, 15)),
62 _mm256_mul_pd(
c2, _mm256_shuffle_pd(other.
c2, other.
c2, 0)));
66 c2 = _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_mul_pd(
c2, _mm256_set1_pd(other));
84 const __m256d& col1 = mtrxCol1.
c2;
85 const __m256d& col2 = mtrxCol2.
c2;
86 const __m256d dupeLo = _mm256_permute2f128_pd(qubit.
c2, qubit.
c2, 0);
87 const __m256d dupeHi = _mm256_permute2f128_pd(qubit.
c2, qubit.
c2, 17);
89 _mm256_add_pd(_mm256_mul_pd(mtrxCol1Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeLo), dupeLo, 15)),
90 _mm256_mul_pd(col1, _mm256_shuffle_pd(dupeLo, dupeLo, 0))),
91 _mm256_add_pd(_mm256_mul_pd(mtrxCol2Shuff.
c2, _mm256_shuffle_pd(_mm256_xor_pd(
SIGNMASK, dupeHi), dupeHi, 15)),
92 _mm256_mul_pd(col2, _mm256_shuffle_pd(dupeHi, dupeHi, 0))));
97 return matrixMul(mtrxCol1, mtrxCol2, mtrxCol1Shuff, mtrxCol2Shuff, qubit) * nrm;
104 return (cu.
f[0] + cu.
f[1] + cu.
f[2] + cu.
f[3]);
Definition: complex16x2simd.hpp:25
std::complex< half_float::half > complex
Definition: qrack_types.hpp:62
static const __m256d SIGNMASK
Definition: complex16x2simd.hpp:27
double norm(const complex2 &c)
Definition: complex16x2simd.hpp:101
complex2 matrixMul(const complex2 &mtrxCol1, const complex2 &mtrxCol2, const complex2 &mtrxCol1Shuff, const complex2 &mtrxCol2Shuff, const complex2 &qubit)
Definition: complex16x2simd.hpp:81
complex2 mtrxColShuff(const complex2 &mtrxCol)
Definition: complex16x2simd.hpp:80
complex2 operator*(const double &lhs, const complex2 &rhs)
Definition: complex16x2simd.hpp:99
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:71
complex2 operator*=(const double &other)
Definition: complex16x2simd.hpp:73
__m256d c2
Definition: complex16x2simd.hpp:31
complex2 operator*=(const complex2 &other)
Definition: complex16x2simd.hpp:64
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(const __m256d &cm2)
Definition: complex16x2simd.hpp:35
complex2 operator+=(const complex2 &other)
Definition: complex16x2simd.hpp:47
complex2 operator-() const
Definition: complex16x2simd.hpp:72
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