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

SymEngine.Basic in struct #199

Open
zhaoli-IHEP opened this issue Mar 15, 2020 · 2 comments
Open

SymEngine.Basic in struct #199

zhaoli-IHEP opened this issue Mar 15, 2020 · 2 comments

Comments

@zhaoli-IHEP
Copy link

After some calculation, the expression just become equal to a symbol.
But the struct constructor seems copied something different.
What is this happening here? And what is the proper approach to do this?
Thank you.

using SymEngine

@vars x

struct test
  val::Basic
end

expr = x+2
expr_m2 = expr-2

println( SymEngine.get_symengine_class(x) ) # Symbol
println( SymEngine.get_symengine_class(expr_m2) ) # also Symbol

println( x == expr_m2 ) # true
println( test(x)==test(x) ) # also true
println( test(x)==test(expr_m2) ) # unexpected false
@isuruf
Copy link
Member

isuruf commented Mar 16, 2020

@zhaoli-IHEP, we create julia objects from symengine C objects as necessary. Therefore expr and (expr+2)-2 are two different objects, but == operator is overloaded to compare. You'll have to overload == operator for test too

@zhaoli-IHEP
Copy link
Author

@zhaoli-IHEP, we create julia objects from symengine C objects as necessary. Therefore expr and (expr+2)-2 are two different objects, but == operator is overloaded to compare. You'll have to overload == operator for test too

Thank you so much. Now I can understand this issue.

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