]> granicus.if.org Git - php/commitdiff
Implemented Windows support for asinh(), acosh(), atanh(), log1p() and expm1() +...
authorKalle Sommer Nielsen <kalle@php.net>
Mon, 5 May 2008 06:28:03 +0000 (06:28 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Mon, 5 May 2008 06:28:03 +0000 (06:28 +0000)
[DOC] Windows support for asinh(), acosh(), atanh(), log1p() and expm1()

12 files changed:
ext/standard/basic_functions.c
ext/standard/math.c
ext/standard/php_math.h
ext/standard/tests/math/acosh_basic.phpt
ext/standard/tests/math/acosh_error.phpt
ext/standard/tests/math/acosh_variation.phpt
ext/standard/tests/math/asinh_basic.phpt
ext/standard/tests/math/asinh_error.phpt
ext/standard/tests/math/asinh_variation.phpt
ext/standard/tests/math/atanh_basic.phpt
ext/standard/tests/math/atanh_error.phpt
ext/standard/tests/math/atanh_variation.phpt

index e87207ce736481739749ed1f019c77703e29f7fe..358e8e821e44f34220a9e63ac97a81cf51a199ad 100644 (file)
@@ -1923,26 +1923,20 @@ ZEND_BEGIN_ARG_INFO(arginfo_tanh, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
 
-#ifdef HAVE_ASINH
 static
 ZEND_BEGIN_ARG_INFO(arginfo_asinh, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
-#endif
 
-#ifdef HAVE_ACOSH
 static
 ZEND_BEGIN_ARG_INFO(arginfo_acosh, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
-#endif
 
-#ifdef HAVE_ATANH
 static
 ZEND_BEGIN_ARG_INFO(arginfo_atanh, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
-#endif
 
 static
 ZEND_BEGIN_ARG_INFO(arginfo_pi, 0)
@@ -1974,19 +1968,15 @@ ZEND_BEGIN_ARG_INFO(arginfo_exp, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
 
-#if !defined(PHP_WIN32) && !defined(NETWARE)
 static
 ZEND_BEGIN_ARG_INFO(arginfo_expm1, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
 
-# ifdef HAVE_LOG1P
 static
 ZEND_BEGIN_ARG_INFO(arginfo_log1p, 0)
        ZEND_ARG_INFO(0, number)
 ZEND_END_ARG_INFO()
-# endif
-#endif /* !defined(PHP_WIN32) && !defined(NETWARE) */
 
 static
 ZEND_BEGIN_ARG_INFO_EX(arginfo_log, 0, 0, 1)
@@ -3330,23 +3320,11 @@ const zend_function_entry basic_functions[] = { /* {{{ */
        PHP_FE(sinh,                                                                                                                    arginfo_sinh)
        PHP_FE(cosh,                                                                                                                    arginfo_cosh)
        PHP_FE(tanh,                                                                                                                    arginfo_tanh)
-
-#ifdef HAVE_ASINH
        PHP_FE(asinh,                                                                                                                   arginfo_asinh)
-#endif
-#ifdef HAVE_ACOSH
        PHP_FE(acosh,                                                                                                                   arginfo_acosh)
-#endif
-#ifdef HAVE_ATANH
        PHP_FE(atanh,                                                                                                                   arginfo_atanh)
-#endif
-#if !defined(PHP_WIN32) && !defined(NETWARE)
        PHP_FE(expm1,                                                                                                                   arginfo_expm1)
-# ifdef HAVE_LOG1P
        PHP_FE(log1p,                                                                                                                   arginfo_log1p)
-# endif
-#endif
-
        PHP_FE(pi,                                                                                                                              arginfo_pi)
        PHP_FE(is_finite,                                                                                                               arginfo_is_finite)
        PHP_FE(is_nan,                                                                                                                  arginfo_is_nan)
index 3a207d250b6f83c84c7ed52c037ed53b12da8430..6e43e7ac0c8e7643b1ffb50f2b8a0e9781d37065 100644 (file)
        val = !zend_isnan(tmp_val) ? tmp_val : val;     \
 }                                                      \
 
+/* {{{ php_asinh
+*/
+double php_asinh(double z)
+{
+#ifdef HAVE_ASINH
+       return(asinh(z));
+#else
+       return(log(z + sqrt(1 + pow(z, 2))) / log(M_E));
+#endif
+}
+/* }}} */
+
+/* {{{ php_acosh
+*/
+double php_acosh(double x)
+{
+#ifdef HAVE_ACOSH
+       return(acosh(x));
+#else
+       return(log(x + sqrt(x * x - 1)));
+#endif
+}
+/* }}} */
+
+/* {{{ php_atanh
+*/
+double php_atanh(double z)
+{
+#ifdef HAVE_ATANH
+       return(atanh(z));
+#else
+       return(0.5 * log((1 + z) / (1 - z)));
+#endif
+}
+/* }}} */
+
+/* {{{ php_log1p
+*/
+double php_log1p(double x)
+{
+#ifdef HAVE_LOG1P
+       return(log1p(x));
+#else
+       return(log(1 + x));
+#endif
+}
+/* }}} */
+
+/* {{{ php_expm1
+*/
+double php_expm1(double x)
+{
+#if !defined(PHP_WIN32) && !defined(NETWARE)
+       return(expm1(x));
+#else
+       return(exp(x) - 1);
+#endif
+}
+/* }}}*/
+
 /* {{{ proto int abs(int number) U
    Return the absolute value of the number */
 PHP_FUNCTION(abs) 
@@ -295,8 +355,6 @@ PHP_FUNCTION(tanh)
 }
 /* }}} */
 
-#if !defined(PHP_WIN32) && !defined(NETWARE)
-#ifdef HAVE_ASINH
 /* {{{ proto float asinh(float number) U
    Returns the inverse hyperbolic sine of the number, i.e. the value whose hyperbolic sine is number */
 PHP_FUNCTION(asinh)
@@ -307,12 +365,10 @@ PHP_FUNCTION(asinh)
                return;
        }
 
-       RETURN_DOUBLE(asinh(num));
+       RETURN_DOUBLE(php_asinh(num));
 }
 /* }}} */
-#endif /* HAVE_ASINH */
 
-#ifdef HAVE_ACOSH
 /* {{{ proto float acosh(float number) U
    Returns the inverse hyperbolic cosine of the number, i.e. the value whose hyperbolic cosine is number */
 PHP_FUNCTION(acosh)
@@ -323,12 +379,10 @@ PHP_FUNCTION(acosh)
                return;
        }
 
-       RETURN_DOUBLE(acosh(num));
+       RETURN_DOUBLE(php_acosh(num));
 }
 /* }}} */
-#endif /* HAVE_ACOSH */
 
-#ifdef HAVE_ATANH
 /* {{{ proto float atanh(float number) U
    Returns the inverse hyperbolic tangent of the number, i.e. the value whose hyperbolic tangent is number */
 PHP_FUNCTION(atanh)
@@ -339,11 +393,9 @@ PHP_FUNCTION(atanh)
                return;
        }
 
-       RETURN_DOUBLE(atanh(num));
+       RETURN_DOUBLE(php_atanh(num));
 }
 /* }}} */
-#endif /* HAVE_ATANH */
-#endif /* !defined(PHP_WIN32) && !defined(NETWARE) */
 
 /* {{{ proto float pi(void) U
    Returns an approximation of pi */
@@ -458,7 +510,6 @@ PHP_FUNCTION(exp)
 }
 /* }}} */
 
-#if !defined(PHP_WIN32) && !defined(NETWARE)
 /* {{{ proto float expm1(float number) U
    Returns exp(number) - 1, computed in a way that accurate even when the value of number is close to zero */
 /*
@@ -473,11 +524,10 @@ PHP_FUNCTION(expm1)
                return;
        }
 
-       RETURN_DOUBLE(expm1(num));
+       RETURN_DOUBLE(php_expm1(num));
 }
 /* }}} */
 
-#ifdef HAVE_LOG1P
 /* {{{ proto float log1p(float number) U
    Returns log(1 + number), computed in a way that accurate even when the value of number is close to zero */ 
 /*
@@ -492,11 +542,9 @@ PHP_FUNCTION(log1p)
                return;
        }
 
-       RETURN_DOUBLE(log1p(num));
+       RETURN_DOUBLE(php_log1p(num));
 }
 /* }}} */
-#endif /* HAVE_LOG1P */
-#endif /* !defined(PHP_WIN32) && !defined(NETWARE) */
 
 /* {{{ proto float log(float number, [float base]) U
    Returns the natural logarithm of the number, or the base log if base is specified */
index 04d47e41c5e2d057a322888fd4a64a0b22bd1685..2f26e1d68144f1212a2efdf98644e39f59d3d67e 100644 (file)
@@ -69,23 +69,15 @@ PHP_FUNCTION(rad2deg);
    */
 PHP_FUNCTION(hypot);
 PHP_FUNCTION(expm1);
-#ifdef HAVE_LOG1P
 PHP_FUNCTION(log1p);
-#endif
 
 PHP_FUNCTION(sinh);
 PHP_FUNCTION(cosh);
 PHP_FUNCTION(tanh);
 
-#ifdef HAVE_ASINH
 PHP_FUNCTION(asinh);
-#endif
-#ifdef HAVE_ACOSH
 PHP_FUNCTION(acosh);
-#endif
-#ifdef HAVE_ATANH
 PHP_FUNCTION(atanh);
-#endif
 
 #include <math.h>
 
index 34839ee2fda65822e25e23b05a3441478b86bdae..d94109d9c192e2ce150f4dcf2f079e1d6ca3ced8 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test return type and value for expected input acosh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN")
-       die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 14
 --FILE--
index 83edfc870be7bfabea4db93c9e5612b9bffe71e5..845e051a96fe32732dff403991e71d888427ee2b 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test wrong number of arguments for acosh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --FILE--
 <?php
 /* 
index f166a4753afbfa0882e4cd968d7e6b7dbbbb21f3..d364f26c68ce963acc98d236ffd4db1f5c51ecf2 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test variations in usage of acosh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 10
 --FILE--
index 61f17315536d6558d7070c5fef247629bfb43900..ff8a2d10ac53b55e0662058f464dcfdca97207f6 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test return type and value for expected input asinh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN")
-       die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 14
 --FILE--
index c83b55526e3f87314baa729ce45645d57a495f55..94d44309d463ce69c66bf237b95dd5b3e5e55869 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test wrong number of arguments for asinh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --FILE--
 <?php
 /* 
index aae658dd744a3caaa4f5a4ca167ef071d45f5f30..ee6eb381af9bd1f866593868f7eeaba2ba0b8b83 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test variations in usage of asinh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 10
 --FILE--
index c259bdb82bd737a932804582780ae827081636d8..7e7144e23939a85fb4ba4804914495bb0218e5dc 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test return type and value for expected input atanh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-       die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 14
 --FILE--
index 0301400369c56d88171345a2b7219ce8a4e336b4..5580543cf06e19197d524951a0d7cb3eea8ce499 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test wrong number of arguments for atanh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --FILE--
 <?php
 /* 
index acde0069808a2e1b5592e9b85d1944d67bcee456..e77e2644027df418b737b484045d55762b58a7db 100644 (file)
@@ -1,10 +1,5 @@
 --TEST--
 Test variations in usage of atanh()
---SKIPIF--
-<?php
-if(substr(PHP_OS, 0, 3) == "WIN" )
-        die ("skip - function not supported on Windows");
-?>
 --INI--
 precision = 10
 --FILE--