Skip to content

Commit 7e661ab

Browse files
committed
Use opt_einsum, much faster
1 parent dd5400b commit 7e661ab

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

filter_functions/superoperator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from typing import Optional, Tuple, Union
4141

4242
import numpy as np
43+
import opt_einsum as oe
4344
from numpy import linalg as nla
4445
from numpy import ndarray
4546
from scipy import linalg as sla
@@ -78,8 +79,8 @@ def liouville_representation(U: ndarray, basis: _b.Basis) -> ndarray:
7879
Hilbert space.
7980
"""
8081
U = np.asanyarray(U)
81-
conjugated_basis = np.einsum('...ba,ibc,...cd->...iad', U.conj(), basis, U,
82-
optimize=['einsum_path', (1, 2), (0, 1)])
82+
conjugated_basis = oe.contract('...ba,ibc,...cd->...iad', U.conj(), basis, U,
83+
optimize=[(0, 1), (0, 1)])
8384
return basis.expand(conjugated_basis, hermitian=basis.isherm)
8485

8586

0 commit comments

Comments
 (0)