Skip to content

Commit 1da795e

Browse files
committed
compiler: more robust safeinv
1 parent 65f1b37 commit 1da795e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

devito/passes/iet/misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ def _(expr, lang):
235235

236236
@_lower_macro_math.register(SafeInv)
237237
def _(expr, lang):
238-
eps = np.finfo(np.float32).resolution**2
238+
eps = 2 * np.finfo(expr.base.dtype).resolution**2
239239
return (('SAFEINV(a, b)',
240-
f'(((a) < {eps} || (b) < {eps}) ? (0.0F) : (1.0F / (a)))'),), {}
240+
f'(((a + b) < {eps}F) ? (0.0F) : ((1.0F) / (a)))'),), {}
241241

242242

243243
@iet_pass

devito/symbolics/extended_dtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
limits_mapper = {
1414
np.int32: Bunch(min=ValueLimit('INT_MIN'), max=ValueLimit('INT_MAX')),
1515
np.int64: Bunch(min=ValueLimit('LONG_MIN'), max=ValueLimit('LONG_MAX')),
16-
np.float32: Bunch(min=-ValueLimit('FLT_MAX'), max=ValueLimit('FLT_MAX')),
17-
np.float64: Bunch(min=-ValueLimit('DBL_MAX'), max=ValueLimit('DBL_MAX')),
16+
np.float32: Bunch(min=-ValueLimit('FLT_MIN'), max=ValueLimit('FLT_MAX')),
17+
np.float64: Bunch(min=-ValueLimit('DBL_MIN'), max=ValueLimit('DBL_MAX')),
1818
}
1919

2020

0 commit comments

Comments
 (0)