Skip to content

Commit

Permalink
♻️ 🔥 use opToSingleGateMatrix to retrieve matrix and remove unused CX…
Browse files Browse the repository at this point in the history
…_MAT and CZ_MAT
  • Loading branch information
Joshy-R committed Nov 14, 2024
1 parent 535f0b6 commit 8c9a224
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 279 deletions.
13 changes: 4 additions & 9 deletions src/dd/NoiseFunctionality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,11 @@ mEdge StochasticNoiseFunctionality::generateNoiseOperation(
stackOperation(operation, target, effect, amplitudeDampingMatrix);
break;
}
case (qc::X): {
operation = stackOperation(operation, target, effect, X_MAT);
break;
}
case (qc::Y): {
operation = stackOperation(operation, target, effect, Y_MAT);
break;
}
case (qc::X):
case (qc::Y):
case (qc::Z): {
operation = stackOperation(operation, target, effect, Z_MAT);
operation = stackOperation(operation, target, effect,
opToSingleGateMatrix(effect));
break;
}
default: {
Expand Down
3 changes: 2 additions & 1 deletion src/dd/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ void extractProbabilityVectorRecursive(const QuantumComputation* qc,

if (RealNumber::approximatelyEquals(pone, 1.)) {
const qc::MatrixDD xGate =
dd.makeGateDD(X_MAT, static_cast<Qubit>(permutation.at(target)));
dd.makeGateDD(opToSingleGateMatrix(qc::X),
static_cast<Qubit>(permutation.at(target)));
const qc::VectorDD resetState = dd.multiply(xGate, state);
dd.incRef(resetState);
dd.decRef(state);
Expand Down
6 changes: 3 additions & 3 deletions test/dd/test_edge_functionality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ TEST(DensityMatrixFunctionality, GetValueByIndexProperDensityMatrix) {
auto dd = std::make_unique<dd::Package<>>(nqubits);
auto zero = dd->makeZeroDensityOperator(nqubits);
dd->incRef(zero);
const auto op1 = dd->makeGateDD(dd::H_MAT, 0U);
const auto op1 = dd->makeGateDD(dd::opToSingleGateMatrix(qc::H), 0U);
const auto op2 = dd->makeGateDD(dd::rzMat(dd::PI_4), 0U);
auto state = dd->applyOperationToDensity(zero, op1);
state = dd->applyOperationToDensity(state, op2);
Expand Down Expand Up @@ -400,7 +400,7 @@ TEST(DensityMatrixFunctionality, GetSparseMatrixConsistency) {
auto dd = std::make_unique<dd::Package<>>(nqubits);
auto zero = dd->makeZeroDensityOperator(nqubits);
dd->incRef(zero);
const auto op1 = dd->makeGateDD(dd::H_MAT, 0U);
const auto op1 = dd->makeGateDD(dd::opToSingleGateMatrix(qc::H), 0U);
const auto op2 = dd->makeGateDD(dd::rzMat(dd::PI_4), 0U);
auto state = dd->applyOperationToDensity(zero, op1);
state = dd->applyOperationToDensity(state, op2);
Expand Down Expand Up @@ -431,7 +431,7 @@ TEST(DensityMatrixFunctionality, PrintMatrix) {
auto dd = std::make_unique<dd::Package<>>(nqubits);
auto zero = dd->makeZeroDensityOperator(nqubits);
dd->incRef(zero);
const auto op1 = dd->makeGateDD(dd::H_MAT, 0U);
const auto op1 = dd->makeGateDD(dd::opToSingleGateMatrix(qc::H), 0U);
const auto op2 = dd->makeGateDD(dd::rzMat(dd::PI_4), 0U);
auto state = dd->applyOperationToDensity(zero, op1);
state = dd->applyOperationToDensity(state, op2);
Expand Down
Loading

0 comments on commit 8c9a224

Please sign in to comment.