EDIT: In the original version of this post, I included the exact expression for computing the jac
output. This allowed other users to run performance tests on dot vs scalar versions of the function. However, I realized that since the expression is based on mathematical equations that have yet to be published, the expression had to be replaced with (EXPRESSION INVOLVING LOTS OF DOTS)
. Once the work has been published, I can re-include the exact expression and reference the published article.
Hi,
I have a colleague who has coded in Python before and is asking me for advice on a function he has written in Julia. He says that his Julia code, which utilizes the function, runs faster if the input arguments are not type specified. This I can understand. However, to achieve correct functionality, he has coded dot-operations everywhere. The function is:
using NaNMath
function his_function(Îł_b, cosLAB, E_b, m_b, m_t, m_d, m_r, A, B, D)
# We have to account for the sign in the quadratic solution, before differentiating
s = -sign.(cos.(Îł_b))
jac = s .* (EXPRESSION INVOLVING LOTS OF DOTS)
return jac
end
The input arguments to the function will always have the types:
his_function(Îł_b::Vector{Float64}, cosLAB::Vector{Float64}, E_b::Vector{Float64}, m_b::Float64, m_t::Float64, m_d::Float64, m_r::Float64, A::Vector{Float64}, B::Vector{Float64}, D::Vector{Float64})
My question is simple. I think all the dots make the code look very Python-esque. How would you re-write the code to make it look better, and also run better? Or maybe I am misunderstanding something, and this is fine?