-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Roadmap #2
Comments
Hi! Thank you for this great package! I'm also developing another package for B-spline: BasicBSpline.jl. With this package, some of the roadmap seem solved.
As commented here,
BasicBSpline.jl has a type With BSplines.jl julia> using BSplines, BenchmarkTools
julia> basis = BSplineBasis(3, [1,2,3])
4-element BSplineBasis{Vector{Int64}}:
order: 3
breakpoints: [1, 2, 3]
julia> length(basis)
4
julia> bsplines(basis,2.1)
3-element OffsetArray(::Vector{Float64}, 2:4) with eltype Float64 with indices 2:4:
0.4049999999999999
0.5850000000000001
0.010000000000000018
julia> @benchmark bsplines(basis,2.1)
BenchmarkTools.Trial: 10000 samples with 967 evaluations.
Range (min … max): 81.488 ns … 4.399 μs ┊ GC (min … max): 0.00% … 97.85%
Time (median): 85.933 ns ┊ GC (median): 0.00%
Time (mean ± σ): 97.631 ns ± 190.500 ns ┊ GC (mean ± σ): 9.34% ± 4.68%
▁▃▆█▆▇▇▆▅▅▄▄▃▂▂▂▂▁▁▁▁ ▁▁▁▁▁ ▁ ▂
▇█████████████████████████▇▇▆▆▇▇███████████▇▇███▇▇▆▆▅▆▇▇█▇▇▄ █
81.5 ns Histogram: log(frequency) by time 119 ns <
Memory estimate: 112 bytes, allocs estimate: 2.
julia> @benchmark bsplines($basis,2.1)
BenchmarkTools.Trial: 10000 samples with 978 evaluations.
Range (min … max): 66.763 ns … 4.663 μs ┊ GC (min … max): 0.00% … 98.37%
Time (median): 69.476 ns ┊ GC (median): 0.00%
Time (mean ± σ): 82.030 ns ± 209.499 ns ┊ GC (mean ± σ): 12.50% ± 4.81%
▃▅▇█▆▅▄▄▃▃▂▂▂▂▂▁▁ ▂
▇███████████████████▇█▇▇█▇▆▇▇▇▆▅▅▆▆▇█▇▇▆▇▆▆▆▆▇▇▇▇▇▆▆▅▅▄▆▄▆▇▆ █
66.8 ns Histogram: log(frequency) by time 102 ns <
Memory estimate: 112 bytes, allocs estimate: 2. With BasicBSplines.jl julia> using BasicBSpline, BenchmarkTools
julia> k = KnotVector(1,1,1,2,3,3,3)
KnotVector([1.0, 1.0, 1.0, 2.0, 3.0, 3.0, 3.0])
julia> P = BSplineSpace{2}(k)
BSplineSpace{2, Float64}(KnotVector([1.0, 1.0, 1.0, 2.0, 3.0, 3.0, 3.0]))
julia> dim(P)
4
julia> bsplinebasisall(P,2,2.1)
3-element StaticArrays.SVector{3, Float64} with indices SOneTo(3):
0.4049999999999999
0.5850000000000001
0.010000000000000018
julia> @benchmark bsplinebasisall(P,2,2.1)
BenchmarkTools.Trial: 10000 samples with 997 evaluations.
Range (min … max): 20.290 ns … 1.596 μs ┊ GC (min … max): 0.00% … 98.44%
Time (median): 21.033 ns ┊ GC (median): 0.00%
Time (mean ± σ): 24.158 ns ± 36.790 ns ┊ GC (mean ± σ): 3.95% ± 2.59%
▅█▇▃ ▁▂▂▃▂ ▁▂ ▁
█████▇▆▆▅▅▄▄▅▅▅▇███████▇▆▄▄▄▄▅▄█████▇▆▄▅▄▃▅▅▅▆▄▆▆▇▇▇█▇▇▇▆▄▅ █
20.3 ns Histogram: log(frequency) by time 42.9 ns <
Memory estimate: 32 bytes, allocs estimate: 1.
julia> @benchmark bsplinebasisall($P,2,2.1)
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
Range (min … max): 5.710 ns … 16.832 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 5.781 ns ┊ GC (median): 0.00%
Time (mean ± σ): 5.793 ns ± 0.283 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▄ ▆▆▂▅█▄ ▂ ▁▃ ▂
▇█▆██████▁██▄▁██▄▁▄▄▃▃▄▄▃▁▄▅▅▁▄▅▃▄▄▅▄▅▄▅▅▅▄▅▄▅▅▄▅▅▄▅▅▅▅▅▃▃ █
5.71 ns Histogram: log(frequency) by time 6.25 ns <
Memory estimate: 0 bytes, allocs estimate: 0. If you are interested in BasicBSpline.jl, please check the documentation. Some of the features in BSplines.jl seem to be missing from BasicBSpline.jl and vice versa. For example, BasicBSpline.jl doesn't have methods for plotting and Merging BSplines.jl and BasicBSpline.jl would be great for other users and developers. Do you have any thoughts on this? |
It looks like BasicBSpline.jl does indeed solve the problems I had planned to address at some point. It also does a lot more. I don’t use BSplines.jl anymore and so I haven’t worked on it for a while. (I started to implement arbitrary knot vectors in #5, but that was already a long time ago. I don’t have the time to finish it right now.) Merging the packages could be nice, but it does not seem straightforward, as the packages do some things quite differently (for example, both packages have a As examples of what is missing in BasicBSpline.jl you mentioned plotting and |
Thanks for the response!
I’m also happy with the API of BasicBSpline.jl, but I’m not sure how other users think about the API. We both have different API, so I thought it’s a good time to review code with each other. But if you don't have time now, never mind about it.
Sorry, I haven’t checked the entire feature of BSplines.jl, so I’m not sure. 😅
Thanks for the suggestion. I’ll deal with them! 😀 |
k
times. ([WIP] Allow more general knot sequences #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 breakpointk
times, equivalent to the old constructor without keyword argument.BSplineBasis
with anAbstractUnitRange
creates a newBSplineBasis
with an appropriate knot vector.view(::BSplineBasis, ::AbstractUnitRange)
creates an equivalentBSplineBasis
whose knot vector is a view. Theindices
keyword argument can then be removed.BSplineBasis
is changed to contain the knot vector instead of the breakpoints,breakpoints(basis)
is changed to returnunique(knots(basis))
. Alternatively, thebreakpoints
function can be removed completely, since the user can just callunique(knots(basis))
themself.StaticBSplineBasis{K, T}
type where the orderK
is a type parameter for potentially better performance.K
are possible.AbstractBSplineBasis{T}
as supertype forBSplineBasis{T}
andStaticBSplineBasis{K, T}
.The text was updated successfully, but these errors were encountered: