The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches

Functions for applying the two-qubit SWAP and related gates. More...

Functions

void applyControlledSqrtSwap (Qureg qureg, int control, int qubit1, int qubit2)
 
void applyControlledSwap (Qureg qureg, int control, int qubit1, int qubit2)
 
void applyMultiControlledSqrtSwap (Qureg qureg, int *controls, int numControls, int qubit1, int qubit2)
 
void applyMultiControlledSwap (Qureg qureg, int *controls, int numControls, int qubit1, int qubit2)
 
void applyMultiStateControlledSqrtSwap (Qureg qureg, int *controls, int *states, int numControls, int qubit1, int qubit2)
 
void applyMultiStateControlledSwap (Qureg qureg, int *controls, int *states, int numControls, int qubit1, int qubit2)
 
void applySqrtSwap (Qureg qureg, int qubit1, int qubit2)
 
void applySwap (Qureg qureg, int qubit1, int qubit2)
 
void multiplySwap (Qureg qureg, int qubit1, int qubit2)
 

Detailed Description

Functions for applying the two-qubit SWAP and related gates.

Function Documentation

◆ applyControlledSqrtSwap()

void applyControlledSqrtSwap ( Qureg qureg,
int control,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 616 of file operations.cpp.

616 {
617 validate_quregFields(qureg, __func__);
618 validate_controlAndTwoTargets(qureg, control, target1, target2, __func__);
619
620 // harmlessly re-validates
621 applyMultiStateControlledSqrtSwap(qureg, &control, nullptr, 1, target1, target2);
622}
void applyMultiStateControlledSqrtSwap(Qureg qureg, int *controls, int *states, int numControls, int target1, int target2)

◆ applyControlledSwap()

void applyControlledSwap ( Qureg qureg,
int control,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 568 of file operations.cpp.

568 {
569 validate_quregFields(qureg, __func__);
570 validate_controlAndTwoTargets(qureg, control, qubit1, qubit2, __func__);
571
572 // harmlessly re-valdiates
573 applyMultiStateControlledSwap(qureg, &control, nullptr, 1, qubit1, qubit2);
574}
void applyMultiStateControlledSwap(Qureg qureg, int *controls, int *states, int numControls, int qubit1, int qubit2)

◆ applyMultiControlledSqrtSwap()

void applyMultiControlledSqrtSwap ( Qureg qureg,
int * controls,
int numControls,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 624 of file operations.cpp.

624 {
625 validate_quregFields(qureg, __func__);
626 validate_controlsAndTwoTargets(qureg, controls, numControls, target1, target2, __func__);
627
628 // harmlessly re-validates
629 applyMultiStateControlledSqrtSwap(qureg, controls, nullptr, numControls, target1, target2);
630}

◆ applyMultiControlledSwap()

void applyMultiControlledSwap ( Qureg qureg,
int * controls,
int numControls,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 576 of file operations.cpp.

576 {
577 validate_quregFields(qureg, __func__);
578 validate_controlsAndTwoTargets(qureg, controls, numControls, qubit1, qubit2, __func__);
579
580 // harmlessly re-valdiates
581 applyMultiStateControlledSwap(qureg, controls, nullptr, numControls, qubit1, qubit2);
582}

◆ applyMultiStateControlledSqrtSwap()

void applyMultiStateControlledSqrtSwap ( Qureg qureg,
int * controls,
int * states,
int numControls,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 632 of file operations.cpp.

632 {
633 validate_quregFields(qureg, __func__);
634 validate_controlsAndTwoTargets(qureg, controls, numControls, target1, target2, __func__);
635 validate_controlStates(states, numControls, __func__); // permits states==nullptr
636
637 /// @todo
638 /// this function exacts sqrtSwap as a dense 2-qubit matrix,
639 /// where as bespoke communication and simulation strategy is
640 /// clearly possible which we have not supported because the gate
641 /// is somewhat esoteric. As such, we must validate mixed-amps fit
642
643 validate_mixedAmpsFitInNode(qureg, 2, __func__); // to throw SqrtSwap error, not generic CompMatr2 error
644
645 CompMatr2 matr = getCompMatr2({
646 {1, 0, 0, 0},
647 {0, .5+.5_i, .5-.5_i, 0},
648 {0, .5-.5_i, .5+.5_i, 0},
649 {0, 0, 0, 1}});
650
651 applyMultiStateControlledCompMatr2(qureg, controls, states, numControls, target1, target2, matr);
652}
static CompMatr2 getCompMatr2(qcomp **in)
Definition matrices.h:320
void applyMultiStateControlledCompMatr2(Qureg qureg, int *controls, int *states, int numControls, int target1, int target2, CompMatr2 matrix)

Referenced by applyControlledSqrtSwap(), applyMultiControlledSqrtSwap(), and applySqrtSwap().

◆ applyMultiStateControlledSwap()

void applyMultiStateControlledSwap ( Qureg qureg,
int * controls,
int * states,
int numControls,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 584 of file operations.cpp.

584 {
585 validate_quregFields(qureg, __func__);
586 validate_controlsAndTwoTargets(qureg, controls, numControls, qubit1, qubit2, __func__);
587 validate_controlStates(states, numControls, __func__); // permits states==nullptr
588
589 auto ctrlVec = util_getVector(controls, numControls);
590 auto stateVec = util_getVector(states, numControls); // empty if states==nullptr
591 localiser_statevec_anyCtrlSwap(qureg, ctrlVec, stateVec, qubit1, qubit2);
592
593 if (!qureg.isDensityMatrix)
594 return;
595
596 ctrlVec = util_getBraQubits(ctrlVec, qureg);
597 qubit1 = util_getBraQubit(qubit1, qureg);
598 qubit2 = util_getBraQubit(qubit2, qureg);
599 localiser_statevec_anyCtrlSwap(qureg, ctrlVec, stateVec, qubit1, qubit2);
600}

Referenced by applyControlledSwap(), applyMultiControlledSwap(), and applySwap().

◆ applySqrtSwap()

void applySqrtSwap ( Qureg qureg,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 608 of file operations.cpp.

608 {
609 validate_quregFields(qureg, __func__);
610 validate_twoTargets(qureg,target1, target2, __func__);
611
612 // harmlessly re-validates
613 applyMultiStateControlledSqrtSwap(qureg, nullptr, nullptr, 0, target1, target2);
614}

◆ applySwap()

void applySwap ( Qureg qureg,
int qubit1,
int qubit2 )

Applies a SWAP gate between qubit1 and qubit2 of qureg.

Diagram
Note
Documentation for this function or struct is under construction!

Definition at line 560 of file operations.cpp.

560 {
561 validate_quregFields(qureg, __func__);
562 validate_twoTargets(qureg, qubit1, qubit2, __func__);
563
564 // harmlessly re-valdiates
565 applyMultiStateControlledSwap(qureg, nullptr, nullptr, 0, qubit1, qubit2);
566}

Referenced by applyQuantumFourierTransform().

◆ multiplySwap()

void multiplySwap ( Qureg qureg,
int qubit1,
int qubit2 )
Note
Documentation for this function or struct is under construction!

Definition at line 553 of file operations.cpp.

553 {
554 validate_quregFields(qureg, __func__);
555 validate_twoTargets(qureg, qubit1, qubit2, __func__);
556
557 localiser_statevec_anyCtrlSwap(qureg, {}, {}, qubit1, qubit2);
558}