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

changebasis_I sometimes returns a matrix with NaN #325

Closed
hyrodium opened this issue Jun 15, 2023 · 2 comments · Fixed by #342
Closed

changebasis_I sometimes returns a matrix with NaN #325

hyrodium opened this issue Jun 15, 2023 · 2 comments · Fixed by #342

Comments

@hyrodium
Copy link
Owner

julia> using BasicBSpline

julia> Pd1 = BSplineSpace{3}(knotvector"44 3  2 121 ")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 7, 7, 9, 10, 10, 11]))

julia> Pd2 = BSplineSpace{4}(knotvector"55 62 3 2121")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 7, 7, 7, 9, 9, 10, 11, 11, 12]))

julia> changebasis_I(Pd1, Pd2)
13×22 SparseArrays.SparseMatrixCSC{Float64, Int32} with 44 stored entries:
⎡⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⎤
⎢⠀⠀⠈⠳⣄⢀⣀⡀⠀⠀⠀⎥
⎢⠀⠀⠀⠀⠀⠀⠙⠿⠶⣤⣤⎥
⎣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⎦
@hyrodium
Copy link
Owner Author

julia> using BasicBSpline

julia> Pd1 = BSplineSpace{3}(knotvector"44 3  2 121 ")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 7, 7, 9, 10, 10, 11]))

julia> Pd2 = BSplineSpace{4}(knotvector"55 62 3 2121")
BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 7, 7, 7, 9, 9, 10, 11, 11, 12]))

julia> changebasis_I(Pd1, Pd2)
13×22 SparseArrays.SparseMatrixCSC{Float64, Int32} with 44 stored entries:
⎡⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⎤
⎢⠀⠀⠈⠳⣄⢀⣀⡀⠀⠀⠀⎥
⎢⠀⠀⠀⠀⠀⠀⠙⠿⠶⣤⣤⎥
⎣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⎦

julia> Matrix(changebasis_I(Pd1, Pd2))
13×22 Matrix{Float64}:
 1.0  0.25  0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.75  0.5  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.5  0.75  0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.25  1.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  1.0  0.25  0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.75  0.5  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.5  0.75  0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.25  1.0  0.0  1.0  0.75  0.555556   0.111111   0.0       0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.25  0.388889   0.555556   0.222222  0.0  0.0    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0555556  0.316667   0.644444  0.7  0.1    0.0    0.0    0.0    0.0
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0166667  0.133333  0.3  0.9  NaN    NaN    NaN    NaN
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0  NaN    NaN    NaN    NaN
 0.0  0.0   0.0  0.0   0.0  0.0  0.0   0.0  0.0   0.0  0.0  0.0  0.0   0.0        0.0        0.0       0.0  0.0    0.0  NaN    NaN    NaN

@hyrodium
Copy link
Owner Author

hyrodium commented Sep 17, 2023

Simple example:

julia> using BasicBSpline

julia> Pd1 = BSplineSpace{2}(knotvector" 21 3")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([2, 2, 3, 5, 5, 5]))

julia> Pd2 = BSplineSpace{3}(knotvector"212 4")
BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 2, 3, 3, 5, 5, 5, 5]))

julia> BasicBSpline.changebasis_I(Pd1, Pd2)
3×5 SparseArrays.SparseMatrixCSC{Float64, Int32} with 9 stored entries:
 NaN    NaN    NaN               
 NaN    NaN    NaN    0.666667    
                   0.333333  1.0

julia> isdegenerate_R(Pd1)
false

julia> isdegenerate_R(Pd2)
false

julia> isdegenerate_I(Pd1)
false

julia> isdegenerate_I(Pd2)
true

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 a pull request may close this issue.

1 participant