summaryrefslogtreecommitdiff
path: root/numpy/core/src/scalarmathmodule.c.src
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2011-04-02 19:54:04 +0200
committerPauli Virtanen <pav@iki.fi>2011-04-02 20:04:13 +0200
commit65b77ee94131bf8365d8a6dba6fa19da1269339c (patch)
tree460fc0f11f3bdc6c3fa8300c55ece47d2c7eadf3 /numpy/core/src/scalarmathmodule.c.src
parentb8101c94e26ee21d3bdc49270efe14924ca08078 (diff)
downloadnumpy-65b77ee94131bf8365d8a6dba6fa19da1269339c.tar.gz
BUG: core: make complex division by zero to yield inf properly (#1776)
Diffstat (limited to 'numpy/core/src/scalarmathmodule.c.src')
-rw-r--r--numpy/core/src/scalarmathmodule.c.src15
1 files changed, 11 insertions, 4 deletions
diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src
index 2bcc516b1..56f1bc238 100644
--- a/numpy/core/src/scalarmathmodule.c.src
+++ b/numpy/core/src/scalarmathmodule.c.src
@@ -382,10 +382,17 @@ static npy_half (*_basic_half_fmod)(npy_half, npy_half);
(outp)->real = (a).real * (b).real - (a).imag * (b).imag; \
(outp)->imag = (a).real * (b).imag + (a).imag * (b).real; \
} while(0)
-#define @name@_ctype_divide(a, b, outp) do{ \
- @rtype@ d = (b).real*(b).real + (b).imag*(b).imag; \
- (outp)->real = ((a).real*(b).real + (a).imag*(b).imag)/d; \
- (outp)->imag = ((a).imag*(b).real - (a).real*(b).imag)/d; \
+/* Note: complex division by zero must yield some complex inf */
+#define @name@_ctype_divide(a, b, outp) do{ \
+ @rtype@ d = (b).real*(b).real + (b).imag*(b).imag; \
+ if (d != 0) { \
+ (outp)->real = ((a).real*(b).real + (a).imag*(b).imag)/d; \
+ (outp)->imag = ((a).imag*(b).real - (a).real*(b).imag)/d; \
+ } \
+ else { \
+ (outp)->real = (a).real/d; \
+ (outp)->imag = (a).imag/d; \
+ } \
} while(0)
#define @name@_ctype_true_divide @name@_ctype_divide
#define @name@_ctype_floor_divide(a, b, outp) do { \