Skip to content

Commit

Permalink
fix edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Oct 31, 2023
1 parent 0a0c46c commit c9545ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/gpt/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

def _simple_map(operator, numpy_operator=None, extra_params={}):
def _mat(first, second=None):
if isinstance(first, list):
return [_mat(x) for x in first]
if second is not None:
dst = first
src = gpt.eval(second)
Expand Down
17 changes: 9 additions & 8 deletions lib/gpt/core/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ def norm2(l):
l = gpt.util.to_list(l)
l_lattices = [(i, l[i]) for i in range(len(l)) if isinstance(l[i], gpt.lattice)]
l_tensors = [(i, l[i]) for i in range(len(l)) if isinstance(l[i], gpt.tensor)]
ip_l = (
l_lattices[0][1]
.grid.globalsum(
numpy.array([rank_inner_product(x, x) for i, x in l_lattices], dtype=numpy.complex128)
if len(l_lattices) > 0:
ip_l = (
l_lattices[0][1]
.grid.globalsum(
numpy.array([rank_inner_product(x, x) for i, x in l_lattices], dtype=numpy.complex128)
)
.real
)
.real
)
ip_t = [x.norm2() for i, x in l_tensors]
ip = numpy.ndarray(dtype=numpy.complex128, shape=(len(l),))
ip_t = [x.norm2().real for i, x in l_tensors]
ip = numpy.ndarray(dtype=numpy.float64, shape=(len(l),))
for i, j in enumerate(l_lattices):
ip[j[0]] = ip_l[i]
for i, j in enumerate(l_tensors):
Expand Down

0 comments on commit c9545ee

Please sign in to comment.