JuliaAstro / AstroLib.jl

Bundle of small astronomical and astrophysical routines.
http://juliaastro.github.io/AstroLib.jl/stable/
Other
80 stars 23 forks source link

Astronomical Routines Tracker #17

Closed TestSubjector closed 7 years ago

TestSubjector commented 7 years ago

This is an issue to track most of the important astronomical utilities, not present in the package.

Additionally, a few of these routines call other procedures, some of which are not there in the package. As AstroLib.jl's functions are not a drop-in replacement of IDL AstroLib's procedures, these 'required' procedures may not be necessary. However they are listed below for reference.

giordano commented 7 years ago

Thanks for the list!

Regarding the required functions:

TestSubjector commented 7 years ago

Julia's @evalpoly should be a drop-in replacement of poly

@evalpoly(z, c...) generates code at compile-time so it requires length of c (the coefficients) at that stage only.

One trick that can be used to avoid that is to have something like @eval @evalpoly(z, $(c...)) where eval forces the evaluation of the argument.

textopen and textclose may not be necessary (but didn't look thoroughly)

Yeap, not required. Just listing for reference.

giordano commented 7 years ago

@evalpoly(z, c...) generates code at compile-time so it requires length of c (the coefficients) at that stage only.

Yes, but in fm_unred the coefficients are known.

TestSubjector commented 7 years ago

Yes, but in fm_unred the coefficients are known.

Not in ismeuv though. (for some reason the poly procedure was not listed as a dependency there)

giordano commented 7 years ago

The c1 and c2 vectors in ismeuv are constant, aren't they?

TestSubjector commented 7 years ago

The c1 and c2 vectors in ismeuv are constant, aren't they?

My bad. Got confused a bit regarding how @evalpoly works.

The main problem I was having was with regards to the coefficient's length julia> d = [1,2,3] julia> @evalpoly(4, d) ERROR: BoundsError: attempt to access (:d,) at index [0] julia> @evalpoly(4, d...) ERROR: BoundsError: attempt to access (:(d...),) at index [0]

However, inserting the coefficients as literal works julia> @evalpoly(4, d[1], d[2], d[3]) 57 Reference: https://stackoverflow.com/questions/28077057/julia-evalpoly-macro-with-varargs

giordano commented 7 years ago

Yes, you can't splat an iterable in a macro call, because at compile time it's a single expression.

You don't even need to allocate a useless array, just do

julia> @evalpoly 4 1 2 3
57

If the length of the coefficient vector is known when you write down the code, @evalpoly is extremely efficient.

helgee commented 7 years ago

Everything date-related should be covered by AstronomicalTime.jl.

giordano commented 7 years ago

All listed functions have been ported, we can close this. Thanks for your work @TestSubjector!