R's splineDesign in Julia

233 views
Skip to first unread message

Tamas Papp

unread,
Apr 4, 2015, 3:27:28 PM4/4/15
to julia...@googlegroups.com
Hi,

I am looking for a function (library) that allows evaluation of a B-spline
basis (specified by the knots and the order), at given points, _and_
also allows the evaluation of derivatives for the same family. R's
splineDesign in the splines package has this, but looking at the splines
libraries in Julia I could not find one that does B-splines and
derivatives. Using internals from some library would be fine, too.

(Knowing that there is no such thing at the moment would also be useful,
I might implement it, but would prefer to avoid that because B-spline
special cases are tricky).

Best,

Tamas

pauld11718

unread,
Apr 4, 2015, 3:34:27 PM4/4/15
to julia...@googlegroups.com

Tamas Papp

unread,
Apr 4, 2015, 3:54:33 PM4/4/15
to julia...@googlegroups.com
I have looked at Dierckx.jl, but could not figure out how to evaluate
the B-spline basis (all the functions in the documentation appear to do
fitting directly). Can you please give me a hint?

Thanks,

Tamas

Kyle Barbary

unread,
Apr 4, 2015, 10:19:42 PM4/4/15
to julia...@googlegroups.com
Hi Tamas,

I'm not familiar with R's splineDesign, so I'm not sure this helps, but you can get internal spline coefficients in Dierckx with `get_coeffs(spl)` where `spl` is a Spline1D object. Or look into the internals here: https://github.com/kbarbary/Dierckx.jl/blob/master/src/Dierckx.jl#L83 .

- Kyle

Tamas Papp

unread,
Apr 5, 2015, 3:44:34 AM4/5/15
to julia...@googlegroups.com
Hi Kyle,

Looking at the internals, I think that one may get a B-spline by
constructing a Spline1D with coefficients [0,,…,0,1,0,…,0], with 1 in
the ith place for B_i, then evaluating it. But I am unsure of the role
of bc and fp in the evaluation (if any).

My impression is that Dierckx is a library that does the fitting for
given functions, which is fine since specialized algorithms exist for
that, but OTOH for finite element methods one needs the basis matrices.

Maybe I will port a B-spline basis generator, one can do it in around 50
LOC but it is full of corner cases (knots coinciding etc), so it would
need quite a bit of testing. Maybe a Google SOC project for someone :D

Best,

Tamas

Viral Shah

unread,
Apr 5, 2015, 4:46:07 AM4/5/15
to julia...@googlegroups.com

Tomas Lycken

unread,
Apr 5, 2015, 5:01:35 AM4/5/15
to julia...@googlegroups.com
Also, Interpolations.jl currently does this for up to quadratic B-splines; cubic are on the road map, but not implemented yet. There's also some functionality for this in Grid.jl, which is more feature complete but less performant than Interpolations.jl.

The other options mentioned above are probably faster and more mature, but I think the interfaces of Interpolations.jl and Grid.jl are very easy to use.

// Tomas
Message has been deleted

Tim Holy

unread,
Apr 5, 2015, 7:01:58 AM4/5/15
to julia...@googlegroups.com
Finally, you can always computes derivatives with DualNumbers.jl. (The
computed derivatives have full precision; this is completely different from
finite differencing.) But it needs to be a pure-Julia implementation.

--Tim
Reply all
Reply to author
Forward
0 new messages