Skip to content

Commit 2f8efe3

Browse files
committed
Compute coeffs using Rationals
1 parent 74614e2 commit 2f8efe3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FiniteDifferences"
22
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
3-
version = "0.9.2"
3+
version = "0.9.3"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

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)