@@ -156,15 +156,20 @@ function _check_p_q(p::Integer, q::Integer)
156
156
end
157
157
158
158
# Compute coefficients for the method
159
+
160
+ const _COEFFS_CACHE = Dict {Tuple{AbstractVector{<:Real}, Integer, Integer}, Vector{Float64}} ()
159
161
function _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
166
170
end
167
171
172
+
168
173
# Estimate the bound on the function value and its derivatives at a point
169
174
_estimate_bound (x, cond) = cond * maximum (abs, x) + TINY
170
175
0 commit comments