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
add more arguments to the function sfunction
in linalg.ordqz
#8790
Comments
Can you give an example of such case? What kind of condition do you need such that you use QZ? |
Yes, here is an example of the problem. Each eigenvalue, E, can be computed as E=alpha/betha. In my case the eigenvalues are complex numbers and I need to sort them: if |E| < 1 - they go to the upper-left block, if |E| > 1 - lower-right block. So far, so good. The problem arises when |E| = 1 - classification of eigenvalues located on the unit circle in the complex plane. In this case, the decision can made using eigenvectors by computing so called group velocity of the wave packet in my example: Im[Z[:, j] * Z[:, j].T] > 0 - upper block, Im[Z[:, j] * Z[:, j].T] < 0 - lower block. The modification I have mentioned can be made in a way that it does not affect the code requiring only alpha and betha by providing default values for Q and Z. |
This still doesn't sort unit sized eigs. Comparison would still be the same for all |
Thank you for the response.
How does this statement come? In my code it works perfectly. It sorts those eigenvalues in the way, that some of them with |E|=1 appear in the upper block, others - in the lower, and it is matters which one exactly goes where. It simply means that if we can not sort them by absolute value we can still sort them by angle, eigenvector properties or whatever. Why do you think that only eigenvalues but not eigenvectors can be used to rearrange Shur forms - isn't it a lack of generality? I just don't want to patch scipy and add it into my package every time I need to distribute my software. |
In LAPACK sorting is done by the function ?TGSEN. It accepts a logical argument |
So if you have two blocks both satisfying |
First I check the magnitude of the eigenvalues, and only if the magnitude equals one I need further information from eigenvectors to define which block do they belong to. Let say I have 4 eigenvalues with |E|=1 - they always come in pairs - so I need to define 2 of them which go to the upper block and other 2 which go to the lower block. Here is example of spectrum of absolute values: |E| = [ 0.1 0.5 1 1 1 1 2 10] - they are already sorted relative to the absolute value, but the order of those having |E|=1 may be wrong. |
So what is the final decision on the issue? |
In the current
scipy
version, one may pass a callable as the argumentsort
of the functionlinalg.ordqz
. This callable is supposed to be a function taking two arguments -alpha
andbetha
, which are thought to be enough to figure out the sorting procedure. I have found applications where sorting is performed is a way that it also requires information on the eigenvectors Q and Z. Therefore, I propose to spread the argument list of the callable making it to accept also Q and Z outputing from the function_qz
- that function is normally called before sorting. If you find this feature useful - let me know and I will make a pull request. In the pull request I have changed the line 358 in the module _decomp_qz.pyfrom
to
The text was updated successfully, but these errors were encountered: