-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
linalg.hankel
returns unexpected results
#14788
Comments
Why is r[0] ignored? Is there a practical reason for this? |
There are a couple of things to unpack here. First is that when given two arguments hence working in the context of nonsymmetric Hankel matrix the result is exactly like as required. It has to be a rectangle matrix otherwise the result is not a Hankel matrix. The data problem here is that the user supplied arrays are not compatible for forming a Hankel matrix, that is to say, the last element of the Matlab handles the violation with a warning in scipy historically it is chosen to ignore the first element since it is supposed to be the last element of the column anyways otherwise Hankelness is not preserved. The point can be emphasized better and I'd appreciate a PR for that but this property of the Hankel matrix can be expected also from the user since the result should be familiar. |
For the last example the input can be entered as |
Please forgive my ignorance, I'm certainly much less experienced in this area and was not familiar with non-square Hankel matrices. However, I'm not entirely sure I understand the difference between my example, which also exhibits constant anti-diagonals, and what you are describing as the necessary property for "Hankelness". |
No problem at all. The difference is the way the function is called. Suppose you are trying to form the array you got from the current implementation array([[1, 2, 3, 5, 6, 7],
[2, 3, 5, 6, 7, 8],
[3, 5, 6, 7, 8, 9]]) what should be the input in your proposed syntax? |
A Hankel matrix is supposed to be a square matrix, but the
scipy
implementation can sometimes return non-square matrices, which I think is misleading/unexpected:Note that
4
is not included in the output, which may be unexpected (I know that the documentation says thatr[0]
is ignored, but the initial description ofr
is "the last row" of the matrix, so at the very least the documentation could do a better job clarifying). This output seems much more reasonable as it captures all elements from both arrays and returns a square matrix:The text was updated successfully, but these errors were encountered: