[ 
https://issues.apache.org/jira/browse/NUMBERS-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17426426#comment-17426426
 ] 

Gilles Sadowski commented on NUMBERS-167:
-----------------------------------------

{quote}PR 105
{quote}
I suggest adding:
{code:java}
public static final class P {
    // ...
    public static DoubleUnaryOperator withArgumentA(double a) {
        final ArgumentA argA = ArgumentA.of(a);
        return x -> value(argA, x);
    }

    public static DoubleUnaryOperator withArgumentX(double x) {
        final ArgumentX argX = ArgumentX.of(x);
        return a -> value(a, argX);
    }

    public static DoubleUnaryOperator withArgumentA(double a,
                                                    final double epsilon,
                                                    final int maxIterations) {
        final ArgumentA argA = ArgumentA.of(a);
        return x -> value(argA, x, epsilon, maxIterations);
    }

    public static DoubleUnaryOperator withArgumentX(double x,
                                                    final double epsilon,
                                                    final int maxIterations) {
        final ArgumentX argX = ArgumentX.of(x);
        return a -> value(a, argX, epsilon, maxIterations);
    }
    // ...
}
{code}
(and similar for {{RegularizedGamma.Q}}).
 With those factory methods, all the other new functions can be made private, 
together with classes {{ArgumentA}} and {{ArgumentX}}, thus simplifying and 
trimming the (public) API.

Then (nit), in {{ArgumentA}} and {{ArgumentX}}, I would not repeat the {{A}} 
(resp. {{X}}) at the end of the method names:
* {{getA()}} -> {{get()}}
* {{getLogGammaA(double)}} -> {{getLogGamma(double)}}
* {{invalidA(double)}} -> {{invalid(double)}}
* ...


> RegularizedGamma.P with precomputed LogGamma value
> --------------------------------------------------
>
>                 Key: NUMBERS-167
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-167
>             Project: Commons Numbers
>          Issue Type: Wish
>          Components: gamma
>            Reporter: Gilles Sadowski
>            Priority: Minor
>             Fix For: 1.1
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> We have
> {code:java}
> double v = RegularizedGamma.P.value(a, x);
> {code}
> where method {{value}} internally calls {{LogGamma.value(a)}}.
> There is a use-case for
> {code:java}
> double logGammaA = LogGamma.value(a);
> double v = RegularizedGamma.P.value(a, x, logGammaA);
> {code}
> for when the user varies {{x}} but not {{a}}.
> Method name TBD:  Another overload of {{value}} may be confusing (?).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to