commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (MATH-1130) A new set of functions for copyof, remove and replace a given value on a slice of array
Date Mon, 23 Jun 2014 13:01:25 GMT


Gilles commented on MATH-1130:

Please make _separate_ patches for each new functionality. It will be clearer and easier to
discuss them.

You should also post on the "dev" ML, to avoid wasting time on something in case it is objected
to there.

In particular, I still don't get the purpose of "canEqual". It looks like a duplicate of "equalsIncludingNaN".

bq. If we are supporting replace and remove for entire array; naming them as removeInRange
or replaceInRange IMO may not be a good fit.

We could have "remove(double[] a, double v)" and "removeInRange(double[] a, int from, int
to, double v)", with
public static double[] remove(double[] a, double v) {
    return removeInRange(a, 0, a.length, v);

bq. signature in verifyValues seemed more natural for me and hence continued the same tradition
even to these methods.

MathArrays was intended to collect methods akin to those in "java.lang.Arrays" and most methods
there use "from" and "to" indices.
"verifyValues" predates the creation of the MathArrays utility class...

> A new set of functions for copyof, remove and replace a given value on a slice of array
> ---------------------------------------------------------------------------------------
>                 Key: MATH-1130
>                 URL:
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 3.4
>            Reporter: Venkatesha Murthy TS
>         Attachments: math-1130.patch
> These are utility functions mostly required as part of MathArrays.
> MathArrays:
> =============
> The requirement is as follows:
> a) double[] copyOf(double[] values, int begin, int length) ;
> Similar to most other functions that support slice defined  by  the array part from [begin,
begin+length) ;its a requirement to copy a slice which is not available (the closest is copyOf(array,
int len) which misses out the begin index)
> b) double[] removeAll(double[] values, int begin, int length, double removable);
> Need a function to remove a value from array slice defined by [begin,begin+length) and
return the filtered version.
> c) double[] replaceAll(double[] values, int begin, int length, double oldValue, double
> Need a function to replace inplace an oldValue substituted with newValue in the array
slice defined by [begin,begin+length) and return the original  complete array with just replaced
values only in the segment [begin,begin+length)
> MathUtils
> =========
> boolean canEqual(double d1, double d2) ;
> provide a canEqual function that is slightly better than exisitng MathUtils.equals. We
could also improve existing equals method however.
> So the change here is that the new enhanced canEqual can do a quick check on Nans and
as well as both +ve and -ve Infinities faster and then move to a detailed
method. This avoids the call for infinities and NaN with faster reference equal
check (i.e == ).

This message was sent by Atlassian JIRA

View raw message