Maestro 0.3.11
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
Circuits::CPGate< Time > Class Template Reference

The controlled P gate. More...

#include <QuantumGates.h>

Inheritance diagram for Circuits::CPGate< Time >:
Collaboration diagram for Circuits::CPGate< Time >:

Public Member Functions

 CPGate (Types::qubit_t ctrl=0, Types::qubit_t target=1, double lambda=0, Time delay=0)
 CPGate constructor.
virtual std::vector< size_t > AffectedBits () const
 Returns the affected bits.
Types::qubits_vector AffectedQubits () const override
 Get the qubits the quantum gate is applied to.
virtual bool CanAffectQuantumState () const
 Find if the operation can affect the quantum state.
std::shared_ptr< IOperation< Types::time_type > > Clone () const override
 Get a shared pointer to a clone of this object.
void Execute (const std::shared_ptr< Simulators::ISimulator > &sim, OperationState &state) const override
 Execute the quantum gate.
Types::time_type GetDelay () const
 Get the delay of the operation.
QuantumGateType GetGateType () const override
 Get the type of the quantum gate.
double GetLambda () const
 Get the lambda parameter for the controlled phase gate.
Eigen::MatrixXcd GetMatrix () const override
 Get the matrix representation of the quantum gate.
unsigned int GetNumQubits () const override
 Get the number of qubits the quantum gate is applied to.
std::vector< double > GetParams () const override
 Get the gate parameters.
std::shared_ptr< IOperation< Types::time_type > > getptr ()
 Get a shared pointer to this object.
Types::qubit_t GetQubit (unsigned int index=0) const override
 Get the qubit the quantum gate is applied to.
OperationType GetType () const override
 Get the type of the operation.
virtual bool IsBranching () const
 Checks if the operation is a branching one.
virtual bool IsClifford () const
 Checks if the operation is a Clifford one.
virtual bool IsConditional () const
 Find if the operation is a conditional operation.
bool IsNoiseless () const
 Whether noise models skip this operation.
virtual bool NeedsEntanglementForDistribution () const
 Find if the operation needs entanglement for distribution.
std::shared_ptr< IOperation< Types::time_type > > Remap (const std::unordered_map< Types::qubit_t, Types::qubit_t > &qubitsMap, const std::unordered_map< Types::qubit_t, Types::qubit_t > &bitsMap={}) const override
 Get a shared pointer to a remapped operation.
virtual void SetDelay (Types::time_type d)
 Set the delay of the operation.
void SetLambda (double l)
 Set the lambda parameter for the controlled phase gate.
void SetNoiseless (bool value=true)
 Mark the operation as exempt from injected gate noise.
void SetQubit (Types::qubit_t q, unsigned long index=0) override
 Set the qubit the quantum gate is applied to.

Detailed Description

template<typename Time = Types::time_type>
class Circuits::CPGate< Time >

The controlled P gate.

The controlled phase gate.

Template Parameters
TimeThe type of the execution delay.
See also
TwoQubitsGate

Definition at line 2362 of file QuantumGates.h.

Constructor & Destructor Documentation

◆ CPGate()

template<typename Time = Types::time_type>
Circuits::CPGate< Time >::CPGate ( Types::qubit_t ctrl = 0,
Types::qubit_t target = 1,
double lambda = 0,
Time delay = 0 )
inline

CPGate constructor.

Constructs the controlled phase gate object. If specified, the delay is the time the quantum gate takes to execute.

Parameters
ctrlThe control qubit the quantum gate is applied to.
targetThe target qubit the quantum gate is applied to.
lambdaThe lambda parameter for the controlled phase gate.
delayThe time the quantum gate takes to execute.
See also
TwoQubitsGate

Definition at line 2376 of file QuantumGates.h.

References CPGate().

Referenced by CPGate().

Member Function Documentation

◆ AffectedBits()

virtual std::vector< size_t > Circuits::IOperation< Types::time_type >::AffectedBits ( ) const
inlinevirtualinherited

Returns the affected bits.

Returns the affected classical bits.

Returns
The affected bits.

Reimplemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, Circuits::IConditionalOperation< Time >, Circuits::IConditionalOperation< Types::time_type >, Circuits::MeasurementOperation< Time >, and Circuits::Random< Time >.

Definition at line 523 of file Operations.h.

◆ AffectedQubits()

Types::qubits_vector Circuits::TwoQubitsGate< Types::time_type >::AffectedQubits ( ) const
inlineoverridevirtualinherited

Get the qubits the quantum gate is applied to.

Returns the qubits the quantum gate is applied to, in this case two qubits.

Returns
The qubits the quantum gate is applied to.

Reimplemented from Circuits::IOperation< Types::time_type >.

Definition at line 355 of file QuantumGates.h.

◆ CanAffectQuantumState()

virtual bool Circuits::IOperation< Types::time_type >::CanAffectQuantumState ( ) const
inlinevirtualinherited

Find if the operation can affect the quantum state.

Returns true if the operation can affect the quantum state, false otherwise.

Returns
True if the operation can affect the quantum state, false otherwise.

Reimplemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, Circuits::Delay< Time >, and Circuits::QuantumChannelOperation< Time >.

Definition at line 473 of file Operations.h.

◆ Clone()

std::shared_ptr< IOperation< Types::time_type > > Circuits::CloneableGate< CPGate, TwoQubitsGate, Types::time_type >::Clone ( ) const
inlineoverridevirtualinherited

Get a shared pointer to a clone of this object.

Returns a shared pointer to a copy of this object.

Returns
A shared pointer to this object.

Implements Circuits::IOperation< Types::time_type >.

Definition at line 144 of file QuantumGates.h.

◆ Execute()

template<typename Time = Types::time_type>
void Circuits::CPGate< Time >::Execute ( const std::shared_ptr< Simulators::ISimulator > & sim,
OperationState & state ) const
inlineoverridevirtual

Execute the quantum gate.

Executes the quantum gate on the given simulator with the given classical state.

Parameters
simThe simulator to execute the quantum gate on.
stateThe classical state to execute the quantum gate with.
See also
ISimulator
ClassicalState

Implements Circuits::IOperation< Types::time_type >.

Definition at line 2391 of file QuantumGates.h.

References GetLambda(), and Circuits::TwoQubitsGate< Time >::GetQubit().

◆ GetDelay()

Get the delay of the operation.

Returns the delay due of the execution time of the operation.

Returns
The delay of the operation.

Definition at line 546 of file Operations.h.

Referenced by Circuits::NoOperation< Time >::Clone().

◆ GetGateType()

template<typename Time = Types::time_type>
QuantumGateType Circuits::CPGate< Time >::GetGateType ( ) const
inlineoverridevirtual

Get the type of the quantum gate.

Returns the type of the quantum gate.

Returns
The type of the quantum gate.
See also
QuantumGateType

Implements Circuits::IQuantumGate< Types::time_type >.

Definition at line 2425 of file QuantumGates.h.

References Circuits::kCPGateType.

◆ GetLambda()

template<typename Time = Types::time_type>
double Circuits::CPGate< Time >::GetLambda ( ) const
inline

Get the lambda parameter for the controlled phase gate.

Returns the lambda parameter for the controlled phase gate.

Returns
The lambda parameter for the controlled phase gate.

Definition at line 2413 of file QuantumGates.h.

Referenced by Execute().

◆ GetMatrix()

template<typename Time = Types::time_type>
Eigen::MatrixXcd Circuits::CPGate< Time >::GetMatrix ( ) const
inlineoverridevirtual

Get the matrix representation of the quantum gate.

Returns the matrix representation of the quantum gate.

Returns
The matrix representation of the quantum gate.

Implements Circuits::IQuantumGate< Types::time_type >.

Definition at line 2447 of file QuantumGates.h.

Referenced by Simulators::FusionGate::Matrix().

◆ GetNumQubits()

unsigned int Circuits::TwoQubitsGate< Types::time_type >::GetNumQubits ( ) const
inlineoverridevirtualinherited

Get the number of qubits the quantum gate is applied to.

Returns the number of qubits the quantum gate is applied to, in this case 2.

Returns
The number of qubits the quantum gate is applied to: 2.

Implements Circuits::IGateOperation< Types::time_type >.

Definition at line 309 of file QuantumGates.h.

◆ GetParams()

template<typename Time = Types::time_type>
std::vector< double > Circuits::CPGate< Time >::GetParams ( ) const
inlineoverridevirtual

Get the gate parameters.

Returns the parameters of the gate.

Returns
A vector with the parameters of the gate.

Reimplemented from Circuits::IQuantumGate< Types::time_type >.

Definition at line 2436 of file QuantumGates.h.

◆ getptr()

std::shared_ptr< IOperation< Types::time_type > > Circuits::IOperation< Types::time_type >::getptr ( )
inlineinherited

Get a shared pointer to this object.

Returns a shared pointer to this object. The object needs to be already wrapped in a shared pointer.

Returns
A shared pointer to this object.

Definition at line 535 of file Operations.h.

◆ GetQubit()

Types::qubit_t Circuits::TwoQubitsGate< Types::time_type >::GetQubit ( unsigned int index = 0) const
inlineoverridevirtualinherited

Get the qubit the quantum gate is applied to.

Returns the qubit the quantum gate is applied to. Either specify zero or one for the index or leave it default (0). If anything else is used, it will return UINT_MAX.

Parameters
indexThe index of the qubit to get (0 or 1, default value 0).
Returns
The qubit the quantum gate is applied to.

Implements Circuits::IGateOperation< Types::time_type >.

Definition at line 339 of file QuantumGates.h.

◆ GetType()

OperationType Circuits::IGateOperation< Types::time_type >::GetType ( ) const
inlineoverridevirtualinherited

Get the type of the operation.

Get the type of the operation, in this case, gate.

Returns
The type of the operation, gate in this case.
See also
OperationType

Reimplemented from Circuits::IOperation< Types::time_type >.

Definition at line 720 of file Operations.h.

◆ IsBranching()

virtual bool Circuits::IOperation< Types::time_type >::IsBranching ( ) const
inlinevirtualinherited

◆ IsClifford()

◆ IsConditional()

virtual bool Circuits::IOperation< Types::time_type >::IsConditional ( ) const
inlinevirtualinherited

Find if the operation is a conditional operation.

Returns true if the operation is conditional, false otherwise.

Returns
True if the operation is conditional, false otherwise.

Definition at line 500 of file Operations.h.

◆ IsNoiseless()

bool Circuits::IOperation< Types::time_type >::IsNoiseless ( ) const
inlineinherited

Whether noise models skip this operation.

Returns
True if no gate noise is injected after this operation.

Definition at line 580 of file Operations.h.

◆ NeedsEntanglementForDistribution()

virtual bool Circuits::IOperation< Types::time_type >::NeedsEntanglementForDistribution ( ) const
inlinevirtualinherited

Find if the operation needs entanglement for distribution.

Returns true if the operation needs entanglement for distribution, false otherwise.

Returns
True if the operation needs entanglement for distribution, false otherwise.

Reimplemented in Circuits::Circuit< Time >, Circuits::Circuit< Types::time_type >, and Circuits::QuantumChannelOperation< Time >.

Definition at line 488 of file Operations.h.

◆ Remap()

std::shared_ptr< IOperation< Types::time_type > > Circuits::TwoQubitsGate< Types::time_type >::Remap ( const std::unordered_map< Types::qubit_t, Types::qubit_t > & qubitsMap,
const std::unordered_map< Types::qubit_t, Types::qubit_t > & bitsMap = {} ) const
inlineoverridevirtualinherited

Get a shared pointer to a remapped operation.

Returns a shared pointer to a copy of the operation with qubits and classical bits changed according to the provided maps.

Parameters
qubitsMapThe map of qubits to remap.
bitsMapThe map of classical bits to remap.
Returns
A shared pointer to the remapped object.

Implements Circuits::IOperation< Types::time_type >.

Definition at line 370 of file QuantumGates.h.

◆ SetDelay()

virtual void Circuits::IOperation< Types::time_type >::SetDelay ( Types::time_type d)
inlinevirtualinherited

Set the delay of the operation.

Sets the delay due of the execution time of the operation.

Parameters
dThe delay of the operation.

Definition at line 557 of file Operations.h.

◆ SetLambda()

template<typename Time = Types::time_type>
void Circuits::CPGate< Time >::SetLambda ( double l)
inline

Set the lambda parameter for the controlled phase gate.

Sets the lambda parameter for the controlled phase gate.

Parameters
lThe lambda parameter for the controlled phase gate.

Definition at line 2402 of file QuantumGates.h.

◆ SetNoiseless()

void Circuits::IOperation< Types::time_type >::SetNoiseless ( bool value = true)
inlineinherited

Mark the operation as exempt from injected gate noise.

Noise models add no noise after a noiseless operation. This is for basis changes that belong to a non-Z measurement or reset rather than being gates in their own right. Gate copies (Clone, Remap) keep the mark.

Parameters
valueTrue to exempt the operation from gate noise.

Definition at line 570 of file Operations.h.

◆ SetQubit()

void Circuits::TwoQubitsGate< Types::time_type >::SetQubit ( Types::qubit_t q,
unsigned long index = 0 )
inlineoverridevirtualinherited

Set the qubit the quantum gate is applied to.

Sets the qubit the quantum gate is applied to. Either specify zero or one for the index or leave it default (0).

Parameters
qThe qubit the quantum gate is applied to.
indexThe index of the qubit to set (0 or 1, default value 0).

Implements Circuits::IGateOperation< Types::time_type >.

Definition at line 322 of file QuantumGates.h.


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