numba-cuda 0.21.1__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. _numba_cuda_redirector.pth +4 -0
  2. _numba_cuda_redirector.py +89 -0
  3. numba_cuda/VERSION +1 -0
  4. numba_cuda/__init__.py +6 -0
  5. numba_cuda/_version.py +11 -0
  6. numba_cuda/numba/cuda/__init__.py +70 -0
  7. numba_cuda/numba/cuda/_internal/cuda_bf16.py +16394 -0
  8. numba_cuda/numba/cuda/_internal/cuda_fp16.py +8112 -0
  9. numba_cuda/numba/cuda/api.py +577 -0
  10. numba_cuda/numba/cuda/api_util.py +76 -0
  11. numba_cuda/numba/cuda/args.py +72 -0
  12. numba_cuda/numba/cuda/bf16.py +397 -0
  13. numba_cuda/numba/cuda/cache_hints.py +287 -0
  14. numba_cuda/numba/cuda/cext/__init__.py +2 -0
  15. numba_cuda/numba/cuda/cext/_devicearray.cp313-win_amd64.pyd +0 -0
  16. numba_cuda/numba/cuda/cext/_devicearray.cpp +159 -0
  17. numba_cuda/numba/cuda/cext/_devicearray.h +29 -0
  18. numba_cuda/numba/cuda/cext/_dispatcher.cp313-win_amd64.pyd +0 -0
  19. numba_cuda/numba/cuda/cext/_dispatcher.cpp +1098 -0
  20. numba_cuda/numba/cuda/cext/_hashtable.cpp +532 -0
  21. numba_cuda/numba/cuda/cext/_hashtable.h +135 -0
  22. numba_cuda/numba/cuda/cext/_helperlib.c +71 -0
  23. numba_cuda/numba/cuda/cext/_helperlib.cp313-win_amd64.pyd +0 -0
  24. numba_cuda/numba/cuda/cext/_helpermod.c +82 -0
  25. numba_cuda/numba/cuda/cext/_pymodule.h +38 -0
  26. numba_cuda/numba/cuda/cext/_typeconv.cp313-win_amd64.pyd +0 -0
  27. numba_cuda/numba/cuda/cext/_typeconv.cpp +206 -0
  28. numba_cuda/numba/cuda/cext/_typeof.cpp +1159 -0
  29. numba_cuda/numba/cuda/cext/_typeof.h +19 -0
  30. numba_cuda/numba/cuda/cext/capsulethunk.h +111 -0
  31. numba_cuda/numba/cuda/cext/mviewbuf.c +385 -0
  32. numba_cuda/numba/cuda/cext/mviewbuf.cp313-win_amd64.pyd +0 -0
  33. numba_cuda/numba/cuda/cext/typeconv.cpp +212 -0
  34. numba_cuda/numba/cuda/cext/typeconv.hpp +101 -0
  35. numba_cuda/numba/cuda/cg.py +67 -0
  36. numba_cuda/numba/cuda/cgutils.py +1294 -0
  37. numba_cuda/numba/cuda/cloudpickle/__init__.py +21 -0
  38. numba_cuda/numba/cuda/cloudpickle/cloudpickle.py +1598 -0
  39. numba_cuda/numba/cuda/cloudpickle/cloudpickle_fast.py +17 -0
  40. numba_cuda/numba/cuda/codegen.py +541 -0
  41. numba_cuda/numba/cuda/compiler.py +1396 -0
  42. numba_cuda/numba/cuda/core/analysis.py +758 -0
  43. numba_cuda/numba/cuda/core/annotations/__init__.py +0 -0
  44. numba_cuda/numba/cuda/core/annotations/pretty_annotate.py +288 -0
  45. numba_cuda/numba/cuda/core/annotations/type_annotations.py +305 -0
  46. numba_cuda/numba/cuda/core/base.py +1332 -0
  47. numba_cuda/numba/cuda/core/boxing.py +1411 -0
  48. numba_cuda/numba/cuda/core/bytecode.py +728 -0
  49. numba_cuda/numba/cuda/core/byteflow.py +2346 -0
  50. numba_cuda/numba/cuda/core/caching.py +744 -0
  51. numba_cuda/numba/cuda/core/callconv.py +392 -0
  52. numba_cuda/numba/cuda/core/codegen.py +171 -0
  53. numba_cuda/numba/cuda/core/compiler.py +199 -0
  54. numba_cuda/numba/cuda/core/compiler_lock.py +85 -0
  55. numba_cuda/numba/cuda/core/compiler_machinery.py +497 -0
  56. numba_cuda/numba/cuda/core/config.py +650 -0
  57. numba_cuda/numba/cuda/core/consts.py +124 -0
  58. numba_cuda/numba/cuda/core/controlflow.py +989 -0
  59. numba_cuda/numba/cuda/core/entrypoints.py +57 -0
  60. numba_cuda/numba/cuda/core/environment.py +66 -0
  61. numba_cuda/numba/cuda/core/errors.py +917 -0
  62. numba_cuda/numba/cuda/core/event.py +511 -0
  63. numba_cuda/numba/cuda/core/funcdesc.py +330 -0
  64. numba_cuda/numba/cuda/core/generators.py +387 -0
  65. numba_cuda/numba/cuda/core/imputils.py +509 -0
  66. numba_cuda/numba/cuda/core/inline_closurecall.py +1787 -0
  67. numba_cuda/numba/cuda/core/interpreter.py +3617 -0
  68. numba_cuda/numba/cuda/core/ir.py +1812 -0
  69. numba_cuda/numba/cuda/core/ir_utils.py +2638 -0
  70. numba_cuda/numba/cuda/core/optional.py +129 -0
  71. numba_cuda/numba/cuda/core/options.py +262 -0
  72. numba_cuda/numba/cuda/core/postproc.py +249 -0
  73. numba_cuda/numba/cuda/core/pythonapi.py +1859 -0
  74. numba_cuda/numba/cuda/core/registry.py +46 -0
  75. numba_cuda/numba/cuda/core/removerefctpass.py +123 -0
  76. numba_cuda/numba/cuda/core/rewrites/__init__.py +26 -0
  77. numba_cuda/numba/cuda/core/rewrites/ir_print.py +91 -0
  78. numba_cuda/numba/cuda/core/rewrites/registry.py +104 -0
  79. numba_cuda/numba/cuda/core/rewrites/static_binop.py +41 -0
  80. numba_cuda/numba/cuda/core/rewrites/static_getitem.py +189 -0
  81. numba_cuda/numba/cuda/core/rewrites/static_raise.py +100 -0
  82. numba_cuda/numba/cuda/core/sigutils.py +68 -0
  83. numba_cuda/numba/cuda/core/ssa.py +498 -0
  84. numba_cuda/numba/cuda/core/targetconfig.py +330 -0
  85. numba_cuda/numba/cuda/core/tracing.py +231 -0
  86. numba_cuda/numba/cuda/core/transforms.py +956 -0
  87. numba_cuda/numba/cuda/core/typed_passes.py +867 -0
  88. numba_cuda/numba/cuda/core/typeinfer.py +1950 -0
  89. numba_cuda/numba/cuda/core/unsafe/__init__.py +0 -0
  90. numba_cuda/numba/cuda/core/unsafe/bytes.py +67 -0
  91. numba_cuda/numba/cuda/core/unsafe/eh.py +67 -0
  92. numba_cuda/numba/cuda/core/unsafe/refcount.py +98 -0
  93. numba_cuda/numba/cuda/core/untyped_passes.py +1979 -0
  94. numba_cuda/numba/cuda/cpython/builtins.py +1153 -0
  95. numba_cuda/numba/cuda/cpython/charseq.py +1218 -0
  96. numba_cuda/numba/cuda/cpython/cmathimpl.py +560 -0
  97. numba_cuda/numba/cuda/cpython/enumimpl.py +103 -0
  98. numba_cuda/numba/cuda/cpython/iterators.py +167 -0
  99. numba_cuda/numba/cuda/cpython/listobj.py +1326 -0
  100. numba_cuda/numba/cuda/cpython/mathimpl.py +499 -0
  101. numba_cuda/numba/cuda/cpython/numbers.py +1475 -0
  102. numba_cuda/numba/cuda/cpython/rangeobj.py +289 -0
  103. numba_cuda/numba/cuda/cpython/slicing.py +322 -0
  104. numba_cuda/numba/cuda/cpython/tupleobj.py +456 -0
  105. numba_cuda/numba/cuda/cpython/unicode.py +2865 -0
  106. numba_cuda/numba/cuda/cpython/unicode_support.py +1597 -0
  107. numba_cuda/numba/cuda/cpython/unsafe/__init__.py +0 -0
  108. numba_cuda/numba/cuda/cpython/unsafe/numbers.py +64 -0
  109. numba_cuda/numba/cuda/cpython/unsafe/tuple.py +92 -0
  110. numba_cuda/numba/cuda/cuda_paths.py +691 -0
  111. numba_cuda/numba/cuda/cudadecl.py +556 -0
  112. numba_cuda/numba/cuda/cudadrv/__init__.py +14 -0
  113. numba_cuda/numba/cuda/cudadrv/devicearray.py +951 -0
  114. numba_cuda/numba/cuda/cudadrv/devices.py +249 -0
  115. numba_cuda/numba/cuda/cudadrv/driver.py +3222 -0
  116. numba_cuda/numba/cuda/cudadrv/drvapi.py +435 -0
  117. numba_cuda/numba/cuda/cudadrv/dummyarray.py +558 -0
  118. numba_cuda/numba/cuda/cudadrv/enums.py +613 -0
  119. numba_cuda/numba/cuda/cudadrv/error.py +48 -0
  120. numba_cuda/numba/cuda/cudadrv/libs.py +220 -0
  121. numba_cuda/numba/cuda/cudadrv/linkable_code.py +184 -0
  122. numba_cuda/numba/cuda/cudadrv/mappings.py +14 -0
  123. numba_cuda/numba/cuda/cudadrv/ndarray.py +26 -0
  124. numba_cuda/numba/cuda/cudadrv/nvrtc.py +193 -0
  125. numba_cuda/numba/cuda/cudadrv/nvvm.py +756 -0
  126. numba_cuda/numba/cuda/cudadrv/rtapi.py +13 -0
  127. numba_cuda/numba/cuda/cudadrv/runtime.py +34 -0
  128. numba_cuda/numba/cuda/cudaimpl.py +995 -0
  129. numba_cuda/numba/cuda/cudamath.py +149 -0
  130. numba_cuda/numba/cuda/datamodel/__init__.py +7 -0
  131. numba_cuda/numba/cuda/datamodel/cuda_manager.py +66 -0
  132. numba_cuda/numba/cuda/datamodel/cuda_models.py +1446 -0
  133. numba_cuda/numba/cuda/datamodel/cuda_packer.py +224 -0
  134. numba_cuda/numba/cuda/datamodel/cuda_registry.py +22 -0
  135. numba_cuda/numba/cuda/datamodel/cuda_testing.py +153 -0
  136. numba_cuda/numba/cuda/datamodel/manager.py +11 -0
  137. numba_cuda/numba/cuda/datamodel/models.py +9 -0
  138. numba_cuda/numba/cuda/datamodel/packer.py +9 -0
  139. numba_cuda/numba/cuda/datamodel/registry.py +11 -0
  140. numba_cuda/numba/cuda/datamodel/testing.py +11 -0
  141. numba_cuda/numba/cuda/debuginfo.py +903 -0
  142. numba_cuda/numba/cuda/decorators.py +294 -0
  143. numba_cuda/numba/cuda/descriptor.py +35 -0
  144. numba_cuda/numba/cuda/device_init.py +158 -0
  145. numba_cuda/numba/cuda/deviceufunc.py +1021 -0
  146. numba_cuda/numba/cuda/dispatcher.py +2463 -0
  147. numba_cuda/numba/cuda/errors.py +72 -0
  148. numba_cuda/numba/cuda/extending.py +697 -0
  149. numba_cuda/numba/cuda/flags.py +178 -0
  150. numba_cuda/numba/cuda/fp16.py +357 -0
  151. numba_cuda/numba/cuda/include/12/cuda_bf16.h +5118 -0
  152. numba_cuda/numba/cuda/include/12/cuda_bf16.hpp +3865 -0
  153. numba_cuda/numba/cuda/include/12/cuda_fp16.h +5363 -0
  154. numba_cuda/numba/cuda/include/12/cuda_fp16.hpp +3483 -0
  155. numba_cuda/numba/cuda/include/13/cuda_bf16.h +5118 -0
  156. numba_cuda/numba/cuda/include/13/cuda_bf16.hpp +3865 -0
  157. numba_cuda/numba/cuda/include/13/cuda_fp16.h +5363 -0
  158. numba_cuda/numba/cuda/include/13/cuda_fp16.hpp +3483 -0
  159. numba_cuda/numba/cuda/initialize.py +24 -0
  160. numba_cuda/numba/cuda/intrinsic_wrapper.py +41 -0
  161. numba_cuda/numba/cuda/intrinsics.py +382 -0
  162. numba_cuda/numba/cuda/itanium_mangler.py +214 -0
  163. numba_cuda/numba/cuda/kernels/__init__.py +2 -0
  164. numba_cuda/numba/cuda/kernels/reduction.py +265 -0
  165. numba_cuda/numba/cuda/kernels/transpose.py +65 -0
  166. numba_cuda/numba/cuda/libdevice.py +3386 -0
  167. numba_cuda/numba/cuda/libdevicedecl.py +20 -0
  168. numba_cuda/numba/cuda/libdevicefuncs.py +1060 -0
  169. numba_cuda/numba/cuda/libdeviceimpl.py +88 -0
  170. numba_cuda/numba/cuda/locks.py +19 -0
  171. numba_cuda/numba/cuda/lowering.py +1951 -0
  172. numba_cuda/numba/cuda/mathimpl.py +374 -0
  173. numba_cuda/numba/cuda/memory_management/__init__.py +4 -0
  174. numba_cuda/numba/cuda/memory_management/memsys.cu +99 -0
  175. numba_cuda/numba/cuda/memory_management/memsys.cuh +22 -0
  176. numba_cuda/numba/cuda/memory_management/nrt.cu +212 -0
  177. numba_cuda/numba/cuda/memory_management/nrt.cuh +48 -0
  178. numba_cuda/numba/cuda/memory_management/nrt.py +390 -0
  179. numba_cuda/numba/cuda/memory_management/nrt_context.py +438 -0
  180. numba_cuda/numba/cuda/misc/appdirs.py +594 -0
  181. numba_cuda/numba/cuda/misc/cffiimpl.py +24 -0
  182. numba_cuda/numba/cuda/misc/coverage_support.py +43 -0
  183. numba_cuda/numba/cuda/misc/dump_style.py +41 -0
  184. numba_cuda/numba/cuda/misc/findlib.py +75 -0
  185. numba_cuda/numba/cuda/misc/firstlinefinder.py +96 -0
  186. numba_cuda/numba/cuda/misc/gdb_hook.py +240 -0
  187. numba_cuda/numba/cuda/misc/literal.py +28 -0
  188. numba_cuda/numba/cuda/misc/llvm_pass_timings.py +412 -0
  189. numba_cuda/numba/cuda/misc/special.py +94 -0
  190. numba_cuda/numba/cuda/models.py +56 -0
  191. numba_cuda/numba/cuda/np/arraymath.py +5130 -0
  192. numba_cuda/numba/cuda/np/arrayobj.py +7635 -0
  193. numba_cuda/numba/cuda/np/extensions.py +11 -0
  194. numba_cuda/numba/cuda/np/linalg.py +3087 -0
  195. numba_cuda/numba/cuda/np/math/__init__.py +0 -0
  196. numba_cuda/numba/cuda/np/math/cmathimpl.py +558 -0
  197. numba_cuda/numba/cuda/np/math/mathimpl.py +487 -0
  198. numba_cuda/numba/cuda/np/math/numbers.py +1461 -0
  199. numba_cuda/numba/cuda/np/npdatetime.py +969 -0
  200. numba_cuda/numba/cuda/np/npdatetime_helpers.py +217 -0
  201. numba_cuda/numba/cuda/np/npyfuncs.py +1808 -0
  202. numba_cuda/numba/cuda/np/npyimpl.py +1027 -0
  203. numba_cuda/numba/cuda/np/numpy_support.py +798 -0
  204. numba_cuda/numba/cuda/np/polynomial/__init__.py +4 -0
  205. numba_cuda/numba/cuda/np/polynomial/polynomial_core.py +242 -0
  206. numba_cuda/numba/cuda/np/polynomial/polynomial_functions.py +380 -0
  207. numba_cuda/numba/cuda/np/ufunc/__init__.py +4 -0
  208. numba_cuda/numba/cuda/np/ufunc/decorators.py +203 -0
  209. numba_cuda/numba/cuda/np/ufunc/sigparse.py +68 -0
  210. numba_cuda/numba/cuda/np/ufunc/ufuncbuilder.py +65 -0
  211. numba_cuda/numba/cuda/np/ufunc_db.py +1282 -0
  212. numba_cuda/numba/cuda/np/unsafe/__init__.py +0 -0
  213. numba_cuda/numba/cuda/np/unsafe/ndarray.py +84 -0
  214. numba_cuda/numba/cuda/nvvmutils.py +254 -0
  215. numba_cuda/numba/cuda/printimpl.py +126 -0
  216. numba_cuda/numba/cuda/random.py +308 -0
  217. numba_cuda/numba/cuda/reshape_funcs.cu +156 -0
  218. numba_cuda/numba/cuda/serialize.py +267 -0
  219. numba_cuda/numba/cuda/simulator/__init__.py +63 -0
  220. numba_cuda/numba/cuda/simulator/_internal/__init__.py +4 -0
  221. numba_cuda/numba/cuda/simulator/_internal/cuda_bf16.py +2 -0
  222. numba_cuda/numba/cuda/simulator/api.py +179 -0
  223. numba_cuda/numba/cuda/simulator/bf16.py +4 -0
  224. numba_cuda/numba/cuda/simulator/compiler.py +38 -0
  225. numba_cuda/numba/cuda/simulator/cudadrv/__init__.py +11 -0
  226. numba_cuda/numba/cuda/simulator/cudadrv/devicearray.py +462 -0
  227. numba_cuda/numba/cuda/simulator/cudadrv/devices.py +122 -0
  228. numba_cuda/numba/cuda/simulator/cudadrv/driver.py +66 -0
  229. numba_cuda/numba/cuda/simulator/cudadrv/drvapi.py +7 -0
  230. numba_cuda/numba/cuda/simulator/cudadrv/dummyarray.py +7 -0
  231. numba_cuda/numba/cuda/simulator/cudadrv/error.py +10 -0
  232. numba_cuda/numba/cuda/simulator/cudadrv/libs.py +10 -0
  233. numba_cuda/numba/cuda/simulator/cudadrv/linkable_code.py +61 -0
  234. numba_cuda/numba/cuda/simulator/cudadrv/nvrtc.py +11 -0
  235. numba_cuda/numba/cuda/simulator/cudadrv/nvvm.py +32 -0
  236. numba_cuda/numba/cuda/simulator/cudadrv/runtime.py +22 -0
  237. numba_cuda/numba/cuda/simulator/dispatcher.py +11 -0
  238. numba_cuda/numba/cuda/simulator/kernel.py +320 -0
  239. numba_cuda/numba/cuda/simulator/kernelapi.py +509 -0
  240. numba_cuda/numba/cuda/simulator/memory_management/__init__.py +4 -0
  241. numba_cuda/numba/cuda/simulator/memory_management/nrt.py +21 -0
  242. numba_cuda/numba/cuda/simulator/reduction.py +19 -0
  243. numba_cuda/numba/cuda/simulator/tests/support.py +4 -0
  244. numba_cuda/numba/cuda/simulator/vector_types.py +65 -0
  245. numba_cuda/numba/cuda/simulator_init.py +18 -0
  246. numba_cuda/numba/cuda/stubs.py +635 -0
  247. numba_cuda/numba/cuda/target.py +505 -0
  248. numba_cuda/numba/cuda/testing.py +347 -0
  249. numba_cuda/numba/cuda/tests/__init__.py +62 -0
  250. numba_cuda/numba/cuda/tests/benchmarks/__init__.py +0 -0
  251. numba_cuda/numba/cuda/tests/benchmarks/test_kernel_launch.py +119 -0
  252. numba_cuda/numba/cuda/tests/cloudpickle_main_class.py +9 -0
  253. numba_cuda/numba/cuda/tests/core/serialize_usecases.py +113 -0
  254. numba_cuda/numba/cuda/tests/core/test_itanium_mangler.py +83 -0
  255. numba_cuda/numba/cuda/tests/core/test_serialize.py +371 -0
  256. numba_cuda/numba/cuda/tests/cudadrv/__init__.py +9 -0
  257. numba_cuda/numba/cuda/tests/cudadrv/test_array_attr.py +147 -0
  258. numba_cuda/numba/cuda/tests/cudadrv/test_context_stack.py +161 -0
  259. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_array_slicing.py +397 -0
  260. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_auto_context.py +24 -0
  261. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_devicerecord.py +180 -0
  262. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_driver.py +313 -0
  263. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_memory.py +187 -0
  264. numba_cuda/numba/cuda/tests/cudadrv/test_cuda_ndarray.py +621 -0
  265. numba_cuda/numba/cuda/tests/cudadrv/test_deallocations.py +247 -0
  266. numba_cuda/numba/cuda/tests/cudadrv/test_detect.py +100 -0
  267. numba_cuda/numba/cuda/tests/cudadrv/test_emm_plugins.py +198 -0
  268. numba_cuda/numba/cuda/tests/cudadrv/test_events.py +53 -0
  269. numba_cuda/numba/cuda/tests/cudadrv/test_host_alloc.py +72 -0
  270. numba_cuda/numba/cuda/tests/cudadrv/test_init.py +138 -0
  271. numba_cuda/numba/cuda/tests/cudadrv/test_inline_ptx.py +43 -0
  272. numba_cuda/numba/cuda/tests/cudadrv/test_is_fp16.py +15 -0
  273. numba_cuda/numba/cuda/tests/cudadrv/test_linkable_code.py +58 -0
  274. numba_cuda/numba/cuda/tests/cudadrv/test_linker.py +348 -0
  275. numba_cuda/numba/cuda/tests/cudadrv/test_managed_alloc.py +128 -0
  276. numba_cuda/numba/cuda/tests/cudadrv/test_module_callbacks.py +301 -0
  277. numba_cuda/numba/cuda/tests/cudadrv/test_nvjitlink.py +174 -0
  278. numba_cuda/numba/cuda/tests/cudadrv/test_nvrtc.py +28 -0
  279. numba_cuda/numba/cuda/tests/cudadrv/test_nvvm_driver.py +185 -0
  280. numba_cuda/numba/cuda/tests/cudadrv/test_pinned.py +39 -0
  281. numba_cuda/numba/cuda/tests/cudadrv/test_profiler.py +23 -0
  282. numba_cuda/numba/cuda/tests/cudadrv/test_reset_device.py +38 -0
  283. numba_cuda/numba/cuda/tests/cudadrv/test_runtime.py +48 -0
  284. numba_cuda/numba/cuda/tests/cudadrv/test_select_device.py +44 -0
  285. numba_cuda/numba/cuda/tests/cudadrv/test_streams.py +127 -0
  286. numba_cuda/numba/cuda/tests/cudapy/__init__.py +9 -0
  287. numba_cuda/numba/cuda/tests/cudapy/cache_usecases.py +231 -0
  288. numba_cuda/numba/cuda/tests/cudapy/cache_with_cpu_usecases.py +50 -0
  289. numba_cuda/numba/cuda/tests/cudapy/cg_cache_usecases.py +36 -0
  290. numba_cuda/numba/cuda/tests/cudapy/complex_usecases.py +116 -0
  291. numba_cuda/numba/cuda/tests/cudapy/enum_usecases.py +59 -0
  292. numba_cuda/numba/cuda/tests/cudapy/extensions_usecases.py +62 -0
  293. numba_cuda/numba/cuda/tests/cudapy/jitlink.ptx +28 -0
  294. numba_cuda/numba/cuda/tests/cudapy/overload_usecases.py +33 -0
  295. numba_cuda/numba/cuda/tests/cudapy/recursion_usecases.py +104 -0
  296. numba_cuda/numba/cuda/tests/cudapy/test_alignment.py +47 -0
  297. numba_cuda/numba/cuda/tests/cudapy/test_analysis.py +1122 -0
  298. numba_cuda/numba/cuda/tests/cudapy/test_array.py +344 -0
  299. numba_cuda/numba/cuda/tests/cudapy/test_array_alignment.py +268 -0
  300. numba_cuda/numba/cuda/tests/cudapy/test_array_args.py +203 -0
  301. numba_cuda/numba/cuda/tests/cudapy/test_array_methods.py +63 -0
  302. numba_cuda/numba/cuda/tests/cudapy/test_array_reductions.py +360 -0
  303. numba_cuda/numba/cuda/tests/cudapy/test_atomics.py +1815 -0
  304. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16.py +599 -0
  305. numba_cuda/numba/cuda/tests/cudapy/test_bfloat16_bindings.py +377 -0
  306. numba_cuda/numba/cuda/tests/cudapy/test_blackscholes.py +160 -0
  307. numba_cuda/numba/cuda/tests/cudapy/test_boolean.py +27 -0
  308. numba_cuda/numba/cuda/tests/cudapy/test_byteflow.py +98 -0
  309. numba_cuda/numba/cuda/tests/cudapy/test_cache_hints.py +210 -0
  310. numba_cuda/numba/cuda/tests/cudapy/test_caching.py +683 -0
  311. numba_cuda/numba/cuda/tests/cudapy/test_casting.py +265 -0
  312. numba_cuda/numba/cuda/tests/cudapy/test_cffi.py +42 -0
  313. numba_cuda/numba/cuda/tests/cudapy/test_compiler.py +718 -0
  314. numba_cuda/numba/cuda/tests/cudapy/test_complex.py +370 -0
  315. numba_cuda/numba/cuda/tests/cudapy/test_complex_kernel.py +23 -0
  316. numba_cuda/numba/cuda/tests/cudapy/test_const_string.py +142 -0
  317. numba_cuda/numba/cuda/tests/cudapy/test_constmem.py +178 -0
  318. numba_cuda/numba/cuda/tests/cudapy/test_cooperative_groups.py +193 -0
  319. numba_cuda/numba/cuda/tests/cudapy/test_copy_propagate.py +131 -0
  320. numba_cuda/numba/cuda/tests/cudapy/test_cuda_array_interface.py +438 -0
  321. numba_cuda/numba/cuda/tests/cudapy/test_cuda_jit_no_types.py +94 -0
  322. numba_cuda/numba/cuda/tests/cudapy/test_datetime.py +101 -0
  323. numba_cuda/numba/cuda/tests/cudapy/test_debug.py +105 -0
  324. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py +889 -0
  325. numba_cuda/numba/cuda/tests/cudapy/test_debuginfo_types.py +476 -0
  326. numba_cuda/numba/cuda/tests/cudapy/test_device_func.py +500 -0
  327. numba_cuda/numba/cuda/tests/cudapy/test_dispatcher.py +820 -0
  328. numba_cuda/numba/cuda/tests/cudapy/test_enums.py +152 -0
  329. numba_cuda/numba/cuda/tests/cudapy/test_errors.py +111 -0
  330. numba_cuda/numba/cuda/tests/cudapy/test_exception.py +170 -0
  331. numba_cuda/numba/cuda/tests/cudapy/test_extending.py +1088 -0
  332. numba_cuda/numba/cuda/tests/cudapy/test_extending_types.py +71 -0
  333. numba_cuda/numba/cuda/tests/cudapy/test_fastmath.py +265 -0
  334. numba_cuda/numba/cuda/tests/cudapy/test_flow_control.py +1433 -0
  335. numba_cuda/numba/cuda/tests/cudapy/test_forall.py +57 -0
  336. numba_cuda/numba/cuda/tests/cudapy/test_freevar.py +34 -0
  337. numba_cuda/numba/cuda/tests/cudapy/test_frexp_ldexp.py +69 -0
  338. numba_cuda/numba/cuda/tests/cudapy/test_globals.py +62 -0
  339. numba_cuda/numba/cuda/tests/cudapy/test_gufunc.py +474 -0
  340. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scalar.py +167 -0
  341. numba_cuda/numba/cuda/tests/cudapy/test_gufunc_scheduling.py +92 -0
  342. numba_cuda/numba/cuda/tests/cudapy/test_idiv.py +39 -0
  343. numba_cuda/numba/cuda/tests/cudapy/test_inline.py +170 -0
  344. numba_cuda/numba/cuda/tests/cudapy/test_inspect.py +255 -0
  345. numba_cuda/numba/cuda/tests/cudapy/test_intrinsics.py +1219 -0
  346. numba_cuda/numba/cuda/tests/cudapy/test_ipc.py +263 -0
  347. numba_cuda/numba/cuda/tests/cudapy/test_ir.py +598 -0
  348. numba_cuda/numba/cuda/tests/cudapy/test_ir_utils.py +276 -0
  349. numba_cuda/numba/cuda/tests/cudapy/test_iterators.py +101 -0
  350. numba_cuda/numba/cuda/tests/cudapy/test_lang.py +68 -0
  351. numba_cuda/numba/cuda/tests/cudapy/test_laplace.py +123 -0
  352. numba_cuda/numba/cuda/tests/cudapy/test_libdevice.py +194 -0
  353. numba_cuda/numba/cuda/tests/cudapy/test_lineinfo.py +220 -0
  354. numba_cuda/numba/cuda/tests/cudapy/test_localmem.py +173 -0
  355. numba_cuda/numba/cuda/tests/cudapy/test_make_function_to_jit_function.py +364 -0
  356. numba_cuda/numba/cuda/tests/cudapy/test_mandel.py +47 -0
  357. numba_cuda/numba/cuda/tests/cudapy/test_math.py +842 -0
  358. numba_cuda/numba/cuda/tests/cudapy/test_matmul.py +76 -0
  359. numba_cuda/numba/cuda/tests/cudapy/test_minmax.py +78 -0
  360. numba_cuda/numba/cuda/tests/cudapy/test_montecarlo.py +25 -0
  361. numba_cuda/numba/cuda/tests/cudapy/test_multigpu.py +145 -0
  362. numba_cuda/numba/cuda/tests/cudapy/test_multiprocessing.py +39 -0
  363. numba_cuda/numba/cuda/tests/cudapy/test_multithreads.py +82 -0
  364. numba_cuda/numba/cuda/tests/cudapy/test_nondet.py +53 -0
  365. numba_cuda/numba/cuda/tests/cudapy/test_operator.py +504 -0
  366. numba_cuda/numba/cuda/tests/cudapy/test_optimization.py +93 -0
  367. numba_cuda/numba/cuda/tests/cudapy/test_overload.py +402 -0
  368. numba_cuda/numba/cuda/tests/cudapy/test_powi.py +128 -0
  369. numba_cuda/numba/cuda/tests/cudapy/test_print.py +193 -0
  370. numba_cuda/numba/cuda/tests/cudapy/test_py2_div_issue.py +37 -0
  371. numba_cuda/numba/cuda/tests/cudapy/test_random.py +117 -0
  372. numba_cuda/numba/cuda/tests/cudapy/test_record_dtype.py +614 -0
  373. numba_cuda/numba/cuda/tests/cudapy/test_recursion.py +130 -0
  374. numba_cuda/numba/cuda/tests/cudapy/test_reduction.py +94 -0
  375. numba_cuda/numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py +83 -0
  376. numba_cuda/numba/cuda/tests/cudapy/test_serialize.py +86 -0
  377. numba_cuda/numba/cuda/tests/cudapy/test_slicing.py +40 -0
  378. numba_cuda/numba/cuda/tests/cudapy/test_sm.py +457 -0
  379. numba_cuda/numba/cuda/tests/cudapy/test_sm_creation.py +233 -0
  380. numba_cuda/numba/cuda/tests/cudapy/test_ssa.py +454 -0
  381. numba_cuda/numba/cuda/tests/cudapy/test_stream_api.py +56 -0
  382. numba_cuda/numba/cuda/tests/cudapy/test_sync.py +277 -0
  383. numba_cuda/numba/cuda/tests/cudapy/test_tracing.py +200 -0
  384. numba_cuda/numba/cuda/tests/cudapy/test_transpose.py +90 -0
  385. numba_cuda/numba/cuda/tests/cudapy/test_typeconv.py +333 -0
  386. numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py +538 -0
  387. numba_cuda/numba/cuda/tests/cudapy/test_ufuncs.py +585 -0
  388. numba_cuda/numba/cuda/tests/cudapy/test_userexc.py +42 -0
  389. numba_cuda/numba/cuda/tests/cudapy/test_vector_type.py +485 -0
  390. numba_cuda/numba/cuda/tests/cudapy/test_vectorize.py +312 -0
  391. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_complex.py +23 -0
  392. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_decor.py +183 -0
  393. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_device.py +40 -0
  394. numba_cuda/numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py +40 -0
  395. numba_cuda/numba/cuda/tests/cudapy/test_warning.py +206 -0
  396. numba_cuda/numba/cuda/tests/cudapy/test_warp_ops.py +331 -0
  397. numba_cuda/numba/cuda/tests/cudasim/__init__.py +9 -0
  398. numba_cuda/numba/cuda/tests/cudasim/support.py +9 -0
  399. numba_cuda/numba/cuda/tests/cudasim/test_cudasim_issues.py +111 -0
  400. numba_cuda/numba/cuda/tests/data/__init__.py +2 -0
  401. numba_cuda/numba/cuda/tests/data/cta_barrier.cu +28 -0
  402. numba_cuda/numba/cuda/tests/data/cuda_include.cu +10 -0
  403. numba_cuda/numba/cuda/tests/data/error.cu +12 -0
  404. numba_cuda/numba/cuda/tests/data/include/add.cuh +8 -0
  405. numba_cuda/numba/cuda/tests/data/jitlink.cu +28 -0
  406. numba_cuda/numba/cuda/tests/data/jitlink.ptx +49 -0
  407. numba_cuda/numba/cuda/tests/data/warn.cu +12 -0
  408. numba_cuda/numba/cuda/tests/doc_examples/__init__.py +9 -0
  409. numba_cuda/numba/cuda/tests/doc_examples/ffi/__init__.py +2 -0
  410. numba_cuda/numba/cuda/tests/doc_examples/ffi/functions.cu +54 -0
  411. numba_cuda/numba/cuda/tests/doc_examples/ffi/include/mul.cuh +8 -0
  412. numba_cuda/numba/cuda/tests/doc_examples/ffi/saxpy.cu +14 -0
  413. numba_cuda/numba/cuda/tests/doc_examples/test_cg.py +86 -0
  414. numba_cuda/numba/cuda/tests/doc_examples/test_cpointer.py +68 -0
  415. numba_cuda/numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py +81 -0
  416. numba_cuda/numba/cuda/tests/doc_examples/test_ffi.py +141 -0
  417. numba_cuda/numba/cuda/tests/doc_examples/test_laplace.py +160 -0
  418. numba_cuda/numba/cuda/tests/doc_examples/test_matmul.py +180 -0
  419. numba_cuda/numba/cuda/tests/doc_examples/test_montecarlo.py +119 -0
  420. numba_cuda/numba/cuda/tests/doc_examples/test_random.py +66 -0
  421. numba_cuda/numba/cuda/tests/doc_examples/test_reduction.py +80 -0
  422. numba_cuda/numba/cuda/tests/doc_examples/test_sessionize.py +206 -0
  423. numba_cuda/numba/cuda/tests/doc_examples/test_ufunc.py +53 -0
  424. numba_cuda/numba/cuda/tests/doc_examples/test_vecadd.py +76 -0
  425. numba_cuda/numba/cuda/tests/nocuda/__init__.py +9 -0
  426. numba_cuda/numba/cuda/tests/nocuda/test_dummyarray.py +391 -0
  427. numba_cuda/numba/cuda/tests/nocuda/test_function_resolution.py +48 -0
  428. numba_cuda/numba/cuda/tests/nocuda/test_import.py +63 -0
  429. numba_cuda/numba/cuda/tests/nocuda/test_library_lookup.py +252 -0
  430. numba_cuda/numba/cuda/tests/nocuda/test_nvvm.py +59 -0
  431. numba_cuda/numba/cuda/tests/nrt/__init__.py +9 -0
  432. numba_cuda/numba/cuda/tests/nrt/test_nrt.py +387 -0
  433. numba_cuda/numba/cuda/tests/nrt/test_nrt_refct.py +124 -0
  434. numba_cuda/numba/cuda/tests/support.py +900 -0
  435. numba_cuda/numba/cuda/typeconv/__init__.py +4 -0
  436. numba_cuda/numba/cuda/typeconv/castgraph.py +137 -0
  437. numba_cuda/numba/cuda/typeconv/rules.py +63 -0
  438. numba_cuda/numba/cuda/typeconv/typeconv.py +121 -0
  439. numba_cuda/numba/cuda/types/__init__.py +233 -0
  440. numba_cuda/numba/cuda/types/__init__.pyi +167 -0
  441. numba_cuda/numba/cuda/types/abstract.py +9 -0
  442. numba_cuda/numba/cuda/types/common.py +9 -0
  443. numba_cuda/numba/cuda/types/containers.py +9 -0
  444. numba_cuda/numba/cuda/types/cuda_abstract.py +533 -0
  445. numba_cuda/numba/cuda/types/cuda_common.py +110 -0
  446. numba_cuda/numba/cuda/types/cuda_containers.py +971 -0
  447. numba_cuda/numba/cuda/types/cuda_function_type.py +230 -0
  448. numba_cuda/numba/cuda/types/cuda_functions.py +798 -0
  449. numba_cuda/numba/cuda/types/cuda_iterators.py +120 -0
  450. numba_cuda/numba/cuda/types/cuda_misc.py +569 -0
  451. numba_cuda/numba/cuda/types/cuda_npytypes.py +690 -0
  452. numba_cuda/numba/cuda/types/cuda_scalars.py +280 -0
  453. numba_cuda/numba/cuda/types/ext_types.py +101 -0
  454. numba_cuda/numba/cuda/types/function_type.py +11 -0
  455. numba_cuda/numba/cuda/types/functions.py +9 -0
  456. numba_cuda/numba/cuda/types/iterators.py +9 -0
  457. numba_cuda/numba/cuda/types/misc.py +9 -0
  458. numba_cuda/numba/cuda/types/npytypes.py +9 -0
  459. numba_cuda/numba/cuda/types/scalars.py +9 -0
  460. numba_cuda/numba/cuda/typing/__init__.py +19 -0
  461. numba_cuda/numba/cuda/typing/arraydecl.py +939 -0
  462. numba_cuda/numba/cuda/typing/asnumbatype.py +130 -0
  463. numba_cuda/numba/cuda/typing/bufproto.py +70 -0
  464. numba_cuda/numba/cuda/typing/builtins.py +1209 -0
  465. numba_cuda/numba/cuda/typing/cffi_utils.py +219 -0
  466. numba_cuda/numba/cuda/typing/cmathdecl.py +47 -0
  467. numba_cuda/numba/cuda/typing/collections.py +138 -0
  468. numba_cuda/numba/cuda/typing/context.py +782 -0
  469. numba_cuda/numba/cuda/typing/ctypes_utils.py +125 -0
  470. numba_cuda/numba/cuda/typing/dictdecl.py +63 -0
  471. numba_cuda/numba/cuda/typing/enumdecl.py +74 -0
  472. numba_cuda/numba/cuda/typing/listdecl.py +147 -0
  473. numba_cuda/numba/cuda/typing/mathdecl.py +158 -0
  474. numba_cuda/numba/cuda/typing/npdatetime.py +322 -0
  475. numba_cuda/numba/cuda/typing/npydecl.py +749 -0
  476. numba_cuda/numba/cuda/typing/setdecl.py +115 -0
  477. numba_cuda/numba/cuda/typing/templates.py +1446 -0
  478. numba_cuda/numba/cuda/typing/typeof.py +301 -0
  479. numba_cuda/numba/cuda/ufuncs.py +746 -0
  480. numba_cuda/numba/cuda/utils.py +724 -0
  481. numba_cuda/numba/cuda/vector_types.py +214 -0
  482. numba_cuda/numba/cuda/vectorizers.py +260 -0
  483. numba_cuda-0.21.1.dist-info/METADATA +109 -0
  484. numba_cuda-0.21.1.dist-info/RECORD +488 -0
  485. numba_cuda-0.21.1.dist-info/WHEEL +5 -0
  486. numba_cuda-0.21.1.dist-info/licenses/LICENSE +26 -0
  487. numba_cuda-0.21.1.dist-info/licenses/LICENSE.numba +24 -0
  488. numba_cuda-0.21.1.dist-info/top_level.txt +1 -0
File without changes
@@ -0,0 +1,558 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2
+ # SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ """
5
+ Implement the cmath module functions.
6
+ """
7
+
8
+ import cmath
9
+ import math
10
+
11
+ from numba.cuda.core.imputils import impl_ret_untracked
12
+ from numba.cuda import types
13
+ from numba.cuda.typing import signature
14
+ from numba.cuda.cpython import mathimpl
15
+
16
+ # registry = Registry('cmathimpl')
17
+ # lower = registry.lower
18
+
19
+
20
+ def is_nan(builder, z):
21
+ return builder.fcmp_unordered("uno", z.real, z.imag)
22
+
23
+
24
+ def is_inf(builder, z):
25
+ return builder.or_(
26
+ mathimpl.is_inf(builder, z.real), mathimpl.is_inf(builder, z.imag)
27
+ )
28
+
29
+
30
+ def is_finite(builder, z):
31
+ return builder.and_(
32
+ mathimpl.is_finite(builder, z.real), mathimpl.is_finite(builder, z.imag)
33
+ )
34
+
35
+
36
+ # @lower(cmath.isnan, types.Complex)
37
+ def isnan_float_impl(context, builder, sig, args):
38
+ [typ] = sig.args
39
+ [value] = args
40
+ z = context.make_complex(builder, typ, value=value)
41
+ res = is_nan(builder, z)
42
+ return impl_ret_untracked(context, builder, sig.return_type, res)
43
+
44
+
45
+ # @lower(cmath.isinf, types.Complex)
46
+ def isinf_float_impl(context, builder, sig, args):
47
+ [typ] = sig.args
48
+ [value] = args
49
+ z = context.make_complex(builder, typ, value=value)
50
+ res = is_inf(builder, z)
51
+ return impl_ret_untracked(context, builder, sig.return_type, res)
52
+
53
+
54
+ # @lower(cmath.isfinite, types.Complex)
55
+ def isfinite_float_impl(context, builder, sig, args):
56
+ [typ] = sig.args
57
+ [value] = args
58
+ z = context.make_complex(builder, typ, value=value)
59
+ res = is_finite(builder, z)
60
+ return impl_ret_untracked(context, builder, sig.return_type, res)
61
+
62
+
63
+ # @overload(cmath.rect)
64
+ def impl_cmath_rect(r, phi):
65
+ if all([isinstance(typ, types.Float) for typ in [r, phi]]):
66
+
67
+ def impl(r, phi):
68
+ if not math.isfinite(phi):
69
+ if not r:
70
+ # cmath.rect(0, phi={inf, nan}) = 0
71
+ return abs(r)
72
+ if math.isinf(r):
73
+ # cmath.rect(inf, phi={inf, nan}) = inf + j phi
74
+ return complex(r, phi)
75
+ real = math.cos(phi)
76
+ imag = math.sin(phi)
77
+ if real == 0.0 and math.isinf(r):
78
+ # 0 * inf would return NaN, we want to keep 0 but xor the sign
79
+ real /= r
80
+ else:
81
+ real *= r
82
+ if imag == 0.0 and math.isinf(r):
83
+ # ditto
84
+ imag /= r
85
+ else:
86
+ imag *= r
87
+ return complex(real, imag)
88
+
89
+ return impl
90
+
91
+
92
+ def intrinsic_complex_unary(inner_func):
93
+ def wrapper(context, builder, sig, args):
94
+ [typ] = sig.args
95
+ [value] = args
96
+ z = context.make_complex(builder, typ, value=value)
97
+ x = z.real
98
+ y = z.imag
99
+ # Same as above: math.isfinite() is unavailable on 2.x so we precompute
100
+ # its value and pass it to the pure Python implementation.
101
+ x_is_finite = mathimpl.is_finite(builder, x)
102
+ y_is_finite = mathimpl.is_finite(builder, y)
103
+ inner_sig = signature(
104
+ sig.return_type, *(typ.underlying_float,) * 2 + (types.boolean,) * 2
105
+ )
106
+ res = context.compile_internal(
107
+ builder, inner_func, inner_sig, (x, y, x_is_finite, y_is_finite)
108
+ )
109
+ return impl_ret_untracked(context, builder, sig, res)
110
+
111
+ return wrapper
112
+
113
+
114
+ NAN = float("nan")
115
+ INF = float("inf")
116
+
117
+
118
+ # @lower(cmath.exp, types.Complex)
119
+ @intrinsic_complex_unary
120
+ def exp_impl(x, y, x_is_finite, y_is_finite):
121
+ """cmath.exp(x + y j)"""
122
+ if x_is_finite:
123
+ if y_is_finite:
124
+ c = math.cos(y)
125
+ s = math.sin(y)
126
+ r = math.exp(x)
127
+ return complex(r * c, r * s)
128
+ else:
129
+ return complex(NAN, NAN)
130
+ elif math.isnan(x):
131
+ if y:
132
+ return complex(x, x) # nan + j nan
133
+ else:
134
+ return complex(x, y) # nan + 0j
135
+ elif x > 0.0:
136
+ # x == +inf
137
+ if y_is_finite:
138
+ real = math.cos(y)
139
+ imag = math.sin(y)
140
+ # Avoid NaNs if math.cos(y) or math.sin(y) == 0
141
+ # (e.g. cmath.exp(inf + 0j) == inf + 0j)
142
+ if real != 0:
143
+ real *= x
144
+ if imag != 0:
145
+ imag *= x
146
+ return complex(real, imag)
147
+ else:
148
+ return complex(x, NAN)
149
+ else:
150
+ # x == -inf
151
+ if y_is_finite:
152
+ r = math.exp(x)
153
+ c = math.cos(y)
154
+ s = math.sin(y)
155
+ return complex(r * c, r * s)
156
+ else:
157
+ r = 0
158
+ return complex(r, r)
159
+
160
+
161
+ # @lower(cmath.log, types.Complex)
162
+ @intrinsic_complex_unary
163
+ def log_impl(x, y, x_is_finite, y_is_finite):
164
+ """cmath.log(x + y j)"""
165
+ a = math.log(math.hypot(x, y))
166
+ b = math.atan2(y, x)
167
+ return complex(a, b)
168
+
169
+
170
+ # @lower(cmath.log, types.Complex, types.Complex)
171
+ def log_base_impl(context, builder, sig, args):
172
+ """cmath.log(z, base)"""
173
+ [z, base] = args
174
+
175
+ def log_base(z, base):
176
+ return cmath.log(z) / cmath.log(base)
177
+
178
+ res = context.compile_internal(builder, log_base, sig, args)
179
+ return impl_ret_untracked(context, builder, sig, res)
180
+
181
+
182
+ # @overload(cmath.log10)
183
+ def impl_cmath_log10(z):
184
+ if not isinstance(z, types.Complex):
185
+ return
186
+
187
+ LN_10 = 2.302585092994045684
188
+
189
+ def log10_impl(z):
190
+ """cmath.log10(z)"""
191
+ z = cmath.log(z)
192
+ # This formula gives better results on +/-inf than cmath.log(z, 10)
193
+ # See http://bugs.python.org/issue22544
194
+ return complex(z.real / LN_10, z.imag / LN_10)
195
+
196
+ return log10_impl
197
+
198
+
199
+ # @overload(cmath.phase)
200
+ def phase_impl(x):
201
+ """cmath.phase(x + y j)"""
202
+
203
+ if not isinstance(x, types.Complex):
204
+ return
205
+
206
+ def impl(x):
207
+ return math.atan2(x.imag, x.real)
208
+
209
+ return impl
210
+
211
+
212
+ # @overload(cmath.polar)
213
+ def polar_impl(x):
214
+ if not isinstance(x, types.Complex):
215
+ return
216
+
217
+ def impl(x):
218
+ r, i = x.real, x.imag
219
+ return math.hypot(r, i), math.atan2(i, r)
220
+
221
+ return impl
222
+
223
+
224
+ # @lower(cmath.sqrt, types.Complex)
225
+ def sqrt_impl(context, builder, sig, args):
226
+ # We risk spurious overflow for components >= FLT_MAX / (1 + sqrt(2)).
227
+
228
+ SQRT2 = 1.414213562373095048801688724209698079e0
229
+ ONE_PLUS_SQRT2 = 1.0 + SQRT2
230
+ theargflt = sig.args[0].underlying_float
231
+ # Get a type specific maximum value so scaling for overflow is based on that
232
+ MAX = mathimpl.DBL_MAX if theargflt.bitwidth == 64 else mathimpl.FLT_MAX
233
+ # THRES will be double precision, should not impact typing as it's just
234
+ # used for comparison, there *may* be a few values near THRES which
235
+ # deviate from e.g. NumPy due to rounding that occurs in the computation
236
+ # of this value in the case of a 32bit argument.
237
+ THRES = MAX / ONE_PLUS_SQRT2
238
+
239
+ def sqrt_impl(z):
240
+ """cmath.sqrt(z)"""
241
+ # This is NumPy's algorithm, see npy_csqrt() in npy_math_complex.c.src
242
+ a = z.real
243
+ b = z.imag
244
+ if a == 0.0 and b == 0.0:
245
+ return complex(abs(b), b)
246
+ if math.isinf(b):
247
+ return complex(abs(b), b)
248
+ if math.isnan(a):
249
+ return complex(a, a)
250
+ if math.isinf(a):
251
+ if a < 0.0:
252
+ return complex(abs(b - b), math.copysign(a, b))
253
+ else:
254
+ return complex(a, math.copysign(b - b, b))
255
+
256
+ # The remaining special case (b is NaN) is handled just fine by
257
+ # the normal code path below.
258
+
259
+ # Scale to avoid overflow
260
+ if abs(a) >= THRES or abs(b) >= THRES:
261
+ a *= 0.25
262
+ b *= 0.25
263
+ scale = True
264
+ else:
265
+ scale = False
266
+ # Algorithm 312, CACM vol 10, Oct 1967
267
+ if a >= 0:
268
+ t = math.sqrt((a + math.hypot(a, b)) * 0.5)
269
+ real = t
270
+ imag = b / (2 * t)
271
+ else:
272
+ t = math.sqrt((-a + math.hypot(a, b)) * 0.5)
273
+ real = abs(b) / (2 * t)
274
+ imag = math.copysign(t, b)
275
+ # Rescale
276
+ if scale:
277
+ return complex(real * 2, imag)
278
+ else:
279
+ return complex(real, imag)
280
+
281
+ res = context.compile_internal(builder, sqrt_impl, sig, args)
282
+ return impl_ret_untracked(context, builder, sig, res)
283
+
284
+
285
+ # @lower(cmath.cos, types.Complex)
286
+ def cos_impl(context, builder, sig, args):
287
+ def cos_impl(z):
288
+ """cmath.cos(z) = cmath.cosh(z j)"""
289
+ return cmath.cosh(complex(-z.imag, z.real))
290
+
291
+ res = context.compile_internal(builder, cos_impl, sig, args)
292
+ return impl_ret_untracked(context, builder, sig, res)
293
+
294
+
295
+ # @overload(cmath.cosh)
296
+ def impl_cmath_cosh(z):
297
+ if not isinstance(z, types.Complex):
298
+ return
299
+
300
+ def cosh_impl(z):
301
+ """cmath.cosh(z)"""
302
+ x = z.real
303
+ y = z.imag
304
+ if math.isinf(x):
305
+ if math.isnan(y):
306
+ # x = +inf, y = NaN => cmath.cosh(x + y j) = inf + Nan * j
307
+ real = abs(x)
308
+ imag = y
309
+ elif y == 0.0:
310
+ # x = +inf, y = 0 => cmath.cosh(x + y j) = inf + 0j
311
+ real = abs(x)
312
+ imag = y
313
+ else:
314
+ real = math.copysign(x, math.cos(y))
315
+ imag = math.copysign(x, math.sin(y))
316
+ if x < 0.0:
317
+ # x = -inf => negate imaginary part of result
318
+ imag = -imag
319
+ return complex(real, imag)
320
+ return complex(math.cos(y) * math.cosh(x), math.sin(y) * math.sinh(x))
321
+
322
+ return cosh_impl
323
+
324
+
325
+ # @lower(cmath.sin, types.Complex)
326
+ def sin_impl(context, builder, sig, args):
327
+ def sin_impl(z):
328
+ """cmath.sin(z) = -j * cmath.sinh(z j)"""
329
+ r = cmath.sinh(complex(-z.imag, z.real))
330
+ return complex(r.imag, -r.real)
331
+
332
+ res = context.compile_internal(builder, sin_impl, sig, args)
333
+ return impl_ret_untracked(context, builder, sig, res)
334
+
335
+
336
+ # @overload(cmath.sinh)
337
+ def impl_cmath_sinh(z):
338
+ if not isinstance(z, types.Complex):
339
+ return
340
+
341
+ def sinh_impl(z):
342
+ """cmath.sinh(z)"""
343
+ x = z.real
344
+ y = z.imag
345
+ if math.isinf(x):
346
+ if math.isnan(y):
347
+ # x = +/-inf, y = NaN => cmath.sinh(x + y j) = x + NaN * j
348
+ real = x
349
+ imag = y
350
+ else:
351
+ real = math.cos(y)
352
+ imag = math.sin(y)
353
+ if real != 0.0:
354
+ real *= x
355
+ if imag != 0.0:
356
+ imag *= abs(x)
357
+ return complex(real, imag)
358
+ return complex(math.cos(y) * math.sinh(x), math.sin(y) * math.cosh(x))
359
+
360
+ return sinh_impl
361
+
362
+
363
+ # @lower(cmath.tan, types.Complex)
364
+ def tan_impl(context, builder, sig, args):
365
+ def tan_impl(z):
366
+ """cmath.tan(z) = -j * cmath.tanh(z j)"""
367
+ r = cmath.tanh(complex(-z.imag, z.real))
368
+ return complex(r.imag, -r.real)
369
+
370
+ res = context.compile_internal(builder, tan_impl, sig, args)
371
+ return impl_ret_untracked(context, builder, sig, res)
372
+
373
+
374
+ # @overload(cmath.tanh)
375
+ def impl_cmath_tanh(z):
376
+ if not isinstance(z, types.Complex):
377
+ return
378
+
379
+ def tanh_impl(z):
380
+ """cmath.tanh(z)"""
381
+ x = z.real
382
+ y = z.imag
383
+ if math.isinf(x):
384
+ real = math.copysign(1.0, x)
385
+ if math.isinf(y):
386
+ imag = 0.0
387
+ else:
388
+ imag = math.copysign(0.0, math.sin(2.0 * y))
389
+ return complex(real, imag)
390
+ # This is CPython's algorithm (see c_tanh() in cmathmodule.c).
391
+ # XXX how to force float constants into single precision?
392
+ tx = math.tanh(x)
393
+ ty = math.tan(y)
394
+ cx = 1.0 / math.cosh(x)
395
+ txty = tx * ty
396
+ denom = 1.0 + txty * txty
397
+ return complex(tx * (1.0 + ty * ty) / denom, ((ty / denom) * cx) * cx)
398
+
399
+ return tanh_impl
400
+
401
+
402
+ # @lower(cmath.acos, types.Complex)
403
+ def acos_impl(context, builder, sig, args):
404
+ LN_4 = math.log(4)
405
+ THRES = mathimpl.FLT_MAX / 4
406
+
407
+ def acos_impl(z):
408
+ """cmath.acos(z)"""
409
+ # CPython's algorithm (see c_acos() in cmathmodule.c)
410
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
411
+ # Avoid unnecessary overflow for large arguments
412
+ # (also handles infinities gracefully)
413
+ real = math.atan2(abs(z.imag), z.real)
414
+ imag = math.copysign(
415
+ math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, -z.imag
416
+ )
417
+ return complex(real, imag)
418
+ else:
419
+ s1 = cmath.sqrt(complex(1.0 - z.real, -z.imag))
420
+ s2 = cmath.sqrt(complex(1.0 + z.real, z.imag))
421
+ real = 2.0 * math.atan2(s1.real, s2.real)
422
+ imag = math.asinh(s2.real * s1.imag - s2.imag * s1.real)
423
+ return complex(real, imag)
424
+
425
+ res = context.compile_internal(builder, acos_impl, sig, args)
426
+ return impl_ret_untracked(context, builder, sig, res)
427
+
428
+
429
+ # @overload(cmath.acosh)
430
+ def impl_cmath_acosh(z):
431
+ if not isinstance(z, types.Complex):
432
+ return
433
+
434
+ LN_4 = math.log(4)
435
+ THRES = mathimpl.FLT_MAX / 4
436
+
437
+ def acosh_impl(z):
438
+ """cmath.acosh(z)"""
439
+ # CPython's algorithm (see c_acosh() in cmathmodule.c)
440
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
441
+ # Avoid unnecessary overflow for large arguments
442
+ # (also handles infinities gracefully)
443
+ real = math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4
444
+ imag = math.atan2(z.imag, z.real)
445
+ return complex(real, imag)
446
+ else:
447
+ s1 = cmath.sqrt(complex(z.real - 1.0, z.imag))
448
+ s2 = cmath.sqrt(complex(z.real + 1.0, z.imag))
449
+ real = math.asinh(s1.real * s2.real + s1.imag * s2.imag)
450
+ imag = 2.0 * math.atan2(s1.imag, s2.real)
451
+ return complex(real, imag)
452
+ # Condensed formula (NumPy)
453
+ # return cmath.log(z + cmath.sqrt(z + 1.) * cmath.sqrt(z - 1.))
454
+
455
+ return acosh_impl
456
+
457
+
458
+ # @lower(cmath.asinh, types.Complex)
459
+ def asinh_impl(context, builder, sig, args):
460
+ LN_4 = math.log(4)
461
+ THRES = mathimpl.FLT_MAX / 4
462
+
463
+ def asinh_impl(z):
464
+ """cmath.asinh(z)"""
465
+ # CPython's algorithm (see c_asinh() in cmathmodule.c)
466
+ if abs(z.real) > THRES or abs(z.imag) > THRES:
467
+ real = math.copysign(
468
+ math.log(math.hypot(z.real * 0.5, z.imag * 0.5)) + LN_4, z.real
469
+ )
470
+ imag = math.atan2(z.imag, abs(z.real))
471
+ return complex(real, imag)
472
+ else:
473
+ s1 = cmath.sqrt(complex(1.0 + z.imag, -z.real))
474
+ s2 = cmath.sqrt(complex(1.0 - z.imag, z.real))
475
+ real = math.asinh(s1.real * s2.imag - s2.real * s1.imag)
476
+ imag = math.atan2(z.imag, s1.real * s2.real - s1.imag * s2.imag)
477
+ return complex(real, imag)
478
+
479
+ res = context.compile_internal(builder, asinh_impl, sig, args)
480
+ return impl_ret_untracked(context, builder, sig, res)
481
+
482
+
483
+ # @lower(cmath.asin, types.Complex)
484
+ def asin_impl(context, builder, sig, args):
485
+ def asin_impl(z):
486
+ """cmath.asin(z) = -j * cmath.asinh(z j)"""
487
+ r = cmath.asinh(complex(-z.imag, z.real))
488
+ return complex(r.imag, -r.real)
489
+
490
+ res = context.compile_internal(builder, asin_impl, sig, args)
491
+ return impl_ret_untracked(context, builder, sig, res)
492
+
493
+
494
+ # @lower(cmath.atan, types.Complex)
495
+ def atan_impl(context, builder, sig, args):
496
+ def atan_impl(z):
497
+ """cmath.atan(z) = -j * cmath.atanh(z j)"""
498
+ r = cmath.atanh(complex(-z.imag, z.real))
499
+ if math.isinf(z.real) and math.isnan(z.imag):
500
+ # XXX this is odd but necessary
501
+ return complex(r.imag, r.real)
502
+ else:
503
+ return complex(r.imag, -r.real)
504
+
505
+ res = context.compile_internal(builder, atan_impl, sig, args)
506
+ return impl_ret_untracked(context, builder, sig, res)
507
+
508
+
509
+ # @lower(cmath.atanh, types.Complex)
510
+ def atanh_impl(context, builder, sig, args):
511
+ THRES_LARGE = math.sqrt(mathimpl.FLT_MAX / 4)
512
+ THRES_SMALL = math.sqrt(mathimpl.FLT_MIN)
513
+ PI_12 = math.pi / 2
514
+
515
+ def atanh_impl(z):
516
+ """cmath.atanh(z)"""
517
+ # CPython's algorithm (see c_atanh() in cmathmodule.c)
518
+ if z.real < 0.0:
519
+ # Reduce to case where z.real >= 0., using atanh(z) = -atanh(-z).
520
+ negate = True
521
+ z = -z
522
+ else:
523
+ negate = False
524
+
525
+ ay = abs(z.imag)
526
+ if math.isnan(z.real) or z.real > THRES_LARGE or ay > THRES_LARGE:
527
+ if math.isinf(z.imag):
528
+ real = math.copysign(0.0, z.real)
529
+ elif math.isinf(z.real):
530
+ real = 0.0
531
+ else:
532
+ # may be safe from overflow, depending on hypot's implementation...
533
+ h = math.hypot(z.real * 0.5, z.imag * 0.5)
534
+ real = z.real / 4.0 / h / h
535
+ imag = -math.copysign(PI_12, -z.imag)
536
+ elif z.real == 1.0 and ay < THRES_SMALL:
537
+ # C99 standard says: atanh(1+/-0.) should be inf +/- 0j
538
+ if ay == 0.0:
539
+ real = INF
540
+ imag = z.imag
541
+ else:
542
+ real = -math.log(math.sqrt(ay) / math.sqrt(math.hypot(ay, 2.0)))
543
+ imag = math.copysign(math.atan2(2.0, -ay) / 2, z.imag)
544
+ else:
545
+ sqay = ay * ay
546
+ zr1 = 1 - z.real
547
+ real = math.log1p(4.0 * z.real / (zr1 * zr1 + sqay)) * 0.25
548
+ imag = -math.atan2(-2.0 * z.imag, zr1 * (1 + z.real) - sqay) * 0.5
549
+
550
+ if math.isnan(z.imag):
551
+ imag = NAN
552
+ if negate:
553
+ return complex(-real, -imag)
554
+ else:
555
+ return complex(real, imag)
556
+
557
+ res = context.compile_internal(builder, atanh_impl, sig, args)
558
+ return impl_ret_untracked(context, builder, sig, res)