commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1228) First Moment is not public
Date Sun, 13 Sep 2015 10:05:45 GMT

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

Gilles commented on MATH-1228:
------------------------------

bq. this effectively means that the public constructor Mean(FirstMoment) is not usable. 

I'd tend to agree that this looks like an internal inconsistency.

However, if {{FirstMoment}} was intended as an internal support class, while {{Mean}} would
be the corresponding public API, it is not good to just make {{FirstMoment}} public, as this
would create a redundancy in the library.

I think that the performance problem would be alleviated significantly if the field "incMoment"
would be *final*.
Currently, the method {{copy(Mean,Mean)}} prevents such a change.
IMHO it should be fixed by removing that method, as it is itself redundant with the copy constructor
{{Mean(Mean)}}.

If I'm not mistaken, the code is from a time when using "new" was to be avoided, leading to
many such "manual" optimizations, that nowadays prove harmful.

I'd suggest that your raise the issue on the "dev" ML (as it concerns a design decision, rather
than a bug fix).

> First Moment is not public
> --------------------------
>
>                 Key: MATH-1228
>                 URL: https://issues.apache.org/jira/browse/MATH-1228
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.5
>            Reporter: Fabian Lange
>
> Hi there,
> is there a specific reason FirstMoment is not public?
> I want to calculate a mean over a List<Double>, for that I want to loop over that
list and invoke Mean.increment(listValue), however this is slower than it could be. Every
increment call makes a check to incMoment.
> I could avoid that if I use a FirstMoment directly, but I cannot create an instance,
because it is protected.
> Also this effectively means that the public constructor Mean(FirstMoment) is not usable.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message