Test that we can pass complex lists to kernel functions.
()
| 227 | |
| 228 | |
| 229 | def test_np_complex128_params(): |
| 230 | """Test that we can pass complex lists to kernel functions.""" |
| 231 | |
| 232 | # Pass a list of complex as a parameter |
| 233 | c = [ |
| 234 | np.complex128(.70710678 + 1j), |
| 235 | np.complex128(0. + 2j), |
| 236 | np.complex128(0.), |
| 237 | np.complex128(0.70710678) |
| 238 | ] |
| 239 | |
| 240 | @cudaq.kernel |
| 241 | def complex_vec_param(vec: list[np.complex128], i: int) -> complex: |
| 242 | return vec[i] |
| 243 | |
| 244 | for i in range(len(c)): |
| 245 | is_close(c[i].real, complex_vec_param(c, i).real) |
| 246 | for i in range(len(c)): |
| 247 | is_close(c[i].imag, complex_vec_param(c, i).imag) |
| 248 | |
| 249 | @cudaq.kernel |
| 250 | def complex_vec_param_real(vec: list[np.complex128], i: int) -> float: |
| 251 | v = vec[i] |
| 252 | return v.real |
| 253 | |
| 254 | for i in range(len(c)): |
| 255 | assert is_close(c[i].real, complex_vec_param_real(c, i)) |
| 256 | |
| 257 | @cudaq.kernel |
| 258 | def complex_vec_param_imag(vec: list[np.complex128], i: int) -> float: |
| 259 | v = vec[i] |
| 260 | return v.imag |
| 261 | |
| 262 | for i in range(len(c)): |
| 263 | assert is_close(c[i].imag, complex_vec_param_imag(c, i)) |
| 264 | |
| 265 | |
| 266 | def test_np_complex128_capture(): |
nothing calls this directly
no test coverage detected