-
Notifications
You must be signed in to change notification settings - Fork 85
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
Using zpk with complex poles requires specific order for conjugates #369
Comments
The reason behind this is that it is not trivial to do the matching when there are numerical errors. Say for example poles at This became a problem when julia changed the behaviour of the eigenvalue solver in v1.2, to do some random ordering by default. You can therefore find calls to I do agree however, that we should either document this requirement, or sort the poles that the user supplies when creating a system. Especially if the user tries to create a TransferFunction{Continous, SisoZpk{<:Real,<:Complex}}, for example in
|
I think that the error message from julia> zpk([], [-1 + im, 1, -1 - im], 1)
ERROR: AssertionError: zpk model should be real-valued, but poles do not come in conjugate pairs. I don't think this is a big nuisance, but if many others do, then I'm not against fixing this. We could have it so that that the If we don't make this change, we should at least change so that the order of e.g. Perhaps there should also be better help for creating complex-coefficient system with |
Ahh, makes sense. Didn't think too far there...
Sounds reasonable to me, if we assume the user supplies numbers without any numercial funniness we could just ad something like this
Yeah, this is the error I ran into and if someone who is not keen on checking the source encounters this it is a bit confusing since there clearly is a conjugate pair. |
Let's fix this asap.
Doesn't this run into the problems for double complex poles? Perhaps it is better after all to try to pair the roots up, and in the case that they don't come after each other, to just search through the reminding roots to see if there is a match somewhere. Using a vectors of |
Unless the gain |
Yeah, you are right.
How do we do the matching in case we have numerical problems though? Don't we need to check all numbers and make sure all are matched in a was that minimizes differences between matches? Otherwise we could imagine having a chain where Do we want users to be able to supply poles/zeros in any order? And do we assume user supplied poles/zeros are nice in that they can easily be sorted? Or should we just add in the docstring that complex numbers should be supplied in positive imaginary part first and negative directly after.
Isn't that exactly what @mfalt wanted to show though? If you don't do the matching correct you might have a system that should work but will error because a pole is left over so it looks like it is complex? |
Is this documented somewhere?
Cause I wanted to use zpk to create a system and had some complex values that I threw in in some random order and got this error about not having matching complex conjugates. Looking at the code it seems that the
roots2real_poly_factors
method requires the pole with positive imaginary part to come first among the two and the other right after. I don't really see the reason why we require an order at all? It should not be very tricky to just keep a set of non-matched complex poles and check through them for matches for every new complex pole we hit, right? Or at least we should document it in the docstring for zpk so people understand why they get this error.The text was updated successfully, but these errors were encountered: