Skip to content

Commit e7aac75

Browse files
committed
Fix fmod bug
1 parent c9775f2 commit e7aac75

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

numexpr/bespoke_functions.hpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ inline long rintl(long x) {return x;}
3030
inline int fabsi(int x) {return x<0 ? -x: x;}
3131
inline long fabsl(long x) {return x<0 ? -x: x;}
3232
// fmod function for ints
33-
inline int fmodi(int x, int y) {return (int)fmodf((float)x, (float)y);}
34-
inline long fmodl(long x, long y) {return (long)fmodf((long)x, (long)y);}
33+
/* Have to add FUNC_III, FUNC_LLL signatures to functions.hpp*/
34+
// inline int fmodi(int x, int y) {return (int)fmodf((float)x, (float)y);}
35+
// inline long fmodl(long x, long y) {return (long)fmodf((long)x, (long)y);}
3536

3637
#ifdef USE_VML
3738
static void viRint(MKL_INT n, const int* x, int* dest)
@@ -84,20 +85,21 @@ static void vdfmod(MKL_INT n, const double* x1, const double* x2, double* dest)
8485
dest[j] = fmod(x1[j], x2[j]);
8586
};
8687
};
87-
static void vifmod(MKL_INT n, const int* x1, const int* x2, int* dest)
88-
{
89-
MKL_INT j;
90-
for(j=0; j < n; j++) {
91-
dest[j] = fmodi(x1[j], x2[j]);
92-
};
93-
};
94-
static void vlfmod(MKL_INT n, const long* x1, const long* x2, long* dest)
95-
{
96-
MKL_INT j;
97-
for(j=0; j < n; j++) {
98-
dest[j] = fmodl(x1[j], x2[j]);
99-
};
100-
};
88+
/* Have to add FUNC_III, FUNC_LLL signatures to functions.hpp*/
89+
// static void vifmod(MKL_INT n, const int* x1, const int* x2, int* dest)
90+
// {
91+
// MKL_INT j;
92+
// for(j=0; j < n; j++) {
93+
// dest[j] = fmodi(x1[j], x2[j]);
94+
// };
95+
// };
96+
// static void vlfmod(MKL_INT n, const long* x1, const long* x2, long* dest)
97+
// {
98+
// MKL_INT j;
99+
// for(j=0; j < n; j++) {
100+
// dest[j] = fmodl(x1[j], x2[j]);
101+
// };
102+
// };
101103

102104
/* no isnan, isfinite, isinf or signbit in VML */
103105
static void vsIsfinite(MKL_INT n, const float* x1, bool* dest)

numexpr/expressions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ def function(*args):
186186
return ConstantNode(func(*[x.value for x in args]))
187187
kind = commonKind(args)
188188
if kind in ('int', 'long'):
189-
if func.__name__ not in ('copy', 'abs', 'fmod', 'ones_like', 'round', 'sign'):
189+
if func.__name__ not in ('copy', 'abs', 'ones_like', 'round', 'sign'):
190190
# except for these special functions (which return ints for int inputs in NumPy)
191191
# just do a cast to double
192+
# FIXME: 'fmod' outputs ints for NumPy when inputs are ints, but need to
193+
# add new function signatures FUNC_LLL FUNC_III to support this
192194
kind = 'double'
193195
else:
194196
# Apply regular casting rules

0 commit comments

Comments
 (0)