Skip to content

Commit b0259dc

Browse files
committed
Compute coeffs using Rationals
1 parent 86f6207 commit b0259dc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/methods.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ end
157157

158158
# Compute coefficients for the method
159159
function _coefs(grid::AbstractVector{<:Real}, p::Integer, q::Integer)
160-
C = [g^i for i in 0:(p - 1), g in grid]
161-
x = zeros(Int, p)
160+
# For high precision on the \ we use Rational, and to prevent overfloats 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)
162164
x[q + 1] = factorial(q)
163-
return C \ x
165+
return Float64.(C \ x)
164166
end
165167

166168
# Estimate the bound on the function value and its derivatives at a point

0 commit comments

Comments
 (0)