JuliaApproximation / SemiclassicalOrthogonalPolynomials.jl

A Julia repository for semiclassical orthogonal polynomials
MIT License
7 stars 3 forks source link

Reduce cost of weighted lowering #87

Closed TSGut closed 1 year ago

TSGut commented 1 year ago

@ioannisPApapadopoulos It's not quite as clean as a direct formula but it's very close (actually I guess it is a direct formula in terms of a ratio of two 2F1s...)!

This should still speed things up significantly (if I haven't made a mistake in the maths ofc). Can you give it a try and let me know if further speed ups are necessary and also if the results look correct? It passes tests and my sanity checks at least.

TSGut commented 1 year ago

This is what I get now for your example

julia> using SemiclassicalOrthogonalPolynomials, ClassicalOrthogonalPolynomials

julia> t = 1.1
1.1

julia> Q₀₀ = SemiclassicalJacobi.(t, 0, 0, 0:∞);

julia> Q₁₁ = SemiclassicalJacobi.(t, 1, 1, 0:∞);

julia> L  = (Weighted.(Q₀₀) .\ Weighted.(Q₁₁));

julia> @time LL = L[1:70];
  4.524202 seconds (45.49 M allocations: 1.567 GiB, 6.03% gc time)

Looks a lot better to me, though I am sure more could be done.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (60fe828) 91.82% compared to head (e4aa8f0) 91.82%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #87 +/- ## ======================================= Coverage 91.82% 91.82% ======================================= Files 3 3 Lines 477 477 ======================================= Hits 438 438 Misses 39 39 ``` | [Files Changed](https://app.codecov.io/gh/JuliaApproximation/SemiclassicalOrthogonalPolynomials.jl/pull/87?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation) | Coverage Δ | | |---|---|---| | [src/SemiclassicalOrthogonalPolynomials.jl](https://app.codecov.io/gh/JuliaApproximation/SemiclassicalOrthogonalPolynomials.jl/pull/87?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=JuliaApproximation#diff-c3JjL1NlbWljbGFzc2ljYWxPcnRob2dvbmFsUG9seW5vbWlhbHMuamw=) | `86.68% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ioannisPApapadopoulos commented 1 year ago

It definitely performs much better and good enough for the examples I wanted to produce for now! In the long run I might need a rethink but that's the future's problem. Thanks a million!!

dlfivefifty commented 1 year ago

Could do a regression test on LazyArrays.jl to find out what caused the slowdown

TSGut commented 1 year ago

I think we can merge this? It's a small change with big performance improvements and no real drawbacks that I can see