sostock / bsplines.jl Goto Github PK
View Code? Open in Web Editor NEWA Julia package for working with B-splines
License: Other
A Julia package for working with B-splines
License: Other
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
k
times. (#5)
BSplineBasis(k, knots=...)
for supplying the knot sequence directly.BSplineBasis(k, breakpoints=...)
which creates the knot vector from the breakpoints by repeating the first and last breakpoint k
times, equivalent to the old constructor without keyword argument.BSplineBasis
with an AbstractUnitRange
creates a new BSplineBasis
with an appropriate knot vector. view(::BSplineBasis, ::AbstractUnitRange)
creates an equivalent BSplineBasis
whose knot vector is a view. The indices
keyword argument can then be removed.BSplineBasis
is changed to contain the knot vector instead of the breakpoints, breakpoints(basis)
is changed to return unique(knots(basis))
. Alternatively, the breakpoints
function can be removed completely, since the user can just call unique(knots(basis))
themself.StaticBSplineBasis{K, T}
type where the order K
is a type parameter for potentially better performance.
K
are possible.AbstractBSplineBasis{T}
as supertype for BSplineBasis{T}
and StaticBSplineBasis{K, T}
.The order k
in this package appears to differ from the corresponding usage in other packages such as Dierckx
or in scipy.interpolate
(which also uses Dierckx I believe). It appears that k
here is somewhat equivalent to k+1
in these packages. For example, in scipy:
In [1]: from scipy import interpolate
In [2]: knots = [0,0,1,2,3,4,4]; k = 2; c = [1,0,0,0,0];
In [3]: interpolate.BSpline(knots, c, k)(1)
Out[3]: array(0.5)
In [4]: c = [0,1,0,0,0];
In [5]: interpolate.BSpline(knots, c, k)(1)
Out[5]: array(0.5)
In Dierckx
,
julia> k = 2; breakpoints = 0:4;
julia> t = vcat([breakpoints[1] for i in 1:k], breakpoints[2:end-1], [breakpoints[end] for i = 1:k])
7-element Array{Int64,1}:
0
0
1
2
3
4
4
julia> c = [1,0,0,0,0];
julia> Dierckx.Spline1D(t, c, k, 0, 0)(1) # matches with scipy
0.5
# comparing with this package
julia> basis = BSplineBasis(k, breakpoints); knots(basis) == t
true
whereas in this package
julia> basis = BSplineBasis(2, 0:4)
5-element BSplineBasis{UnitRange{Int64}}:
order: 2
breakpoints: 0:4
julia> knots(basis)
7-element BSplines.KnotVector{Int64,UnitRange{Int64}}:
0
0
1
2
3
4
4
julia> bsplines(basis, 1)
2-element OffsetArray(::Array{Float64,1}, 2:3) with eltype Float64 with indices 2:3:
1.0
0.0
julia> basis = BSplineBasis(3, 0:4)
6-element BSplineBasis{UnitRange{Int64}}:
order: 3
breakpoints: 0:4
julia> knots(basis)
9-element BSplines.KnotVector{Int64,UnitRange{Int64}}:
0
0
0
1
2
3
4
4
4
julia> bsplines(basis, 1)
3-element OffsetArray(::Array{Float64,1}, 2:4) with eltype Float64 with indices 2:4:
0.5
0.5
0.0
Using order=3
in this package leads to values that seem to match the results for k=2
in scipy, although the knots differ as expected at the edges. I wonder if these differences could be explained in the documentation?
Hi
Thank you for this package. I consider using it in another package, but there is a thing I don't understand -- from simple examples I expect to have fewer functions.
Consider the knot vector
using BSplines
knots = [0; 0; 0; 1; 1; 1]
basis = BSplineBasis(1, knots)
Here, length(basis)
returns 5 as expected and plotting the function look right. But when increasing the order I run into trouble
basis = BSplineBasis(2, knots)
Here, length(basis)
returns 6, but I expect 4. Consider the output of plot(basis)
I would index the functions from 0 through 3. I expect the 0th and 3rd functions to be constantly 0. The 1st and 2nd should be the two straight lines.
What are the rest?
This becomes a problem when constructing a Spline
because it insists on having a larger coeffs
vector than the number of basis functions I anticipate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.