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
Some enhancements #32
Conversation
…principal_log_branch using `rem`
…`@validatetau`, since their roles are closer to macros instead of functions
I like most of the changes in your first commit "change styles of some functions...". But when you replaced I don't like the change of the validation functions to macros. A macro is intended to transform source code prior to compilation. There is no such transformation being accomplished here. The validity checks still need to be made at run time, and using the macro does not even reduce the typing required by the user at all, so I don't see the point here. It simply makes the code a little harder to understand without any benefit, IMO. |
When julia> z = BigFloat(2) + im * BigFloat(10)
2.0 + 10.0im
julia> typeof(z)
Complex{BigFloat}
julia> EllipticFunctions.principal_log_branch(z)
2.0 - 2.5663706143591724639918538741767406463623046875im
julia> ans |> typeof
Complex{BigFloat} A macro on the one hand helps the compiler to emit less codes by transforming the function to be function something(...)
abs(q) < 1 || error("...")
...
end On the other hand, it put the thrown error right from where the error happen (function |
Regarding use of julia> z = 1 + (BigFloat(pi) - BigFloat("1e-18"))*im
1.0 + 3.141592653589793237462643383279502884197169399375105820974944592307816406286212im
julia> rem(imag(z), 2pi, RoundNearest)
-3.141592653589792994533283553808867438983982944374894179025055407692183593713788
julia> rem(imag(z), 2*BigFloat(pi), RoundNearest)
3.141592653589793237462643383279502884197169399375105820974944592307816406286212 |
Regarding the use of macros for validation. I understand that the advantage is that the test is performed inline in the function where the argument occurs, so that a traceback will show this function at the top of the stack. Also, the slight overhead of a function call is avoided. The latter advantage is probably moot because LLVM will inline the short validation function anyway. I understand your point, but my philosophy is to avoid macros when the functionality can be achieved easily by a function. YMMV, of course. Again, it's @stla's repo, he can make the call here. I'm OK either way. |
I'm waiting for an agreement between you. You know Julia better than me. |
Sorry I overlooked the @stla You decide whether to keep function |
I'm fine with all the changes, after fixing the pi issue. Thanks for your useful contributions, @hammerfunctor! |
I'm ok for the macros. In this way I will learn something. |
@hammerfunctor Have you made the change regarding pi? |
…i; change input of jtheta_ab to tau instead of q
@stla @simonp0420 It's done now. Please check out the changes. |
This PR is very impressive. Adding a benchmark suite is a great contribution, as is the use of IrrationalConstants, which I was unaware of. I won't be able to provide a detailed review, if desired, until after the holidays. |
Looks good. I'm going to merge. Thanks @hammerfunctor |
principal_log_branch
is simplified using standard libraryrem
validateq
andvalidatetau
by two similar macros, since their functionalities are comp-time determined.UPDATE 12/18:
4. I introduced
IrrationalConstants.jl
and rewrote many places involving pi. E.g.1/pi
is nowinvπ
and2pi
is nowtwoπ
without digits loss.5. I added a benchmark system to the test. To use it, run (on linux) e.g.
env BENCHMARK=1 BASELINE_COMMIT=bd39fe8 julia -e 'import Pkg; Pkg.activate("."); Pkg.test()'
the output is put below.
6. Input of
jtheta_ab
is changed fromq
totau
Results
A ratio greater than
1.0
denotes a possible regression (marked with ❌), while a ratio lessthan
1.0
denotes a possible improvement (marked with ✅). All results are shown below.["Elliptic functions", "Aid functions of jacobi theta", "argtheta3"]
["Elliptic functions", "Aid functions of jacobi theta", "calctheta3"]
["Elliptic functions", "Aid functions of jacobi theta", "dologtheta3"]
["Elliptic functions", "Carlson functions", "RC"]
["Elliptic functions", "Carlson functions", "RD"]
["Elliptic functions", "Carlson functions", "RF"]
["Elliptic functions", "Carlson functions", "RG"]
["Elliptic functions", "Carlson functions", "RJ"]
["Elliptic functions", "Eisenstein series", "E2 on 0.005+0.005im"]
["Elliptic functions", "Jacobi thetas", "jtheta1"]
["Elliptic functions", "Jacobi thetas", "jtheta1dash"]
["Elliptic functions", "Jacobi thetas", "jtheta2"]
["Elliptic functions", "Jacobi thetas", "jtheta3"]
["Elliptic functions", "Jacobi thetas", "jtheta4"]
["Elliptic functions", "Klein J", "kleinj(2im)"]
["Elliptic functions", "Klein J", "kleinjinv(0.1+0.2im)"]
["Elliptic functions", "Lambda", "on 1im * sqrt(1/x)"]
["Elliptic functions", "Lambda", "on 1im * sqrt(x)"]
["Elliptic functions", "Log-Jacobi thetas", "ljtheta1"]
["Elliptic functions", "Log-Jacobi thetas", "ljtheta2"]
["Elliptic functions", "Log-Jacobi thetas", "ljtheta3"]
["Elliptic functions", "Log-Jacobi thetas", "ljtheta4"]
["Elliptic functions", "Neville theta functions", "thetaC on big"]
["Elliptic functions", "Neville theta functions", "thetaC"]
["Elliptic functions", "Neville theta functions", "thetaD"]
["Elliptic functions", "Neville theta functions", "thetaN"]
["Elliptic functions", "Neville theta functions", "thetaS"]
["Elliptic functions", "Others", "agm"]
["Elliptic functions", "Others", "elliptic Invariants"]
["Elliptic functions", "Others", "jellip"]
["Elliptic functions", "Others", "wp"]
["Elliptic functions", "Others", "wsigma"]
["Elliptic functions", "Others", "wzeta 1"]
["Elliptic functions", "Others", "wzeta 2"]
["Elliptic functions", "Various elliptic's", "ellipticE on 0.5"]
["Elliptic functions", "Various elliptic's", "ellipticE on 2-3im"]
["Elliptic functions", "Various elliptic's", "ellipticF(big\"0.15\", big\"0.81\")"]
["Elliptic functions", "Various elliptic's", "ellipticK on 0.5"]
["Elliptic functions", "Various elliptic's", "ellipticK on big\"0.5\""]
["Elliptic functions", "Various elliptic's", "ellipticPI(1+im, 1, 2-im)"]
["Elliptic functions", "Various elliptic's", "ellipticZ(-5+3im,-4-9im)"]
["Elliptic functions", "etaDedekind", "on 1im / 2"]
["Elliptic functions", "etaDedekind", "on 2im"]