Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Issue 457643002: Implement Math.log1p using port from fdlibm. (Closed)

Created:
6 years, 4 months ago by Yang
Modified:
6 years, 4 months ago
Reviewers:
Raymond Toy
CC:
v8-dev
Project:
v8
Visibility:
Public.

Description

Implement Math.log1p using port from fdlibm. Port contributed by Raymond Toy <rtoy@google.com>;. R=rtoy@chromium.org LOG=N BUG=v8:3481 Committed: https://code.google.com/p/v8/source/detail?r=23082

Patch Set 1 #

Total comments: 31

Patch Set 2 : addressed comments #

Patch Set 3 : changed test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+234 lines, -52 lines) Patch
M src/bootstrapper.cc View 1 1 chunk +3 lines, -5 lines 0 comments Download
M src/math.js View 2 chunks +1 line, -21 lines 0 comments Download
M test/mjsunit/es6/math-log1p.js View 1 2 2 chunks +38 lines, -7 lines 0 comments Download
M third_party/fdlibm/fdlibm.h View 1 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/fdlibm/fdlibm.cc View 1 2 chunks +12 lines, -1 line 0 comments Download
M third_party/fdlibm/fdlibm.js View 1 6 chunks +177 lines, -15 lines 0 comments Download
M tools/generate-runtime-tests.py View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 11 (0 generated)
Yang
6 years, 4 months ago (2014-08-08 10:00:07 UTC) #1
Raymond Toy
https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js File test/mjsunit/es6/math-log1p.js (right): https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js#newcode20 test/mjsunit/es6/math-log1p.js:20: Although not part of the CL, I noticed this. ...
6 years, 4 months ago (2014-08-08 17:32:18 UTC) #2
Raymond Toy
https://codereview.chromium.org/457643002/diff/1/third_party/fdlibm/fdlibm.js File third_party/fdlibm/fdlibm.js (right): https://codereview.chromium.org/457643002/diff/1/third_party/fdlibm/fdlibm.js#newcode427 third_party/fdlibm/fdlibm.js:427: const TWO_THIRD = kMath[37]; On 2014/08/08 17:32:17, Raymond Toy ...
6 years, 4 months ago (2014-08-08 17:40:30 UTC) #3
Yang
https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js File test/mjsunit/es6/math-log1p.js (right): https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js#newcode20 test/mjsunit/es6/math-log1p.js:20: On 2014/08/08 17:32:16, Raymond Toy wrote: > Although not ...
6 years, 4 months ago (2014-08-11 07:51:07 UTC) #4
Raymond Toy
Did you forget to upload a new patch set? I can't see any changes.
6 years, 4 months ago (2014-08-11 16:40:03 UTC) #5
Yang
On 2014/08/11 16:40:03, Raymond Toy wrote: > Did you forget to upload a new patch ...
6 years, 4 months ago (2014-08-11 19:03:42 UTC) #6
Raymond Toy
Looks good, but I have one last comment. https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js File test/mjsunit/es6/math-log1p.js (right): https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js#newcode20 test/mjsunit/es6/math-log1p.js:20: On ...
6 years, 4 months ago (2014-08-11 20:04:35 UTC) #7
Raymond Toy
lgtm I don't want to block this CL because of the comment on the test ...
6 years, 4 months ago (2014-08-12 05:57:28 UTC) #8
Yang
On 2014/08/11 20:04:35, Raymond Toy wrote: > Looks good, but I have one last comment. ...
6 years, 4 months ago (2014-08-12 08:59:52 UTC) #9
Yang
Committed patchset #3 manually as 23082.
6 years, 4 months ago (2014-08-12 13:36:45 UTC) #10
Raymond Toy
6 years, 4 months ago (2014-08-12 17:28:01 UTC) #11
Message was sent while issue was closed.
On 2014/08/12 08:59:52, Yang wrote:
> On 2014/08/11 20:04:35, Raymond Toy wrote:
> > Looks good, but I have one last comment.
> > 
> >
>
https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p.js
> > File test/mjsunit/es6/math-log1p.js (right):
> > 
> >
>
https://codereview.chromium.org/457643002/diff/1/test/mjsunit/es6/math-log1p....
> > test/mjsunit/es6/math-log1p.js:20: 
> > On 2014/08/11 07:51:06, Yang wrote:
> > > On 2014/08/08 17:32:16, Raymond Toy wrote:
> > > > Although not part of the CL, I noticed this. I think this test should
> avoid
> > > > testing down to 0.1, where log(x+1) and log1p(x) are supposed to be
> > different.
> > > > Based on the comments from fdlibm log1p(x) = log(1+x) when x > 2^53. 
Then
> > > your
> > > > delta should be zero, or at least closer to 1.1e-16 (float epsilon).
> > > 
> > > Done.
> > 
> > Why 1e2 and not 2^53?. It's obviously true for x > 2^53 that 1+x = x so
> log1p(x)
> > == log(1+x). In fact, testing a few random values quickly finds, for
example,
> > 
> > x = 203.02512450909163d0
> > log(1+x) = 5.318243145619017d0
> > log1p(x) = 5.318243145619018d0
> > 
> > (Both log and log1p used fdlibm algorithm)
> > 
> > So, what is the intent of this test? That log1p is close to log(1+x)? If so,
> you
> > should say so in a comment, and describe why 1e-14 is a good threshold for
> this.
> 
> I see. The original implementation did not have high accuracy as goal. The
test
> is more of a sanity check: for reasonably large numbers, log1p(x) should stay
> reasonably close to log(1+x), with "reasonably" being 1E-14. Obviously, now
that
> we have a more accurate implementation, that test can be made more strict. I
> changed it to x > 1E16.

I think you should have added a comment for the test that log1p(x) = log(1+x)
for x > 2^53 (or 1e16). 1e16 now looks like some random number without
explanation of why. 

I'm also curious if log1p(x) really is equal to log(1+x) so that the threshold
of 1e-16 could actually be 0. But that's for another day.

Powered by Google App Engine
This is Rietveld 408576698