Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sumlog #48
base: master
Are you sure you want to change the base?
sumlog #48
Changes from 13 commits
581b9df
5725aa9
77aa3d9
88d6fb1
9ecf589
9db732f
76533e1
5747205
0f5a927
977723d
4d488cd
afa5d94
e400483
cc1aaac
07809b7
16ee153
1af518b
0eaf8d2
1f478d0
0807f7a
2a0004d
e5809d1
eb1b524
6fe8bb1
0def97d
3ad95b2
a0a9348
fa667ec
989a111
a54a024
dc48433
39ca989
207fce2
55d125e
bef4728
9572e48
3848848
c4c3e89
e0f410e
23b5bf1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some surprises:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
Base.Math._exponent_finite_nonzero
works around the NaN problem (although not for BigFloats).Adding
xj < 0 && Base.Math.throw_complex_domainerror(:log, xj)
doesn't seem to cost much speed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, note that tests right now only test Float64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that you removed the type restriction. Thus we should extend the tests and eg. check more general iterables (also with different types, abstract eltype etc since
sum(log, x)
would work for them) and also complex numbers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eltype
doesn't work well forBase.Generator
s. Usually this is when I'd turn to something likeWe could instead have it fall back on the default, but I'd guess that will sacrifice performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet you could write an equally fast version which explicitly calls
iterate
, and widens if the type changes. (But usually the compiler will prove that it won't.)One reason to keep
mapreduce
for arrays is that you can give itdims
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check more carefully, but this appears to work & is as fast as current version:
And for dims:
Should I make a PR to the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cscherrer#1 is a tidier version of the above.