-
Notifications
You must be signed in to change notification settings - Fork 41
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
[#148] Generalize 'inverseSigma' and 'inverseTotient' #188
Conversation
Tests will fail because of some issues with roundtrip tests (may be overflow related in |
617fc33
to
be8a7f3
Compare
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.
Please add a couple of unit tests as well.
-> (a -> b) | ||
-> a | ||
-> b | ||
inverseSigmaK k point = invertFunction point (sigmaA k) invSigma |
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.
You probably need to generalize invSigma
, making it work for any k
.
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.
invTotient
worked out of the box for inverseJordan
, but it seems invSigma
will need some work.
Could you clarify the generalization that section 5.2 (of the paper you used to write this) had that you removed because invSigma
only needed the k = 1
case?
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.
invTotient
works, but mostly by coincidence and doing more than needed. I think ps = mapMaybe (isPrime . (+ 1)) divs
should become ps = mapMaybe (\d -> exactRoot k (d + 1) >>= isPrime) divs
.
With regards to invSigma
it would probably suffice to replace p
by p ^ k
in conditions in doPrime
and pksLarge
.
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.
Thanks for the tip! That's exactly the hint I needed - this made me understand there are a few other places that need to be changed.
With that in mind, why is this line
, e <- [1 .. intToWord (integerLogBase (toInteger lim) (toInteger d))]
instead of
, e <- [1 .. intToWord (integerLogBase (toInteger lim) (toInteger (d - 1)))]
test-suite/Math/NumberTheory/ArithmeticFunctions/InverseTests.hs
Outdated
Show resolved
Hide resolved
test-suite/Math/NumberTheory/ArithmeticFunctions/InverseTests.hs
Outdated
Show resolved
Hide resolved
test-suite/Math/NumberTheory/ArithmeticFunctions/InverseTests.hs
Outdated
Show resolved
Hide resolved
test-suite/Math/NumberTheory/ArithmeticFunctions/InverseTests.hs
Outdated
Show resolved
Hide resolved
14339d7
to
7621884
Compare
7621884
to
9ee18e8
Compare
@Bodigrim added some unit tests from OEIS. Should be good to go. |
9ee18e8
to
1bc5e11
Compare
8ff5335
to
5221fe6
Compare
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.
Almost there :) Sorry for so many rounds of review, I'm on the run.
test-suite/Math/NumberTheory/ArithmeticFunctions/InverseTests.hs
Outdated
Show resolved
Hide resolved
On the contrary, I appreciate the attention you've been giving this! 👍 |
5221fe6
to
85df1c5
Compare
85df1c5
to
0ff40e6
Compare
Well done! |
Closes #148.