dawbarton / BarycentricInterpolation.jl

A Julia implementation of Barycentric interpolation and differentiation formulae
Other
11 stars 2 forks source link

broken on julia 1.0 - very small changes required #1

Closed AshtonSBradley closed 5 years ago

AshtonSBradley commented 5 years ago

thanks for the cool package. I found that if I update line 112 of /src/Barycentric.jl to

    return BarycentricWeights{length(w), T}(1 ./ w, x)

that is, adding spaces around ./, then using Barycentric works.

AshtonSBradley commented 5 years ago

to get the readme examples going I replaced interpolationmatrix with (only differs in lines 3,6):

function interpolationmatrix(w::BarycentricWeights{N, T}, x::AbstractVector{T}) where {N, T}
    # Eq. (4.2)
    xdiff = Matrix{T}(undef,length(x), N)
    xdiff .= x .- w.x'
    M = w.w' ./ xdiff
    Msum = sum(M, dims=2)
    for i ∈ 1:size(M, 2)
        for j ∈ 1:size(M, 1)
            if Msum[j] == 0
                M[j, i] = 0
            elseif xdiff[j, i] == 0
                M[j, i] = 1
            else
                M[j, i] /= Msum[j]
            end
        end
    end
    return M
end

also note in the first readme example there is minor misprint, last line should read

interpolationmatrix(w, x)*y₀ ≈ sin.(pi*x)
dawbarton commented 5 years ago

Thanks for your comments. I was actually in the process of a complete overhaul for Julia v1.0 - try it out now and hopefully you'll find it significantly faster.