public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ghazi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/29335] transcendental functions with constant arguments should be resolved at compile-time
Date: Thu, 02 Nov 2006 14:41:00 -0000 [thread overview]
Message-ID: <20061102144131.3530.qmail@sourceware.org> (raw)
In-Reply-To: <bug-29335-578@http.gcc.gnu.org/bugzilla/>
------- Comment #30 from ghazi at gcc dot gnu dot org 2006-11-02 14:41 -------
(In reply to comment #28)
> (In reply to comment #27)
> > It's likely that I'll end up doing it, so would you please tell me how?
> According to the C rationale (I haven't checked), the sign of gamma(x) is -1 if
> [iff] x < 0 && remainder(floor(x), 2) != 0. But if x is a non-positive integer,
> the sign of gamma(x) isn't defined. Handle these cases first.
> The test x < 0 is easy to do. In MPFR, you can compute floor(x) (or trunc(x))
> with the precision min(PREC(x),max(EXP(x),MPFR_PREC_MIN)), but then, there's no
> direct function to decide whether the result is even or odd (I thought we added
> this, but this isn't the case). The solution can be to divide x by 2 (this is
> exact, except in case of underflow) and call mpfr_frac directly. If the result
> is between -0.5 and 0, then gamma(x) is negative. If the result is between -1
> and -0.5, then gamma(x) is positive. So, a 2-bit precision for mpfr_frac should
> be sufficient (as -0.5 is representable in this precision), but choose a
> directed rounding (not GMP_RNDN) for that. Then you can just do a comparison
> with -0.5; the case of equality with -0.5 depends on the chosen rounding (if
> you obtain -0.5, then it is an inexact result since x is not an integer). For
> instance, if you choose GMP_RNDZ, then a result > -0.5 means that gamma(x) is
> negative, and a result <= -0.5 means that gamma(x) is positive.
Vincent, thank you for the detailed instructions. I also read your two
possible solutions posted here:
http://sympa.loria.fr/wwsympa/arc/mpfr/2006-10/msg00036.html
I could be satisfied with either solution from that message. However in the
case of choice 1, I feel the calculation of signgam should be provided from a
function call in the library rather than forcing each user to write a routine
to calculate it. IMHO, I'd rather leave the math to the mathematicians. :-)
E.g. you could add a function mpfr_signgam() that figures out the value for the
user and thereby leave the interface for mpfr_lngamma() unchanged. Choice 2
also solves the issue by providing the int* parameter.
Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29335
next prev parent reply other threads:[~2006-11-02 14:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-03 16:48 [Bug middle-end/29335] New: " ghazi at gcc dot gnu dot org
2006-10-05 5:11 ` [Bug middle-end/29335] " pinskia at gcc dot gnu dot org
2006-10-05 17:54 ` kargl at gcc dot gnu dot org
2006-10-06 13:25 ` ghazi at gcc dot gnu dot org
2006-10-06 14:40 ` kargl at gcc dot gnu dot org
2006-10-06 15:36 ` ghazi at gcc dot gnu dot org
2006-10-06 17:03 ` kargl at gcc dot gnu dot org
2006-10-07 2:05 ` ghazi at gcc dot gnu dot org
2006-10-07 14:08 ` ghazi at gcc dot gnu dot org
2006-10-09 17:16 ` ghazi at gcc dot gnu dot org
2006-10-14 16:12 ` ghazi at gcc dot gnu dot org
2006-10-14 16:14 ` ghazi at gcc dot gnu dot org
2006-10-20 15:54 ` ghazi at gcc dot gnu dot org
2006-10-23 20:25 ` ghazi at gcc dot gnu dot org
2006-10-24 17:45 ` ghazi at gcc dot gnu dot org
2006-10-25 20:44 ` ghazi at gcc dot gnu dot org
2006-10-28 3:20 ` ghazi at gcc dot gnu dot org
2006-10-28 3:48 ` sgk at troutmask dot apl dot washington dot edu
2006-10-28 9:07 ` vincent at vinc17 dot org
2006-10-28 13:29 ` ghazi at gcc dot gnu dot org
2006-10-28 14:06 ` vincent at vinc17 dot org
2006-10-28 16:04 ` ghazi at gcc dot gnu dot org
2006-10-28 16:58 ` vincent at vinc17 dot org
2006-10-29 2:02 ` ghazi at gcc dot gnu dot org
2006-10-30 20:22 ` ghazi at gcc dot gnu dot org
2006-10-31 3:14 ` ghazi at gcc dot gnu dot org
2006-10-31 9:55 ` vincent at vinc17 dot org
2006-10-31 20:09 ` ghazi at gcc dot gnu dot org
2006-10-31 22:15 ` vincent at vinc17 dot org
2006-11-02 3:21 ` ghazi at gcc dot gnu dot org
2006-11-02 14:41 ` ghazi at gcc dot gnu dot org [this message]
2006-11-02 15:57 ` vincent at vinc17 dot org
2006-11-02 22:44 ` ghazi at gcc dot gnu dot org
2006-11-05 23:27 ` vincent at vinc17 dot org
2006-11-07 2:46 ` ghazi at gcc dot gnu dot org
2006-11-30 19:45 ` chaoyingfu at gcc dot gnu dot org
2006-12-18 14:54 ` ghazi at gcc dot gnu dot org
2006-12-26 19:03 ` ghazi at gcc dot gnu dot org
2006-12-26 19:13 ` ghazi at gcc dot gnu dot org
2007-01-20 0:33 ` ghazi at gcc dot gnu dot org
2007-01-31 15:06 ` ghazi at gcc dot gnu dot org
[not found] <bug-29335-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 10:00 ` jackie.rosen at hushmail dot com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061102144131.3530.qmail@sourceware.org \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).