Skip to content

Remove vectorized versions of algorithms #92

Open
@LilithHafner

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions