AssociatedLegendrePolynomials.jl icon indicating copy to clipboard operation
AssociatedLegendrePolynomials.jl copied to clipboard

Use OffsetArrays

Open jmert opened this issue 5 years ago • 2 comments

Since the Associated Legendre Polynomials are naturally 0-indexed, we should take advantage of the OffsetArrays package and work with 0-indexed arrays.

jmert avatar May 15 '20 17:05 jmert

It looks like CustomUnitRanges.jl provides a ZeroRange type which will probably be needed to get 0-indexed OffsetArrays without the overhead of an unknown start index (as I expect will happen if you use regular UnitRanges).

jmert avatar May 18 '20 20:05 jmert

OffsetArrays store an offset as a struct field, so the fact that CustomUnitRanges.jl provides a type-based zero-indexed range type doesn't actually lift the indexing calculations to the type domain/compile time.

I haven't yet checked whether LLVM can lift the index offset out of the inner loops to avoid the overhead or not, but as a practical matter it might be easier to instead add an interface which accepts OffsetArray inputs, validates the range of the degree/order dimensions has a zero starting index, and then passes the underlying parent Arrays to the inner calculation function. That way OffsetArrays also becomes an optional interface rather than a necessary one.

jmert avatar Jun 04 '20 19:06 jmert