Skip to content

Commit e96c177

Browse files
committed
UDPATE:
1. using standard `sin` and `cos` functions instead of inner functions
1 parent 38dce4f commit e96c177

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

qubitverse/simulator/gates/gates.hh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ namespace simulator
5959
static void apply_theta_gate(complex (&__s)[1 << n_qubits], const gate_type &__g_type, const double &__theta, const std::size_t &qubit_target);
6060
static void apply_2qubit_gate(complex (&__s)[1 << n_qubits], const gate_type &__g_type, const std::size_t &q_control, const std::size_t &q_target);
6161

62-
private:
6362
// a vector-space (hilbert-space) defined over complex numbers C
6463
// 1 << n_qubit translates to 2^N, where N is the number of qubit the hilbert-space(quantum-system) supports
6564
// memory consumption on x86_64 architecture for N-qubit system is: f(N) = 16 * 2^abs(N) bytes, that is exponential growth
@@ -127,17 +126,17 @@ namespace simulator
127126
break;
128127

129128
case gate_type::ROTATION_X:
130-
__g.matrix[0][0] = std::__complex_cos<double>(__theta / 2.0);
131-
__g.matrix[0][1] = (complex){0.0, -1.0} * std::__complex_sin<double>(__theta / 2.0);
132-
__g.matrix[1][0] = (complex){0.0, -1.0} * std::__complex_sin<double>(__theta / 2.0);
133-
__g.matrix[1][1] = std::__complex_cos<double>(__theta / 2.0);
129+
__g.matrix[0][0] = std::cos<double>(__theta / 2.0);
130+
__g.matrix[0][1] = (complex){0.0, -1.0} * std::sin<double>(__theta / 2.0);
131+
__g.matrix[1][0] = (complex){0.0, -1.0} * std::sin<double>(__theta / 2.0);
132+
__g.matrix[1][1] = std::cos<double>(__theta / 2.0);
134133
break;
135134

136135
case gate_type::ROTATION_Y:
137-
__g.matrix[0][0] = std::__complex_cos<double>(__theta / 2.0);
138-
__g.matrix[0][1] = -std::__complex_sin<double>(__theta / 2.0);
139-
__g.matrix[1][0] = std::__complex_sin<double>(__theta / 2.0);
140-
__g.matrix[1][1] = std::__complex_cos<double>(__theta / 2.0);
136+
__g.matrix[0][0] = std::cos<double>(__theta / 2.0);
137+
__g.matrix[0][1] = -std::sin<double>(__theta / 2.0);
138+
__g.matrix[1][0] = std::sin<double>(__theta / 2.0);
139+
__g.matrix[1][1] = std::cos<double>(__theta / 2.0);
141140
break;
142141

143142
case gate_type::ROTATION_Z:

0 commit comments

Comments
 (0)