Skip to content

Refactor changebasis_I#399

Merged
hyrodium merged 5 commits intomainfrom
feature/refactor_changebasis_I
Feb 8, 2026
Merged

Refactor changebasis_I#399
hyrodium merged 5 commits intomainfrom
feature/refactor_changebasis_I

Conversation

@hyrodium
Copy link
Copy Markdown
Owner

@hyrodium hyrodium commented Feb 8, 2026

Before this PR

julia> using BasicBSpline, BenchmarkTools

julia> p = 3
3

julia> P = BSplineSpace{p}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

julia> P′ = BSplineSpace{p}(KnotVector([1,2,3,4,4.5,5,6,7,8.1,9.1,10.5]))
BSplineSpace{3, Float64, KnotVector{Float64}}(KnotVector([1.0, 2.0, 3.0, 4.0, 4.5, 5.0, 6.0, 7.0, 8.1, 9.1, 10.5]))

julia> changebasis(P,P′)
6×7 SparseArrays.SparseMatrixCSC{Float64, Int32} with 13 stored entries:
 1.0  0.166667                                 
     0.833333  0.5                             
              0.5  0.833333                    
                  0.166667  1.0  -0.0333333   0.0183333
                                1.03333    -0.103333
                                           1.085

julia> @benchmark changebasis(P,P′)
BenchmarkTools.Trial: 10000 samples with 1 evaluation per sample.
 Range (min  max):  17.111 μs   17.679 ms  ┊ GC (min  max): 0.00%  99.49%
 Time  (median):     19.486 μs               ┊ GC (median):    0.00%
 Time  (mean ± σ):   22.863 μs ± 176.635 μs  ┊ GC (mean ± σ):  7.69% ±  0.99%

      ▄█▄                                                       
  ▁▁▄████▆▅▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  17.1 μs         Histogram: frequency by time         39.6 μs <

 Memory estimate: 31.19 KiB, allocs estimate: 604.

After this PR

julia> using BasicBSpline, BenchmarkTools

julia> p = 3
3

julia> P = BSplineSpace{p}(KnotVector(1:10))
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))

julia> P′ = BSplineSpace{p}(KnotVector([1,2,3,4,4.5,5,6,7,8.1,9.1,10.5]))
BSplineSpace{3, Float64, KnotVector{Float64}}(KnotVector([1.0, 2.0, 3.0, 4.0, 4.5, 5.0, 6.0, 7.0, 8.1, 9.1, 10.5]))

julia> changebasis(P,P′)
6×7 SparseArrays.SparseMatrixCSC{Float64, Int32} with 13 stored entries:
 1.0  0.166667                                 
     0.833333  0.5                             
              0.5  0.833333                    
                  0.166667  1.0  -0.0333333   0.0183333
                                1.03333    -0.103333
                                           1.085

julia> @benchmark changebasis(P,P′)
BenchmarkTools.Trial: 10000 samples with 7 evaluations per sample.
 Range (min  max):  4.190 μs   2.114 ms  ┊ GC (min  max): 0.00%  99.34%
 Time  (median):     4.500 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.036 μs ± 25.724 μs  ┊ GC (mean ± σ):  7.07% ±  1.40%

    ▃▂▆▆█▇██▃▆▂▄ ▂▂ ▁ ▁  ▁ ▁ ▂▁▁▂▁▂ ▂▁▁▁ ▂ ▁                 ▂
  ▆▇███████████████▇█▆█▅██▇█▇████████████████▇▇▆▆▇▆▅▆▇▆▅▅▆▅▅ █
  4.19 μs      Histogram: log(frequency) by time     6.43 μs <

 Memory estimate: 5.94 KiB, allocs estimate: 112.

x-ref: #323 (comment)

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.58%. Comparing base (e173f9b) to head (4b7a2c1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #399      +/-   ##
==========================================
- Coverage   95.11%   94.58%   -0.53%     
==========================================
  Files          14       14              
  Lines        2066     2086      +20     
==========================================
+ Hits         1965     1973       +8     
- Misses        101      113      +12     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hyrodium
Copy link
Copy Markdown
Owner Author

hyrodium commented Feb 8, 2026

Note that this PR introduces 0.0 value element. (may be fixed in the future PR)

Before this PR

julia> P1 = BSplineSpace{2}(KnotVector([-3, -3, -2, 1, 2, 2, 2]))
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([-3, -3, -2, 1, 2, 2, 2]))

julia> P2 = BSplineSpace{4}(KnotVector([-5, -4, -2, -2, -2, 1, 1, 1, 2, 2, 2, 2, 2]))
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([-5, -4, -2, -2, -2, 1, 1, 1, 2, 2, 2, 2, 2]))

julia> changebasis_I(P1, P2)
4×8 SparseArrays.SparseMatrixCSC{Float64, Int32} with 16 stored entries:
 1.0  0.375  0.125                              
     0.625  0.75   0.625  0.125  0.0416667        
           0.125  0.375  0.875  0.791667   0.5    
                             0.166667   0.5  1.0

After this PR

julia> P1 = BSplineSpace{2}(KnotVector([-3, -3, -2, 1, 2, 2, 2]))
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([-3, -3, -2, 1, 2, 2, 2]))

julia> P2 = BSplineSpace{4}(KnotVector([-5, -4, -2, -2, -2, 1, 1, 1, 2, 2, 2, 2, 2]))
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([-5, -4, -2, -2, -2, 1, 1, 1, 2, 2, 2, 2, 2]))

julia> changebasis_I(P1, P2)
4×8 SparseArrays.SparseMatrixCSC{Float64, Int32} with 17 stored entries:
 1.0  0.375  0.125                              
 0.0  0.625  0.75   0.625  0.125  0.0416667        
           0.125  0.375  0.875  0.791667   0.5    
                             0.166667   0.5  1.0

@hyrodium hyrodium merged commit a563f7a into main Feb 8, 2026
12 of 17 checks passed
@hyrodium hyrodium deleted the feature/refactor_changebasis_I branch February 8, 2026 10:51
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.

1 participant