Skip to content
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

Merged
merged 7 commits into from
Jul 20, 2023

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Jun 20, 2023

cross-ref gh-7403

  • tf2zpk
  • tf2sos
  • tf2ss
  • ss2tf
  • zpk2ss
  • ss2zpk
  • sos2tf
  • sos2zpk
  • BadCoefficients

Note that there are two utilities which delegate to NumPy on CPU, _polyutils.roots and .poly. Both rely on np.linalg.eigvals, which on GPU is only available from MAGMA.

this is on top of gh-7644

@ev-br
Copy link
Contributor Author

ev-br commented Jun 29, 2023

Rebased on main, this PR is ready for review.

@takagi
Copy link
Member

takagi commented Jun 30, 2023

/test full

@mergify
Copy link
Contributor

mergify bot commented Jul 4, 2023

This pull request is now in conflicts. Could you fix it @ev-br? 🙏

@takagi
Copy link
Member

takagi commented Jul 4, 2023

/test full

@mergify
Copy link
Contributor

mergify bot commented Jul 10, 2023

This pull request is now in conflicts. Could you fix it @ev-br? 🙏

Comment on lines 26 to 37
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()
Copy link
Member

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?

Comment on lines 542 to 544

assert_array_almost_equal(b, [-2, 1, 2, 4, 1])
assert_array_almost_equal(a, [1, 10, 0, -10, -1])
Copy link
Member

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?

Copy link
Member

@takagi takagi left a 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!

@ev-br
Copy link
Contributor Author

ev-br commented Jul 12, 2023

Comments addressed.

@takagi takagi added this to the v13.0.0b1 milestone Jul 14, 2023
@takagi
Copy link
Member

takagi commented Jul 14, 2023

/test full

@takagi takagi merged commit eb4a7b4 into cupy:main Jul 20, 2023
43 checks passed
@takagi
Copy link
Member

takagi commented Jul 20, 2023

Thanks, @ev-br!

@ev-br
Copy link
Contributor Author

ev-br commented Jul 20, 2023

Thank you for the reviews! (this PR and others)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants