Test that we can pass complex lists to kernel functions.
()
| 51 | |
| 52 | |
| 53 | def test_complex_capture(): |
| 54 | """Test that we can pass complex lists to kernel functions.""" |
| 55 | |
| 56 | # Capture a list of complex |
| 57 | c = [.70710678 + 1j, 2j, 0., 0.70710678] |
| 58 | |
| 59 | @cudaq.kernel |
| 60 | def complex_vec_capture_real(i: int) -> float: |
| 61 | v = c[i] |
| 62 | return v.real |
| 63 | |
| 64 | for i in range(len(c)): |
| 65 | assert is_close(c[i].real, complex_vec_capture_real(i)) |
| 66 | |
| 67 | @cudaq.kernel |
| 68 | def complex_vec_capture_imag(i: int) -> float: |
| 69 | v = c[i] |
| 70 | return v.imag |
| 71 | |
| 72 | for i in range(len(c)): |
| 73 | assert is_close(c[i].imag, complex_vec_capture_imag(i)) |
| 74 | |
| 75 | |
| 76 | def test_complex_definition(): |
nothing calls this directly
no test coverage detected