Skip to content

Commit

Permalink
Use FMA for Rz gate
Browse files Browse the repository at this point in the history
  • Loading branch information
smu160 committed Jul 19, 2023
1 parent 85497dd commit e3cd072
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions spinoza/src/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ fn p_c_apply(state: &mut State, control: usize, target: usize, angle: Float) {
}

fn rz_apply_strategy1(state: &mut State, target: usize, diag_matrix: &[Amplitude; 2]) {
let chunk_size = 1 << target; // 2^{t}
// num_chunks = state.len() / chunk_size; // 2^{n} / 2^{t}
let chunk_size = 1 << target;

state
.reals
Expand All @@ -405,9 +404,8 @@ fn rz_apply_strategy1(state: &mut State, target: usize, diag_matrix: &[Amplitude
let m = diag_matrix[i & 1];
let c = *a;
let d = *b;

*a = c * m.re - d * m.im;
*b = c * m.im + d * m.re;
*a = c.mul_add(m.re, -d * m.im);
*b = c.mul_add(m.im, d * m.re);
});
});
}
Expand Down

0 comments on commit e3cd072

Please sign in to comment.