Test that we can pass complex lists to kernel functions.
()
| 442 | |
| 443 | |
| 444 | def test_np_complex64_capture(): |
| 445 | """Test that we can pass complex lists to kernel functions.""" |
| 446 | |
| 447 | # Capture a list of complex |
| 448 | c = [ |
| 449 | np.complex64(.70710678 + 1j), |
| 450 | np.complex64(0. + 2j), |
| 451 | np.complex64(0.), |
| 452 | np.complex64(0.70710678) |
| 453 | ] |
| 454 | |
| 455 | @cudaq.kernel |
| 456 | def complex_vec_capture_real(i: int) -> np.float32: |
| 457 | v = c[i] |
| 458 | return v.real |
| 459 | |
| 460 | for i in range(len(c)): |
| 461 | assert is_close(c[i].real, complex_vec_capture_real(i)) |
| 462 | |
| 463 | @cudaq.kernel |
| 464 | def complex_vec_capture_imag(i: int) -> np.float32: |
| 465 | v = c[i] |
| 466 | return v.imag |
| 467 | |
| 468 | for i in range(len(c)): |
| 469 | assert is_close(c[i].imag, complex_vec_capture_imag(i)) |
| 470 | |
| 471 | |
| 472 | def test_np_complex64_definition(): |
nothing calls this directly
no test coverage detected