mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-08-07 01:30:59 +02:00
31902: rationalise use of gamma function.
Make zsh/mathfunc consistent across systems and use tgamma() where available
This commit is contained in:
parent
7a79f660db
commit
ef4d20ad6f
5 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-10-26 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
|
* Jun T: 31902: rationalise gamma function in mathfunc for
|
||||||
|
consistency with various libraries and user expectations.
|
||||||
|
|
||||||
2013-10-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
2013-10-25 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||||
|
|
||||||
* 31890 (with Mikael's fixes in 31891): NEWS: add descriptions
|
* 31890 (with Mikael's fixes in 31891): NEWS: add descriptions
|
||||||
|
|
|
@ -33,7 +33,7 @@ returns an integer.
|
||||||
The function tt(signgam) takes no arguments, and returns an integer, which
|
The function tt(signgam) takes no arguments, and returns an integer, which
|
||||||
is the C variable of the same name, as described in manref(gamma)(3). Note
|
is the C variable of the same name, as described in manref(gamma)(3). Note
|
||||||
that it is therefore only useful immediately after a call to tt(gamma) or
|
that it is therefore only useful immediately after a call to tt(gamma) or
|
||||||
tt(lgamma). Note also that `tt(signgam+LPAR()RPAR)' and `tt(signgam)' are
|
tt(lgamma). Note also that `tt(signgam+LPAR()RPAR())' and `tt(signgam)' are
|
||||||
distinct expressions.
|
distinct expressions.
|
||||||
|
|
||||||
The following functions take two floating point arguments: tt(copysign),
|
The following functions take two floating point arguments: tt(copysign),
|
||||||
|
|
|
@ -340,7 +340,16 @@ math_func(char *name, int argc, mnumber *argv, int id)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MF_GAMMA:
|
case MF_GAMMA:
|
||||||
|
#ifdef HAVE_TGAMMA
|
||||||
|
retd = tgamma(argd);
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_SIGNGAM
|
||||||
|
retd = lgamma(argd);
|
||||||
|
retd = signgam*exp(retd);
|
||||||
|
#else /*XXX assume gamma(x) returns Gamma(x), not log(|Gamma(x)|) */
|
||||||
retd = gamma(argd);
|
retd = gamma(argd);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MF_HYPOT:
|
case MF_HYPOT:
|
||||||
|
|
|
@ -136,3 +136,9 @@ F:This test fails if your math library doesn't have erand48().
|
||||||
done
|
done
|
||||||
(( ok ))
|
(( ok ))
|
||||||
0:Test random number generator distributions are not grossly broken
|
0:Test random number generator distributions are not grossly broken
|
||||||
|
|
||||||
|
float -F 5 g l
|
||||||
|
(( g = gamma(2), l = lgamma(2) ))
|
||||||
|
print $g, $l
|
||||||
|
0:Test Gamma function gamma and lgamma
|
||||||
|
>1.00000, 0.00000
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
|
||||||
getrlimit getrusage \
|
getrlimit getrusage \
|
||||||
setlocale \
|
setlocale \
|
||||||
uname \
|
uname \
|
||||||
signgam \
|
signgam tgamma \
|
||||||
putenv getenv setenv unsetenv xw\
|
putenv getenv setenv unsetenv xw\
|
||||||
brk sbrk \
|
brk sbrk \
|
||||||
pathconf sysconf \
|
pathconf sysconf \
|
||||||
|
|
Loading…
Reference in a new issue