Skip to content

Commit

Permalink
import binomial from num-integer
Browse files Browse the repository at this point in the history
  • Loading branch information
minhctran committed Jan 10, 2025
1 parent 2b9ba3c commit cd9ce59
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pyo3 = { version = "0.21", features = [
"num-complex",
"abi3-py39",
] }
num-integer = "0.1"

[target.'cfg(target_os = "linux")'.dependencies]
blas-src = { version = "0.10", features = ["openblas"] }
Expand Down
9 changes: 1 addition & 8 deletions src/fermion_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// copyright notice, and modified files need to carry a notice indicating
// that they have been altered from the originals.

use num_integer::binomial;
use numpy::Complex64;
use pyo3::class::basic::CompareOp;
use pyo3::exceptions::PyKeyError;
Expand Down Expand Up @@ -516,14 +517,6 @@ fn term_trace(op: &[(bool, bool, i32)], norb: usize, nelec: (usize, usize)) -> i
}
}

let binomial = |n, k| {
if k > n {
0
} else {
(1..=n).rev().take(k).product::<usize>() / (1..=k).product::<usize>()
}
};

term_phase(op)
* binomial(norb - norb_alpha, n_alpha - nelec_alpha) as i32
* binomial(norb - norb_beta, n_beta - nelec_beta) as i32
Expand Down

0 comments on commit cd9ce59

Please sign in to comment.