-
Notifications
You must be signed in to change notification settings - Fork 53
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
Small fix in Taylor1 constructor? #346
Conversation
Good catch @PerezHz, and sorry for the delay to get into it... In general, I like the simplicity of the proposed solution, and agree to merge this. Before that, let me ask some questions: Do you know if there is a similar example/problem for |
Just to have it written somewhere, I think this issue is due to the |
Indeed, on current julia> using TaylorSeries
julia> set_variables("x", numvars=2, order=2)
2-element Vector{TaylorN{Float64}}:
1.0 x₁ + 𝒪(‖x‖³)
1.0 x₂ + 𝒪(‖x‖³)
julia> x = TaylorN(Taylor1(5),0)
( 1.0 t + 𝒪(t⁶)) + 𝒪(‖x‖¹)
julia> y = x
( 1.0 t + 𝒪(t⁶)) + 𝒪(‖x‖¹)
julia> y[0][1][0] = 7.1
7.1
julia> x
( 7.1 + 1.0 t + 𝒪(t⁶)) + 𝒪(‖x‖¹)
julia> x = Taylor1(rand(5))
0.6049707581312165 + 0.175608853487092 t + 0.16818194777538198 t² + 0.6251617825278187 t³ + 0.8179378046391547 t⁴ + 𝒪(t⁵)
julia> y = x
0.6049707581312165 + 0.175608853487092 t + 0.16818194777538198 t² + 0.6251617825278187 t³ + 0.8179378046391547 t⁴ + 𝒪(t⁵)
julia> y[0] = 1.0
1.0
julia> x
1.0 + 0.175608853487092 t + 0.16818194777538198 t² + 0.6251617825278187 t³ + 0.8179378046391547 t⁴ + 𝒪(t⁵) And if I remove the |
I agree that in general it's best to avoid allocations as much as possible, but If I think about how we use |
I fully agree with you. Let us go then that way. Can you also fix the |
Merging this; the patch will come eventually... Thanks a lot @PerezHz |
@lbenet thanks for merging and sorry for delay with the patch, I'll try to come back around this in the next few days! |
Nevermind... we can always bump the version later! |
This PR is a bit related to #342 and #343 and represents a solution to the following (unexpected?) behavior: if we have a
Taylor1{TaylorN{Float64}}
constructed from another variable of the same type, modifying in-place the former modifies also the latter:What are your thoughts over this @lbenet?