diff --git a/GaussTuranExampleTemp/example.jl b/GaussTuranExampleTemp/example.jl index c57dc44..2098d52 100644 --- a/GaussTuranExampleTemp/example.jl +++ b/GaussTuranExampleTemp/example.jl @@ -1,13 +1,13 @@ using Optim +using DoubleFloats using TaylorDiff using PreallocationTools using Integrals -using DoubleFloats # This fix is needed to avoid crashing: https://github.com/JuliaLang/julia/pull/54201 include("linear_algebra_fix.jl") -FT = Float64 # Double64 +FT = Double64 n = 5 s = 1 a = FT(0.0) @@ -44,7 +44,7 @@ I = Integrals.GaussTuran( max_int_error_upper = maximum(abs(I(x -> f(x, j)) - I.cache.rhs_upper[j]) for j in 1:(I.cache.N)) @show max_int_error_upper -# max_int_error_upper = 2.220446049250313e-16 +# max_int_error_upper = 2.465190328815662e-32 # Integration error |I(fⱼ) - ₐ∫ᵇfⱼ(x)dx| last n functions fⱼ max_int_error_lower = maximum( @@ -53,9 +53,9 @@ for j in (I.cache.N + 1):(I.cache.N + I.cache.n) ) @show max_int_error_lower -# max_int_error_lower = 2.0211055051788662e-12 +# max_int_error_lower = 9.079315240327527e-30 # Example with eˣ exp_error = abs(I(Base.exp) - (Base.exp(1) - 1)) @show exp_error; -# exp_error = 1.5543122344752192e-15 +# exp_error = 6.43662141695295e-18 diff --git a/Project.toml b/Project.toml index 25a276b..03e0ca0 100644 --- a/Project.toml +++ b/Project.toml @@ -32,8 +32,8 @@ IntegralsCubaExt = "Cuba" IntegralsCubatureExt = "Cubature" IntegralsFastGaussQuadratureExt = "FastGaussQuadrature" IntegralsForwardDiffExt = "ForwardDiff" -IntegralsMCIntegrationExt = "MCIntegration" IntegralsGaussTuranExt = ["Optim", "TaylorDiff", "PreallocationTools"] +IntegralsMCIntegrationExt = "MCIntegration" IntegralsZygoteExt = ["Zygote", "ChainRulesCore"] [compat] diff --git a/ext/IntegralsGaussTuranExt.jl b/ext/IntegralsGaussTuranExt.jl index b06e693..8b54e84 100644 --- a/ext/IntegralsGaussTuranExt.jl +++ b/ext/IntegralsGaussTuranExt.jl @@ -87,14 +87,14 @@ function GaussTuranLoss!(f, ΔX::AbstractVector{T}, cache) where {T} cumsum!(X, ΔX) X .+= a - # Evaluating f! + # Evaluating f for (i, x) in enumerate(X) # Threads.@threads for j = 1:N for j in 1:N - M_upper[j, i:n:N] .= derivatives(x -> f(x, j), x, one(T), Val(2s + 1)).value + M_upper[j, i:n:N] .= derivatives(x -> f(x, j), x, 1, Val(2s + 1)).value end Threads.@threads for j in (N + 1):(N + n) - M_lower[j - N, i:n:N] .= derivatives(x -> f(x, j), x, one(T), Val(2s + 1)).value + M_lower[j - N, i:n:N] .= derivatives(x -> f(x, j), x, 1, Val(2s + 1)).value end end