Migrate fully to JetSpace backend (remove legacy TaylorN lookup tables)#414
Conversation
JetSpace backend (remove legacy TaylorN lookup tables)JetSpace backend (remove legacy TaylorN lookup tables)
|
I think I found a way to make the product tables include less entries by removing those which are never used (thanks to @lbenet who noticed many entries remained empty in julia> using TaylorSeries
julia> space = JetSpace(order=4, variables=[:x, :y])
JetSpace
Expansion order: 4
Number of variables: 2
Variable names: ["x", "y"]
Variable symbols: [:x, :y]
julia> x, y = variables(space)
2-element Vector{TaylorN{Float64}}:
1.0 x + 𝒪(‖x‖⁵)
1.0 y + 𝒪(‖x‖⁵)
julia> space.mul_table # empty because of lazy loading
4-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
julia> exp(1+x)*exp(1-y)
7.3890560989306495 + 7.3890560989306495 x - 7.3890560989306495 y + 3.6945280494653248 x² - 7.3890560989306495 x y + 3.6945280494653248 y² + 1.2315093498217748 x³ - 3.6945280494653248 x² y + 3.6945280494653248 x y² - 1.2315093498217748 y³ + 0.3078773374554437 x⁴ - 1.2315093498217748 x³ y + 1.8472640247326624 x² y² - 1.2315093498217748 x y³ + 0.3078773374554437 y⁴ + 𝒪(‖x‖⁵)
julia> space.mul_table # many entries filled, but also many others empty
4-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3], [1, 2, 4, 5], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000006], 3), TaylorSeries.HomogeneousProductTable([1, 2, 3, 4, 2, 3, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000005, 0x00000003, 0x00000006, 0x00000004, 0x00000007, 0x00000008], 4), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4, 3, 4, 5], [1, 2, 4, 7, 9, 10], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000007, 0x00000006, 0x00000008, 0x00000009], 3), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008], 2), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]In this case, So with the changes in commit d170995 this changes to: julia> using TaylorSeries
julia> space = JetSpace(order=4, variables=[:x, :y])
JetSpace
Expansion order: 4
Number of variables: 2
Variable names: ["x", "y"]
Variable symbols: [:x, :y]
julia> space.mul_table # empty because of lazy loading
3-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0), TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
[TaylorSeries.HomogeneousProductTable(Int64[], Int64[], UInt32[], 0)]
julia> x, y = variables(space)
2-element Vector{TaylorN{Float64}}:
1.0 x + 𝒪(‖x‖⁵)
1.0 y + 𝒪(‖x‖⁵)
julia> exp(1+x)*exp(1-y)
7.3890560989306495 + 7.3890560989306495 x - 7.3890560989306495 y + 3.6945280494653248 x² - 7.3890560989306495 x y + 3.6945280494653248 y² + 1.2315093498217748 x³ - 3.6945280494653248 x² y + 3.6945280494653248 x y² - 1.2315093498217748 y³ + 0.3078773374554437 x⁴ - 1.2315093498217748 x³ y + 1.8472640247326624 x² y² - 1.2315093498217748 x y³ + 0.3078773374554437 y⁴ + 𝒪(‖x‖⁵)
julia> space.mul_table # less entries, and all of them are now filled
3-element Vector{Vector{TaylorSeries.HomogeneousProductTable}}:
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3], [1, 2, 4, 5], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000006], 3), TaylorSeries.HomogeneousProductTable([1, 2, 3, 4, 2, 3, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000005, 0x00000003, 0x00000006, 0x00000004, 0x00000007, 0x00000008], 4)]
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4], [1, 2, 4, 6, 7], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006], 2), TaylorSeries.HomogeneousProductTable([1, 2, 3, 2, 3, 4, 3, 4, 5], [1, 2, 4, 7, 9, 10], UInt32[0x00000001, 0x00000002, 0x00000004, 0x00000003, 0x00000005, 0x00000007, 0x00000006, 0x00000008, 0x00000009], 3)]
[TaylorSeries.HomogeneousProductTable([1, 2, 2, 3, 3, 4, 4, 5], [1, 2, 4, 6, 8, 9], UInt32[0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008], 2)]This should not have a great impact on performance, but does allow for better bookkeeping. |
|
@lbenet this is now ready for you to have a look |
lbenet
left a comment
There was a problem hiding this comment.
Thanks @PerezHz for cleaning up the code so we can get rid of the old (global constant) hash tables. In general, everythings LGTM, and the simplification of mul_table are really welcome. Yet, I've left some comments and suggestions. I think the important ones are:
- treat
TS.default_space[]as aconstor force it to be::JetSpace, so its type cannot be changed; - emit a warning if the
TS.default_space[]is reset.
Co-authored-by: Luis Benet <lbenet@users.noreply.github.com>
Co-authored-by: Luis Benet <lbenet@users.noreply.github.com>
Co-authored-by: Luis Benet <lbenet@users.noreply.github.com>
Co-authored-by: Luis Benet <lbenet@users.noreply.github.com>
|
@lbenet thank you for your comments and suggestions; I think I have addressed them. So this is again ready for review |
After #410 introduced
JetSpace, v0.21.10 was released as a compatibility release. Here, we migrate fully to theJetSpacebackend, removing the legacy lookup tables. The intention is for this PR to become the next minor release (0.22).