Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Jan 22, 2025
1 parent fdff8da commit 19ff7ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gem/gem.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,16 @@ def __new__(cls, i, j, dtype=None):
if isinstance(i, Integral) and isinstance(j, Integral):
return one if i == j else Zero()

if isinstance(i, Integral):
expr = numpy.full(j.extent, Zero(), dtype=object)
expr[i] = one
return Indexed(ListTensor(expr), (j,))

if isinstance(j, Integral):
expr = numpy.full(i.extent, Zero(), dtype=object)
expr[j] = one
return Indexed(ListTensor(expr), (i,))

self = super(Delta, cls).__new__(cls)
self.i = i
self.j = j
Expand Down

0 comments on commit 19ff7ef

Please sign in to comment.