summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-02-20 09:57:19 +0200
committerGitHub <noreply@github.com>2019-02-20 09:57:19 +0200
commit02ae0e3aa5f8f894f5e0496e609e3efe0f49eacd (patch)
tree2137405d139c5fc0edc8b444a68157e56d8c29f1
parentd2517ed1311e12bda3c453dd43f4979b84ef60b3 (diff)
parent0cb96b10f164f0b4a532e42353c6cf04249e9bd1 (diff)
downloadnumpy-02ae0e3aa5f8f894f5e0496e609e3efe0f49eacd.tar.gz
Merge pull request #12996 from eric-wieser/complex-interp-slope-cleanup
MAINT: Use the same multiplication order in interp for cached and uncached slopes
-rw-r--r--numpy/core/src/multiarray/compiled_base.c15
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 235e389e8..118cf3754 100644
--- a/numpy/core/src/multiarray/compiled_base.c
+++ b/numpy/core/src/multiarray/compiled_base.c
@@ -776,17 +776,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;
}
}