From owner-freebsd-numerics@FreeBSD.ORG Sun Sep 14 21:58:26 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8E352742 for ; Sun, 14 Sep 2014 21:58:26 +0000 (UTC) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 51DADC2E for ; Sun, 14 Sep 2014 21:58:25 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 78DFDD621F0; Mon, 15 Sep 2014 07:36:50 +1000 (EST) Date: Mon, 15 Sep 2014 07:36:49 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Steve Kargl Subject: Re: lgammal[_r] patch In-Reply-To: <20140913193634.GA2323@troutmask.apl.washington.edu> Message-ID: <20140915072530.T6209@besplex.bde.org> References: <20140913193634.GA2323@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=idpLQEjTYo0A:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=IA8RstZcDPKuw5DDDAkA:9 a=CjuIK1q_8ugA:10 Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2014 21:58:26 -0000 On Sat, 13 Sep 2014, Steve Kargl wrote: > Following my .sig is a patch that contains the ld80 and ld128 > implementations of lgamma[_r](). It also contains an update > to lgammaf_r() and lgamma_r(). Specifically, it has Looks good. It passed all my tests so far. I haven't tested ld128 or compared ld80 with more than d64. You even matched the fdlibm style bugs almost perfectly :-). Do you know agree that copying a reasonable method is easiest? > Index: ld80/e_lgammal_r.c > =================================================================== > --- ld80/e_lgammal_r.c (revision 0) > +++ ld80/e_lgammal_r.c (working copy) > @@ -0,0 +1,343 @@ > +/* @(#)e_lgamma_r.c 1.3 95/01/18 */ > +/* > + * ==================================================== > + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. > + * > + * Developed at SunSoft, a Sun Microsystems, Inc. business. > + * Permission to use, copy, modify, and distribute this > + * software is freely granted, provided that this notice > + * is preserved. > + * ==================================================== > + */ > + > +#include > +__FBSDID("$FreeBSD"); > +/* > + * See s_lgamma_r.c for complete comments. > + * > + * Converted to long double by Steven G. Kargl. > + */ > +#include > +#ifdef __i386__ > +#include > +#endif Missing blank line before the include here and in most other places. > Index: src/math.h > =================================================================== > --- src/math.h (revision 271479) > +++ src/math.h (working copy) > @@ -496,8 +496,12 @@ > long double tanl(long double); > long double tgammal(long double); > long double truncl(long double); > +#endif /* __ISO_C_VISIBLE >= 1999 */ > > -#endif /* __ISO_C_VISIBLE >= 1999 */ > +#if __BSD_VISIBLE > +long double lgammal_r(long double, int *); > +#endif /* __BSD_VISIBLE */ This comment has extra indentation and is not needed. Only larger sections or more complicated conditionals need a comment on #endif. The rest of the file mostly follows this rule. One large section is missing a comment. The BSD extras aren't very well sorted. Neither are the float and double sections. It was only useful to keep the float and double functions in separate sections in 1990 when they weren't standard. > + > __END_DECLS > > #endif /* !_MATH_H_ */ Bruce From owner-freebsd-numerics@FreeBSD.ORG Mon Sep 15 00:11:05 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 92A57711 for ; Mon, 15 Sep 2014 00:11:05 +0000 (UTC) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask.apl.washington.edu", Issuer "troutmask.apl.washington.edu" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 73680A7A for ; Mon, 15 Sep 2014 00:11:05 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id s8F0Ax2l007366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 14 Sep 2014 17:10:59 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id s8F0AxX8007365; Sun, 14 Sep 2014 17:10:59 -0700 (PDT) (envelope-from sgk) Date: Sun, 14 Sep 2014 17:10:59 -0700 From: Steve Kargl To: Bruce Evans Subject: Re: lgammal[_r] patch Message-ID: <20140915001058.GA7352@troutmask.apl.washington.edu> References: <20140913193634.GA2323@troutmask.apl.washington.edu> <20140915072530.T6209@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140915072530.T6209@besplex.bde.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Sep 2014 00:11:05 -0000 On Mon, Sep 15, 2014 at 07:36:49AM +1000, Bruce Evans wrote: > On Sat, 13 Sep 2014, Steve Kargl wrote: > > > Following my .sig is a patch that contains the ld80 and ld128 > > implementations of lgamma[_r](). It also contains an update > > to lgammaf_r() and lgamma_r(). Specifically, it has > > Looks good. It passed all my tests so far. I haven't tested ld128 > or compared ld80 with more than d64. I tested ld128 on flame, but it is far from exhaustive (during development, 10000, 20000, or 1000000 values in an interval. :-) > You even matched the fdlibm style bugs almost perfectly :-). Do you > know agree that copying a reasonable method is easiest? It was painful. I tend to now try to conform to style(9). But, having contribute to gfortran for years, I got use to GNU style. fdlibm style is just different. > > Index: ld80/e_lgammal_r.c > > =================================================================== > > --- ld80/e_lgammal_r.c (revision 0) > > +++ ld80/e_lgammal_r.c (working copy) > > @@ -0,0 +1,343 @@ > > +/* @(#)e_lgamma_r.c 1.3 95/01/18 */ > > +/* > > + * ==================================================== > > + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. > > + * > > + * Developed at SunSoft, a Sun Microsystems, Inc. business. > > + * Permission to use, copy, modify, and distribute this > > + * software is freely granted, provided that this notice > > + * is preserved. > > + * ==================================================== > > + */ > > + > > +#include > > +__FBSDID("$FreeBSD"); > > +/* > > + * See s_lgamma_r.c for complete comments. > > + * > > + * Converted to long double by Steven G. Kargl. > > + */ > > +#include > > +#ifdef __i386__ > > +#include > > +#endif > > Missing blank line before the include here and in most other > places. OK. I'll fix this before I commit. > > Index: src/math.h > > =================================================================== > > --- src/math.h (revision 271479) > > +++ src/math.h (working copy) > > @@ -496,8 +496,12 @@ > > long double tanl(long double); > > long double tgammal(long double); > > long double truncl(long double); > > +#endif /* __ISO_C_VISIBLE >= 1999 */ > > > > -#endif /* __ISO_C_VISIBLE >= 1999 */ > > +#if __BSD_VISIBLE > > +long double lgammal_r(long double, int *); > > +#endif /* __BSD_VISIBLE */ > > This comment has extra indentation and is not needed. Only larger > sections or more complicated conditionals need a comment on #endif. > The rest of the file mostly follows this rule. One large section > is missing a comment. > > The BSD extras aren't very well sorted. Neither are the float and > double sections. It was only useful to keep the float and double > functions in separate sections in 1990 when they weren't standard. OK. I'll delete the comment. Note, this section will grow when sincosl, j0l, j1l, etc are added. I'm inclined to coalesce and sort the various __BSD_VISIBLE sections into one. -- Steve From owner-freebsd-numerics@FreeBSD.ORG Wed Sep 17 19:03:18 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E3054156 for ; Wed, 17 Sep 2014 19:03:18 +0000 (UTC) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask.apl.washington.edu", Issuer "troutmask.apl.washington.edu" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id BFC8DA1E for ; Wed, 17 Sep 2014 19:03:18 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id s8HJ3CXG073858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 17 Sep 2014 12:03:12 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id s8HJ3CYR073857; Wed, 17 Sep 2014 12:03:12 -0700 (PDT) (envelope-from sgk) Date: Wed, 17 Sep 2014 12:03:12 -0700 From: Steve Kargl To: enh Subject: Re: lgamma_r and lgammaf_r return the wrong sign for -0.f Message-ID: <20140917190312.GA73699@troutmask.apl.washington.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Sep 2014 19:03:19 -0000 On Fri, Sep 12, 2014 at 02:15:37PM -0700, enh via freebsd-numerics wrote: > if I pass -0.f to lgammaf_r, the sign returned in *signgamp is 1. this > is incorrect --- it should be -1. > > both lgamma_r and lgammaf_r are affected, but the other special cases > in those functions look fine to me. > > this is fixed in OpenBSD and glibc, but FreeBSD and NetBSD both have > the same bug. > > patch below (whitespace mangled courtesy of gmail). i'd prefer to wait > for this to be fixed in FreeBSD and pull down the fix rather than just > fix it locally. > > btw, it looks like you're missing coshl/sinhl/tanhl for ld128 now? > (they've been removed from imprecise.c without having ld128 > implementations added afaics.) > > --elliott (Android libc maintainer) I committed your patch along with the necessary changes to the ld80/e_lgamma_r.c and ld128/e_lgamma_r.c. Thanks for bug report. -- Steve From owner-freebsd-numerics@FreeBSD.ORG Thu Sep 18 23:15:53 2014 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B6A4434E for ; Thu, 18 Sep 2014 23:15:53 +0000 (UTC) Received: from mail-yk0-x22c.google.com (mail-yk0-x22c.google.com [IPv6:2607:f8b0:4002:c07::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 730D1343 for ; Thu, 18 Sep 2014 23:15:53 +0000 (UTC) Received: by mail-yk0-f172.google.com with SMTP id q9so409869ykb.17 for ; Thu, 18 Sep 2014 16:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=+6mgek4ZFbJ+SUmbo7hMurl6YieMLoh3DRZBD9hoX6c=; b=govKzOkOcIKl6yc0QFT5Kskd6B4QFaFAX9tdQCYmZ/18lFWKmZGAoRZwHIRp42mWbw Jy9cF3CRsFfJGSV1wlFESBf2qNIJ0pURwmWWfzI+DQehm++0plgNGmIJ60wMHBPUPSvk 2pGU4xKNBIwyMb6ymHmy3ijmnGLNOWTPbDV45hSPaguEmWnGwkKsmyP79mVnf/5PFcZv DdBAbtQrVI8jCIRWKI3vEDC0/Cti2cmYZz0eaFMSa5Or+LRAQxmTHJNhPIj8Nc2C9euI e4N3+M7JN/3RPo/V1zFsPgDArag3LB7TwzieOaiC+wE1qUo8fbTZqNzJ+dE7t5hRE+uW 1ejA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=+6mgek4ZFbJ+SUmbo7hMurl6YieMLoh3DRZBD9hoX6c=; b=g+3rHKCWKvryAEoiUOWJIF5mshwU/4im7t/jzbg8+jp+oQ+CF639jRAEe0VmYo68QA Zdu/kv9j5pwWOzSlZB3cRbQCYnecy7HwhZSVqaiuhHCynKnwkBJDj6zmeqvtsXnvP3SJ udv45U+/LrBwSgV5mE9uoiYParNSmrrO3efzzrcYINitLmcrK48IeBQEw3oLpvv3vdUt daY/lumW/9VF1C3g2YqlbITaS5amRQj7Yn5hKkhWbDF1nlAUBUF8DrDsEZwRtoFZZQq3 FBME9ZUwfo1zRnvEQVd7bst1BZxr0mIr1Vf9RF9k7R50SaeDV/dBS58n1yCVDSMmXE7b yA6Q== X-Gm-Message-State: ALoCoQn6dbkABjxPMw1RFIZQfV0ZFMVUtoXRYLoftNEQSvrDozTcMYvOJuXbPYIhuNf7dtsMQd4R X-Received: by 10.236.63.68 with SMTP id z44mr8369415yhc.49.1411082152351; Thu, 18 Sep 2014 16:15:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.170.147.69 with HTTP; Thu, 18 Sep 2014 16:15:31 -0700 (PDT) In-Reply-To: <20140917190312.GA73699@troutmask.apl.washington.edu> References: <20140917190312.GA73699@troutmask.apl.washington.edu> From: enh Date: Thu, 18 Sep 2014 16:15:31 -0700 Message-ID: Subject: Re: lgamma_r and lgammaf_r return the wrong sign for -0.f To: Steve Kargl Content-Type: text/plain; charset=UTF-8 Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Sep 2014 23:15:53 -0000 thanks. i've moved Android over to your current implementations (and the ld128 lgammal). On Wed, Sep 17, 2014 at 12:03 PM, Steve Kargl wrote: > On Fri, Sep 12, 2014 at 02:15:37PM -0700, enh via freebsd-numerics wrote: >> if I pass -0.f to lgammaf_r, the sign returned in *signgamp is 1. this >> is incorrect --- it should be -1. >> >> both lgamma_r and lgammaf_r are affected, but the other special cases >> in those functions look fine to me. >> >> this is fixed in OpenBSD and glibc, but FreeBSD and NetBSD both have >> the same bug. >> >> patch below (whitespace mangled courtesy of gmail). i'd prefer to wait >> for this to be fixed in FreeBSD and pull down the fix rather than just >> fix it locally. >> >> btw, it looks like you're missing coshl/sinhl/tanhl for ld128 now? >> (they've been removed from imprecise.c without having ld128 >> implementations added afaics.) >> >> --elliott (Android libc maintainer) > > I committed your patch along with the necessary changes to the > ld80/e_lgamma_r.c and ld128/e_lgamma_r.c. > > Thanks for bug report. > > -- > Steve