46 static const std::vector<size_t> dims{2, 2};
47 auto tensor = std::make_shared<Utils::Tensor<>>(dims);
49 std::vector<size_t> indices{0, 0};
50 (*tensor)(indices) = onZero ? 1. : 0.;
52 (*tensor)(indices) = 0;
54 (*tensor)(indices) = onZero ? 0. : 1.;
56 (*tensor)(indices) = 0;
62 static const std::vector<size_t> dims{2};
63 auto tensor = std::make_shared<Utils::Tensor<>>(dims);
65 std::vector<size_t> indices{0};
66 (*tensor)(indices) = 1.0;
68 (*tensor)(indices) = 0.0;
74 static const std::vector<size_t> dims{2};
75 auto tensor = std::make_shared<Utils::Tensor<>>(dims);
77 std::vector<size_t> indices{0};
78 (*tensor)(indices) = 0.0;
80 (*tensor)(indices) = 1.0;
86 const QC::Gates::QuantumGateWithOp<MatrixClass> &gate) {
87 static const std::vector<size_t> dims{2, 2};
88 auto tensor = std::make_shared<Utils::Tensor<>>(dims);
90 const MatrixClass &mat = gate.getRawOperatorMatrix();
92 std::vector<size_t> indices{0, 0};
93 (*tensor)(indices) = mat(0, 0);
95 (*tensor)(indices) = mat(1, 0);
97 (*tensor)(indices) = mat(1, 1);
99 (*tensor)(indices) = mat(0, 1);
105 const QC::Gates::QuantumGateWithOp<MatrixClass> &gate) {
106 static const std::vector<size_t> dims{2, 2, 2, 2};
107 auto tensor = std::make_shared<Utils::Tensor<>>(dims);
109 const MatrixClass &mat = gate.getRawOperatorMatrix();
111 std::vector<size_t> indices;
115 for (
int q0l = 0; q0l < 2; ++q0l)
117 const int l0 = q0l << 1;
119 for (
int q0c = 0; q0c < 2; ++q0c)
122 const int c0 = q0c << 1;
123 for (
int q1l = 0; q1l < 2; ++q1l) {
125 for (
int q1c = 0; q1c < 2; ++q1c) {
127 (*tensor)(indices) = mat(l0 | q1l, c0 | q1c);