First cut at lgamma support

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1228 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2005-01-05 17:32:03 +00:00
parent 1bdf9a7876
commit 5792a4f18e
4 changed files with 12219 additions and 3784 deletions

View File

@ -1077,6 +1077,57 @@ p_atanh(Term t E_ARGS)
RFLOAT(out);
}
/*
lgamma(x) is the logarithm of the gamma function.
*/
static E_FUNC
p_lgamma(Term t E_ARGS)
{
Functor f = AritFunctorOfTerm(t);
union arith_ret v;
blob_type bt;
Float dbl, out;
switch (BlobOfFunctor(f)) {
case long_int_e:
dbl = IntegerOfTerm(t);
break;
case double_e:
dbl = FloatOfTerm(t);
break;
#ifdef USE_GMP
case big_int_e:
dbl = mpz_get_d(Yap_BigIntOfTerm(t));
break;
#endif
default:
/* we've got a full term, need to evaluate it first */
bt = Yap_Eval(t, &v);
/* second case, no need no evaluation */
switch (bt) {
case long_int_e:
dbl = v.Int;
break;
case double_e:
dbl = v.dbl;
break;
#ifdef USE_GMP
case big_int_e:
dbl = mpz_get_d(v.big);
break;
#endif
default:
/* Yap_Error */
RERROR();
}
}
#if HAVE_LGAMMA
out = lgamma(dbl);
#endif
RFLOAT(out);
}
/*
floor(x) maximum integer greatest or equal to X
@ -1961,6 +2012,7 @@ static InitUnEntry InitUnTab[] = {
{"asin", p_asin},
{"acos", p_acos},
{"atan", p_atan},
{"lgamma", p_lgamma},
{"asinh", p_asinh},
{"acosh", p_acosh},
{"atanh", p_atanh},

View File

@ -165,6 +165,7 @@
#undef HAVE_ISNAN
#undef HAVE_KILL
#undef HAVE_LABS
#undef HAVE_LGAMMA
#undef HAVE_LINK
#undef HAVE_LOCALTIME
#undef HAVE_LSTAT

15947
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -963,7 +963,8 @@ AC_CHECK_FUNCS(acosh asinh atanh chdir dlopen dup2)
AC_CHECK_FUNCS(fesettrapenable finite getcwd getenv)
AC_CHECK_FUNCS(gethostbyname gethostid gethostname)
AC_CHECK_FUNCS(gethrtime getpwnam getrusage gettimeofday getwd)
AC_CHECK_FUNCS(isatty isnan kill labs link localtime lstat)
AC_CHECK_FUNCS(isatty isnan kill labs link lgamma)
AC_CHECK_FUNCS(localtime lstat)
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp mktime opendir)
AC_CHECK_FUNCS(putenv rand random readlink regexec)
AC_CHECK_FUNCS(rename rint rl_set_prompt sbrk select)