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

implement fallback conj to fix dot #233

Merged
merged 3 commits into from
Oct 1, 2021
Merged

Conversation

ranocha
Copy link
Contributor

@ranocha ranocha commented Sep 30, 2021

Right now on master,

julia> using SymEngine

julia> @vars x
(x,)

julia> using LinearAlgebra

julia> dot([1, x], [x, 0])
ERROR: MethodError: no method matching conj(::Basic)

real etc. is not really working properly right now, see #110 and

julia> using SymEngine

julia> @vars x
(x,)

julia> x == real(x)
true

julia> iszero(x - real(x))
true

Thus, this implemented fallback conj(x) = x is in accordance with the sensible definition

conj(x) = real(x) - (x - real(x))

for complex numbers.

I would like to get this merged into a new release of SymEngine.jl to allow further working with dot products of symbolic variables (which seem to be mostly real). Extensions to a proper support of complex numbers and further fixes should be discussed in #110 etc.

This fixes a problem reported by @ketch (dot product involving SymEngine.Basic variables representing real numbers).

@isuruf
Copy link
Member

isuruf commented Sep 30, 2021

Thus, this implemented fallback conj(x) = x is in accordance with the sensible definition
conj(x) = real(x) - (x - real(x))

This is almost true. For 2*IM, real(2*IM) == 0. (There's a definition for complex numbers further up in the file)

@ranocha
Copy link
Contributor Author

ranocha commented Oct 1, 2021

What about the updated version? I get

julia> using SymEngine

julia> conj(2 * IM)
-2*im

@ranocha
Copy link
Contributor Author

ranocha commented Oct 1, 2021

This should also make #196 obsolete

@isuruf isuruf merged commit 1ba9c4c into symengine:master Oct 1, 2021
@isuruf
Copy link
Member

isuruf commented Oct 1, 2021

Thanks

@ranocha ranocha deleted the hr/dot branch October 1, 2021 15:56
@ranocha
Copy link
Contributor Author

ranocha commented Oct 1, 2021

Well, thank you for this nice package - great work!

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

Successfully merging this pull request may close these issues.

2 participants