Test that we can pass complex lists to kernel functions.
()
| 19 | |
| 20 | |
| 21 | def test_complex_params(): |
| 22 | """Test that we can pass complex lists to kernel functions.""" |
| 23 | |
| 24 | # Pass a list of complex as a parameter |
| 25 | c = [.70710678 + 1j, 2j, 0., 0.70710678] |
| 26 | |
| 27 | @cudaq.kernel |
| 28 | def complex_vec_param(vec: list[complex], i: int) -> complex: |
| 29 | return vec[i] |
| 30 | |
| 31 | for i in range(len(c)): |
| 32 | is_close(c[i].real, complex_vec_param(c, i).real) |
| 33 | for i in range(len(c)): |
| 34 | is_close(c[i].imag, complex_vec_param(c, i).imag) |
| 35 | |
| 36 | @cudaq.kernel |
| 37 | def complex_vec_param_real(vec: list[complex], i: int) -> float: |
| 38 | v = vec[i] |
| 39 | return v.real |
| 40 | |
| 41 | for i in range(len(c)): |
| 42 | assert is_close(c[i].real, complex_vec_param_real(c, i)) |
| 43 | |
| 44 | @cudaq.kernel |
| 45 | def complex_vec_param_imag(vec: list[complex], i: int) -> float: |
| 46 | v = vec[i] |
| 47 | return v.imag |
| 48 | |
| 49 | for i in range(len(c)): |
| 50 | assert is_close(c[i].imag, complex_vec_param_imag(c, i)) |
| 51 | |
| 52 | |
| 53 | def test_complex_capture(): |
nothing calls this directly
no test coverage detected