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

Functions for applying general two-qubit dense matrices, as CompMatr2. More...

Functions

void applyCompMatr2 (Qureg qureg, int target1, int target2, CompMatr2 matrix)
 
void applyControlledCompMatr2 (Qureg qureg, int control, int target1, int target2, CompMatr2 matr)
 
void applyMultiControlledCompMatr2 (Qureg qureg, int *controls, int numControls, int target1, int target2, CompMatr2 matr)
 
void applyMultiControlledCompMatr2 (Qureg qureg, std::vector< int > controls, int target1, int target2, CompMatr2 matr)
 
void applyMultiStateControlledCompMatr2 (Qureg qureg, int *controls, int *states, int numControls, int target1, int target2, CompMatr2 matr)
 
void applyMultiStateControlledCompMatr2 (Qureg qureg, std::vector< int > controls, std::vector< int > states, int numControls, int target1, int target2, CompMatr2 matr)
 
void multiplyCompMatr2 (Qureg qureg, int target1, int target2, CompMatr2 matr)
 

Detailed Description

Functions for applying general two-qubit dense matrices, as CompMatr2.

Function Documentation

◆ applyCompMatr2()

void applyCompMatr2 ( Qureg qureg,
int target1,
int target2,
CompMatr2 matrix )

Applies a general two-qubit dense unitary matrix to qubits target1 and target2 (treated as increasing significance) of qureg.

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

Definition at line 131 of file operations.cpp.

131 {
132
133 int targs[] = {target1, target2};
134 validateAndApplyAnyCtrlAnyTargUnitaryMatrix(qureg, nullptr, nullptr, 0, targs, 2, matrix, __func__);
135}

◆ applyControlledCompMatr2()

void applyControlledCompMatr2 ( Qureg qureg,
int control,
int target1,
int target2,
CompMatr2 matr )

Applies a singly-controlled two-qubit dense unitary matrix to qubits target1 and target2 (treated as increasing significance) of qureg.

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

Definition at line 137 of file operations.cpp.

137 {
138
139 int targs[] = {target1, target2};
140 validateAndApplyAnyCtrlAnyTargUnitaryMatrix(qureg, &control, nullptr, 1, targs, 2, matrix, __func__);
141}

◆ applyMultiControlledCompMatr2() [1/2]

void applyMultiControlledCompMatr2 ( Qureg qureg,
int * controls,
int numControls,
int target1,
int target2,
CompMatr2 matr )

Applies a multiply-controlled two-qubit dense unitary matrix to qubits target1 and target2 (treated as increasing significance) of qureg.

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

Definition at line 143 of file operations.cpp.

143 {
144
145 int targs[] = {target1, target2};
146 validateAndApplyAnyCtrlAnyTargUnitaryMatrix(qureg, controls, nullptr, numControls, targs, 2, matrix, __func__);
147}

Referenced by applyMultiControlledCompMatr2().

◆ applyMultiControlledCompMatr2() [2/2]

void applyMultiControlledCompMatr2 ( Qureg qureg,
std::vector< int > controls,
int target1,
int target2,
CompMatr2 matr )
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!
Attention
This function's input validation has not yet been unit tested, so erroneous usage may produce unexpected output. Please use with caution!
Note
Documentation for this function or struct is under construction!
Remarks
This function is only available in C++.

Definition at line 157 of file operations.cpp.

157 {
158
159 applyMultiControlledCompMatr2(qureg, controls.data(), controls.size(), target1, target2, matr);
160}
void applyMultiControlledCompMatr2(Qureg qureg, int *controls, int numControls, int target1, int target2, CompMatr2 matrix)

◆ applyMultiStateControlledCompMatr2() [1/2]

void applyMultiStateControlledCompMatr2 ( Qureg qureg,
int * controls,
int * states,
int numControls,
int target1,
int target2,
CompMatr2 matr )

Applies an arbitrarily-controlled two-qubit dense unitary matrix to qubits target1 and target2 (treated as increasing significance) of qureg, conditioned upon the controls being in the given states.

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

Definition at line 149 of file operations.cpp.

149 {
150
151 int targs[] = {target1, target2};
152 validateAndApplyAnyCtrlAnyTargUnitaryMatrix(qureg, controls, states, numControls, targs, 2, matrix, __func__);
153}

Referenced by applyMultiStateControlledCompMatr2(), and applyMultiStateControlledSqrtSwap().

◆ applyMultiStateControlledCompMatr2() [2/2]

void applyMultiStateControlledCompMatr2 ( Qureg qureg,
std::vector< int > controls,
std::vector< int > states,
int numControls,
int target1,
int target2,
CompMatr2 matr )
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!
Attention
This function's input validation has not yet been unit tested, so erroneous usage may produce unexpected output. Please use with caution!
Note
Documentation for this function or struct is under construction!
Remarks
This function is only available in C++.

Definition at line 162 of file operations.cpp.

162 {
163 validate_controlsMatchStates(controls.size(), states.size(), __func__);
164
165 applyMultiStateControlledCompMatr2(qureg, controls.data(), states.data(), controls.size(), target1, target2, matr);
166}
void applyMultiStateControlledCompMatr2(Qureg qureg, int *controls, int *states, int numControls, int target1, int target2, CompMatr2 matrix)

◆ multiplyCompMatr2()

void multiplyCompMatr2 ( Qureg qureg,
int target1,
int target2,
CompMatr2 matr )
Note
Documentation for this function or struct is under construction!

Definition at line 121 of file operations.cpp.

121 {
122 validate_quregFields(qureg, __func__);
123 validate_twoTargets(qureg, target1, target2, __func__);
124 validate_matrixFields(matrix, __func__); // matrix can be non-unitary
125 validate_mixedAmpsFitInNode(qureg, 2, __func__);
126
127 bool conj = false;
128 localiser_statevec_anyCtrlTwoTargDenseMatr(qureg, {}, {}, target1, target2, matrix, conj);
129}