Question

I am writing a function, actually translating it from a pseudocode form to julia. I keep getting the following complaint:

julia> include("coefficients.jl") ERROR: syntax: incomplete: "function" at /Users/comerduncan/MarkFiniteDiffDerivativs/coefficients.jl:1 requires end in include at boot.jl:244 while loading /Users/comerduncan/MarkFiniteDiffDerivativs/coefficients.jl, in expression starting on line 1

Here is my current version of the function:

function coefficients(order, x_list, x0)
    M = order
    N = length(x_list) - 1
delta = [0 for i=0:N,j=0:N,k=0:M]
delta[0,0,0]= 1
c1 = 1
for n =1:N+1
    c2 = 1
        for nu =0:n
            c3 = x_list[n]-x_list[nu]
            c2 = c2 * c3
            if n <= M
        delta[n,n-1,nu]=0
            for k=0:min(n,M)+1
                delta[k,n,nu] = (x_list[n]-x0)*delta[k,n-1,nu] -\
                k*delta[k-1,n-1,nu]
                delta[k,n,nu] /= c3
    end # k

    end # nu

        for m=0:min(n,M)+1
            delta[m,n,n] = c1/c2*(m*delta[m-1,n-1,n-1] \
            - (x_list[n-1]-x0)*delta[m,n-1,n-1] )
    end # m
        c1 = c2
end # n

return delta

end
Was it helpful?

Solution

Unless I'm missing something, you have four ends, and four loops: but you also write if n <= M, and that isn't ended.

So your end # nu isn't actually closing the nu loop, it's closing the if, and you have one too few.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top