Skip to content
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

General dimensional currying #361

Merged
merged 14 commits into from
Dec 31, 2023
Merged

General dimensional currying #361

merged 14 commits into from
Dec 31, 2023

Conversation

hyrodium
Copy link
Owner

Before this PR

julia> using BasicBSpline

julia> P1 = BSplineSpace{3}(knotvector"43211112112112")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 14]))

julia> P2 = BSplineSpace{4}(knotvector"3211  1 112112115")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 2, 2, 3, 4, 7, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 17, 17, 17, 17]))

julia> P3 = BSplineSpace{5}(knotvector" 411  1 112112 11133")
BSplineSpace{5, Int64, KnotVector{Int64}}(KnotVector([2, 2, 2, 2, 3, 4, 7, 9, 10, 11, 11, 12, 13, 14, 14, 16, 17, 18, 19, 19, 19, 20, 20, 20]))

julia> P4 = BSplineSpace{4}(knotvector"4 1112113 11 13 3")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 3, 4, 5, 6, 6, 7, 8, 9, 9, 9, 11, 12, 14, 15, 15, 15, 17, 17, 17]))

julia> a = rand(dim(P1), dim(P2), dim(P3), dim(P4));

julia> M = BSplineManifold(a, P1, P2, P3, P4);

julia> domain(P1), domain(P2), domain(P3), domain(P4)
(1 .. 12, 2 .. 17, 4 .. 19, 3 .. 15)

julia> M(3.4, 3.9, 12.3, 9.55)
0.5302365715364042

julia> M(3.4, :, 12.3, :)(3.9, 9.55)
ERROR: MethodError: no method matching (::BSplineManifold{4, (3, 4, 5, 4), Float64, Int64, Tuple{BSplineSpace{3, Int64, KnotVector{Int64}}, BSplineSpace{4, Int64, KnotVector{Int64}}, BSplineSpace{5, Int64, KnotVector{Int64}}, BSplineSpace{4, Int64, KnotVector{Int64}}}})(::Float64, ::Colon, ::Float64, ::Colon)

Closest candidates are:
  (::BasicBSpline.AbstractManifold{Dim})(::Real...) where Dim
   @ BasicBSpline ~/.julia/dev/BasicBSpline/src/_BSplineManifold.jl:133

After this PR

julia> using BasicBSpline

julia> P1 = BSplineSpace{3}(knotvector"43211112112112")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 14]))

julia> P2 = BSplineSpace{4}(knotvector"3211  1 112112115")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 2, 2, 3, 4, 7, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 17, 17, 17, 17, 17]))

julia> P3 = BSplineSpace{5}(knotvector" 411  1 112112 11133")
BSplineSpace{5, Int64, KnotVector{Int64}}(KnotVector([2, 2, 2, 2, 3, 4, 7, 9, 10, 11, 11, 12, 13, 14, 14, 16, 17, 18, 19, 19, 19, 20, 20, 20]))

julia> P4 = BSplineSpace{4}(knotvector"4 1112113 11 13 3")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 3, 4, 5, 6, 6, 7, 8, 9, 9, 9, 11, 12, 14, 15, 15, 15, 17, 17, 17]))

julia> a = rand(dim(P1), dim(P2), dim(P3), dim(P4));

julia> M = BSplineManifold(a, P1, P2, P3, P4);

julia> domain(P1), domain(P2), domain(P3), domain(P4)
(1 .. 12, 2 .. 17, 4 .. 19, 3 .. 15)

julia> M(3.4, 3.9, 12.3, 9.55)
0.4813824624978066

julia> M(3.4, :, 12.3, :)(3.9, 9.55)
0.4813824624978067

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (1fb2872) 96.27% compared to head (c517c6d) 96.23%.

Files Patch % Lines
src/_BSplineSpace.jl 0.00% 2 Missing ⚠️
src/_util.jl 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #361      +/-   ##
==========================================
- Coverage   96.27%   96.23%   -0.05%     
==========================================
  Files          14       14              
  Lines        1800     1859      +59     
==========================================
+ Hits         1733     1789      +56     
- Misses         67       70       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hyrodium hyrodium merged commit 36c601f into main Dec 31, 2023
12 of 13 checks passed
@hyrodium hyrodium deleted the feature/generaldim-currying branch January 4, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant