Test that we can define complex lists inside kernel functions.
()
| 74 | |
| 75 | |
| 76 | def test_complex_definition(): |
| 77 | """Test that we can define complex lists inside kernel functions.""" |
| 78 | |
| 79 | # Define a list of complex inside a kernel |
| 80 | c = [.70710678 + 1j, 2j, 0., 0.70710678] |
| 81 | |
| 82 | @cudaq.kernel |
| 83 | def complex_vec_definition_real(i: int) -> float: |
| 84 | v = [.70710678 + 1j, 2j, 0., 0.70710678][i] |
| 85 | return v.real |
| 86 | |
| 87 | for i in range(len(c)): |
| 88 | assert is_close(c[i].real, complex_vec_definition_real(i)) |
| 89 | |
| 90 | @cudaq.kernel |
| 91 | def complex_vec_definition_imag(i: int) -> float: |
| 92 | v = [.70710678 + 1j, 2j, 0., 0.70710678][i] |
| 93 | return v.imag |
| 94 | |
| 95 | for i in range(len(c)): |
| 96 | assert is_close(c[i].imag, complex_vec_definition_imag(i)) |
| 97 | |
| 98 | |
| 99 | def test_complex_definition_with_constructor(): |
nothing calls this directly
no test coverage detected