Skip to content

Commit

Permalink
Fix: cphase was missing a qubit
Browse files Browse the repository at this point in the history
  • Loading branch information
notmgsk committed Jul 30, 2021
1 parent f0d1e3f commit 13222de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/gates/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ define_gate!(
define_gate!(
cphase,
[theta],
[q],
[control, target],
[
[C1, C0, C0, C0],
[C0, C1, C0, C0],
Expand Down Expand Up @@ -245,6 +245,12 @@ pub fn gate_matrix(name: String, params: Vec<f64>, qubits: Vec<usize>) -> Result
let target = qubits.get(1).ok_or(GateError::GateMatrixMissingQubit)?;
Ok(ccnot(*control0, *control1, *target))
}
"CPHASE" => {
let control = qubits.get(0).ok_or(GateError::GateMatrixMissingQubit)?;
let target = qubits.get(1).ok_or(GateError::GateMatrixMissingQubit)?;
let theta = params.get(0).ok_or(GateError::GateMatrixMissingParameter)?;
Ok(cphase(*theta, *control, *target))
}
_ => Err(GateError::UnknownGate(name)),
}
}

0 comments on commit 13222de

Please sign in to comment.