Quantum++  v1.0.0-beta1
C++11 quantum computing library
qpp::Gates Class Referencefinal

const Singleton class that implements most commonly used gates More...

#include <classes/gates.h>

Inheritance diagram for qpp::Gates:
Collaboration diagram for qpp::Gates:

Public Member Functions

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...
 

Public Attributes

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...
 

Private Member Functions

 Gates ()
 Initializes the gates. More...
 
 ~Gates ()=default
 Default destructor. More...
 

Friends

class internal::Singleton< const Gates >
 

Additional Inherited Members

- Static Public Member Functions inherited from qpp::internal::Singleton< const Gates >
static const Gatesget_instance () noexcept(std::is_nothrow_constructible< const Gates >::value)
 
static const Gatesget_thread_local_instance () noexcept(std::is_nothrow_constructible< const Gates >::value)
 
- Protected Member Functions inherited from qpp::internal::Singleton< const Gates >
 Singleton () noexcept=default
 
 Singleton (const Singleton &)=delete
 
Singletonoperator= (const Singleton &)=delete
 
virtual ~Singleton ()=default
 

Detailed Description

const Singleton class that implements most commonly used gates

Constructor & Destructor Documentation

qpp::Gates::Gates ( )
inlineprivate

Initializes the gates.

qpp::Gates::~Gates ( )
privatedefault

Default destructor.

Member Function Documentation

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
AEigen expression
ctrlControl subsystem indexes
subsysSubsystem indexes where the gate A is applied
NTotal number of subsystems
dSubsystem 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
AEigen expression
posPosition
dimsDimensions of the multi-partite system
Returns
Tensor product $ I\otimes\cdots\otimes I\otimes A \otimes I \otimes\cdots\otimes I$, with A on position pos, as a dynamic matrix over the same scalar field as A
cmat qpp::Gates::Fd ( idx  D) const
inline

Fourier transform gate for qudits.

Note
Defined as $ F = \sum_{jk} \exp(2\pi i jk/D) |j\rangle\langle k| $
Parameters
DDimension 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
DDimension of the Hilbert space
Returns
Identity gate
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
thetaRotation angle
n3-dimensional real (unit) vector
Returns
Rotation gate
cmat qpp::Gates::Xd ( idx  D) const
inline

Generalized X gate for qudits.

Note
Defined as $ X = \sum_j |j\oplus 1\rangle\langle j| $, i.e. raising operator $ X|j\rangle = |j\oplus 1\rangle>$
Parameters
DDimension of the Hilbert space
Returns
Generalized X gate for qudits
cmat qpp::Gates::Zd ( idx  D) const
inline

Generalized Z gate for qudits.

Note
Defined as $ Z = \sum_j \exp(2\pi i j/D) |j\rangle\langle j| $
Parameters
DDimension of the Hilbert space
Returns
Generalized Z gate for qudits

Friends And Related Function Documentation

friend class internal::Singleton< const Gates >
friend

Member Data Documentation

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)}

Controlled-Phase gate.

cmat qpp::Gates::FRED {cmat::Identity(8, 8)}

Fredkin gate.

cmat qpp::Gates::H {cmat::Zero(2, 2)}

Hadamard gate.

cmat qpp::Gates::Id2 {cmat::Identity(2, 2)}

Identity gate.

cmat qpp::Gates::S {cmat::Zero(2, 2)}

S gate.

cmat qpp::Gates::SWAP {cmat::Identity(4, 4)}

SWAP gate.

cmat qpp::Gates::T {cmat::Zero(2, 2)}

T gate.

cmat qpp::Gates::TOF {cmat::Identity(8, 8)}

Toffoli gate.

cmat qpp::Gates::X {cmat::Zero(2, 2)}

Pauli Sigma-X gate.

cmat qpp::Gates::Y {cmat::Zero(2, 2)}

Pauli Sigma-Y gate.

cmat qpp::Gates::Z {cmat::Zero(2, 2)}

Pauli Sigma-Z gate.


The documentation for this class was generated from the following file: