Skip to content

Commit ecf9720

Browse files
committed
dsl: SparseFunction coordinates now always real
1 parent 2247707 commit ecf9720

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

devito/operations/interpolators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ def _weights(self, subdomain=None):
472472
@cached_property
473473
def _point_symbols(self):
474474
"""Symbol for coordinate value in each Dimension of the point."""
475-
return DimensionTuple(*(Symbol(name='p%s' % d, dtype=self.sfunction.dtype)
475+
dtype = self.sfunction.coordinates.dtype
476+
return DimensionTuple(*(Symbol(name='p%s' % d, dtype=dtype)
476477
for d in self.grid.dimensions),
477478
getters=self.grid.dimensions)
478479

devito/types/sparse.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ def __subfunc_setup__(self, suffix, keys, dtype=None, inkwargs=False, **kwargs):
202202
else:
203203
dtype = dtype or self.dtype
204204

205+
# Complex coordinates are not valid, so fall back to corresponding
206+
# real floating point type if dtype is complex.
207+
if issubclass(dtype, np.complexfloating):
208+
dtype = {np.complex64: np.float32,
209+
np.complex128: np.float64}.get(dtype, np.float32)
210+
205211
sf = SparseSubFunction(
206212
name=name, dtype=dtype, dimensions=dimensions,
207213
shape=shape, space_order=0, initializer=key, alias=self.alias,

0 commit comments

Comments
 (0)