Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C1309BD4 for ; Fri, 7 Oct 2011 13:18:19 +0000 (UTC) Received: (qmail 437 invoked by uid 500); 7 Oct 2011 13:18:18 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 321 invoked by uid 500); 7 Oct 2011 13:18:18 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 313 invoked by uid 99); 7 Oct 2011 13:18:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2011 13:18:18 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [193.74.71.26] (HELO hel.is.scarlet.be) (193.74.71.26) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Oct 2011 13:18:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1317993471; bh=vC1sloNkrdKOCyEGzNH4tq4j4C5Xkd+UoYLUw4+f3GA=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=NwwkKhWearLTYycBI/p6RInEj7JTE+TurmA+L83+6LujRojAJyRQjzNt5HLOK5fHF J+8pOdwm3eTQULDEKMAqS+HIn6LV6AGEk7X6vRjUNZ3bZJR7U7Oh2rVs+TDqbnVihj TYQw4dbRzcrtSN0W0//P7VrHL2dRBOIEtHtcCHTs= Received: from mail.harfang.homelinux.org (ip-213-49-232-237.dsl.scarlet.be [213.49.232.237]) by hel.is.scarlet.be (8.14.5/8.14.5) with ESMTP id p97DHoxd029966 for ; Fri, 7 Oct 2011 15:17:50 +0200 X-Scarlet: d=1317993470 c=213.49.232.237 Received: from localhost (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 350F561D22 for ; Fri, 7 Oct 2011 15:17:50 +0200 (CEST) Received: from mail.harfang.homelinux.org ([192.168.20.11]) by localhost (mail.harfang.homelinux.org [192.168.20.11]) (amavisd-new, port 10024) with ESMTP id NlD88-BdTS4H for ; Fri, 7 Oct 2011 15:17:45 +0200 (CEST) Received: from dusk.harfang.homelinux.org (mail.harfang.homelinux.org [192.168.20.11]) by mail.harfang.homelinux.org (Postfix) with ESMTP id 6D6B1617B5 for ; Fri, 7 Oct 2011 15:17:45 +0200 (CEST) Received: from eran by dusk.harfang.homelinux.org with local (Exim 4.76) (envelope-from ) id 1RCAJ7-0000er-9w for dev@commons.apache.org; Fri, 07 Oct 2011 15:17:45 +0200 Date: Fri, 7 Oct 2011 15:17:45 +0200 From: Gilles Sadowski To: dev@commons.apache.org Subject: Re: svn commit: r1179928 - in [...] Message-ID: <20111007131745.GN17388@dusk.harfang.homelinux.org> Mail-Followup-To: dev@commons.apache.org References: <20111007095927.GK17388@dusk.harfang.homelinux.org> <61257E46-E542-4AFE-916B-09B149B98D70@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <61257E46-E542-4AFE-916B-09B149B98D70@gmail.com> X-Operating-System: Tiny Tux X-PGP-Key-Fingerprint: 53B9 972E C2E6 B93C BEAD 7092 09E6 AF46 51D0 5641 User-Agent: Mutt/1.5.21 (2010-09-15) X-DCC-scarlet.be-Metrics: hel 20002; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: clamav-milter 0.97.1-exp at hel X-Virus-Status: Clean > >> > >> /** > >> - * Sinc function. > >> + * Sinc function, defined by

> >> + *
> >> + * sinc(x) = 1 if abs(x) < 1e-9;
> >> + *           sin(x) / x; otherwise
> >> + * 
> > > > I would not document the first part of the alternative since it is an > > implementation detail. "1e-9" was chosen just because, with "double" > > precision, the function value will be indistinguishable from 1. Strictly > > speaking it is not part of the definition of "sinc". [This part of the > > implementation could even be removed if it is deemed that we lose more time > > doing the check than we gain when the user asks the value of points below > > 1e-9.] > > > > Also, there probably should not be a ";" after the statements. > > If it a) makes a difference in the returned result and b) is correct (up to double equality), I don't understand what you write here. What I meant above is: For values < 1e-9, it does not make a difference at double precision whether the computation is done in full (sin(x) / x) or by assigning "1" directly. > I think we should leave the check in Yes, of course; the suggestion to remove it was a mistake (see below). > and document it. We should always document top-coding or other departures from the formulas we define things by. I don't see why give a wrong definition since it makes no difference. The definition of "sinc" is[1]: sinc(x) = sin(x) / x To compute it, care must be taken to not divide by zero, thus the simplest operational definition is[2]: sinc(x) = 1 if x = 0 sin(x) / x otherwise The one in CM is an efficiency improvement (to avoid evaluation of a sine and a division when the result is indistinguishable from the known result). The rationale for the shortcut could be a code comment, but as a user-level comment, it is confusing. Gilles > > I am fine changing the semicolons (which are being used as punctuation) to commas or even dropping them altogether. > > Phil [1] http://en.wikipedia.org/wiki/Sinc_function [2] http://mathworld.wolfram.com/SincFunction.html --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org