Skip to content

Commit

Permalink
use opt einsum contract for wick (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung authored Nov 6, 2023
1 parent 4e66086 commit a81f1c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/ffsim/states/wick.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from collections.abc import Sequence

import numpy as np
from opt_einsum import contract


def expectation_one_body_product(
Expand Down Expand Up @@ -84,11 +85,11 @@ def expectation_one_body_product(
tensors.append(
one_rdm if indices.index(c_i) < indices.index(a_i) else anti_one_rdm
)
result += sign * np.einsum(
result += sign * contract(
f'{",".join(subscripts)}->',
*one_body_tensors,
*tensors[:n_tensors],
optimize=True,
optimize="greedy",
)
return result

Expand Down

0 comments on commit a81f1c2

Please sign in to comment.