32 #ifndef CLASSES_STATES_H_ 33 #define CLASSES_STATES_H_ 106 ket psi =
mket({0, 0}, {d, d});
107 for (
idx i = 1; i < d; ++i) {
108 psi +=
mket({i, i}, {d, d});
111 return psi / std::sqrt(d);
132 idx D =
static_cast<idx>(std::pow(d, n));
133 ket result = ket::Zero(D);
157 ket result = ket::Zero(static_cast<ket::Index>(std::pow(d, n)));
158 result(
multiidx2n(std::vector<idx>(n, 1), std::vector<idx>(n, d))) = 1;
186 ket result = ket::Zero(static_cast<ket::Index>(std::pow(d, n)));
187 result(
multiidx2n(std::vector<idx>(n, j), std::vector<idx>(n, d))) = 1;
206 idx D =
static_cast<idx>(std::pow(2, n));
207 ket result = ket::Ones(D);
209 return result / std::sqrt(D);
235 x0 << 1 / std::sqrt(2.), 1 / std::sqrt(2.);
236 x1 << 1 / std::sqrt(2.), -1 / std::sqrt(2.);
237 y0 << 1 / std::sqrt(2.), 1_i / std::sqrt(2.);
238 y1 << 1 / std::sqrt(2.), -1_i / std::sqrt(2.);
251 b00 << 1 / std::sqrt(2.), 0, 0, 1 / std::sqrt(2.);
253 b01 << 0, 1 / std::sqrt(2.), 1 / std::sqrt(2.), 0;
255 b10 << 1 / std::sqrt(2.), 0, 0, -1 / std::sqrt(2.);
257 b11 << 0, 1 / std::sqrt(2.), -1 / std::sqrt(2.), 0;
265 GHZ << 1, 0, 0, 0, 0, 0, 0, 1;
266 GHZ =
GHZ / std::sqrt(2.);
267 W << 0, 1, 1, 0, 1, 0, 0, 0;
268 W =
W / std::sqrt(3.);
271 pW =
W *
W.adjoint();
ket zero(idx n, idx d=2) const
Zero state of n qudits.
Definition: states.h:121
ket minus(idx n) const
Minus state of n qubits.
Definition: states.h:218
ket W
W state.
Definition: states.h:85
cmat pb01
Projector onto the Bell-01 state.
Definition: states.h:79
ket GHZ
GHZ state.
Definition: states.h:84
cmat pb11
Projector onto the Bell-11 state.
Definition: states.h:81
Singleton policy class, used internally to implement the singleton pattern via CRTP (Curiously recurr...
Definition: singleton.h:80
Subsystems mismatch dimensions exception.
Definition: exception.h:365
Eigen::VectorXcd ket
Complex (double precision) dynamic Eigen column vector.
Definition: types.h:54
ket y0
Pauli Sigma-Y 0-eigenstate |y+>
Definition: states.h:48
Quantum++ main namespace.
Definition: codes.h:35
const Singleton class that implements most commonly used states
Definition: states.h:40
Invalid dimension(s) exception.
Definition: exception.h:269
cmat pb00
Projector onto the Bell-00 state.
Definition: states.h:78
ket z1
Pauli Sigma-Z 1-eigenstate |1>
Definition: states.h:51
ket b01
Bell-01 state (following the convention in Nielsen and Chuang)
Definition: states.h:70
ket b00
Bell-00 state (following the convention in Nielsen and Chuang)
Definition: states.h:68
cmat pb10
Projector onto the Bell-10 state.
Definition: states.h:80
cmat pW
Projector onto the W state.
Definition: states.h:89
idx multiidx2n(const std::vector< idx > &midx, const std::vector< idx > &dims)
Multi-index to non-negative integer index.
Definition: functions.h:1376
~States()=default
Default destructor.
cmat py0
Projector onto the Pauli Sigma-Y 0-eigenstate |y+><y+|.
Definition: states.h:58
dyn_mat< typename Derived::Scalar > kronpow(const Eigen::MatrixBase< Derived > &A, idx n)
Kronecker power.
Definition: functions.h:944
cmat px0
Projector onto the Pauli Sigma-X 0-eigenstate |+><+|.
Definition: states.h:54
ket x1
Pauli Sigma-X 1-eigenstate |->
Definition: states.h:47
ket y1
Pauli Sigma-Y 1-eigenstate |y->
Definition: states.h:49
ket z0
Pauli Sigma-Z 0-eigenstate |0>
Definition: states.h:50
ket b11
Bell-11 state (following the convention in Nielsen and Chuang)
Definition: states.h:74
Parameter out of range exception.
Definition: exception.h:515
ket mes(idx d=2) const
Maximally entangled state of 2 qudits.
Definition: states.h:98
ket jn(idx j, idx n, idx d=2) const
state of n qudits
Definition: states.h:171
ket plus(idx n) const
Plus state of n qubits.
Definition: states.h:198
ket one(idx n, idx d=2) const
One state of n qudits.
Definition: states.h:146
cmat pz0
Projector onto the Pauli Sigma-Z 0-eigenstate |0><0|.
Definition: states.h:62
cmat pGHZ
Projector onto the GHZ state.
Definition: states.h:88
Eigen::MatrixXcd cmat
Complex (double precision) dynamic Eigen matrix.
Definition: types.h:64
ket mket(const std::vector< idx > &mask, const std::vector< idx > &dims)
Multi-partite qudit ket.
Definition: functions.h:1405
std::size_t idx
Non-negative integer index.
Definition: types.h:39
ket b10
Bell-10 state (following the convention in Nielsen and Chuang)
Definition: states.h:72
ket x0
Pauli Sigma-X 0-eigenstate |+>
Definition: states.h:46
cmat py1
Projector onto the Pauli Sigma-Y 1-eigenstate |y-><y-|.
Definition: states.h:60
cmat px1
Projector onto the Pauli Sigma-X 1-eigenstate |-><-|.
Definition: states.h:56
cmat pz1
Projector onto the Pauli Sigma-Z 1-eigenstate |1><1|.
Definition: states.h:64
States()
Definition: states.h:233