Skip to content
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

Remove vectorized versions of algorithms #92

Open
LilithHafner opened this issue Dec 9, 2024 · 1 comment
Open

Remove vectorized versions of algorithms #92

LilithHafner opened this issue Dec 9, 2024 · 1 comment

Comments

@LilithHafner
Copy link
Contributor

There are trivial vectorized versions of algorithms (such as sunpos) that are not appropriate for a Julia library. These reflect the (false in Julia) assumption that it is always faster to call a library function to process things in a batch than to loop over all the elements in user code calling a scalar library function. It would be simpler and in some cases more performant to use broadcasting or for loops than to provide additional methods for vectors of inputs.

This would be breaking.

# This function doesn't belong
function sunpos(jd::AbstractVector{J}; radians::Bool=false) where {J<:Real}
    typej = float(J)
    ra = similar(jd, typej)
    dec = similar(jd, typej)
    longmed = similar(jd, typej)
    oblt = similar(jd, typej)
    for i in eachindex(jd)
        ra[i], dec[i], longmed[i], oblt[i] = sunpos(jd[i], radians=radians)
    end
    return ra, dec, longmed, oblt
end

The primary reason to make this change is to shrink the API surface area without reducing functionality or ease of use.

@giordano
Copy link
Member

giordano commented Dec 9, 2024

The problem is that the broadcast version of these functions returns vectors of tuples, instead of tuples of vectors. This is basically to work around JuliaLang/julia#22129.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants