Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E3DA6200C6E for ; Mon, 8 May 2017 11:01:56 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DFDAF160BA5; Mon, 8 May 2017 09:01:56 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2FAD6160B99 for ; Mon, 8 May 2017 11:01:56 +0200 (CEST) Received: (qmail 67163 invoked by uid 500); 8 May 2017 09:01:50 -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 67151 invoked by uid 99); 8 May 2017 09:01:50 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 May 2017 09:01:49 +0000 Received: from mail-ua0-f169.google.com (mail-ua0-f169.google.com [209.85.217.169]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 94C0F1A002E for ; Mon, 8 May 2017 09:01:49 +0000 (UTC) Received: by mail-ua0-f169.google.com with SMTP id e55so36994592uaa.2 for ; Mon, 08 May 2017 02:01:49 -0700 (PDT) X-Gm-Message-State: AN3rC/4T0N9EvwhprcZHpSElHV/OSff//d/8YYrg5o/i4jMPYftJsvHo EPKeQj98DOxmhevtkn+C/sF+FeJkXw== X-Received: by 10.176.3.19 with SMTP id 19mr25761974uat.87.1494234108628; Mon, 08 May 2017 02:01:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.74.87 with HTTP; Mon, 8 May 2017 02:01:48 -0700 (PDT) X-Originating-IP: [130.88.240.85] Received: by 10.176.74.87 with HTTP; Mon, 8 May 2017 02:01:48 -0700 (PDT) In-Reply-To: <238bcf7a2899ea47bead71bbf22b2aee@scarlet.be> References: <238bcf7a2899ea47bead71bbf22b2aee@scarlet.be> From: Stian Soiland-Reyes Date: Mon, 8 May 2017 10:01:48 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [Numbers] NUMBERS-33 To: Commons Developers List Content-Type: multipart/alternative; boundary=001a113542e041ab81054eff7d3d archived-at: Mon, 08 May 2017 09:01:57 -0000 --001a113542e041ab81054eff7d3d Content-Type: text/plain; charset=UTF-8 Thanks! Not being a mathematician I am afraid I have not been able to review the correctness of the equation use. Overall the addition looks good and well commented. The javadoc is a bit sparse and could do with some more hyperlinks. I have some code design questions you may be able to clarify: * Why have static methods all called value()? Static methods are good as they can be imported independently (and without wasting object state), yet by calling all the public methods .value() only one can be imported, and with a meaningless name; we are forced instead to always call them via the class Gamma.value() * Why do some of the package private classes (e.g. InvGamma1pm1) have a needless static singleton instance and a single method (and no state), when here as well a static method would do? The only reason I can see for this is to implement interfaces or subclasses, yet none of those seem to be present, and these could rather follow the same pattern as the public API with private constructors. Won't this loop loose precision on digamma? (Could be called up to 49 times) while (x < C_LIMIT) { + digamma -= 1 / x; + x += 1; + } In this loop I was confused as the formula does not at first seem to match the code: final double inv = 1 / (x * x); + // 1 1 1 1 + // log(x) - --- - ------ + ------- - ------- + // 2 x 12 x^2 120 x^4 252 x^6 + digamma += Math.log(x) - 0.5 / x - inv * (F_1_12 + inv * (F_1_120 - F_1_252 * inv)); + + return digamma; Here and other places: /** Helper. */ + private static final InvGamma1pm1 INV_GAMMA_1P_M1 = InvGamma1pm1.instance; Unless there were state to initialize in certain order I don't see the benefit of this field wastage over just calling InvGamma1pm1.value() directly. Based on the NSWC Library of Mathematics Subroutines double + * precision implementation, {@code DGAMMA}. What is the license/url of this nswc code? What is the nature of "based on" here? On 8 May 2017 1:30 am, "Gilles" wrote: Hi. Please review branch "task_NUMBERS-33__Gamma": https://issues.apache.org/jira/browse/NUMBERS-33 Thanks, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org --001a113542e041ab81054eff7d3d--