In [1]:
import BSpline
reload("BSpline")
Plot spline functions
In [2]:
import PyPlot
In [3]:
M = 4
bs = BSpline.BSplineT(M,1.,6.,6)
num_basis = BSpline.num_basis(bs);
In [4]:
X = [-2:0.01:9]
psiX = zeros(length(X), num_basis)
BSpline.bspline_basismatrix!(psiX, bs, X)
PyPlot.plot(X, psiX);
Plot Derivatives
In [5]:
X = [-2:0.01:9]
BSpline.derivative_bspline_basismatrix!(psiX, bs, X)
PyPlot.plot(X, psiX);
In [6]:
using DualNumbers
In [7]:
dualDeriv = zeros(length(X))
for j=0:num_basis-1
for i=1:length(X)
x = dual(X[i], 1)
y = BSpline.bspline_basis(j, bs, x)
dualDeriv[i] = epsilon(y)
end
@show maximum(abs(dualDeriv-psiX[:,j+1]))
end
In [8]:
X = [-2:0.01:9]
BSpline.derivative2_bspline_basismatrix!(psiX, bs, X)
PyPlot.plot(X, psiX);
In [9]:
dualDeriv = zeros(length(X))
for j=0:num_basis-1
for i=1:length(X)
x = dual(X[i], 1)
y = BSpline.derivative_bspline_basis(j, bs, x)
dualDeriv[i] = epsilon(y)
end
@show maximum(abs(dualDeriv-psiX[:,j+1]))
end
In [ ]: