File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed
Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,8 @@ fn main() -> Result<()> {
8484 let angle_z = ( x * x) . acos ( ) ;
8585
8686 for i in 0 ..nqubit {
87- u. add_gate_at_mut ( i, ry_matrix ( angle_y) ) ?;
88- u. add_gate_at_mut ( i, rz_matrix ( angle_z) ) ?;
87+ u. add_gate_at ( i, ry_matrix ( angle_y) ) ?;
88+ u. add_gate_at ( i, rz_matrix ( angle_z) ) ?;
8989 }
9090
9191 Ok ( u)
@@ -104,11 +104,11 @@ fn main() -> Result<()> {
104104 for i in 0 ..nqubit {
105105 // TODO: Support parameterized gates
106106 let angle = 2.0 * PI * rng. random :: < f64 > ( ) ;
107- u_out. add_gate_at_mut ( i, rx_matrix ( angle) ) ?;
107+ u_out. add_gate_at ( i, rx_matrix ( angle) ) ?;
108108 let angle = 2.0 * PI * rng. random :: < f64 > ( ) ;
109- u_out. add_gate_at_mut ( i, rz_matrix ( angle) ) ?;
109+ u_out. add_gate_at ( i, rz_matrix ( angle) ) ?;
110110 let angle = 2.0 * PI * rng. random :: < f64 > ( ) ;
111- u_out. add_gate_at_mut ( i, rx_matrix ( angle) ) ?;
111+ u_out. add_gate_at ( i, rx_matrix ( angle) ) ?;
112112 }
113113 }
114114
Original file line number Diff line number Diff line change @@ -15,13 +15,13 @@ use simple_qsim::{
1515fn run_pqc_circuit ( phi : & Vector6 < f64 > ) -> Result < QState > {
1616 let q = QState :: from_str ( "00" ) ?;
1717 let circuit = Circuit :: new ( 2 )
18- . add_gate_at ( 0 , rx_matrix ( phi[ 0 ] ) ) ?
19- . add_gate_at ( 0 , rz_matrix ( phi[ 1 ] ) ) ?
20- . add_gate_at ( 1 , rx_matrix ( phi[ 2 ] ) ) ?
21- . add_gate_at ( 1 , rz_matrix ( phi[ 3 ] ) ) ?
18+ . gate_at ( 0 , rx_matrix ( phi[ 0 ] ) ) ?
19+ . gate_at ( 0 , rz_matrix ( phi[ 1 ] ) ) ?
20+ . gate_at ( 1 , rx_matrix ( phi[ 2 ] ) ) ?
21+ . gate_at ( 1 , rz_matrix ( phi[ 3 ] ) ) ?
2222 . cnot ( 1 , 0 ) ?
23- . add_gate_at ( 1 , rz_matrix ( phi[ 4 ] ) ) ?
24- . add_gate_at ( 1 , rx_matrix ( phi[ 5 ] ) ) ?;
23+ . gate_at ( 1 , rz_matrix ( phi[ 4 ] ) ) ?
24+ . gate_at ( 1 , rx_matrix ( phi[ 5 ] ) ) ?;
2525 Ok ( circuit. apply ( & q) )
2626}
2727
Original file line number Diff line number Diff line change @@ -54,21 +54,21 @@ impl Circuit {
5454 Ok ( matrix)
5555 }
5656
57- pub fn add_gate_at ( mut self , index : usize , gate : CsrMatrix < Qbit > ) -> Result < Self > {
57+ pub fn gate_at ( mut self , index : usize , gate : CsrMatrix < Qbit > ) -> Result < Self > {
5858 let gate = self . create_gate_for_index ( index, & gate) ?;
5959 self . add_gate ( gate) ;
6060 Ok ( self )
6161 }
6262
63- pub fn add_gate_at_mut ( & mut self , index : usize , gate : CsrMatrix < Qbit > ) -> Result < ( ) > {
63+ pub fn add_gate_at ( & mut self , index : usize , gate : CsrMatrix < Qbit > ) -> Result < ( ) > {
6464 let gate = self . create_gate_for_index ( index, & gate) ?;
6565 self . add_gate ( gate) ;
6666 Ok ( ( ) )
6767 }
6868
6969 #[ allow( non_snake_case) ]
7070 pub fn H ( self , index : usize ) -> Result < Self > {
71- self . add_gate_at ( index, h_matrix ( ) )
71+ self . gate_at ( index, h_matrix ( ) )
7272 }
7373
7474 pub fn control (
You can’t perform that action at this time.
0 commit comments