view patches/guile-cexp.patch @ 6512:ccc20ae889ca default tip guix

mingw::guile-2.0.7 builds.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Thu, 24 Mar 2016 08:03:39 +0100
parents 437369541c3d
children
line wrap: on
line source

diff --git a/configure.in b/configure.in
index d2eca30..b574180 100644
--- a/configure.in
+++ b/configure.in
@@ -662,6 +662,8 @@ AC_SEARCH_LIBS(crypt, crypt,
 # for the principal root.
 #
 if test "$ac_cv_type_complex_double" = yes; then
+
+  AC_CHECK_FUNCS(cexp clog carg)		         
   AC_CACHE_CHECK([whether csqrt is usable],
     guile_cv_use_csqrt,
     [AC_TRY_RUN([
diff --git a/libguile/numbers.c b/libguile/numbers.c
index a0ef29c..36f25a5 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -5997,6 +5997,33 @@ scm_is_number (SCM z)
   return scm_is_true (scm_number_p (z));
 }
 
+#if !HAVE_CLOG
+complex double clog (complex double z);
+complex double
+clog (complex double z)
+{
+  return log(cabs(z))+I*carg(z);
+}
+#endif
+
+#if !HAVE_CEXP
+complex double cexp (complex double z);
+complex double
+cexp (complex double z)
+{
+  return exp (cabs (z)) * cos(carg (z) + I*sin(carg (z)));
+}
+#endif
+
+#if !HAVE_CARG
+double carg (complex double z);
+double
+carg (complex double z)
+{
+  return atan2 (cimag(z), creal(z));
+}
+#endif
+
 
 /* In the following functions we dispatch to the real-arg funcs like log()
    when we know the arg is real, instead of just handing everything to