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

Function test_np_complex64_capture

python/tests/kernel/test_kernel_complex.py:444–469  ·  view source on GitHub ↗

Test that we can pass complex lists to kernel functions.

()

Source from the content-addressed store, hash-verified

442
443
444def test_np_complex64_capture():
445 """Test that we can pass complex lists to kernel functions."""
446
447 # Capture a list of complex
448 c = [
449 np.complex64(.70710678 + 1j),
450 np.complex64(0. + 2j),
451 np.complex64(0.),
452 np.complex64(0.70710678)
453 ]
454
455 @cudaq.kernel
456 def complex_vec_capture_real(i: int) -> np.float32:
457 v = c[i]
458 return v.real
459
460 for i in range(len(c)):
461 assert is_close(c[i].real, complex_vec_capture_real(i))
462
463 @cudaq.kernel
464 def complex_vec_capture_imag(i: int) -> np.float32:
465 v = c[i]
466 return v.imag
467
468 for i in range(len(c)):
469 assert is_close(c[i].imag, complex_vec_capture_imag(i))
470
471
472def test_np_complex64_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