summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
}