[ https://issues.apache.org/jira/browse/MATH-1130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14043913#comment-14043913 ]
Venkatesha Murthy TS commented on MATH-1130: -------------------------------------------- Regarding equalsIncludingNaN: What is the test code used or the micro benchmark? can you please share ? What does N correspond to? In my measurements in my machine with respect to the test testMath1130ForDoubleEqual in PrecisionTest.java attached i j d time in seconds(old code) time in seconds(with venkats code) 10 10 10 00.027 00.003 10 10 100 00.020 00.011 10 10 1000 00.038 00.023 10 100 1000 00.066 00.073 10 1000 1000 00.287 00.127 10 10000 1000 02.280 00.947 10 10000 10000 22.217 09.275 10 10000 100000 224.454 91.918 10 100000 10000 224.673 91.319 Well trying to understand a bit more. So as i am seeing most times the above timings... Wondering where am i seeing the gap as at every level (i,j,d) there is a clear difference from (10s of milliseconds to 100s of seconds)(bigger as the iterations go up) Basically If only one of them is NaN it does not make sense to get to a detailed compare which is what i have eliminated. Iam just following this tradition already existing in say MathArrays.equals(final float[] x, final float[] y) method where null checks are eliminated earlier in this fashion. Also if x!=x seems cryptic, i could replace with Double.isNaN() to make it bit obvious.(is this is the concern?) Please help me as to what is less clear > A new set of functions for copyof, remove and replace a given value on a > slice of array > --------------------------------------------------------------------------------------- > > Key: MATH-1130 > URL: https://issues.apache.org/jira/browse/MATH-1130 > Project: Commons Math > Issue Type: New Feature > Affects Versions: 3.4 > Reporter: Venkatesha Murthy TS > Attachments: equalsIncludingNaN.dat, math-1130-checknotnan.patch, > math-1130-precision-equals.patch, math-1130-remove.patch, > math-1130-replace.patch, 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 newValue); > 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 then move to a detailed Double.compare(..) method. This avoids the > Double.compare call when any one of them is NaN. -- This message was sent by Atlassian JIRA (v6.2#6252)