-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix degree_complex #292
Fix degree_complex #292
Conversation
More consistent behavior of degree_complex and halfdegree Make assertions into actual checks
halfdegree(t::AbstractTermLike) | ||
|
||
Return the equivalent of `ceil(degree(t)/2)`` for real-valued terms or `degree_complex(t)` for terms with only complex | ||
variables; however, respect any mixing between complex and real-valued variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an example section in the docstring to help the reader understand ?
""" | ||
degree_complex(t::AbstractTermLike) | ||
|
||
Return the _total complex degree_ of the monomial of the term `t`, i.e., the maximum of the total degree of the declared | ||
variables in `t` and the total degree of the conjugate variables in `t`. | ||
To be well-defined, the monomial must not contain real parts or imaginary parts of variables. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reader might not know what happens to this example: degree_complex(x^2 * conj(x) * y * conj(y)^2))
. Is it 3 or 4 ? It might be useful as example to clarify.
Good point, added some examples. |
src/complex.jl
Outdated
""" | ||
degree_complex(t::AbstractTermLike) | ||
|
||
Return the _total complex degree_ of the monomial of the term `t`, i.e., the maximum of the total degree of the declared | ||
variables in `t` and the total degree of the conjugate variables in `t`. | ||
To be well-defined, the monomial must not contain real parts or imaginary parts of variables. | ||
If `x` is a real-valued variable and `z` is complex-valued, | ||
- `degree_complex(x^5) = 5` | ||
- `degree_complex(z^3 * conj(z)^4) = 4` and `degree_complex(z^4 * conj(z)^3) = 4` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant also an example with two different complex-valued where one has a larger degree for the conjugate and not the other one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, now I use two real and two complex variables for the example, I hope this covers what you thought of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Currently, the behavior of
degree_complex
andhalfdegree
is inconsistent:degree_complex
lumps real variables and declared complex variables together, whilehalfdegree
counts them separately. I would say that the second variant makes much more sense. This PR makes the behavior consistent: the complex degree is the sum of the degree of the real variables plus the maximum of the degrees of the declared complex vs. conjugated variables.Additionally, the methods contained some assertion-related checks; but they are not really assertions as it is perfectly valid for the user to define a monomial that contains both the variable and its real and imaginary parts individually. But for the purpose of complex degrees, this does not make sense, so we forbid it explicitly.