-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
ENH: cupyx/scipy/signal: add missing LTI format conversions #7652
Conversation
ca8757e
to
fde035a
Compare
Rebased on main, this PR is ready for review. |
/test full |
This pull request is now in conflicts. Could you fix it @ev-br? 🙏 |
/test full |
This pull request is now in conflicts. Could you fix it @ev-br? 🙏 |
cupyx/scipy/signal/_polyutils.py
Outdated
seq_of_zeros = np.linalg.eigvals(A.get()) | ||
seq_of_zeros = cupy.asarray(seq_of_zeros) | ||
|
||
dt = seq_of_zeros.dtype | ||
a = cupy.ones((1,), dtype=dt) | ||
for zero in seq_of_zeros: | ||
a = cupy.convolve(a, cupy.r_[1, -zero], mode='full') | ||
|
||
if issubclass(a.dtype.type, cupy.complexfloating): | ||
# if complex roots are all complex conjugates, the roots are real. | ||
roots = cupy.asarray(seq_of_zeros, dtype=complex) | ||
if cupy.all(cupy.sort(roots) == cupy.sort(roots.conjugate())): | ||
a = a.real.copy() |
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.
How about computing on CPU not only eigvals
but also the whole of these calculations, then cupy.asarray
just before return?
|
||
assert_array_almost_equal(b, [-2, 1, 2, 4, 1]) | ||
assert_array_almost_equal(a, [1, 10, 0, -10, -1]) |
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.
Would you remove these unreachable lines?
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.
LGTM except for some comments!
Wrap NumPy's `linalg.eigvals` on CPU (not available in CUDA otherwise).
Comments addressed. |
/test full |
Thanks, @ev-br! |
Thank you for the reviews! (this PR and others) |
cross-ref gh-7403
Note that there are two utilities which delegate to NumPy on CPU,
_polyutils.roots
and.poly
. Both rely onnp.linalg.eigvals
, which on GPU is only available from MAGMA.this is on top of gh-7644