Test that we can pass complex lists to kernel functions.
()
| 405 | |
| 406 | |
| 407 | def test_np_complex64_params(): |
| 408 | """Test that we can pass complex lists to kernel functions.""" |
| 409 | |
| 410 | # Pass a list of complex as a parameter |
| 411 | c = [ |
| 412 | np.complex64(.70710678 + 1j), |
| 413 | np.complex64(0. + 2j), |
| 414 | np.complex64(0.), |
| 415 | np.complex64(0.70710678) |
| 416 | ] |
| 417 | |
| 418 | @cudaq.kernel |
| 419 | def complex_vec_param(vec: list[np.complex64], i: int) -> np.complex64: |
| 420 | return vec[i] |
| 421 | |
| 422 | for i in range(len(c)): |
| 423 | is_close(c[i].real, complex_vec_param(c, i).real) |
| 424 | for i in range(len(c)): |
| 425 | is_close(c[i].imag, complex_vec_param(c, i).imag) |
| 426 | |
| 427 | @cudaq.kernel |
| 428 | def complex_vec_param_real(vec: list[np.complex64], i: int) -> np.float32: |
| 429 | v = vec[i] |
| 430 | return v.real |
| 431 | |
| 432 | for i in range(len(c)): |
| 433 | assert is_close(c[i].real, complex_vec_param_real(c, i)) |
| 434 | |
| 435 | @cudaq.kernel |
| 436 | def complex_vec_param_imag(vec: list[np.complex64], i: int) -> np.float32: |
| 437 | v = vec[i] |
| 438 | return v.imag |
| 439 | |
| 440 | for i in range(len(c)): |
| 441 | assert is_close(c[i].imag, complex_vec_param_imag(c, i)) |
| 442 | |
| 443 | |
| 444 | def test_np_complex64_capture(): |
nothing calls this directly
no test coverage detected