[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/01: Fix atan procedure when applied to complex number
From: |
Mark H. Weaver |
Subject: |
[Guile-commits] 01/01: Fix atan procedure when applied to complex numbers. |
Date: |
Thu, 23 Jul 2015 01:04:02 +0000 |
mhw pushed a commit to branch stable-2.0
in repository guile.
commit e3c59bfb8d822526d8cff3993ff653ac0d2b2961
Author: Mark H Weaver <address@hidden>
Date: Wed Jul 22 20:56:18 2015 -0400
Fix atan procedure when applied to complex numbers.
Fixes a regression introduced in commit
ad79736c68a803a59814fbfc0cb4b092c2b4cddf.
* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
---
libguile/numbers.c | 4 ++--
test-suite/tests/numbers.test | 7 ++++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index a80b064..1e3fc30 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -8977,8 +8977,8 @@ SCM_PRIMITIVE_GENERIC (scm_atan, "atan", 1, 1, 0,
double v, w;
v = SCM_COMPLEX_REAL (z);
w = SCM_COMPLEX_IMAG (z);
- return scm_divide (scm_log (scm_divide (scm_c_make_rectangular (v, w
- 1.0),
- scm_c_make_rectangular (v, w
+ 1.0))),
+ return scm_divide (scm_log (scm_divide (scm_c_make_rectangular (-v,
1.0 - w),
+ scm_c_make_rectangular ( v,
1.0 + w))),
scm_c_make_rectangular (0, 2));
}
else
diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test
index 847f939..0adf216 100644
--- a/test-suite/tests/numbers.test
+++ b/test-suite/tests/numbers.test
@@ -1,6 +1,6 @@
;;;; numbers.test --- tests guile's numbers -*- scheme -*-
-;;;; Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2009, 2010, 2011,
-;;;; 2012, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 2000, 2001, 2003-2006, 2009-2013,
+;;;; 2015 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -4467,7 +4467,8 @@
(pass-if (eqv? 0 (atan 0)))
(pass-if (eqv? 0.0 (atan 0.0)))
(pass-if (eqv-loosely? 1.57 (atan +inf.0)))
- (pass-if (eqv-loosely? -1.57 (atan -inf.0))))
+ (pass-if (eqv-loosely? -1.57 (atan -inf.0)))
+ (pass-if (eqv-loosely? -1.42+0.5i (atan -0.5+2.0i))))
;;;
;;; sinh