MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / test_complex_capture

Function test_complex_capture

python/tests/kernel/test_kernel_complex.py:53–73  ·  view source on GitHub ↗

Test that we can pass complex lists to kernel functions.

()

Source from the content-addressed store, hash-verified

51
52
53def 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
76def test_complex_definition():

Callers

nothing calls this directly

Calls 4

complex_vec_capture_realFunction · 0.85
complex_vec_capture_imagFunction · 0.85
is_closeFunction · 0.70
rangeFunction · 0.50

Tested by

no test coverage detected