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

Functions for applying many-qubit rotations around Pauli Z axis, and phase flips and shifts. More...

Functions

void applyControlledPhaseGadget (Qureg qureg, int control, int *targets, int numTargets, qreal angle)
 
void applyMultiControlledPhaseGadget (Qureg qureg, int *controls, int numControls, int *targets, int numTargets, qreal angle)
 
void applyMultiQubitPhaseFlip (Qureg qureg, int *targets, int numTargets)
 
void applyMultiQubitPhaseShift (Qureg qureg, int *targets, int numTargets, qreal angle)
 
void applyMultiStateControlledPhaseGadget (Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, qreal angle)
 
void applyPhaseFlip (Qureg qureg, int target)
 
void applyPhaseGadget (Qureg qureg, int *targets, int numTargets, qreal angle)
 
void applyPhaseShift (Qureg qureg, int target, qreal angle)
 
void applyTwoQubitPhaseFlip (Qureg qureg, int target1, int target2)
 
void applyTwoQubitPhaseShift (Qureg qureg, int target1, int target2, qreal angle)
 
void multiplyPhaseGadget (Qureg qureg, int *targets, int numTargets, qreal angle)
 

Detailed Description

Functions for applying many-qubit rotations around Pauli Z axis, and phase flips and shifts.

Function Documentation

◆ applyControlledPhaseGadget()

void applyControlledPhaseGadget ( Qureg qureg,
int control,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1154 of file operations.cpp.

1154 {
1155 validate_quregFields(qureg, __func__);
1156 validate_controlAndTargets(qureg, control, targets, numTargets, __func__);
1157
1158 // harmlessly re-validates
1159 applyMultiStateControlledPhaseGadget(qureg, &control, nullptr, 1, targets, numTargets, angle);
1160}
void applyMultiStateControlledPhaseGadget(Qureg qureg, int *controls, int *states, int numControls, int *targets, int numTargets, qreal angle)

◆ applyMultiControlledPhaseGadget()

void applyMultiControlledPhaseGadget ( Qureg qureg,
int * controls,
int numControls,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1162 of file operations.cpp.

1162 {
1163 validate_quregFields(qureg, __func__);
1164 validate_controlsAndTargets(qureg, controls, numControls, targets, numTargets, __func__);
1165
1166 // harmlessly re-validates
1167 applyMultiStateControlledPhaseGadget(qureg, controls, nullptr, numControls, targets, numTargets, angle);
1168}

◆ applyMultiQubitPhaseFlip()

void applyMultiQubitPhaseFlip ( Qureg qureg,
int * targets,
int numTargets )
Note
Documentation for this function or struct is under construction!

Definition at line 1247 of file operations.cpp.

1247 {
1248 validate_quregFields(qureg, __func__);
1249 validate_targets(qureg, targets, numTargets, __func__);
1250
1251 // treat as a (numTargets-1)-controlled 1-target Pauli Z
1252 DiagMatr1 matr = getDiagMatr1({1, -1});
1253
1254 // harmlessly re-validates
1255 applyMultiStateControlledDiagMatr1(qureg, &targets[1], nullptr, numTargets-1, targets[0], matr);
1256}
static DiagMatr1 getDiagMatr1(qcomp *in)
Definition matrices.h:338
void applyMultiStateControlledDiagMatr1(Qureg qureg, int *controls, int *states, int numControls, int target, DiagMatr1 matrix)

Referenced by applyPhaseFlip(), and applyTwoQubitPhaseFlip().

◆ applyMultiQubitPhaseShift()

void applyMultiQubitPhaseShift ( Qureg qureg,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1213 of file operations.cpp.

1213 {
1214 validate_quregFields(qureg, __func__);
1215 validate_targets(qureg, targets, numTargets, __func__);
1216
1217 // treat as a (numTargets-1)-controlled 1-target diagonal matrix
1218 DiagMatr1 matr = getDiagMatr1({1, std::exp(1_i * angle)});
1219
1220 // harmlessly re-validates
1221 applyMultiStateControlledDiagMatr1(qureg, &targets[1], nullptr, numTargets-1, targets[0], matr);
1222}

Referenced by applyPhaseShift(), and applyTwoQubitPhaseShift().

◆ applyMultiStateControlledPhaseGadget()

void applyMultiStateControlledPhaseGadget ( Qureg qureg,
int * controls,
int * states,
int numControls,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1170 of file operations.cpp.

1170 {
1171 validate_quregFields(qureg, __func__);
1172 validate_controlsAndTargets(qureg, controls, numControls, targets, numTargets, __func__);
1173 validate_controlStates(states, numControls, __func__);
1174
1175 qreal phase = util_getPhaseFromGateAngle(angle);
1176 auto ctrlVec = util_getVector(controls, numControls);
1177 auto targVec = util_getVector(targets, numTargets);
1178 auto stateVec = util_getVector(states, numControls); // empty if states==nullptr
1179 localiser_statevec_anyCtrlPhaseGadget(qureg, ctrlVec, stateVec, targVec, phase);
1180
1181 if (!qureg.isDensityMatrix)
1182 return;
1183
1184 phase *= -1;
1185 ctrlVec = util_getBraQubits(ctrlVec, qureg);
1186 targVec = util_getBraQubits(targVec, qureg);
1187 localiser_statevec_anyCtrlPhaseGadget(qureg, ctrlVec, stateVec, targVec, phase);
1188}

Referenced by applyControlledPhaseGadget(), applyMultiControlledPhaseGadget(), and applyPhaseGadget().

◆ applyPhaseFlip()

void applyPhaseFlip ( Qureg qureg,
int target )
Note
Documentation for this function or struct is under construction!

Definition at line 1230 of file operations.cpp.

1230 {
1231 validate_quregFields(qureg, __func__);
1232 validate_target(qureg, target, __func__);
1233
1234 // harmlessly re-validates
1235 applyMultiQubitPhaseFlip(qureg, &target, 1);
1236}
void applyMultiQubitPhaseFlip(Qureg qureg, int *targets, int numTargets)

◆ applyPhaseGadget()

void applyPhaseGadget ( Qureg qureg,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1146 of file operations.cpp.

1146 {
1147 validate_quregFields(qureg, __func__);
1148 validate_targets(qureg, targets, numTargets, __func__);
1149
1150 // harmlessly re-validates
1151 applyMultiStateControlledPhaseGadget(qureg, nullptr, nullptr, 0, targets, numTargets, angle);
1152}

◆ applyPhaseShift()

void applyPhaseShift ( Qureg qureg,
int target,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1196 of file operations.cpp.

1196 {
1197 validate_quregFields(qureg, __func__);
1198 validate_target(qureg, target, __func__);
1199
1200 // harmlessly re-validates
1201 applyMultiQubitPhaseShift(qureg, &target, 1, angle);
1202}
void applyMultiQubitPhaseShift(Qureg qureg, int *targets, int numTargets, qreal angle)

◆ applyTwoQubitPhaseFlip()

void applyTwoQubitPhaseFlip ( Qureg qureg,
int target1,
int target2 )

Applies a two-qubit phase flip upon qubit1 and qubit2 of qureg.

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

Definition at line 1238 of file operations.cpp.

1238 {
1239 validate_quregFields(qureg, __func__);
1240 validate_twoTargets(qureg, target1, target2, __func__);
1241
1242 // harmlessly re-validates
1243 int targets[] = {target1, target2};
1244 applyMultiQubitPhaseFlip(qureg, targets, 2);
1245}

◆ applyTwoQubitPhaseShift()

void applyTwoQubitPhaseShift ( Qureg qureg,
int target1,
int target2,
qreal angle )

Applies a two-qubit phase flip upon qubit1 and qubit2 of qureg.

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

Definition at line 1204 of file operations.cpp.

1204 {
1205 validate_quregFields(qureg, __func__);
1206 validate_twoTargets(qureg, target1, target2, __func__);
1207
1208 // harmlessly re-validates
1209 int targets[] = {target1, target2};
1210 applyMultiQubitPhaseShift(qureg, targets, 2, angle);
1211}

Referenced by applyQuantumFourierTransform().

◆ multiplyPhaseGadget()

void multiplyPhaseGadget ( Qureg qureg,
int * targets,
int numTargets,
qreal angle )
Note
Documentation for this function or struct is under construction!

Definition at line 1138 of file operations.cpp.

1138 {
1139 validate_quregFields(qureg, __func__);
1140 validate_targets(qureg, targets, numTargets, __func__);
1141
1142 qreal phase = util_getPhaseFromGateAngle(angle);
1143 localiser_statevec_anyCtrlPhaseGadget(qureg, {}, {}, util_getVector(targets,numTargets), phase);
1144}