diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-02-19 23:03:35 -0800 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2019-02-19 23:03:35 -0800 |
commit | 0cb96b10f164f0b4a532e42353c6cf04249e9bd1 (patch) | |
tree | 3e4e30a0a0584a0e70fdbd8905dd9a903e2bcbc3 | |
parent | 806a9453979d0435073a5b343adc16cdc29a9afb (diff) | |
download | numpy-0cb96b10f164f0b4a532e42353c6cf04249e9bd1.tar.gz |
MAINT: Use the same multiplication order for cached and uncached slopes
It's possible that the switched order could cause a different result, something that optimizations should not affect.
This also just deduplicates code, which is a good thing anyway
-rw-r--r-- | numpy/core/src/multiarray/compiled_base.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c index 625028bfb..b498ed243 100644 --- a/numpy/core/src/multiarray/compiled_base.c +++ b/numpy/core/src/multiarray/compiled_base.c @@ -774,17 +774,18 @@ arr_interp_complex(PyObject *NPY_UNUSED(self), PyObject *args, PyObject *kwdict) dres[i] = dy[j]; } else { - if (slopes!=NULL) { - dres[i].real = slopes[j].real*(x_val - dx[j]) + dy[j].real; - dres[i].imag = slopes[j].imag*(x_val - dx[j]) + dy[j].imag; + npy_cdouble slope; + if (slopes != NULL) { + slope = slopes[j]; } else { const npy_double inv_dx = 1.0 / (dx[j+1] - dx[j]); - dres[i].real = (dy[j+1].real - dy[j].real)*(x_val - dx[j])* - inv_dx + dy[j].real; - dres[i].imag = (dy[j+1].imag - dy[j].imag)*(x_val - dx[j])* - inv_dx + dy[j].imag; + slope.real = (dy[j+1].real - dy[j].real) * inv_dx; + slope.imag = (dy[j+1].imag - dy[j].imag) * inv_dx; } + + dres[i].real = slope.real*(x_val - dx[j]) + dy[j].real; + dres[i].imag = slope.imag*(x_val - dx[j]) + dy[j].imag; } } |