-
Notifications
You must be signed in to change notification settings - Fork 2
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
Reduce type flexibility in BsplineManifold
#355
Reduce type flexibility in BsplineManifold
#355
Conversation
ba7d7e3
to
6677acc
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #355 +/- ##
==========================================
- Coverage 93.84% 93.79% -0.06%
==========================================
Files 14 14
Lines 1642 1660 +18
==========================================
+ Hits 1541 1557 +16
- Misses 101 103 +2 ☔ View full report in Codecov by Sentry. |
Before this PR julia> using BasicBSpline
julia> P1 = BSplineSpace{2, Int}(knotvector"3 113")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 3, 4, 5, 5, 5]))
julia> P2 = BSplineSpace{2, Rational{Int}}(knotvector"3 113")
BSplineSpace{2, Rational{Int64}, KnotVector{Rational{Int64}}}(KnotVector(Rational{Int64}[1//1, 1//1, 1//1, 3//1, 4//1, 5//1, 5//1, 5//1]))
julia> a = rand(dim(P1), dim(P2))
5×5 Matrix{Float64}:
0.741979 0.263108 0.316128 0.372952 0.421981
0.486815 0.67646 0.328703 0.451822 0.340635
0.0072873 0.962419 0.128144 0.163797 0.621682
0.605695 0.600226 0.0666295 0.745873 0.0474121
0.546628 0.018101 0.305919 0.290262 0.884664
julia> bsplinespaces(BSplineManifold(a, P1, P2))[1]
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 3, 4, 5, 5, 5]))
julia> bsplinespaces(BSplineManifold(a, P1, P2))[2]
BSplineSpace{2, Rational{Int64}, KnotVector{Rational{Int64}}}(KnotVector(Rational{Int64}[1//1, 1//1, 1//1, 3//1, 4//1, 5//1, 5//1, 5//1])) After this PR julia> using BasicBSpline
julia> P1 = BSplineSpace{2, Int}(knotvector"3 113")
BSplineSpace{2, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 3, 4, 5, 5, 5]))
julia> P2 = BSplineSpace{2, Rational{Int}}(knotvector"3 113")
BSplineSpace{2, Rational{Int64}, KnotVector{Rational{Int64}}}(KnotVector(Rational{Int64}[1//1, 1//1, 1//1, 3//1, 4//1, 5//1, 5//1, 5//1]))
julia> a = rand(dim(P1), dim(P2))
5×5 Matrix{Float64}:
0.933547 0.324843 0.977758 0.182171 0.55386
0.404299 0.911178 0.0584839 0.615514 0.264623
0.00691595 0.896858 0.102844 0.553428 0.226851
0.846493 0.987066 0.476708 0.99308 0.129281
0.301458 0.242925 0.420328 0.224337 0.957864
julia> bsplinespaces(BSplineManifold(a, P1, P2))[1]
BSplineSpace{2, Rational{Int64}, KnotVector{Rational{Int64}}}(KnotVector(Rational{Int64}[1//1, 1//1, 1//1, 3//1, 4//1, 5//1, 5//1, 5//1]))
julia> bsplinespaces(BSplineManifold(a, P1, P2))[2]
BSplineSpace{2, Rational{Int64}, KnotVector{Rational{Int64}}}(KnotVector(Rational{Int64}[1//1, 1//1, 1//1, 3//1, 4//1, 5//1, 5//1, 5//1])) |
Sometimes type promotions may fail because julia> AbstractKnotVector{Int}(UniformKnotVector(1:5))
ERROR: MethodError: no method matching AbstractKnotVector{Int64}(::UniformKnotVector{Int64, UnitRange{Int64}})
Closest candidates are:
AbstractKnotVector{S}(::KnotVector{T}) where {S, T}
@ BasicBSpline ~/.julia/dev/BasicBSpline/src/_KnotVector.jl:93
Stacktrace:
[1] top-level scope
@ REPL[9]:1 One can just modify the arguments manually not to require type promotions ( |
|
This PR fixes #353.