- Wouldn't it be better to return Wnew? (i.e., set Wnew = W before the loop) - You can set the precision to eps(), because the convergence is quadratic; - For the same reason, don't set a limit for n, or set it much higher (n < 100) - The array version returns NaN where the scalar version throws an error, this is kind of inconsistent, I think. - k could be a keyword instead of an option. - For the array version, you could use map instead of a loop; or don't provide an array version, that might be more Julia-like.
On Friday, October 17, 2014 10:23:53 PM UTC+2, Robert DJ wrote: > > That's a good point! I've added the repository to GitHub: > > https://github.com/robertdj/LambertW.jl > > Best, > > Robert > > On Friday, October 17, 2014 5:43:19 PM UTC+2, Stefan Karpinski wrote: >> >> It would be helpful to see some code. Otherwise, it's hard to tell what's >> happening. >> >> On Fri, Oct 17, 2014 at 11:37 AM, Robert DJ <[email protected]> wrote: >> >>> Hi, >>> >>> I am having some troubles understanding and selecting the right types. >>> >>> I have implemented an approximation of Lambert’s W function in two >>> versions: One for scalar input and one for array input. >>> >>> I’ve chosen the type Real for the scalar version and Array{Float64} for >>> the array version. >>> But if I delete the array version I can still call the function with an >>> array. How can this be? >>> Also, I would prefer to have a type like Array{Real} instead >>> Array{Float64}, but this does not seem to work. >>> >>> A third thing is that the function takes a second input that is either >>> -1 or 0. Now I specify the type as Int and check if it is -1 or 0. Is there >>> a smarter way to do this? >>> >>> Thanks, >>> >>> Robert >>> >>> >>
