Skip to content

Commit 42fbeaf

Browse files
Fix warnings
1 parent 751118d commit 42fbeaf

File tree

2 files changed

+7
-45
lines changed

2 files changed

+7
-45
lines changed

examples/qcl.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
//! This example implements a Quantum Circuit Learning (QCL)
22
//! This is a port of https://dojo.qulacs.org/ja/latest/notebooks/5.2_Quantum_Circuit_Learning.html
33
4-
use core::{f64, time};
5-
use std::{
6-
collections::{HashMap, VecDeque},
7-
f64::consts::PI,
8-
};
4+
use core::f64;
5+
use std::f64::consts::PI;
96

107
use anyhow::Result;
11-
use nalgebra::{Complex, DMatrix, DVector, Matrix1, Matrix2, Matrix4, MatrixN, SMatrix, Vector6};
12-
use nalgebra_sparse::convert::serial::convert_csr_dense;
13-
use nalgebra_sparse::CsrMatrix;
8+
use nalgebra::{Complex, DMatrix};
149
use plotters::prelude::*;
15-
use rand::{distr, Rng};
16-
use rand_distr::num_traits::FromPrimitive;
10+
use rand::Rng;
1711
use simple_qsim::{
18-
circuit::kronecker_product,
19-
gates::{rx_matrix, ry_matrix, rz_matrix, x_matrix, z_matrix},
12+
gates::{rx_matrix, ry_matrix, rz_matrix},
2013
Circuit, QState, Qbit,
2114
};
2215

@@ -106,7 +99,7 @@ fn main() -> Result<()> {
10699
let mut u_out = Circuit::new(nqubit);
107100

108101
let mut rng = rand::rng();
109-
for d in 0..c_depth {
102+
for _ in 0..c_depth {
110103
u_out.add_dence_gate(time_evol_op.clone());
111104
for i in 0..nqubit {
112105
// TODO: Support parameterized gates

src/observable.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use crate::{
66
qstate::QState,
77
};
88
use anyhow::Result;
9-
use nalgebra_sparse::{
10-
convert::serial::{convert_csr_dense, convert_dense_csr},
11-
CsrMatrix,
12-
};
9+
use nalgebra_sparse::{convert::serial::convert_dense_csr, CsrMatrix};
1310

1411
pub struct Observable {
1512
operators: Vec<PauliOperator>,
@@ -37,34 +34,6 @@ impl Observable {
3734
let mut expectation = 0.0;
3835

3936
for operator in &self.operators {
40-
let mut term = 0.0;
41-
// for pauli_matrix in &operator.ops {
42-
// let index = pauli_matrix.index;
43-
// let kind = &pauli_matrix.kind;
44-
45-
// let alpha = qstate
46-
// .state
47-
// .get(index)
48-
// .ok_or_else(|| anyhow::anyhow!("Index out of bounds for qstate"))?;
49-
// let beta = qstate
50-
// .state
51-
// .get(index + 1)
52-
// .ok_or_else(|| anyhow::anyhow!("Index out of bounds for qstate"))?;
53-
54-
// match kind {
55-
// Pauli::I => {
56-
// // Identity does not change the expectation value
57-
// }
58-
// Pauli::X => term += 2.0 * (alpha.conj() * beta).re,
59-
// Pauli::Y => term += 2.0 * (alpha.conj() * beta).im,
60-
// Pauli::Z => {
61-
// let alpha = alpha.norm_sqr();
62-
// let beta = beta.norm_sqr();
63-
// term += alpha - beta;
64-
// }
65-
// }
66-
// }
67-
6837
let mut kinds = iter::repeat(Pauli::I)
6938
.take(qstate.num_of_qbits())
7039
.collect::<Vec<_>>();

0 commit comments

Comments
 (0)