@@ -156,15 +156,20 @@ function _check_p_q(p::Integer, q::Integer)
156156end
157157
158158# Compute coefficients for the method
159+
160+ const _COEFFS_CACHE = Dict {Tuple{AbstractVector{<:Real}, Integer, Integer}, Vector{Float64}} ()
159161function _coefs (grid:: AbstractVector{<:Real} , p:: Integer , q:: Integer )
160- # For high precision on the \ we use Rational, and to prevent overflows we use Int128
161- # At the end we go to Float64 for fast floating point math (rather than rational math)
162- C = [Rational {Int128} (g^ i) for i in 0 : (p - 1 ), g in grid]
163- x = zeros (Rational{Int128}, p)
164- x[q + 1 ] = factorial (q)
165- return Float64 .(C \ x)
162+ return get! (_COEFFS_CACHE, (grid, p, q)) do
163+ # For high precision on the \ we use Rational, and to prevent overflows we use Int128
164+ # At the end we go to Float64 for fast floating point math (rather than rational math)
165+ C = [Rational {Int128} (g^ i) for i in 0 : (p - 1 ), g in grid]
166+ x = zeros (Rational{Int128}, p)
167+ x[q + 1 ] = factorial (q)
168+ return Float64 .(C \ x)
169+ end
166170end
167171
172+
168173# Estimate the bound on the function value and its derivatives at a point
169174_estimate_bound (x, cond) = cond * maximum (abs, x) + TINY
170175
0 commit comments