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

Issue converting SymMatryx with N #381

Closed
Kelvyn88 opened this issue Oct 12, 2020 · 2 comments
Closed

Issue converting SymMatryx with N #381

Kelvyn88 opened this issue Oct 12, 2020 · 2 comments

Comments

@Kelvyn88
Copy link

Kelvyn88 commented Oct 12, 2020

using SymPy
@vars x1 x2

x = [1.0,0.0]
s = [-1;-1]
f = x1*x2
∇f = diff(f, [x1, x2])
∇fn = subs(∇f, (x1, 1), (x2, 0))
a = N(∇fn)
typeof(a)

I got "SymMatrix" and should be a vector of Int64

@jverzani
Copy link
Collaborator

Yeah, this is unexpected, but perhaps unavoidable. It comes from applying diff without broadcasting:

julia> ∇f = diff.(f, [x1, x2])
2-element Array{Sym,1}:
 x₂
 x₁

julia> ∇fn = subs.(∇f, x1=>1, x2=>0)
2-element Array{Sym,1}:
 0
 1

julia> N.(∇fn)
2-element Array{Int64,1}:
 0
 1

@Kelvyn88
Copy link
Author

Thanks!

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

No branches or pull requests

2 participants