const Singleton class that implements most commonly used gates
More...
#include <classes/gates.h>
|
cmat | Rn (double theta, const std::vector< double > &n) const |
| Qubit rotation of theta about the 3-dimensional real (unit) vector n. More...
|
|
cmat | Zd (idx D) const |
| Generalized Z gate for qudits. More...
|
|
cmat | Fd (idx D) const |
| Fourier transform gate for qudits. More...
|
|
cmat | Xd (idx D) const |
| Generalized X gate for qudits. More...
|
|
template<typename Derived = Eigen::MatrixXcd> |
Derived | Id (idx D) const |
| Identity gate. More...
|
|
template<typename Derived > |
dyn_mat< typename Derived::Scalar > | CTRL (const Eigen::MatrixBase< Derived > &A, const std::vector< idx > &ctrl, const std::vector< idx > &subsys, idx N, idx d=2) const |
| Generates the multi-partite multiple-controlled-A gate in matrix form. More...
|
|
template<typename Derived > |
dyn_mat< typename Derived::Scalar > | expandout (const Eigen::MatrixBase< Derived > &A, idx pos, const std::vector< idx > &dims) const |
| Expands out. More...
|
|
template<typename Derived > |
dyn_mat< typename Derived::Scalar > | expandout (const Eigen::MatrixBase< Derived > &A, idx pos, const std::initializer_list< idx > &dims) const |
| Expands out. More...
|
|
template<typename Derived > |
dyn_mat< typename Derived::Scalar > | expandout (const Eigen::MatrixBase< Derived > &A, idx pos, idx N, idx d=2) const |
| Expands out. More...
|
|
|
cmat | Id2 {cmat::Identity(2, 2)} |
| Identity gate. More...
|
|
cmat | H {cmat::Zero(2, 2)} |
| Hadamard gate. More...
|
|
cmat | X {cmat::Zero(2, 2)} |
| Pauli Sigma-X gate. More...
|
|
cmat | Y {cmat::Zero(2, 2)} |
| Pauli Sigma-Y gate. More...
|
|
cmat | Z {cmat::Zero(2, 2)} |
| Pauli Sigma-Z gate. More...
|
|
cmat | S {cmat::Zero(2, 2)} |
| S gate. More...
|
|
cmat | T {cmat::Zero(2, 2)} |
| T gate. More...
|
|
cmat | CNOT {cmat::Identity(4, 4)} |
| Controlled-NOT control target gate. More...
|
|
cmat | CZ {cmat::Identity(4, 4)} |
| Controlled-Phase gate. More...
|
|
cmat | CNOTba {cmat::Zero(4, 4)} |
| Controlled-NOT target control gate. More...
|
|
cmat | SWAP {cmat::Identity(4, 4)} |
| SWAP gate. More...
|
|
cmat | TOF {cmat::Identity(8, 8)} |
| Toffoli gate. More...
|
|
cmat | FRED {cmat::Identity(8, 8)} |
| Fredkin gate. More...
|
|
const Singleton class that implements most commonly used gates
template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::Gates::CTRL |
( |
const Eigen::MatrixBase< Derived > & |
A, |
|
|
const std::vector< idx > & |
ctrl, |
|
|
const std::vector< idx > & |
subsys, |
|
|
idx |
N, |
|
|
idx |
d = 2 |
|
) |
| const |
|
inline |
Generates the multi-partite multiple-controlled-A gate in matrix form.
- See also
- qpp::applyCTRL()
- Note
- The dimension of the gate A must match the dimension of subsys
- Parameters
-
A | Eigen expression |
ctrl | Control subsystem indexes |
subsys | Subsystem indexes where the gate A is applied |
N | Total number of subsystems |
d | Subsystem dimensions |
- Returns
- CTRL-A gate, as a matrix over the same scalar field as A
template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::Gates::expandout |
( |
const Eigen::MatrixBase< Derived > & |
A, |
|
|
idx |
pos, |
|
|
const std::vector< idx > & |
dims |
|
) |
| const |
|
inline |
Expands out.
- See also
- qpp::kron()
Expands out A as a matrix in a multi-partite system. Faster than using qpp::kron(I, I, ..., I, A, I, ..., I).
- Parameters
-
A | Eigen expression |
pos | Position |
dims | Dimensions of the multi-partite system |
- Returns
- Tensor product
, with A on position pos, as a dynamic matrix over the same scalar field as A
template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::Gates::expandout |
( |
const Eigen::MatrixBase< Derived > & |
A, |
|
|
idx |
pos, |
|
|
const std::initializer_list< idx > & |
dims |
|
) |
| const |
|
inline |
Expands out.
- See also
- qpp::kron()
Expands out A as a matrix in a multi-partite system. Faster than using qpp::kron(I, I, ..., I, A, I, ..., I).
- Note
- The std::initializer_list overload exists because otherwise, in the degenerate case when dims has only one element, the one element list is implicitly converted to the element's underlying type, i.e. qpp::idx, which has the net effect of picking the wrong (non-vector) qpp::expandout() overload
- Parameters
-
A | Eigen expression |
pos | Position |
dims | Dimensions of the multi-partite system |
- Returns
- Tensor product
, with A on position pos, as a dynamic matrix over the same scalar field as A
template<typename Derived >
dyn_mat<typename Derived::Scalar> qpp::Gates::expandout |
( |
const Eigen::MatrixBase< Derived > & |
A, |
|
|
idx |
pos, |
|
|
idx |
N, |
|
|
idx |
d = 2 |
|
) |
| const |
|
inline |
Expands out.
- See also
- qpp::kron()
Expands out A as a matrix in a multi-partite system. Faster than using qpp::kron(I, I, ..., I, A, I, ..., I).
- Parameters
-
A | Eigen expression |
pos | Position |
N | Number of subsystems |
d | Subsystem dimension |
- Returns
- Tensor product
, with A on position pos, as a dynamic matrix over the same scalar field as A
Fourier transform gate for qudits.
- Note
- Defined as

- Parameters
-
D | Dimension of the Hilbert space |
- Returns
- Fourier transform gate for qudits
template<typename Derived = Eigen::MatrixXcd>
Derived qpp::Gates::Id |
( |
idx |
D | ) |
const |
|
inline |
Identity gate.
- Note
- Can change the return type from complex matrix (default) by explicitly specifying the template parameter
- Parameters
-
D | Dimension of the Hilbert space |
- Returns
- Identity gate on a Hilbert space of dimension D
cmat qpp::Gates::Rn |
( |
double |
theta, |
|
|
const std::vector< double > & |
n |
|
) |
| const |
|
inline |
Qubit rotation of theta about the 3-dimensional real (unit) vector n.
- Parameters
-
theta | Rotation angle |
n | 3-dimensional real (unit) vector |
- Returns
- Rotation gate
Generalized X gate for qudits.
- Note
- Defined as
, i.e. raising operator 
- Parameters
-
D | Dimension of the Hilbert space |
- Returns
- Generalized X gate for qudits
Generalized Z gate for qudits.
- Note
- Defined as

- Parameters
-
D | Dimension of the Hilbert space |
- Returns
- Generalized Z gate for qudits
cmat qpp::Gates::CNOT {cmat::Identity(4, 4)} |
Controlled-NOT control target gate.
cmat qpp::Gates::CNOTba {cmat::Zero(4, 4)} |
Controlled-NOT target control gate.
cmat qpp::Gates::CZ {cmat::Identity(4, 4)} |
cmat qpp::Gates::FRED {cmat::Identity(8, 8)} |
cmat qpp::Gates::H {cmat::Zero(2, 2)} |
cmat qpp::Gates::Id2 {cmat::Identity(2, 2)} |
cmat qpp::Gates::S {cmat::Zero(2, 2)} |
cmat qpp::Gates::SWAP {cmat::Identity(4, 4)} |
cmat qpp::Gates::T {cmat::Zero(2, 2)} |
cmat qpp::Gates::TOF {cmat::Identity(8, 8)} |
cmat qpp::Gates::X {cmat::Zero(2, 2)} |
cmat qpp::Gates::Y {cmat::Zero(2, 2)} |
cmat qpp::Gates::Z {cmat::Zero(2, 2)} |
The documentation for this class was generated from the following file: