BasisMatrices.jl icon indicating copy to clipboard operation
BasisMatrices.jl copied to clipboard

Spline derivatives issue

Open cc7768 opened this issue 7 years ago • 1 comments

using BasisMatrices

x = linspace(0.0, 5.0, 25)
p = SplineParams(x, 0, 3)

itp = BasisMatrices.Interpoland(Basis(p), [nodes(p).^2 nodes(p).^3])

pts = [1.0, 2.0, 3.0]

println(itp(1.0, reshape([0, 1], (2, 1))))
println(itp(1.0, reshape([0, 1], (1, 2))))
println(itp(1.0, reshape([1], (1, 1))))

The first print command should give the level and first derivative of the two functions

The second print command should compute df(x)/dy and should fail because there isn't a second dimension to take a derivative with respect to.

The third print command reacts as expected.

cc7768 avatar Jul 09 '17 06:07 cc7768

ouch... you seem to have hit three errors here.

  1. This method should only be calling vec when order::Int. When order::AbstractMatrix then we should be squeezing the first dimension instead of all dimensions. splitting that method in two should make the fix easy.
  2. We shouldn't accept things like itp(1.0, [0 1]). The specification for the order argument should be either an integer for evaluating all dimensions at the same order of derivative or a matrix that has N columns -- where N is the dimensionality of the basis. Having a 1d basis and passing a 2 column order should be an error
  3. Spline derivatives look accurate when we only ask for the derivative. There is something funky going on when we ask for more than one thing at a time. We need to debug this... I'd start by making sure the two basis matrices

sglyon avatar Jul 10 '17 15:07 sglyon