Skip to content

Commit

Permalink
Define PI2 and PI4 once each
Browse files Browse the repository at this point in the history
These were defined and used in more than one source file.
  • Loading branch information
jlapeyre committed Jun 25, 2024
1 parent a90b04e commit fc05ef1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions crates/accelerate/src/two_qubit_decompose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ use rand_distr::StandardNormal;
use rand_pcg::Pcg64Mcg;

use qiskit_circuit::gate_matrix::{CX_GATE, H_GATE, ONE_QUBIT_IDENTITY, SX_GATE, X_GATE};
use qiskit_circuit::util::{c64, GateArray1Q, GateArray2Q, C_M_ONE, C_ONE, C_ZERO, IM, M_IM};
use qiskit_circuit::util::{
c64, GateArray1Q, GateArray2Q, C_M_ONE, C_ONE, C_ZERO, IM, M_IM, PI2, PI4,
};
use qiskit_circuit::SliceOrInt;

const PI2: f64 = PI / 2.0;
const PI4: f64 = PI / 4.0;
const PI32: f64 = 3.0 * PI2;
const TWO_PI: f64 = 2.0 * PI;

Expand Down
3 changes: 1 addition & 2 deletions crates/accelerate/src/uc_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use ndarray::prelude::*;
use numpy::{IntoPyArray, PyReadonlyArray2};

use crate::euler_one_qubit_decomposer::det_one_qubit;
use qiskit_circuit::util::{c64, C_ZERO, IM};
use qiskit_circuit::util::{c64, C_ZERO, IM, PI2};

const PI2: f64 = PI / 2.;
const EPS: f64 = 1e-10;

// These constants are the non-zero elements of an RZ gate's unitary with an
Expand Down
1 change: 0 additions & 1 deletion crates/circuit/src/gate_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

use num_complex::Complex64;
use std::f64::consts::FRAC_1_SQRT_2;

use crate::util::{
Expand Down
4 changes: 1 addition & 3 deletions crates/circuit/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::f64::consts::PI;

use crate::circuit_data::CircuitData;
use crate::imports::{PARAMETER_EXPRESSION, QUANTUM_CIRCUIT};
use crate::util::{PI2, PI4};
use crate::{gate_matrix, Qubit};

use ndarray::{aview2, Array2};
Expand All @@ -24,9 +25,6 @@ use pyo3::prelude::*;
use pyo3::{intern, IntoPy, Python};
use smallvec::smallvec;

const PI2: f64 = PI / 2.0;
const PI4: f64 = PI / 4.0;

/// Valid types for an operation field in a CircuitInstruction
///
/// These are basically the types allowed in a QuantumCircuit
Expand Down
6 changes: 5 additions & 1 deletion crates/circuit/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

use num_complex::{Complex, Complex64};
use num_complex::Complex64;
use std::f64::consts::PI;

// This is a very conservative version of an abbreviation for constructing new Complex64.
// A couple of alternatives to this function are
Expand Down Expand Up @@ -46,3 +47,6 @@ pub const C_ONE: Complex64 = c64(1., 0.);
pub const C_M_ONE: Complex64 = c64(-1., 0.);
pub const IM: Complex64 = c64(0., 1.);
pub const M_IM: Complex64 = c64(0., -1.);

pub const PI2: f64 = PI / 2.0;
pub const PI4: f64 = PI / 4.0;

0 comments on commit fc05ef1

Please sign in to comment.