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

define real number parameter? #172

Open
Lightup1 opened this issue May 26, 2023 · 3 comments
Open

define real number parameter? #172

Lightup1 opened this issue May 26, 2023 · 3 comments

Comments

@Lightup1
Copy link

There is a macro @cnumber.
However sometimes, the expression can be further simplified when the parameters are real.
Is there a way to define real number parameters?

@Lightup1
Copy link
Author

For now, I manually set conj(real_number) to real_number as a workaround for this issue.
It is kind of inconvenient. For example, I need to manually define x_conj=g'/omega for x=g/omega with complex g and real omega.

@Lightup1
Copy link
Author

Lightup1 commented May 26, 2023

I do not go through all the code of QuantumCumulants.jl. It seems not complex that we can define a new type RNumber<:CNumber and define a function adjoint for this subtype. I'm not sure whether this definition will make the simplification workable directly.

@david-pl
Copy link
Member

@Lightup1 the implementation you suggest would be an option. The other option, however, would be to implement something such as RNumber <: Real, which would then automatically simplify like

using SymbolicUtils
@syms p::Real
simplify(conj(p))  # p

We could additionally define an adjoint method then. The downside of this approach is that this requires some duplicated code, e.g. RealParamter <: RNumber (similar implementation to Parameter). Also, these types won't share the same supertype, but we can dispatch on const AbstractQCParameter = Union{CNumber, RNumber}.

I'm not entirely sure about all the details or which approach is best here, but I do see some appeal in having the symtype of a real parameter being <: Real since that is how SymbolicUtils does things.

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