Hi Kaj,

A pull request adding a wrapper for this to Dierckx.jl would be most
welcome. This would be a matter of reading the docstring for the parcur
function here
<https://github.com/kbarbary/Dierckx.jl/blob/master/deps/src/ddierckx/parcur.f>
and then writing a wrapper function that sets up the arguments correctly
and calls the Fortran function with ccall. There are a lot of examples in
Dierckx.jl. It’s a bit tedious but mostly straight forward. Fortunately
(for me anyway) knowing Fortran is not a requirement. I usually consult the
relevant scipy.interpolate wrapper (e.g., this one for splprep
<https://github.com/scipy/scipy/blob/05dc7b8b0662c9c973203b36044458ca35084833/scipy/interpolate/fitpack.py#L107>)
to see how they handled things, and look at the tests in that package as
well.

You can construct an array of vectors by prepending the element type, which
in your example would be Vector{Float64}. For example:

julia> a = [1., 2.];

julia> b = [3., 4.];

julia> Vector{Float64}[a, b]
2-element Array{Array{Float64,1},1}:
 [1.0,2.0]
 [3.0,4.0]

The plan for Julia 0.5, is that you won’t need to prepend the element type:
just [a, b] will do.

By the way, collect is often not necessary. For example:

julia> t = 0.0:0.1:0.5
0.0:0.1:0.5

julia> sin(2*pi*t)
6-element Array{Float64,1}:
 0.0
 0.587785
 0.951057
 0.951057
 0.587785
 1.22465e-16

Best,
— Kyle
​

On Sat, Mar 19, 2016 at 3:24 PM, Kaj Wiik <kaj.w...@gmail.com> wrote:

> Replying to myself...sorry.
>
> It seems that the easiest way for now is to call SciPy:
>
> using PyCall
> @pyimport scipy.interpolate as interpolate
> t = collect(0:.1:1)
> x = sin(2π*t)
> y = cos(2π*t)
> p = Array[]
> push!(p, x)
> push!(p, y)
> tck, u = interpolate.splprep(p, s=0)
> unew = collect(0:0.01:1)
> out = interpolate.splev(unew, tck)
>
> using Winston
> plot(x, y, "o", out[1], out[2], "-r")
>
> BTW, is there an easier way to create an array of vectors?
>
> Cheers,
> Kaj
>
>
> On Saturday, March 19, 2016 at 4:13:19 PM UTC+2, Kaj Wiik wrote:
>>
>>
>> Is there a Julia package that implements parametric splines?
>>
>> I noticed that the Dierckx Fortran library has an implementation but the
>> corresponding Julia package does not does not have bindings for it.
>>
>> Thanks,
>> Kaj
>>
>

Reply via email to