-
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
add! does not work to add two TaylorN #156
Comments
Maybe I'm misunderstanding what |
The basic idea of I am not sure what are you after, but the following works: julia> TaylorSeries.add!(s, 3x, 1)
julia> s
3.0 x + 1.0 x³ + 3.0 x² y + 3.0 x y² + 1.0 y³ + 𝒪(‖x‖⁷) |
I want to add a TaylorSeries |
I don't understand what the coefficient
|
The coefficient for k in 0:s.order
TaylorSeries.add!(s, s, t, k)
end
s For example: julia> s = (x + y)^2
1.0 x² + 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> t = (x-y)^2
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> for k in 0:s.order
TaylorSeries.add!(s, s, t, k)
end
julia> s
2.0 x² + 2.0 y² + 𝒪(‖x‖⁷)
julia> t
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷) |
OK, thanks.
Would it make sense to add a method to add! to do this?
On 23 Feb 2018 2:37 pm, "Luis Benet" <[email protected]> wrote:
The coefficient k is the only you compute. So you need something like
for k in 0:s.order
TaylorSeries.add!(s, s, t, k)end
s
For example:
julia> s = (x + y)^2
1.0 x² + 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> t = (x-y)^2
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> for k in 0:s.order
TaylorSeries.add!(s, s, t, k)
end
julia> s
2.0 x² + 2.0 y² + 𝒪(‖x‖⁷)
julia> t
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALtTpBbGsyAqgUYNZL_EDXjgEKETSVvks5tXyGSgaJpZM4SRabQ>
.
|
I'm not sure what are you after, but in the example above, this is what you get with |
s = s+t (or equivalently s += t) doesn't work in place and so is not
possible if s is a field of an immutable object.
Maybe we should allow s .= s+t for inplace add.
…On 23 Feb 2018 3:54 pm, "Luis Benet" ***@***.***> wrote:
I'm not sure what are you after, but in the example above, this is what
you get with s+t.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALtTtx5vxluUNd_j1F2MrVfgb9CVbB8ks5tXzOMgaJpZM4SRabQ>
.
|
It does work, though not as an in-place operation. julia> using TaylorSeries
julia> x, y = set_variables("x y")
2-element Array{TaylorSeries.TaylorN{Float64},1}:
1.0 x + 𝒪(‖x‖⁷)
1.0 y + 𝒪(‖x‖⁷)
julia> s = (x + y)^2
1.0 x² + 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> t = (x-y)^2
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> s = s+t
2.0 x² + 2.0 y² + 𝒪(‖x‖⁷) |
My question is how to do that inplace, though.
…On 23 Feb 2018 4:03 pm, "Luis Benet" ***@***.***> wrote:
It does work, though not as an in-place operation.
julia> using TaylorSeries
julia> x, y = set_variables("x y")2-element Array{TaylorSeries.TaylorN{Float64},1}:
1.0 x + 𝒪(‖x‖⁷)
1.0 y + 𝒪(‖x‖⁷)
julia> s = (x + y)^2
1.0 x² + 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> t = (x-y)^2
1.0 x² - 2.0 x y + 1.0 y² + 𝒪(‖x‖⁷)
julia> s = s+t
2.0 x² + 2.0 y² + 𝒪(‖x‖⁷)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AALtTg7VEPuEXIumvTpvRkjRUSzHzPKcks5tXzWWgaJpZM4SRabQ>
.
|
Currently there is no specific method that does that. I guess you could add The current use of all those in-place functions ( |
The text was updated successfully, but these errors were encountered: