You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Artem Barger <ar...@bargr.net> on 2016/06/01 08:49:22 UTC
Re: [Math] Adding min/max and argmin/argmax values for an arrays of
double/int (Comparable).
Hi,
I've create a JIRA ticket MATH-1372 and attached a patch to it, also
submitted PR on GitHub: https://github.com/apache/commons-math/pull/36.
Best regards,
Artem Barger.
On Tue, May 31, 2016 at 3:32 AM, Artem Barger <ar...@bargr.net> wrote:
>
> On Tue, May 31, 2016 at 3:17 AM, Gilles <gi...@harfang.homelinux.org>
> wrote:
>
>> On Tue, 31 May 2016 02:58:27 +0300, Artem Barger wrote:
>>
>>> Methods "getMinValue()", "getMinIndex()".
>>>>
>>>> Important note: any contribution should be based on the contents of
>>>> the "develop" branch, not "master". See file
>>>> doc/development/development.howto.txt
>>>> in the source tree.
>>>>
>>>>
>>>> So in order to use them I need to instantiate a RealVector, right?
>>>
>>
>> Yes.
>> And the iteration is probably not efficient since it use the
>> high-level API.
>>
>> Hence I think the question whenever to add static method w/
>>> similar functionality to MathArrays class is still valid, especially if
>>> I can enhance it to accept array or list of Comparables or to accept
>>> Comparator as an additional parameter.
>>>
>>
>> Yes.
>> But perhaps a more general functionality would be useful.
>>
>
> General? Could you give an example?
> Aren't these enough?
>
> public static <T extends Comparable<T>> T min(T...array);
>
> public static <T extends Comparable<T>> T max(T...array);
>
> public static <T extends Comparable<T>> int argmin(T...array);
>
> public static <T extends Comparable<T>> int argmax(T...array);
>
>
>
>> Especially with the new Java 8 function types.
>>
>
> It's easy to implement having Java 8 function types, not sure I'm
> following you
> w/ how it could affect the API's of proposed methods.
>
> I think I will submit a JIRA ticket w/ these and submit a patch, reviewing
> it we will
> be able to eventually come to some reasonable solution.
>
> Anyway if such functionality is already exist in "RealVector", I guess
>>>>
>>>>> there is no point of adding
>>>>> it to MathArrays, unless RealVector should be refactored and
>>>>> functionality
>>>>> should be removed from
>>>>> there.
>>>>>
>>>>>
>>>> Yes, refactored it should be:
>>>> https://issues.apache.org/jira/browse/MATH-765
>>>>
>>>>
>>>> It says that these methods to be removed from RealVector.
>>>
>>
>> A pity that what it says did not occur. :-}
>>
>
> :)))
>
> Best,
> Artem Barger.
>
>