Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/__pycache__/function_docs.cpython-311.pyc +3 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/__init__.py +14 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/bessel.py +1108 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/factorials.py +187 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/functions.py +645 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/hypergeometric.py +1413 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/theta.py +1049 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/zetazeros.py +1018 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/__init__.py +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_basic_ops.py +451 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_bitwise.py +188 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_convert.py +233 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_eigen.py +179 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_fp.py +1671 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_functions.py +920 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/__init__.py +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGL.h +605 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_device_runtime_api.h +268 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_surface_types.h +103 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudart_platform.h +57 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/device_atomic_functions.h +211 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_atomic_functions.h +131 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_intrinsics.h +510 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_intrinsics.hpp +588 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_60_atomic_functions.h +539 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/__pycache__/__init__.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExt.h +1561 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExtCudaRt.h +140 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExtSync.h +406 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExt.h +1499 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCuda.h +170 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtSync.h +411 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxInit.h +343 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxInitDecls.h +73 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxLinkOnce.h +75 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/cmdline.py +668 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/filters/__pycache__/__init__.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/formatters/rtf.py +349 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/lexers/__pycache__/__init__.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/scanner.py +104 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/style.py +203 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__init__.py +61 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__pycache__/__init__.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__pycache__/_mapping.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/token.py +214 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/qat/__init__.py +1 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/qat/__pycache__/__init__.cpython-311.pyc +0 -0
- tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/quantized/modules/__init__.py +17 -0
.gitattributes
CHANGED
|
@@ -64,3 +64,4 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/functorch/_C.cpyt
|
|
| 64 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/Cython/Compiler/__pycache__/Nodes.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 65 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/torchgen/__pycache__/model.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 66 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/__pycache__/test_fp.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 64 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/Cython/Compiler/__pycache__/Nodes.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 65 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/torchgen/__pycache__/model.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 66 |
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/__pycache__/test_fp.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/__pycache__/function_docs.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/__pycache__/function_docs.cpython-311.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:49a68f636d901e68fe4418b90d031c3589fe1aa4e9fdef65a20221a4e53a5962
|
| 3 |
+
size 284965
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import functions
|
| 2 |
+
# Hack to update methods
|
| 3 |
+
from . import factorials
|
| 4 |
+
from . import hypergeometric
|
| 5 |
+
from . import expintegrals
|
| 6 |
+
from . import bessel
|
| 7 |
+
from . import orthogonal
|
| 8 |
+
from . import theta
|
| 9 |
+
from . import elliptic
|
| 10 |
+
from . import signals
|
| 11 |
+
from . import zeta
|
| 12 |
+
from . import rszeta
|
| 13 |
+
from . import zetazeros
|
| 14 |
+
from . import qfunctions
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/bessel.py
ADDED
|
@@ -0,0 +1,1108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .functions import defun, defun_wrapped
|
| 2 |
+
|
| 3 |
+
@defun
|
| 4 |
+
def j0(ctx, x):
|
| 5 |
+
"""Computes the Bessel function `J_0(x)`. See :func:`~mpmath.besselj`."""
|
| 6 |
+
return ctx.besselj(0, x)
|
| 7 |
+
|
| 8 |
+
@defun
|
| 9 |
+
def j1(ctx, x):
|
| 10 |
+
"""Computes the Bessel function `J_1(x)`. See :func:`~mpmath.besselj`."""
|
| 11 |
+
return ctx.besselj(1, x)
|
| 12 |
+
|
| 13 |
+
@defun
|
| 14 |
+
def besselj(ctx, n, z, derivative=0, **kwargs):
|
| 15 |
+
if type(n) is int:
|
| 16 |
+
n_isint = True
|
| 17 |
+
else:
|
| 18 |
+
n = ctx.convert(n)
|
| 19 |
+
n_isint = ctx.isint(n)
|
| 20 |
+
if n_isint:
|
| 21 |
+
n = int(ctx._re(n))
|
| 22 |
+
if n_isint and n < 0:
|
| 23 |
+
return (-1)**n * ctx.besselj(-n, z, derivative, **kwargs)
|
| 24 |
+
z = ctx.convert(z)
|
| 25 |
+
M = ctx.mag(z)
|
| 26 |
+
if derivative:
|
| 27 |
+
d = ctx.convert(derivative)
|
| 28 |
+
# TODO: the integer special-casing shouldn't be necessary.
|
| 29 |
+
# However, the hypergeometric series gets inaccurate for large d
|
| 30 |
+
# because of inaccurate pole cancellation at a pole far from
|
| 31 |
+
# zero (needs to be fixed in hypercomb or hypsum)
|
| 32 |
+
if ctx.isint(d) and d >= 0:
|
| 33 |
+
d = int(d)
|
| 34 |
+
orig = ctx.prec
|
| 35 |
+
try:
|
| 36 |
+
ctx.prec += 15
|
| 37 |
+
v = ctx.fsum((-1)**k * ctx.binomial(d,k) * ctx.besselj(2*k+n-d,z)
|
| 38 |
+
for k in range(d+1))
|
| 39 |
+
finally:
|
| 40 |
+
ctx.prec = orig
|
| 41 |
+
v *= ctx.mpf(2)**(-d)
|
| 42 |
+
else:
|
| 43 |
+
def h(n,d):
|
| 44 |
+
r = ctx.fmul(ctx.fmul(z, z, prec=ctx.prec+M), -0.25, exact=True)
|
| 45 |
+
B = [0.5*(n-d+1), 0.5*(n-d+2)]
|
| 46 |
+
T = [([2,ctx.pi,z],[d-2*n,0.5,n-d],[],B,[(n+1)*0.5,(n+2)*0.5],B+[n+1],r)]
|
| 47 |
+
return T
|
| 48 |
+
v = ctx.hypercomb(h, [n,d], **kwargs)
|
| 49 |
+
else:
|
| 50 |
+
# Fast case: J_n(x), n int, appropriate magnitude for fixed-point calculation
|
| 51 |
+
if (not derivative) and n_isint and abs(M) < 10 and abs(n) < 20:
|
| 52 |
+
try:
|
| 53 |
+
return ctx._besselj(n, z)
|
| 54 |
+
except NotImplementedError:
|
| 55 |
+
pass
|
| 56 |
+
if not z:
|
| 57 |
+
if not n:
|
| 58 |
+
v = ctx.one + n+z
|
| 59 |
+
elif ctx.re(n) > 0:
|
| 60 |
+
v = n*z
|
| 61 |
+
else:
|
| 62 |
+
v = ctx.inf + z + n
|
| 63 |
+
else:
|
| 64 |
+
#v = 0
|
| 65 |
+
orig = ctx.prec
|
| 66 |
+
try:
|
| 67 |
+
# XXX: workaround for accuracy in low level hypergeometric series
|
| 68 |
+
# when alternating, large arguments
|
| 69 |
+
ctx.prec += min(3*abs(M), ctx.prec)
|
| 70 |
+
w = ctx.fmul(z, 0.5, exact=True)
|
| 71 |
+
def h(n):
|
| 72 |
+
r = ctx.fneg(ctx.fmul(w, w, prec=max(0,ctx.prec+M)), exact=True)
|
| 73 |
+
return [([w], [n], [], [n+1], [], [n+1], r)]
|
| 74 |
+
v = ctx.hypercomb(h, [n], **kwargs)
|
| 75 |
+
finally:
|
| 76 |
+
ctx.prec = orig
|
| 77 |
+
v = +v
|
| 78 |
+
return v
|
| 79 |
+
|
| 80 |
+
@defun
|
| 81 |
+
def besseli(ctx, n, z, derivative=0, **kwargs):
|
| 82 |
+
n = ctx.convert(n)
|
| 83 |
+
z = ctx.convert(z)
|
| 84 |
+
if not z:
|
| 85 |
+
if derivative:
|
| 86 |
+
raise ValueError
|
| 87 |
+
if not n:
|
| 88 |
+
# I(0,0) = 1
|
| 89 |
+
return 1+n+z
|
| 90 |
+
if ctx.isint(n):
|
| 91 |
+
return 0*(n+z)
|
| 92 |
+
r = ctx.re(n)
|
| 93 |
+
if r == 0:
|
| 94 |
+
return ctx.nan*(n+z)
|
| 95 |
+
elif r > 0:
|
| 96 |
+
return 0*(n+z)
|
| 97 |
+
else:
|
| 98 |
+
return ctx.inf+(n+z)
|
| 99 |
+
M = ctx.mag(z)
|
| 100 |
+
if derivative:
|
| 101 |
+
d = ctx.convert(derivative)
|
| 102 |
+
def h(n,d):
|
| 103 |
+
r = ctx.fmul(ctx.fmul(z, z, prec=ctx.prec+M), 0.25, exact=True)
|
| 104 |
+
B = [0.5*(n-d+1), 0.5*(n-d+2), n+1]
|
| 105 |
+
T = [([2,ctx.pi,z],[d-2*n,0.5,n-d],[n+1],B,[(n+1)*0.5,(n+2)*0.5],B,r)]
|
| 106 |
+
return T
|
| 107 |
+
v = ctx.hypercomb(h, [n,d], **kwargs)
|
| 108 |
+
else:
|
| 109 |
+
def h(n):
|
| 110 |
+
w = ctx.fmul(z, 0.5, exact=True)
|
| 111 |
+
r = ctx.fmul(w, w, prec=max(0,ctx.prec+M))
|
| 112 |
+
return [([w], [n], [], [n+1], [], [n+1], r)]
|
| 113 |
+
v = ctx.hypercomb(h, [n], **kwargs)
|
| 114 |
+
return v
|
| 115 |
+
|
| 116 |
+
@defun_wrapped
|
| 117 |
+
def bessely(ctx, n, z, derivative=0, **kwargs):
|
| 118 |
+
if not z:
|
| 119 |
+
if derivative:
|
| 120 |
+
# Not implemented
|
| 121 |
+
raise ValueError
|
| 122 |
+
if not n:
|
| 123 |
+
# ~ log(z/2)
|
| 124 |
+
return -ctx.inf + (n+z)
|
| 125 |
+
if ctx.im(n):
|
| 126 |
+
return ctx.nan * (n+z)
|
| 127 |
+
r = ctx.re(n)
|
| 128 |
+
q = n+0.5
|
| 129 |
+
if ctx.isint(q):
|
| 130 |
+
if n > 0:
|
| 131 |
+
return -ctx.inf + (n+z)
|
| 132 |
+
else:
|
| 133 |
+
return 0 * (n+z)
|
| 134 |
+
if r < 0 and int(ctx.floor(q)) % 2:
|
| 135 |
+
return ctx.inf + (n+z)
|
| 136 |
+
else:
|
| 137 |
+
return ctx.ninf + (n+z)
|
| 138 |
+
# XXX: use hypercomb
|
| 139 |
+
ctx.prec += 10
|
| 140 |
+
m, d = ctx.nint_distance(n)
|
| 141 |
+
if d < -ctx.prec:
|
| 142 |
+
h = +ctx.eps
|
| 143 |
+
ctx.prec *= 2
|
| 144 |
+
n += h
|
| 145 |
+
elif d < 0:
|
| 146 |
+
ctx.prec -= d
|
| 147 |
+
# TODO: avoid cancellation for imaginary arguments
|
| 148 |
+
cos, sin = ctx.cospi_sinpi(n)
|
| 149 |
+
return (ctx.besselj(n,z,derivative,**kwargs)*cos - \
|
| 150 |
+
ctx.besselj(-n,z,derivative,**kwargs))/sin
|
| 151 |
+
|
| 152 |
+
@defun_wrapped
|
| 153 |
+
def besselk(ctx, n, z, **kwargs):
|
| 154 |
+
if not z:
|
| 155 |
+
return ctx.inf
|
| 156 |
+
M = ctx.mag(z)
|
| 157 |
+
if M < 1:
|
| 158 |
+
# Represent as limit definition
|
| 159 |
+
def h(n):
|
| 160 |
+
r = (z/2)**2
|
| 161 |
+
T1 = [z, 2], [-n, n-1], [n], [], [], [1-n], r
|
| 162 |
+
T2 = [z, 2], [n, -n-1], [-n], [], [], [1+n], r
|
| 163 |
+
return T1, T2
|
| 164 |
+
# We could use the limit definition always, but it leads
|
| 165 |
+
# to very bad cancellation (of exponentially large terms)
|
| 166 |
+
# for large real z
|
| 167 |
+
# Instead represent in terms of 2F0
|
| 168 |
+
else:
|
| 169 |
+
ctx.prec += M
|
| 170 |
+
def h(n):
|
| 171 |
+
return [([ctx.pi/2, z, ctx.exp(-z)], [0.5,-0.5,1], [], [], \
|
| 172 |
+
[n+0.5, 0.5-n], [], -1/(2*z))]
|
| 173 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 174 |
+
|
| 175 |
+
@defun_wrapped
|
| 176 |
+
def hankel1(ctx,n,x,**kwargs):
|
| 177 |
+
return ctx.besselj(n,x,**kwargs) + ctx.j*ctx.bessely(n,x,**kwargs)
|
| 178 |
+
|
| 179 |
+
@defun_wrapped
|
| 180 |
+
def hankel2(ctx,n,x,**kwargs):
|
| 181 |
+
return ctx.besselj(n,x,**kwargs) - ctx.j*ctx.bessely(n,x,**kwargs)
|
| 182 |
+
|
| 183 |
+
@defun_wrapped
|
| 184 |
+
def whitm(ctx,k,m,z,**kwargs):
|
| 185 |
+
if z == 0:
|
| 186 |
+
# M(k,m,z) = 0^(1/2+m)
|
| 187 |
+
if ctx.re(m) > -0.5:
|
| 188 |
+
return z
|
| 189 |
+
elif ctx.re(m) < -0.5:
|
| 190 |
+
return ctx.inf + z
|
| 191 |
+
else:
|
| 192 |
+
return ctx.nan * z
|
| 193 |
+
x = ctx.fmul(-0.5, z, exact=True)
|
| 194 |
+
y = 0.5+m
|
| 195 |
+
return ctx.exp(x) * z**y * ctx.hyp1f1(y-k, 1+2*m, z, **kwargs)
|
| 196 |
+
|
| 197 |
+
@defun_wrapped
|
| 198 |
+
def whitw(ctx,k,m,z,**kwargs):
|
| 199 |
+
if z == 0:
|
| 200 |
+
g = abs(ctx.re(m))
|
| 201 |
+
if g < 0.5:
|
| 202 |
+
return z
|
| 203 |
+
elif g > 0.5:
|
| 204 |
+
return ctx.inf + z
|
| 205 |
+
else:
|
| 206 |
+
return ctx.nan * z
|
| 207 |
+
x = ctx.fmul(-0.5, z, exact=True)
|
| 208 |
+
y = 0.5+m
|
| 209 |
+
return ctx.exp(x) * z**y * ctx.hyperu(y-k, 1+2*m, z, **kwargs)
|
| 210 |
+
|
| 211 |
+
@defun
|
| 212 |
+
def hyperu(ctx, a, b, z, **kwargs):
|
| 213 |
+
a, atype = ctx._convert_param(a)
|
| 214 |
+
b, btype = ctx._convert_param(b)
|
| 215 |
+
z = ctx.convert(z)
|
| 216 |
+
if not z:
|
| 217 |
+
if ctx.re(b) <= 1:
|
| 218 |
+
return ctx.gammaprod([1-b],[a-b+1])
|
| 219 |
+
else:
|
| 220 |
+
return ctx.inf + z
|
| 221 |
+
bb = 1+a-b
|
| 222 |
+
bb, bbtype = ctx._convert_param(bb)
|
| 223 |
+
try:
|
| 224 |
+
orig = ctx.prec
|
| 225 |
+
try:
|
| 226 |
+
ctx.prec += 10
|
| 227 |
+
v = ctx.hypsum(2, 0, (atype, bbtype), [a, bb], -1/z, maxterms=ctx.prec)
|
| 228 |
+
return v / z**a
|
| 229 |
+
finally:
|
| 230 |
+
ctx.prec = orig
|
| 231 |
+
except ctx.NoConvergence:
|
| 232 |
+
pass
|
| 233 |
+
def h(a,b):
|
| 234 |
+
w = ctx.sinpi(b)
|
| 235 |
+
T1 = ([ctx.pi,w],[1,-1],[],[a-b+1,b],[a],[b],z)
|
| 236 |
+
T2 = ([-ctx.pi,w,z],[1,-1,1-b],[],[a,2-b],[a-b+1],[2-b],z)
|
| 237 |
+
return T1, T2
|
| 238 |
+
return ctx.hypercomb(h, [a,b], **kwargs)
|
| 239 |
+
|
| 240 |
+
@defun
|
| 241 |
+
def struveh(ctx,n,z, **kwargs):
|
| 242 |
+
n = ctx.convert(n)
|
| 243 |
+
z = ctx.convert(z)
|
| 244 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/StruveH/26/01/02/
|
| 245 |
+
def h(n):
|
| 246 |
+
return [([z/2, 0.5*ctx.sqrt(ctx.pi)], [n+1, -1], [], [n+1.5], [1], [1.5, n+1.5], -(z/2)**2)]
|
| 247 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 248 |
+
|
| 249 |
+
@defun
|
| 250 |
+
def struvel(ctx,n,z, **kwargs):
|
| 251 |
+
n = ctx.convert(n)
|
| 252 |
+
z = ctx.convert(z)
|
| 253 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/StruveL/26/01/02/
|
| 254 |
+
def h(n):
|
| 255 |
+
return [([z/2, 0.5*ctx.sqrt(ctx.pi)], [n+1, -1], [], [n+1.5], [1], [1.5, n+1.5], (z/2)**2)]
|
| 256 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 257 |
+
|
| 258 |
+
def _anger(ctx,which,v,z,**kwargs):
|
| 259 |
+
v = ctx._convert_param(v)[0]
|
| 260 |
+
z = ctx.convert(z)
|
| 261 |
+
def h(v):
|
| 262 |
+
b = ctx.mpq_1_2
|
| 263 |
+
u = v*b
|
| 264 |
+
m = b*3
|
| 265 |
+
a1,a2,b1,b2 = m-u, m+u, 1-u, 1+u
|
| 266 |
+
c, s = ctx.cospi_sinpi(u)
|
| 267 |
+
if which == 0:
|
| 268 |
+
A, B = [b*z, s], [c]
|
| 269 |
+
if which == 1:
|
| 270 |
+
A, B = [b*z, -c], [s]
|
| 271 |
+
w = ctx.square_exp_arg(z, mult=-0.25)
|
| 272 |
+
T1 = A, [1, 1], [], [a1,a2], [1], [a1,a2], w
|
| 273 |
+
T2 = B, [1], [], [b1,b2], [1], [b1,b2], w
|
| 274 |
+
return T1, T2
|
| 275 |
+
return ctx.hypercomb(h, [v], **kwargs)
|
| 276 |
+
|
| 277 |
+
@defun
|
| 278 |
+
def angerj(ctx, v, z, **kwargs):
|
| 279 |
+
return _anger(ctx, 0, v, z, **kwargs)
|
| 280 |
+
|
| 281 |
+
@defun
|
| 282 |
+
def webere(ctx, v, z, **kwargs):
|
| 283 |
+
return _anger(ctx, 1, v, z, **kwargs)
|
| 284 |
+
|
| 285 |
+
@defun
|
| 286 |
+
def lommels1(ctx, u, v, z, **kwargs):
|
| 287 |
+
u = ctx._convert_param(u)[0]
|
| 288 |
+
v = ctx._convert_param(v)[0]
|
| 289 |
+
z = ctx.convert(z)
|
| 290 |
+
def h(u,v):
|
| 291 |
+
b = ctx.mpq_1_2
|
| 292 |
+
w = ctx.square_exp_arg(z, mult=-0.25)
|
| 293 |
+
return ([u-v+1, u+v+1, z], [-1, -1, u+1], [], [], [1], \
|
| 294 |
+
[b*(u-v+3),b*(u+v+3)], w),
|
| 295 |
+
return ctx.hypercomb(h, [u,v], **kwargs)
|
| 296 |
+
|
| 297 |
+
@defun
|
| 298 |
+
def lommels2(ctx, u, v, z, **kwargs):
|
| 299 |
+
u = ctx._convert_param(u)[0]
|
| 300 |
+
v = ctx._convert_param(v)[0]
|
| 301 |
+
z = ctx.convert(z)
|
| 302 |
+
# Asymptotic expansion (GR p. 947) -- need to be careful
|
| 303 |
+
# not to use for small arguments
|
| 304 |
+
# def h(u,v):
|
| 305 |
+
# b = ctx.mpq_1_2
|
| 306 |
+
# w = -(z/2)**(-2)
|
| 307 |
+
# return ([z], [u-1], [], [], [b*(1-u+v)], [b*(1-u-v)], w),
|
| 308 |
+
def h(u,v):
|
| 309 |
+
b = ctx.mpq_1_2
|
| 310 |
+
w = ctx.square_exp_arg(z, mult=-0.25)
|
| 311 |
+
T1 = [u-v+1, u+v+1, z], [-1, -1, u+1], [], [], [1], [b*(u-v+3),b*(u+v+3)], w
|
| 312 |
+
T2 = [2, z], [u+v-1, -v], [v, b*(u+v+1)], [b*(v-u+1)], [], [1-v], w
|
| 313 |
+
T3 = [2, z], [u-v-1, v], [-v, b*(u-v+1)], [b*(1-u-v)], [], [1+v], w
|
| 314 |
+
#c1 = ctx.cospi((u-v)*b)
|
| 315 |
+
#c2 = ctx.cospi((u+v)*b)
|
| 316 |
+
#s = ctx.sinpi(v)
|
| 317 |
+
#r1 = (u-v+1)*b
|
| 318 |
+
#r2 = (u+v+1)*b
|
| 319 |
+
#T2 = [c1, s, z, 2], [1, -1, -v, v], [], [-v+1], [], [-v+1], w
|
| 320 |
+
#T3 = [-c2, s, z, 2], [1, -1, v, -v], [], [v+1], [], [v+1], w
|
| 321 |
+
#T2 = [c1, s, z, 2], [1, -1, -v, v+u-1], [r1, r2], [-v+1], [], [-v+1], w
|
| 322 |
+
#T3 = [-c2, s, z, 2], [1, -1, v, -v+u-1], [r1, r2], [v+1], [], [v+1], w
|
| 323 |
+
return T1, T2, T3
|
| 324 |
+
return ctx.hypercomb(h, [u,v], **kwargs)
|
| 325 |
+
|
| 326 |
+
@defun
|
| 327 |
+
def ber(ctx, n, z, **kwargs):
|
| 328 |
+
n = ctx.convert(n)
|
| 329 |
+
z = ctx.convert(z)
|
| 330 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/KelvinBer2/26/01/02/0001/
|
| 331 |
+
def h(n):
|
| 332 |
+
r = -(z/4)**4
|
| 333 |
+
cos, sin = ctx.cospi_sinpi(-0.75*n)
|
| 334 |
+
T1 = [cos, z/2], [1, n], [], [n+1], [], [0.5, 0.5*(n+1), 0.5*n+1], r
|
| 335 |
+
T2 = [sin, z/2], [1, n+2], [], [n+2], [], [1.5, 0.5*(n+3), 0.5*n+1], r
|
| 336 |
+
return T1, T2
|
| 337 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 338 |
+
|
| 339 |
+
@defun
|
| 340 |
+
def bei(ctx, n, z, **kwargs):
|
| 341 |
+
n = ctx.convert(n)
|
| 342 |
+
z = ctx.convert(z)
|
| 343 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/KelvinBei2/26/01/02/0001/
|
| 344 |
+
def h(n):
|
| 345 |
+
r = -(z/4)**4
|
| 346 |
+
cos, sin = ctx.cospi_sinpi(0.75*n)
|
| 347 |
+
T1 = [cos, z/2], [1, n+2], [], [n+2], [], [1.5, 0.5*(n+3), 0.5*n+1], r
|
| 348 |
+
T2 = [sin, z/2], [1, n], [], [n+1], [], [0.5, 0.5*(n+1), 0.5*n+1], r
|
| 349 |
+
return T1, T2
|
| 350 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 351 |
+
|
| 352 |
+
@defun
|
| 353 |
+
def ker(ctx, n, z, **kwargs):
|
| 354 |
+
n = ctx.convert(n)
|
| 355 |
+
z = ctx.convert(z)
|
| 356 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/KelvinKer2/26/01/02/0001/
|
| 357 |
+
def h(n):
|
| 358 |
+
r = -(z/4)**4
|
| 359 |
+
cos1, sin1 = ctx.cospi_sinpi(0.25*n)
|
| 360 |
+
cos2, sin2 = ctx.cospi_sinpi(0.75*n)
|
| 361 |
+
T1 = [2, z, 4*cos1], [-n-3, n, 1], [-n], [], [], [0.5, 0.5*(1+n), 0.5*(n+2)], r
|
| 362 |
+
T2 = [2, z, -sin1], [-n-3, 2+n, 1], [-n-1], [], [], [1.5, 0.5*(3+n), 0.5*(n+2)], r
|
| 363 |
+
T3 = [2, z, 4*cos2], [n-3, -n, 1], [n], [], [], [0.5, 0.5*(1-n), 1-0.5*n], r
|
| 364 |
+
T4 = [2, z, -sin2], [n-3, 2-n, 1], [n-1], [], [], [1.5, 0.5*(3-n), 1-0.5*n], r
|
| 365 |
+
return T1, T2, T3, T4
|
| 366 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 367 |
+
|
| 368 |
+
@defun
|
| 369 |
+
def kei(ctx, n, z, **kwargs):
|
| 370 |
+
n = ctx.convert(n)
|
| 371 |
+
z = ctx.convert(z)
|
| 372 |
+
# http://functions.wolfram.com/Bessel-TypeFunctions/KelvinKei2/26/01/02/0001/
|
| 373 |
+
def h(n):
|
| 374 |
+
r = -(z/4)**4
|
| 375 |
+
cos1, sin1 = ctx.cospi_sinpi(0.75*n)
|
| 376 |
+
cos2, sin2 = ctx.cospi_sinpi(0.25*n)
|
| 377 |
+
T1 = [-cos1, 2, z], [1, n-3, 2-n], [n-1], [], [], [1.5, 0.5*(3-n), 1-0.5*n], r
|
| 378 |
+
T2 = [-sin1, 2, z], [1, n-1, -n], [n], [], [], [0.5, 0.5*(1-n), 1-0.5*n], r
|
| 379 |
+
T3 = [-sin2, 2, z], [1, -n-1, n], [-n], [], [], [0.5, 0.5*(n+1), 0.5*(n+2)], r
|
| 380 |
+
T4 = [-cos2, 2, z], [1, -n-3, n+2], [-n-1], [], [], [1.5, 0.5*(n+3), 0.5*(n+2)], r
|
| 381 |
+
return T1, T2, T3, T4
|
| 382 |
+
return ctx.hypercomb(h, [n], **kwargs)
|
| 383 |
+
|
| 384 |
+
# TODO: do this more generically?
|
| 385 |
+
def c_memo(f):
|
| 386 |
+
name = f.__name__
|
| 387 |
+
def f_wrapped(ctx):
|
| 388 |
+
cache = ctx._misc_const_cache
|
| 389 |
+
prec = ctx.prec
|
| 390 |
+
p,v = cache.get(name, (-1,0))
|
| 391 |
+
if p >= prec:
|
| 392 |
+
return +v
|
| 393 |
+
else:
|
| 394 |
+
cache[name] = (prec, f(ctx))
|
| 395 |
+
return cache[name][1]
|
| 396 |
+
return f_wrapped
|
| 397 |
+
|
| 398 |
+
@c_memo
|
| 399 |
+
def _airyai_C1(ctx):
|
| 400 |
+
return 1 / (ctx.cbrt(9) * ctx.gamma(ctx.mpf(2)/3))
|
| 401 |
+
|
| 402 |
+
@c_memo
|
| 403 |
+
def _airyai_C2(ctx):
|
| 404 |
+
return -1 / (ctx.cbrt(3) * ctx.gamma(ctx.mpf(1)/3))
|
| 405 |
+
|
| 406 |
+
@c_memo
|
| 407 |
+
def _airybi_C1(ctx):
|
| 408 |
+
return 1 / (ctx.nthroot(3,6) * ctx.gamma(ctx.mpf(2)/3))
|
| 409 |
+
|
| 410 |
+
@c_memo
|
| 411 |
+
def _airybi_C2(ctx):
|
| 412 |
+
return ctx.nthroot(3,6) / ctx.gamma(ctx.mpf(1)/3)
|
| 413 |
+
|
| 414 |
+
def _airybi_n2_inf(ctx):
|
| 415 |
+
prec = ctx.prec
|
| 416 |
+
try:
|
| 417 |
+
v = ctx.power(3,'2/3')*ctx.gamma('2/3')/(2*ctx.pi)
|
| 418 |
+
finally:
|
| 419 |
+
ctx.prec = prec
|
| 420 |
+
return +v
|
| 421 |
+
|
| 422 |
+
# Derivatives at z = 0
|
| 423 |
+
# TODO: could be expressed more elegantly using triple factorials
|
| 424 |
+
def _airyderiv_0(ctx, z, n, ntype, which):
|
| 425 |
+
if ntype == 'Z':
|
| 426 |
+
if n < 0:
|
| 427 |
+
return z
|
| 428 |
+
r = ctx.mpq_1_3
|
| 429 |
+
prec = ctx.prec
|
| 430 |
+
try:
|
| 431 |
+
ctx.prec += 10
|
| 432 |
+
v = ctx.gamma((n+1)*r) * ctx.power(3,n*r) / ctx.pi
|
| 433 |
+
if which == 0:
|
| 434 |
+
v *= ctx.sinpi(2*(n+1)*r)
|
| 435 |
+
v /= ctx.power(3,'2/3')
|
| 436 |
+
else:
|
| 437 |
+
v *= abs(ctx.sinpi(2*(n+1)*r))
|
| 438 |
+
v /= ctx.power(3,'1/6')
|
| 439 |
+
finally:
|
| 440 |
+
ctx.prec = prec
|
| 441 |
+
return +v + z
|
| 442 |
+
else:
|
| 443 |
+
# singular (does the limit exist?)
|
| 444 |
+
raise NotImplementedError
|
| 445 |
+
|
| 446 |
+
@defun
|
| 447 |
+
def airyai(ctx, z, derivative=0, **kwargs):
|
| 448 |
+
z = ctx.convert(z)
|
| 449 |
+
if derivative:
|
| 450 |
+
n, ntype = ctx._convert_param(derivative)
|
| 451 |
+
else:
|
| 452 |
+
n = 0
|
| 453 |
+
# Values at infinities
|
| 454 |
+
if not ctx.isnormal(z) and z:
|
| 455 |
+
if n and ntype == 'Z':
|
| 456 |
+
if n == -1:
|
| 457 |
+
if z == ctx.inf:
|
| 458 |
+
return ctx.mpf(1)/3 + 1/z
|
| 459 |
+
if z == ctx.ninf:
|
| 460 |
+
return ctx.mpf(-2)/3 + 1/z
|
| 461 |
+
if n < -1:
|
| 462 |
+
if z == ctx.inf:
|
| 463 |
+
return z
|
| 464 |
+
if z == ctx.ninf:
|
| 465 |
+
return (-1)**n * (-z)
|
| 466 |
+
if (not n) and z == ctx.inf or z == ctx.ninf:
|
| 467 |
+
return 1/z
|
| 468 |
+
# TODO: limits
|
| 469 |
+
raise ValueError("essential singularity of Ai(z)")
|
| 470 |
+
# Account for exponential scaling
|
| 471 |
+
if z:
|
| 472 |
+
extraprec = max(0, int(1.5*ctx.mag(z)))
|
| 473 |
+
else:
|
| 474 |
+
extraprec = 0
|
| 475 |
+
if n:
|
| 476 |
+
if n == 1:
|
| 477 |
+
def h():
|
| 478 |
+
# http://functions.wolfram.com/03.07.06.0005.01
|
| 479 |
+
if ctx._re(z) > 4:
|
| 480 |
+
ctx.prec += extraprec
|
| 481 |
+
w = z**1.5; r = -0.75/w; u = -2*w/3
|
| 482 |
+
ctx.prec -= extraprec
|
| 483 |
+
C = -ctx.exp(u)/(2*ctx.sqrt(ctx.pi))*ctx.nthroot(z,4)
|
| 484 |
+
return ([C],[1],[],[],[(-1,6),(7,6)],[],r),
|
| 485 |
+
# http://functions.wolfram.com/03.07.26.0001.01
|
| 486 |
+
else:
|
| 487 |
+
ctx.prec += extraprec
|
| 488 |
+
w = z**3 / 9
|
| 489 |
+
ctx.prec -= extraprec
|
| 490 |
+
C1 = _airyai_C1(ctx) * 0.5
|
| 491 |
+
C2 = _airyai_C2(ctx)
|
| 492 |
+
T1 = [C1,z],[1,2],[],[],[],[ctx.mpq_5_3],w
|
| 493 |
+
T2 = [C2],[1],[],[],[],[ctx.mpq_1_3],w
|
| 494 |
+
return T1, T2
|
| 495 |
+
return ctx.hypercomb(h, [], **kwargs)
|
| 496 |
+
else:
|
| 497 |
+
if z == 0:
|
| 498 |
+
return _airyderiv_0(ctx, z, n, ntype, 0)
|
| 499 |
+
# http://functions.wolfram.com/03.05.20.0004.01
|
| 500 |
+
def h(n):
|
| 501 |
+
ctx.prec += extraprec
|
| 502 |
+
w = z**3/9
|
| 503 |
+
ctx.prec -= extraprec
|
| 504 |
+
q13,q23,q43 = ctx.mpq_1_3, ctx.mpq_2_3, ctx.mpq_4_3
|
| 505 |
+
a1=q13; a2=1; b1=(1-n)*q13; b2=(2-n)*q13; b3=1-n*q13
|
| 506 |
+
T1 = [3, z], [n-q23, -n], [a1], [b1,b2,b3], \
|
| 507 |
+
[a1,a2], [b1,b2,b3], w
|
| 508 |
+
a1=q23; b1=(2-n)*q13; b2=1-n*q13; b3=(4-n)*q13
|
| 509 |
+
T2 = [3, z, -z], [n-q43, -n, 1], [a1], [b1,b2,b3], \
|
| 510 |
+
[a1,a2], [b1,b2,b3], w
|
| 511 |
+
return T1, T2
|
| 512 |
+
v = ctx.hypercomb(h, [n], **kwargs)
|
| 513 |
+
if ctx._is_real_type(z) and ctx.isint(n):
|
| 514 |
+
v = ctx._re(v)
|
| 515 |
+
return v
|
| 516 |
+
else:
|
| 517 |
+
def h():
|
| 518 |
+
if ctx._re(z) > 4:
|
| 519 |
+
# We could use 1F1, but it results in huge cancellation;
|
| 520 |
+
# the following expansion is better.
|
| 521 |
+
# TODO: asymptotic series for derivatives
|
| 522 |
+
ctx.prec += extraprec
|
| 523 |
+
w = z**1.5; r = -0.75/w; u = -2*w/3
|
| 524 |
+
ctx.prec -= extraprec
|
| 525 |
+
C = ctx.exp(u)/(2*ctx.sqrt(ctx.pi)*ctx.nthroot(z,4))
|
| 526 |
+
return ([C],[1],[],[],[(1,6),(5,6)],[],r),
|
| 527 |
+
else:
|
| 528 |
+
ctx.prec += extraprec
|
| 529 |
+
w = z**3 / 9
|
| 530 |
+
ctx.prec -= extraprec
|
| 531 |
+
C1 = _airyai_C1(ctx)
|
| 532 |
+
C2 = _airyai_C2(ctx)
|
| 533 |
+
T1 = [C1],[1],[],[],[],[ctx.mpq_2_3],w
|
| 534 |
+
T2 = [z*C2],[1],[],[],[],[ctx.mpq_4_3],w
|
| 535 |
+
return T1, T2
|
| 536 |
+
return ctx.hypercomb(h, [], **kwargs)
|
| 537 |
+
|
| 538 |
+
@defun
|
| 539 |
+
def airybi(ctx, z, derivative=0, **kwargs):
|
| 540 |
+
z = ctx.convert(z)
|
| 541 |
+
if derivative:
|
| 542 |
+
n, ntype = ctx._convert_param(derivative)
|
| 543 |
+
else:
|
| 544 |
+
n = 0
|
| 545 |
+
# Values at infinities
|
| 546 |
+
if not ctx.isnormal(z) and z:
|
| 547 |
+
if n and ntype == 'Z':
|
| 548 |
+
if z == ctx.inf:
|
| 549 |
+
return z
|
| 550 |
+
if z == ctx.ninf:
|
| 551 |
+
if n == -1:
|
| 552 |
+
return 1/z
|
| 553 |
+
if n == -2:
|
| 554 |
+
return _airybi_n2_inf(ctx)
|
| 555 |
+
if n < -2:
|
| 556 |
+
return (-1)**n * (-z)
|
| 557 |
+
if not n:
|
| 558 |
+
if z == ctx.inf:
|
| 559 |
+
return z
|
| 560 |
+
if z == ctx.ninf:
|
| 561 |
+
return 1/z
|
| 562 |
+
# TODO: limits
|
| 563 |
+
raise ValueError("essential singularity of Bi(z)")
|
| 564 |
+
if z:
|
| 565 |
+
extraprec = max(0, int(1.5*ctx.mag(z)))
|
| 566 |
+
else:
|
| 567 |
+
extraprec = 0
|
| 568 |
+
if n:
|
| 569 |
+
if n == 1:
|
| 570 |
+
# http://functions.wolfram.com/03.08.26.0001.01
|
| 571 |
+
def h():
|
| 572 |
+
ctx.prec += extraprec
|
| 573 |
+
w = z**3 / 9
|
| 574 |
+
ctx.prec -= extraprec
|
| 575 |
+
C1 = _airybi_C1(ctx)*0.5
|
| 576 |
+
C2 = _airybi_C2(ctx)
|
| 577 |
+
T1 = [C1,z],[1,2],[],[],[],[ctx.mpq_5_3],w
|
| 578 |
+
T2 = [C2],[1],[],[],[],[ctx.mpq_1_3],w
|
| 579 |
+
return T1, T2
|
| 580 |
+
return ctx.hypercomb(h, [], **kwargs)
|
| 581 |
+
else:
|
| 582 |
+
if z == 0:
|
| 583 |
+
return _airyderiv_0(ctx, z, n, ntype, 1)
|
| 584 |
+
def h(n):
|
| 585 |
+
ctx.prec += extraprec
|
| 586 |
+
w = z**3/9
|
| 587 |
+
ctx.prec -= extraprec
|
| 588 |
+
q13,q23,q43 = ctx.mpq_1_3, ctx.mpq_2_3, ctx.mpq_4_3
|
| 589 |
+
q16 = ctx.mpq_1_6
|
| 590 |
+
q56 = ctx.mpq_5_6
|
| 591 |
+
a1=q13; a2=1; b1=(1-n)*q13; b2=(2-n)*q13; b3=1-n*q13
|
| 592 |
+
T1 = [3, z], [n-q16, -n], [a1], [b1,b2,b3], \
|
| 593 |
+
[a1,a2], [b1,b2,b3], w
|
| 594 |
+
a1=q23; b1=(2-n)*q13; b2=1-n*q13; b3=(4-n)*q13
|
| 595 |
+
T2 = [3, z], [n-q56, 1-n], [a1], [b1,b2,b3], \
|
| 596 |
+
[a1,a2], [b1,b2,b3], w
|
| 597 |
+
return T1, T2
|
| 598 |
+
v = ctx.hypercomb(h, [n], **kwargs)
|
| 599 |
+
if ctx._is_real_type(z) and ctx.isint(n):
|
| 600 |
+
v = ctx._re(v)
|
| 601 |
+
return v
|
| 602 |
+
else:
|
| 603 |
+
def h():
|
| 604 |
+
ctx.prec += extraprec
|
| 605 |
+
w = z**3 / 9
|
| 606 |
+
ctx.prec -= extraprec
|
| 607 |
+
C1 = _airybi_C1(ctx)
|
| 608 |
+
C2 = _airybi_C2(ctx)
|
| 609 |
+
T1 = [C1],[1],[],[],[],[ctx.mpq_2_3],w
|
| 610 |
+
T2 = [z*C2],[1],[],[],[],[ctx.mpq_4_3],w
|
| 611 |
+
return T1, T2
|
| 612 |
+
return ctx.hypercomb(h, [], **kwargs)
|
| 613 |
+
|
| 614 |
+
def _airy_zero(ctx, which, k, derivative, complex=False):
|
| 615 |
+
# Asymptotic formulas are given in DLMF section 9.9
|
| 616 |
+
def U(t): return t**(2/3.)*(1-7/(t**2*48))
|
| 617 |
+
def T(t): return t**(2/3.)*(1+5/(t**2*48))
|
| 618 |
+
k = int(k)
|
| 619 |
+
if k < 1:
|
| 620 |
+
raise ValueError("k cannot be less than 1")
|
| 621 |
+
if not derivative in (0,1):
|
| 622 |
+
raise ValueError("Derivative should lie between 0 and 1")
|
| 623 |
+
if which == 0:
|
| 624 |
+
if derivative:
|
| 625 |
+
return ctx.findroot(lambda z: ctx.airyai(z,1),
|
| 626 |
+
-U(3*ctx.pi*(4*k-3)/8))
|
| 627 |
+
return ctx.findroot(ctx.airyai, -T(3*ctx.pi*(4*k-1)/8))
|
| 628 |
+
if which == 1 and complex == False:
|
| 629 |
+
if derivative:
|
| 630 |
+
return ctx.findroot(lambda z: ctx.airybi(z,1),
|
| 631 |
+
-U(3*ctx.pi*(4*k-1)/8))
|
| 632 |
+
return ctx.findroot(ctx.airybi, -T(3*ctx.pi*(4*k-3)/8))
|
| 633 |
+
if which == 1 and complex == True:
|
| 634 |
+
if derivative:
|
| 635 |
+
t = 3*ctx.pi*(4*k-3)/8 + 0.75j*ctx.ln2
|
| 636 |
+
s = ctx.expjpi(ctx.mpf(1)/3) * T(t)
|
| 637 |
+
return ctx.findroot(lambda z: ctx.airybi(z,1), s)
|
| 638 |
+
t = 3*ctx.pi*(4*k-1)/8 + 0.75j*ctx.ln2
|
| 639 |
+
s = ctx.expjpi(ctx.mpf(1)/3) * U(t)
|
| 640 |
+
return ctx.findroot(ctx.airybi, s)
|
| 641 |
+
|
| 642 |
+
@defun
|
| 643 |
+
def airyaizero(ctx, k, derivative=0):
|
| 644 |
+
return _airy_zero(ctx, 0, k, derivative, False)
|
| 645 |
+
|
| 646 |
+
@defun
|
| 647 |
+
def airybizero(ctx, k, derivative=0, complex=False):
|
| 648 |
+
return _airy_zero(ctx, 1, k, derivative, complex)
|
| 649 |
+
|
| 650 |
+
def _scorer(ctx, z, which, kwargs):
|
| 651 |
+
z = ctx.convert(z)
|
| 652 |
+
if ctx.isinf(z):
|
| 653 |
+
if z == ctx.inf:
|
| 654 |
+
if which == 0: return 1/z
|
| 655 |
+
if which == 1: return z
|
| 656 |
+
if z == ctx.ninf:
|
| 657 |
+
return 1/z
|
| 658 |
+
raise ValueError("essential singularity")
|
| 659 |
+
if z:
|
| 660 |
+
extraprec = max(0, int(1.5*ctx.mag(z)))
|
| 661 |
+
else:
|
| 662 |
+
extraprec = 0
|
| 663 |
+
if kwargs.get('derivative'):
|
| 664 |
+
raise NotImplementedError
|
| 665 |
+
# Direct asymptotic expansions, to avoid
|
| 666 |
+
# exponentially large cancellation
|
| 667 |
+
try:
|
| 668 |
+
if ctx.mag(z) > 3:
|
| 669 |
+
if which == 0 and abs(ctx.arg(z)) < ctx.pi/3 * 0.999:
|
| 670 |
+
def h():
|
| 671 |
+
return (([ctx.pi,z],[-1,-1],[],[],[(1,3),(2,3),1],[],9/z**3),)
|
| 672 |
+
return ctx.hypercomb(h, [], maxterms=ctx.prec, force_series=True)
|
| 673 |
+
if which == 1 and abs(ctx.arg(-z)) < 2*ctx.pi/3 * 0.999:
|
| 674 |
+
def h():
|
| 675 |
+
return (([-ctx.pi,z],[-1,-1],[],[],[(1,3),(2,3),1],[],9/z**3),)
|
| 676 |
+
return ctx.hypercomb(h, [], maxterms=ctx.prec, force_series=True)
|
| 677 |
+
except ctx.NoConvergence:
|
| 678 |
+
pass
|
| 679 |
+
def h():
|
| 680 |
+
A = ctx.airybi(z, **kwargs)/3
|
| 681 |
+
B = -2*ctx.pi
|
| 682 |
+
if which == 1:
|
| 683 |
+
A *= 2
|
| 684 |
+
B *= -1
|
| 685 |
+
ctx.prec += extraprec
|
| 686 |
+
w = z**3/9
|
| 687 |
+
ctx.prec -= extraprec
|
| 688 |
+
T1 = [A], [1], [], [], [], [], 0
|
| 689 |
+
T2 = [B,z], [-1,2], [], [], [1], [ctx.mpq_4_3,ctx.mpq_5_3], w
|
| 690 |
+
return T1, T2
|
| 691 |
+
return ctx.hypercomb(h, [], **kwargs)
|
| 692 |
+
|
| 693 |
+
@defun
|
| 694 |
+
def scorergi(ctx, z, **kwargs):
|
| 695 |
+
return _scorer(ctx, z, 0, kwargs)
|
| 696 |
+
|
| 697 |
+
@defun
|
| 698 |
+
def scorerhi(ctx, z, **kwargs):
|
| 699 |
+
return _scorer(ctx, z, 1, kwargs)
|
| 700 |
+
|
| 701 |
+
@defun_wrapped
|
| 702 |
+
def coulombc(ctx, l, eta, _cache={}):
|
| 703 |
+
if (l, eta) in _cache and _cache[l,eta][0] >= ctx.prec:
|
| 704 |
+
return +_cache[l,eta][1]
|
| 705 |
+
G3 = ctx.loggamma(2*l+2)
|
| 706 |
+
G1 = ctx.loggamma(1+l+ctx.j*eta)
|
| 707 |
+
G2 = ctx.loggamma(1+l-ctx.j*eta)
|
| 708 |
+
v = 2**l * ctx.exp((-ctx.pi*eta+G1+G2)/2 - G3)
|
| 709 |
+
if not (ctx.im(l) or ctx.im(eta)):
|
| 710 |
+
v = ctx.re(v)
|
| 711 |
+
_cache[l,eta] = (ctx.prec, v)
|
| 712 |
+
return v
|
| 713 |
+
|
| 714 |
+
@defun_wrapped
|
| 715 |
+
def coulombf(ctx, l, eta, z, w=1, chop=True, **kwargs):
|
| 716 |
+
# Regular Coulomb wave function
|
| 717 |
+
# Note: w can be either 1 or -1; the other may be better in some cases
|
| 718 |
+
# TODO: check that chop=True chops when and only when it should
|
| 719 |
+
#ctx.prec += 10
|
| 720 |
+
def h(l, eta):
|
| 721 |
+
try:
|
| 722 |
+
jw = ctx.j*w
|
| 723 |
+
jwz = ctx.fmul(jw, z, exact=True)
|
| 724 |
+
jwz2 = ctx.fmul(jwz, -2, exact=True)
|
| 725 |
+
C = ctx.coulombc(l, eta)
|
| 726 |
+
T1 = [C, z, ctx.exp(jwz)], [1, l+1, 1], [], [], [1+l+jw*eta], \
|
| 727 |
+
[2*l+2], jwz2
|
| 728 |
+
except ValueError:
|
| 729 |
+
T1 = [0], [-1], [], [], [], [], 0
|
| 730 |
+
return (T1,)
|
| 731 |
+
v = ctx.hypercomb(h, [l,eta], **kwargs)
|
| 732 |
+
if chop and (not ctx.im(l)) and (not ctx.im(eta)) and (not ctx.im(z)) and \
|
| 733 |
+
(ctx.re(z) >= 0):
|
| 734 |
+
v = ctx.re(v)
|
| 735 |
+
return v
|
| 736 |
+
|
| 737 |
+
@defun_wrapped
|
| 738 |
+
def _coulomb_chi(ctx, l, eta, _cache={}):
|
| 739 |
+
if (l, eta) in _cache and _cache[l,eta][0] >= ctx.prec:
|
| 740 |
+
return _cache[l,eta][1]
|
| 741 |
+
def terms():
|
| 742 |
+
l2 = -l-1
|
| 743 |
+
jeta = ctx.j*eta
|
| 744 |
+
return [ctx.loggamma(1+l+jeta) * (-0.5j),
|
| 745 |
+
ctx.loggamma(1+l-jeta) * (0.5j),
|
| 746 |
+
ctx.loggamma(1+l2+jeta) * (0.5j),
|
| 747 |
+
ctx.loggamma(1+l2-jeta) * (-0.5j),
|
| 748 |
+
-(l+0.5)*ctx.pi]
|
| 749 |
+
v = ctx.sum_accurately(terms, 1)
|
| 750 |
+
_cache[l,eta] = (ctx.prec, v)
|
| 751 |
+
return v
|
| 752 |
+
|
| 753 |
+
@defun_wrapped
|
| 754 |
+
def coulombg(ctx, l, eta, z, w=1, chop=True, **kwargs):
|
| 755 |
+
# Irregular Coulomb wave function
|
| 756 |
+
# Note: w can be either 1 or -1; the other may be better in some cases
|
| 757 |
+
# TODO: check that chop=True chops when and only when it should
|
| 758 |
+
if not ctx._im(l):
|
| 759 |
+
l = ctx._re(l) # XXX: for isint
|
| 760 |
+
def h(l, eta):
|
| 761 |
+
# Force perturbation for integers and half-integers
|
| 762 |
+
if ctx.isint(l*2):
|
| 763 |
+
T1 = [0], [-1], [], [], [], [], 0
|
| 764 |
+
return (T1,)
|
| 765 |
+
l2 = -l-1
|
| 766 |
+
try:
|
| 767 |
+
chi = ctx._coulomb_chi(l, eta)
|
| 768 |
+
jw = ctx.j*w
|
| 769 |
+
s = ctx.sin(chi); c = ctx.cos(chi)
|
| 770 |
+
C1 = ctx.coulombc(l,eta)
|
| 771 |
+
C2 = ctx.coulombc(l2,eta)
|
| 772 |
+
u = ctx.exp(jw*z)
|
| 773 |
+
x = -2*jw*z
|
| 774 |
+
T1 = [s, C1, z, u, c], [-1, 1, l+1, 1, 1], [], [], \
|
| 775 |
+
[1+l+jw*eta], [2*l+2], x
|
| 776 |
+
T2 = [-s, C2, z, u], [-1, 1, l2+1, 1], [], [], \
|
| 777 |
+
[1+l2+jw*eta], [2*l2+2], x
|
| 778 |
+
return T1, T2
|
| 779 |
+
except ValueError:
|
| 780 |
+
T1 = [0], [-1], [], [], [], [], 0
|
| 781 |
+
return (T1,)
|
| 782 |
+
v = ctx.hypercomb(h, [l,eta], **kwargs)
|
| 783 |
+
if chop and (not ctx._im(l)) and (not ctx._im(eta)) and (not ctx._im(z)) and \
|
| 784 |
+
(ctx._re(z) >= 0):
|
| 785 |
+
v = ctx._re(v)
|
| 786 |
+
return v
|
| 787 |
+
|
| 788 |
+
def mcmahon(ctx,kind,prime,v,m):
|
| 789 |
+
"""
|
| 790 |
+
Computes an estimate for the location of the Bessel function zero
|
| 791 |
+
j_{v,m}, y_{v,m}, j'_{v,m} or y'_{v,m} using McMahon's asymptotic
|
| 792 |
+
expansion (Abramowitz & Stegun 9.5.12-13, DLMF 20.21(vi)).
|
| 793 |
+
|
| 794 |
+
Returns (r,err) where r is the estimated location of the root
|
| 795 |
+
and err is a positive number estimating the error of the
|
| 796 |
+
asymptotic expansion.
|
| 797 |
+
"""
|
| 798 |
+
u = 4*v**2
|
| 799 |
+
if kind == 1 and not prime: b = (4*m+2*v-1)*ctx.pi/4
|
| 800 |
+
if kind == 2 and not prime: b = (4*m+2*v-3)*ctx.pi/4
|
| 801 |
+
if kind == 1 and prime: b = (4*m+2*v-3)*ctx.pi/4
|
| 802 |
+
if kind == 2 and prime: b = (4*m+2*v-1)*ctx.pi/4
|
| 803 |
+
if not prime:
|
| 804 |
+
s1 = b
|
| 805 |
+
s2 = -(u-1)/(8*b)
|
| 806 |
+
s3 = -4*(u-1)*(7*u-31)/(3*(8*b)**3)
|
| 807 |
+
s4 = -32*(u-1)*(83*u**2-982*u+3779)/(15*(8*b)**5)
|
| 808 |
+
s5 = -64*(u-1)*(6949*u**3-153855*u**2+1585743*u-6277237)/(105*(8*b)**7)
|
| 809 |
+
if prime:
|
| 810 |
+
s1 = b
|
| 811 |
+
s2 = -(u+3)/(8*b)
|
| 812 |
+
s3 = -4*(7*u**2+82*u-9)/(3*(8*b)**3)
|
| 813 |
+
s4 = -32*(83*u**3+2075*u**2-3039*u+3537)/(15*(8*b)**5)
|
| 814 |
+
s5 = -64*(6949*u**4+296492*u**3-1248002*u**2+7414380*u-5853627)/(105*(8*b)**7)
|
| 815 |
+
terms = [s1,s2,s3,s4,s5]
|
| 816 |
+
s = s1
|
| 817 |
+
err = 0.0
|
| 818 |
+
for i in range(1,len(terms)):
|
| 819 |
+
if abs(terms[i]) < abs(terms[i-1]):
|
| 820 |
+
s += terms[i]
|
| 821 |
+
else:
|
| 822 |
+
err = abs(terms[i])
|
| 823 |
+
if i == len(terms)-1:
|
| 824 |
+
err = abs(terms[-1])
|
| 825 |
+
return s, err
|
| 826 |
+
|
| 827 |
+
def generalized_bisection(ctx,f,a,b,n):
|
| 828 |
+
"""
|
| 829 |
+
Given f known to have exactly n simple roots within [a,b],
|
| 830 |
+
return a list of n intervals isolating the roots
|
| 831 |
+
and having opposite signs at the endpoints.
|
| 832 |
+
|
| 833 |
+
TODO: this can be optimized, e.g. by reusing evaluation points.
|
| 834 |
+
"""
|
| 835 |
+
if n < 1:
|
| 836 |
+
raise ValueError("n cannot be less than 1")
|
| 837 |
+
N = n+1
|
| 838 |
+
points = []
|
| 839 |
+
signs = []
|
| 840 |
+
while 1:
|
| 841 |
+
points = ctx.linspace(a,b,N)
|
| 842 |
+
signs = [ctx.sign(f(x)) for x in points]
|
| 843 |
+
ok_intervals = [(points[i],points[i+1]) for i in range(N-1) \
|
| 844 |
+
if signs[i]*signs[i+1] == -1]
|
| 845 |
+
if len(ok_intervals) == n:
|
| 846 |
+
return ok_intervals
|
| 847 |
+
N = N*2
|
| 848 |
+
|
| 849 |
+
def find_in_interval(ctx, f, ab):
|
| 850 |
+
return ctx.findroot(f, ab, solver='illinois', verify=False)
|
| 851 |
+
|
| 852 |
+
def bessel_zero(ctx, kind, prime, v, m, isoltol=0.01, _interval_cache={}):
|
| 853 |
+
prec = ctx.prec
|
| 854 |
+
workprec = max(prec, ctx.mag(v), ctx.mag(m))+10
|
| 855 |
+
try:
|
| 856 |
+
ctx.prec = workprec
|
| 857 |
+
v = ctx.mpf(v)
|
| 858 |
+
m = int(m)
|
| 859 |
+
prime = int(prime)
|
| 860 |
+
if v < 0:
|
| 861 |
+
raise ValueError("v cannot be negative")
|
| 862 |
+
if m < 1:
|
| 863 |
+
raise ValueError("m cannot be less than 1")
|
| 864 |
+
if not prime in (0,1):
|
| 865 |
+
raise ValueError("prime should lie between 0 and 1")
|
| 866 |
+
if kind == 1:
|
| 867 |
+
if prime: f = lambda x: ctx.besselj(v,x,derivative=1)
|
| 868 |
+
else: f = lambda x: ctx.besselj(v,x)
|
| 869 |
+
if kind == 2:
|
| 870 |
+
if prime: f = lambda x: ctx.bessely(v,x,derivative=1)
|
| 871 |
+
else: f = lambda x: ctx.bessely(v,x)
|
| 872 |
+
# The first root of J' is very close to 0 for small
|
| 873 |
+
# orders, and this needs to be special-cased
|
| 874 |
+
if kind == 1 and prime and m == 1:
|
| 875 |
+
if v == 0:
|
| 876 |
+
return ctx.zero
|
| 877 |
+
if v <= 1:
|
| 878 |
+
# TODO: use v <= j'_{v,1} < y_{v,1}?
|
| 879 |
+
r = 2*ctx.sqrt(v*(1+v)/(v+2))
|
| 880 |
+
return find_in_interval(ctx, f, (r/10, 2*r))
|
| 881 |
+
if (kind,prime,v,m) in _interval_cache:
|
| 882 |
+
return find_in_interval(ctx, f, _interval_cache[kind,prime,v,m])
|
| 883 |
+
r, err = mcmahon(ctx, kind, prime, v, m)
|
| 884 |
+
if err < isoltol:
|
| 885 |
+
return find_in_interval(ctx, f, (r-isoltol, r+isoltol))
|
| 886 |
+
# An x such that 0 < x < r_{v,1}
|
| 887 |
+
if kind == 1 and not prime: low = 2.4
|
| 888 |
+
if kind == 1 and prime: low = 1.8
|
| 889 |
+
if kind == 2 and not prime: low = 0.8
|
| 890 |
+
if kind == 2 and prime: low = 2.0
|
| 891 |
+
n = m+1
|
| 892 |
+
while 1:
|
| 893 |
+
r1, err = mcmahon(ctx, kind, prime, v, n)
|
| 894 |
+
if err < isoltol:
|
| 895 |
+
r2, err2 = mcmahon(ctx, kind, prime, v, n+1)
|
| 896 |
+
intervals = generalized_bisection(ctx, f, low, 0.5*(r1+r2), n)
|
| 897 |
+
for k, ab in enumerate(intervals):
|
| 898 |
+
_interval_cache[kind,prime,v,k+1] = ab
|
| 899 |
+
return find_in_interval(ctx, f, intervals[m-1])
|
| 900 |
+
else:
|
| 901 |
+
n = n*2
|
| 902 |
+
finally:
|
| 903 |
+
ctx.prec = prec
|
| 904 |
+
|
| 905 |
+
@defun
|
| 906 |
+
def besseljzero(ctx, v, m, derivative=0):
|
| 907 |
+
r"""
|
| 908 |
+
For a real order `\nu \ge 0` and a positive integer `m`, returns
|
| 909 |
+
`j_{\nu,m}`, the `m`-th positive zero of the Bessel function of the
|
| 910 |
+
first kind `J_{\nu}(z)` (see :func:`~mpmath.besselj`). Alternatively,
|
| 911 |
+
with *derivative=1*, gives the first nonnegative simple zero
|
| 912 |
+
`j'_{\nu,m}` of `J'_{\nu}(z)`.
|
| 913 |
+
|
| 914 |
+
The indexing convention is that used by Abramowitz & Stegun
|
| 915 |
+
and the DLMF. Note the special case `j'_{0,1} = 0`, while all other
|
| 916 |
+
zeros are positive. In effect, only simple zeros are counted
|
| 917 |
+
(all zeros of Bessel functions are simple except possibly `z = 0`)
|
| 918 |
+
and `j_{\nu,m}` becomes a monotonic function of both `\nu`
|
| 919 |
+
and `m`.
|
| 920 |
+
|
| 921 |
+
The zeros are interlaced according to the inequalities
|
| 922 |
+
|
| 923 |
+
.. math ::
|
| 924 |
+
|
| 925 |
+
j'_{\nu,k} < j_{\nu,k} < j'_{\nu,k+1}
|
| 926 |
+
|
| 927 |
+
j_{\nu,1} < j_{\nu+1,2} < j_{\nu,2} < j_{\nu+1,2} < j_{\nu,3} < \cdots
|
| 928 |
+
|
| 929 |
+
**Examples**
|
| 930 |
+
|
| 931 |
+
Initial zeros of the Bessel functions `J_0(z), J_1(z), J_2(z)`::
|
| 932 |
+
|
| 933 |
+
>>> from mpmath import *
|
| 934 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 935 |
+
>>> besseljzero(0,1); besseljzero(0,2); besseljzero(0,3)
|
| 936 |
+
2.404825557695772768621632
|
| 937 |
+
5.520078110286310649596604
|
| 938 |
+
8.653727912911012216954199
|
| 939 |
+
>>> besseljzero(1,1); besseljzero(1,2); besseljzero(1,3)
|
| 940 |
+
3.831705970207512315614436
|
| 941 |
+
7.01558666981561875353705
|
| 942 |
+
10.17346813506272207718571
|
| 943 |
+
>>> besseljzero(2,1); besseljzero(2,2); besseljzero(2,3)
|
| 944 |
+
5.135622301840682556301402
|
| 945 |
+
8.417244140399864857783614
|
| 946 |
+
11.61984117214905942709415
|
| 947 |
+
|
| 948 |
+
Initial zeros of `J'_0(z), J'_1(z), J'_2(z)`::
|
| 949 |
+
|
| 950 |
+
0.0
|
| 951 |
+
3.831705970207512315614436
|
| 952 |
+
7.01558666981561875353705
|
| 953 |
+
>>> besseljzero(1,1,1); besseljzero(1,2,1); besseljzero(1,3,1)
|
| 954 |
+
1.84118378134065930264363
|
| 955 |
+
5.331442773525032636884016
|
| 956 |
+
8.536316366346285834358961
|
| 957 |
+
>>> besseljzero(2,1,1); besseljzero(2,2,1); besseljzero(2,3,1)
|
| 958 |
+
3.054236928227140322755932
|
| 959 |
+
6.706133194158459146634394
|
| 960 |
+
9.969467823087595793179143
|
| 961 |
+
|
| 962 |
+
Zeros with large index::
|
| 963 |
+
|
| 964 |
+
>>> besseljzero(0,100); besseljzero(0,1000); besseljzero(0,10000)
|
| 965 |
+
313.3742660775278447196902
|
| 966 |
+
3140.807295225078628895545
|
| 967 |
+
31415.14114171350798533666
|
| 968 |
+
>>> besseljzero(5,100); besseljzero(5,1000); besseljzero(5,10000)
|
| 969 |
+
321.1893195676003157339222
|
| 970 |
+
3148.657306813047523500494
|
| 971 |
+
31422.9947255486291798943
|
| 972 |
+
>>> besseljzero(0,100,1); besseljzero(0,1000,1); besseljzero(0,10000,1)
|
| 973 |
+
311.8018681873704508125112
|
| 974 |
+
3139.236339643802482833973
|
| 975 |
+
31413.57032947022399485808
|
| 976 |
+
|
| 977 |
+
Zeros of functions with large order::
|
| 978 |
+
|
| 979 |
+
>>> besseljzero(50,1)
|
| 980 |
+
57.11689916011917411936228
|
| 981 |
+
>>> besseljzero(50,2)
|
| 982 |
+
62.80769876483536093435393
|
| 983 |
+
>>> besseljzero(50,100)
|
| 984 |
+
388.6936600656058834640981
|
| 985 |
+
>>> besseljzero(50,1,1)
|
| 986 |
+
52.99764038731665010944037
|
| 987 |
+
>>> besseljzero(50,2,1)
|
| 988 |
+
60.02631933279942589882363
|
| 989 |
+
>>> besseljzero(50,100,1)
|
| 990 |
+
387.1083151608726181086283
|
| 991 |
+
|
| 992 |
+
Zeros of functions with fractional order::
|
| 993 |
+
|
| 994 |
+
>>> besseljzero(0.5,1); besseljzero(1.5,1); besseljzero(2.25,4)
|
| 995 |
+
3.141592653589793238462643
|
| 996 |
+
4.493409457909064175307881
|
| 997 |
+
15.15657692957458622921634
|
| 998 |
+
|
| 999 |
+
Both `J_{\nu}(z)` and `J'_{\nu}(z)` can be expressed as infinite
|
| 1000 |
+
products over their zeros::
|
| 1001 |
+
|
| 1002 |
+
>>> v,z = 2, mpf(1)
|
| 1003 |
+
>>> (z/2)**v/gamma(v+1) * \
|
| 1004 |
+
... nprod(lambda k: 1-(z/besseljzero(v,k))**2, [1,inf])
|
| 1005 |
+
...
|
| 1006 |
+
0.1149034849319004804696469
|
| 1007 |
+
>>> besselj(v,z)
|
| 1008 |
+
0.1149034849319004804696469
|
| 1009 |
+
>>> (z/2)**(v-1)/2/gamma(v) * \
|
| 1010 |
+
... nprod(lambda k: 1-(z/besseljzero(v,k,1))**2, [1,inf])
|
| 1011 |
+
...
|
| 1012 |
+
0.2102436158811325550203884
|
| 1013 |
+
>>> besselj(v,z,1)
|
| 1014 |
+
0.2102436158811325550203884
|
| 1015 |
+
|
| 1016 |
+
"""
|
| 1017 |
+
return +bessel_zero(ctx, 1, derivative, v, m)
|
| 1018 |
+
|
| 1019 |
+
@defun
|
| 1020 |
+
def besselyzero(ctx, v, m, derivative=0):
|
| 1021 |
+
r"""
|
| 1022 |
+
For a real order `\nu \ge 0` and a positive integer `m`, returns
|
| 1023 |
+
`y_{\nu,m}`, the `m`-th positive zero of the Bessel function of the
|
| 1024 |
+
second kind `Y_{\nu}(z)` (see :func:`~mpmath.bessely`). Alternatively,
|
| 1025 |
+
with *derivative=1*, gives the first positive zero `y'_{\nu,m}` of
|
| 1026 |
+
`Y'_{\nu}(z)`.
|
| 1027 |
+
|
| 1028 |
+
The zeros are interlaced according to the inequalities
|
| 1029 |
+
|
| 1030 |
+
.. math ::
|
| 1031 |
+
|
| 1032 |
+
y_{\nu,k} < y'_{\nu,k} < y_{\nu,k+1}
|
| 1033 |
+
|
| 1034 |
+
y_{\nu,1} < y_{\nu+1,2} < y_{\nu,2} < y_{\nu+1,2} < y_{\nu,3} < \cdots
|
| 1035 |
+
|
| 1036 |
+
**Examples**
|
| 1037 |
+
|
| 1038 |
+
Initial zeros of the Bessel functions `Y_0(z), Y_1(z), Y_2(z)`::
|
| 1039 |
+
|
| 1040 |
+
>>> from mpmath import *
|
| 1041 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 1042 |
+
>>> besselyzero(0,1); besselyzero(0,2); besselyzero(0,3)
|
| 1043 |
+
0.8935769662791675215848871
|
| 1044 |
+
3.957678419314857868375677
|
| 1045 |
+
7.086051060301772697623625
|
| 1046 |
+
>>> besselyzero(1,1); besselyzero(1,2); besselyzero(1,3)
|
| 1047 |
+
2.197141326031017035149034
|
| 1048 |
+
5.429681040794135132772005
|
| 1049 |
+
8.596005868331168926429606
|
| 1050 |
+
>>> besselyzero(2,1); besselyzero(2,2); besselyzero(2,3)
|
| 1051 |
+
3.384241767149593472701426
|
| 1052 |
+
6.793807513268267538291167
|
| 1053 |
+
10.02347797936003797850539
|
| 1054 |
+
|
| 1055 |
+
Initial zeros of `Y'_0(z), Y'_1(z), Y'_2(z)`::
|
| 1056 |
+
|
| 1057 |
+
>>> besselyzero(0,1,1); besselyzero(0,2,1); besselyzero(0,3,1)
|
| 1058 |
+
2.197141326031017035149034
|
| 1059 |
+
5.429681040794135132772005
|
| 1060 |
+
8.596005868331168926429606
|
| 1061 |
+
>>> besselyzero(1,1,1); besselyzero(1,2,1); besselyzero(1,3,1)
|
| 1062 |
+
3.683022856585177699898967
|
| 1063 |
+
6.941499953654175655751944
|
| 1064 |
+
10.12340465543661307978775
|
| 1065 |
+
>>> besselyzero(2,1,1); besselyzero(2,2,1); besselyzero(2,3,1)
|
| 1066 |
+
5.002582931446063945200176
|
| 1067 |
+
8.350724701413079526349714
|
| 1068 |
+
11.57419546521764654624265
|
| 1069 |
+
|
| 1070 |
+
Zeros with large index::
|
| 1071 |
+
|
| 1072 |
+
>>> besselyzero(0,100); besselyzero(0,1000); besselyzero(0,10000)
|
| 1073 |
+
311.8034717601871549333419
|
| 1074 |
+
3139.236498918198006794026
|
| 1075 |
+
31413.57034538691205229188
|
| 1076 |
+
>>> besselyzero(5,100); besselyzero(5,1000); besselyzero(5,10000)
|
| 1077 |
+
319.6183338562782156235062
|
| 1078 |
+
3147.086508524556404473186
|
| 1079 |
+
31421.42392920214673402828
|
| 1080 |
+
>>> besselyzero(0,100,1); besselyzero(0,1000,1); besselyzero(0,10000,1)
|
| 1081 |
+
313.3726705426359345050449
|
| 1082 |
+
3140.807136030340213610065
|
| 1083 |
+
31415.14112579761578220175
|
| 1084 |
+
|
| 1085 |
+
Zeros of functions with large order::
|
| 1086 |
+
|
| 1087 |
+
>>> besselyzero(50,1)
|
| 1088 |
+
53.50285882040036394680237
|
| 1089 |
+
>>> besselyzero(50,2)
|
| 1090 |
+
60.11244442774058114686022
|
| 1091 |
+
>>> besselyzero(50,100)
|
| 1092 |
+
387.1096509824943957706835
|
| 1093 |
+
>>> besselyzero(50,1,1)
|
| 1094 |
+
56.96290427516751320063605
|
| 1095 |
+
>>> besselyzero(50,2,1)
|
| 1096 |
+
62.74888166945933944036623
|
| 1097 |
+
>>> besselyzero(50,100,1)
|
| 1098 |
+
388.6923300548309258355475
|
| 1099 |
+
|
| 1100 |
+
Zeros of functions with fractional order::
|
| 1101 |
+
|
| 1102 |
+
>>> besselyzero(0.5,1); besselyzero(1.5,1); besselyzero(2.25,4)
|
| 1103 |
+
1.570796326794896619231322
|
| 1104 |
+
2.798386045783887136720249
|
| 1105 |
+
13.56721208770735123376018
|
| 1106 |
+
|
| 1107 |
+
"""
|
| 1108 |
+
return +bessel_zero(ctx, 2, derivative, v, m)
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/factorials.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..libmp.backend import xrange
|
| 2 |
+
from .functions import defun, defun_wrapped
|
| 3 |
+
|
| 4 |
+
@defun
|
| 5 |
+
def gammaprod(ctx, a, b, _infsign=False):
|
| 6 |
+
a = [ctx.convert(x) for x in a]
|
| 7 |
+
b = [ctx.convert(x) for x in b]
|
| 8 |
+
poles_num = []
|
| 9 |
+
poles_den = []
|
| 10 |
+
regular_num = []
|
| 11 |
+
regular_den = []
|
| 12 |
+
for x in a: [regular_num, poles_num][ctx.isnpint(x)].append(x)
|
| 13 |
+
for x in b: [regular_den, poles_den][ctx.isnpint(x)].append(x)
|
| 14 |
+
# One more pole in numerator or denominator gives 0 or inf
|
| 15 |
+
if len(poles_num) < len(poles_den): return ctx.zero
|
| 16 |
+
if len(poles_num) > len(poles_den):
|
| 17 |
+
# Get correct sign of infinity for x+h, h -> 0 from above
|
| 18 |
+
# XXX: hack, this should be done properly
|
| 19 |
+
if _infsign:
|
| 20 |
+
a = [x and x*(1+ctx.eps) or x+ctx.eps for x in poles_num]
|
| 21 |
+
b = [x and x*(1+ctx.eps) or x+ctx.eps for x in poles_den]
|
| 22 |
+
return ctx.sign(ctx.gammaprod(a+regular_num,b+regular_den)) * ctx.inf
|
| 23 |
+
else:
|
| 24 |
+
return ctx.inf
|
| 25 |
+
# All poles cancel
|
| 26 |
+
# lim G(i)/G(j) = (-1)**(i+j) * gamma(1-j) / gamma(1-i)
|
| 27 |
+
p = ctx.one
|
| 28 |
+
orig = ctx.prec
|
| 29 |
+
try:
|
| 30 |
+
ctx.prec = orig + 15
|
| 31 |
+
while poles_num:
|
| 32 |
+
i = poles_num.pop()
|
| 33 |
+
j = poles_den.pop()
|
| 34 |
+
p *= (-1)**(i+j) * ctx.gamma(1-j) / ctx.gamma(1-i)
|
| 35 |
+
for x in regular_num: p *= ctx.gamma(x)
|
| 36 |
+
for x in regular_den: p /= ctx.gamma(x)
|
| 37 |
+
finally:
|
| 38 |
+
ctx.prec = orig
|
| 39 |
+
return +p
|
| 40 |
+
|
| 41 |
+
@defun
|
| 42 |
+
def beta(ctx, x, y):
|
| 43 |
+
x = ctx.convert(x)
|
| 44 |
+
y = ctx.convert(y)
|
| 45 |
+
if ctx.isinf(y):
|
| 46 |
+
x, y = y, x
|
| 47 |
+
if ctx.isinf(x):
|
| 48 |
+
if x == ctx.inf and not ctx._im(y):
|
| 49 |
+
if y == ctx.ninf:
|
| 50 |
+
return ctx.nan
|
| 51 |
+
if y > 0:
|
| 52 |
+
return ctx.zero
|
| 53 |
+
if ctx.isint(y):
|
| 54 |
+
return ctx.nan
|
| 55 |
+
if y < 0:
|
| 56 |
+
return ctx.sign(ctx.gamma(y)) * ctx.inf
|
| 57 |
+
return ctx.nan
|
| 58 |
+
xy = ctx.fadd(x, y, prec=2*ctx.prec)
|
| 59 |
+
return ctx.gammaprod([x, y], [xy])
|
| 60 |
+
|
| 61 |
+
@defun
|
| 62 |
+
def binomial(ctx, n, k):
|
| 63 |
+
n1 = ctx.fadd(n, 1, prec=2*ctx.prec)
|
| 64 |
+
k1 = ctx.fadd(k, 1, prec=2*ctx.prec)
|
| 65 |
+
nk1 = ctx.fsub(n1, k, prec=2*ctx.prec)
|
| 66 |
+
return ctx.gammaprod([n1], [k1, nk1])
|
| 67 |
+
|
| 68 |
+
@defun
|
| 69 |
+
def rf(ctx, x, n):
|
| 70 |
+
xn = ctx.fadd(x, n, prec=2*ctx.prec)
|
| 71 |
+
return ctx.gammaprod([xn], [x])
|
| 72 |
+
|
| 73 |
+
@defun
|
| 74 |
+
def ff(ctx, x, n):
|
| 75 |
+
x1 = ctx.fadd(x, 1, prec=2*ctx.prec)
|
| 76 |
+
xn1 = ctx.fadd(ctx.fsub(x, n, prec=2*ctx.prec), 1, prec=2*ctx.prec)
|
| 77 |
+
return ctx.gammaprod([x1], [xn1])
|
| 78 |
+
|
| 79 |
+
@defun_wrapped
|
| 80 |
+
def fac2(ctx, x):
|
| 81 |
+
if ctx.isinf(x):
|
| 82 |
+
if x == ctx.inf:
|
| 83 |
+
return x
|
| 84 |
+
return ctx.nan
|
| 85 |
+
return 2**(x/2)*(ctx.pi/2)**((ctx.cospi(x)-1)/4)*ctx.gamma(x/2+1)
|
| 86 |
+
|
| 87 |
+
@defun_wrapped
|
| 88 |
+
def barnesg(ctx, z):
|
| 89 |
+
if ctx.isinf(z):
|
| 90 |
+
if z == ctx.inf:
|
| 91 |
+
return z
|
| 92 |
+
return ctx.nan
|
| 93 |
+
if ctx.isnan(z):
|
| 94 |
+
return z
|
| 95 |
+
if (not ctx._im(z)) and ctx._re(z) <= 0 and ctx.isint(ctx._re(z)):
|
| 96 |
+
return z*0
|
| 97 |
+
# Account for size (would not be needed if computing log(G))
|
| 98 |
+
if abs(z) > 5:
|
| 99 |
+
ctx.dps += 2*ctx.log(abs(z),2)
|
| 100 |
+
# Reflection formula
|
| 101 |
+
if ctx.re(z) < -ctx.dps:
|
| 102 |
+
w = 1-z
|
| 103 |
+
pi2 = 2*ctx.pi
|
| 104 |
+
u = ctx.expjpi(2*w)
|
| 105 |
+
v = ctx.j*ctx.pi/12 - ctx.j*ctx.pi*w**2/2 + w*ctx.ln(1-u) - \
|
| 106 |
+
ctx.j*ctx.polylog(2, u)/pi2
|
| 107 |
+
v = ctx.barnesg(2-z)*ctx.exp(v)/pi2**w
|
| 108 |
+
if ctx._is_real_type(z):
|
| 109 |
+
v = ctx._re(v)
|
| 110 |
+
return v
|
| 111 |
+
# Estimate terms for asymptotic expansion
|
| 112 |
+
# TODO: fixme, obviously
|
| 113 |
+
N = ctx.dps // 2 + 5
|
| 114 |
+
G = 1
|
| 115 |
+
while abs(z) < N or ctx.re(z) < 1:
|
| 116 |
+
G /= ctx.gamma(z)
|
| 117 |
+
z += 1
|
| 118 |
+
z -= 1
|
| 119 |
+
s = ctx.mpf(1)/12
|
| 120 |
+
s -= ctx.log(ctx.glaisher)
|
| 121 |
+
s += z*ctx.log(2*ctx.pi)/2
|
| 122 |
+
s += (z**2/2-ctx.mpf(1)/12)*ctx.log(z)
|
| 123 |
+
s -= 3*z**2/4
|
| 124 |
+
z2k = z2 = z**2
|
| 125 |
+
for k in xrange(1, N+1):
|
| 126 |
+
t = ctx.bernoulli(2*k+2) / (4*k*(k+1)*z2k)
|
| 127 |
+
if abs(t) < ctx.eps:
|
| 128 |
+
#print k, N # check how many terms were needed
|
| 129 |
+
break
|
| 130 |
+
z2k *= z2
|
| 131 |
+
s += t
|
| 132 |
+
#if k == N:
|
| 133 |
+
# print "warning: series for barnesg failed to converge", ctx.dps
|
| 134 |
+
return G*ctx.exp(s)
|
| 135 |
+
|
| 136 |
+
@defun
|
| 137 |
+
def superfac(ctx, z):
|
| 138 |
+
return ctx.barnesg(z+2)
|
| 139 |
+
|
| 140 |
+
@defun_wrapped
|
| 141 |
+
def hyperfac(ctx, z):
|
| 142 |
+
# XXX: estimate needed extra bits accurately
|
| 143 |
+
if z == ctx.inf:
|
| 144 |
+
return z
|
| 145 |
+
if abs(z) > 5:
|
| 146 |
+
extra = 4*int(ctx.log(abs(z),2))
|
| 147 |
+
else:
|
| 148 |
+
extra = 0
|
| 149 |
+
ctx.prec += extra
|
| 150 |
+
if not ctx._im(z) and ctx._re(z) < 0 and ctx.isint(ctx._re(z)):
|
| 151 |
+
n = int(ctx.re(z))
|
| 152 |
+
h = ctx.hyperfac(-n-1)
|
| 153 |
+
if ((n+1)//2) & 1:
|
| 154 |
+
h = -h
|
| 155 |
+
if ctx._is_complex_type(z):
|
| 156 |
+
return h + 0j
|
| 157 |
+
return h
|
| 158 |
+
zp1 = z+1
|
| 159 |
+
# Wrong branch cut
|
| 160 |
+
#v = ctx.gamma(zp1)**z
|
| 161 |
+
#ctx.prec -= extra
|
| 162 |
+
#return v / ctx.barnesg(zp1)
|
| 163 |
+
v = ctx.exp(z*ctx.loggamma(zp1))
|
| 164 |
+
ctx.prec -= extra
|
| 165 |
+
return v / ctx.barnesg(zp1)
|
| 166 |
+
|
| 167 |
+
'''
|
| 168 |
+
@defun
|
| 169 |
+
def psi0(ctx, z):
|
| 170 |
+
"""Shortcut for psi(0,z) (the digamma function)"""
|
| 171 |
+
return ctx.psi(0, z)
|
| 172 |
+
|
| 173 |
+
@defun
|
| 174 |
+
def psi1(ctx, z):
|
| 175 |
+
"""Shortcut for psi(1,z) (the trigamma function)"""
|
| 176 |
+
return ctx.psi(1, z)
|
| 177 |
+
|
| 178 |
+
@defun
|
| 179 |
+
def psi2(ctx, z):
|
| 180 |
+
"""Shortcut for psi(2,z) (the tetragamma function)"""
|
| 181 |
+
return ctx.psi(2, z)
|
| 182 |
+
|
| 183 |
+
@defun
|
| 184 |
+
def psi3(ctx, z):
|
| 185 |
+
"""Shortcut for psi(3,z) (the pentagamma function)"""
|
| 186 |
+
return ctx.psi(3, z)
|
| 187 |
+
'''
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/functions.py
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..libmp.backend import xrange
|
| 2 |
+
|
| 3 |
+
class SpecialFunctions(object):
|
| 4 |
+
"""
|
| 5 |
+
This class implements special functions using high-level code.
|
| 6 |
+
|
| 7 |
+
Elementary and some other functions (e.g. gamma function, basecase
|
| 8 |
+
hypergeometric series) are assumed to be predefined by the context as
|
| 9 |
+
"builtins" or "low-level" functions.
|
| 10 |
+
"""
|
| 11 |
+
defined_functions = {}
|
| 12 |
+
|
| 13 |
+
# The series for the Jacobi theta functions converge for |q| < 1;
|
| 14 |
+
# in the current implementation they throw a ValueError for
|
| 15 |
+
# abs(q) > THETA_Q_LIM
|
| 16 |
+
THETA_Q_LIM = 1 - 10**-7
|
| 17 |
+
|
| 18 |
+
def __init__(self):
|
| 19 |
+
cls = self.__class__
|
| 20 |
+
for name in cls.defined_functions:
|
| 21 |
+
f, wrap = cls.defined_functions[name]
|
| 22 |
+
cls._wrap_specfun(name, f, wrap)
|
| 23 |
+
|
| 24 |
+
self.mpq_1 = self._mpq((1,1))
|
| 25 |
+
self.mpq_0 = self._mpq((0,1))
|
| 26 |
+
self.mpq_1_2 = self._mpq((1,2))
|
| 27 |
+
self.mpq_3_2 = self._mpq((3,2))
|
| 28 |
+
self.mpq_1_4 = self._mpq((1,4))
|
| 29 |
+
self.mpq_1_16 = self._mpq((1,16))
|
| 30 |
+
self.mpq_3_16 = self._mpq((3,16))
|
| 31 |
+
self.mpq_5_2 = self._mpq((5,2))
|
| 32 |
+
self.mpq_3_4 = self._mpq((3,4))
|
| 33 |
+
self.mpq_7_4 = self._mpq((7,4))
|
| 34 |
+
self.mpq_5_4 = self._mpq((5,4))
|
| 35 |
+
self.mpq_1_3 = self._mpq((1,3))
|
| 36 |
+
self.mpq_2_3 = self._mpq((2,3))
|
| 37 |
+
self.mpq_4_3 = self._mpq((4,3))
|
| 38 |
+
self.mpq_1_6 = self._mpq((1,6))
|
| 39 |
+
self.mpq_5_6 = self._mpq((5,6))
|
| 40 |
+
self.mpq_5_3 = self._mpq((5,3))
|
| 41 |
+
|
| 42 |
+
self._misc_const_cache = {}
|
| 43 |
+
|
| 44 |
+
self._aliases.update({
|
| 45 |
+
'phase' : 'arg',
|
| 46 |
+
'conjugate' : 'conj',
|
| 47 |
+
'nthroot' : 'root',
|
| 48 |
+
'polygamma' : 'psi',
|
| 49 |
+
'hurwitz' : 'zeta',
|
| 50 |
+
#'digamma' : 'psi0',
|
| 51 |
+
#'trigamma' : 'psi1',
|
| 52 |
+
#'tetragamma' : 'psi2',
|
| 53 |
+
#'pentagamma' : 'psi3',
|
| 54 |
+
'fibonacci' : 'fib',
|
| 55 |
+
'factorial' : 'fac',
|
| 56 |
+
})
|
| 57 |
+
|
| 58 |
+
self.zetazero_memoized = self.memoize(self.zetazero)
|
| 59 |
+
|
| 60 |
+
# Default -- do nothing
|
| 61 |
+
@classmethod
|
| 62 |
+
def _wrap_specfun(cls, name, f, wrap):
|
| 63 |
+
setattr(cls, name, f)
|
| 64 |
+
|
| 65 |
+
# Optional fast versions of common functions in common cases.
|
| 66 |
+
# If not overridden, default (generic hypergeometric series)
|
| 67 |
+
# implementations will be used
|
| 68 |
+
def _besselj(ctx, n, z): raise NotImplementedError
|
| 69 |
+
def _erf(ctx, z): raise NotImplementedError
|
| 70 |
+
def _erfc(ctx, z): raise NotImplementedError
|
| 71 |
+
def _gamma_upper_int(ctx, z, a): raise NotImplementedError
|
| 72 |
+
def _expint_int(ctx, n, z): raise NotImplementedError
|
| 73 |
+
def _zeta(ctx, s): raise NotImplementedError
|
| 74 |
+
def _zetasum_fast(ctx, s, a, n, derivatives, reflect): raise NotImplementedError
|
| 75 |
+
def _ei(ctx, z): raise NotImplementedError
|
| 76 |
+
def _e1(ctx, z): raise NotImplementedError
|
| 77 |
+
def _ci(ctx, z): raise NotImplementedError
|
| 78 |
+
def _si(ctx, z): raise NotImplementedError
|
| 79 |
+
def _altzeta(ctx, s): raise NotImplementedError
|
| 80 |
+
|
| 81 |
+
def defun_wrapped(f):
|
| 82 |
+
SpecialFunctions.defined_functions[f.__name__] = f, True
|
| 83 |
+
return f
|
| 84 |
+
|
| 85 |
+
def defun(f):
|
| 86 |
+
SpecialFunctions.defined_functions[f.__name__] = f, False
|
| 87 |
+
return f
|
| 88 |
+
|
| 89 |
+
def defun_static(f):
|
| 90 |
+
setattr(SpecialFunctions, f.__name__, f)
|
| 91 |
+
return f
|
| 92 |
+
|
| 93 |
+
@defun_wrapped
|
| 94 |
+
def cot(ctx, z): return ctx.one / ctx.tan(z)
|
| 95 |
+
|
| 96 |
+
@defun_wrapped
|
| 97 |
+
def sec(ctx, z): return ctx.one / ctx.cos(z)
|
| 98 |
+
|
| 99 |
+
@defun_wrapped
|
| 100 |
+
def csc(ctx, z): return ctx.one / ctx.sin(z)
|
| 101 |
+
|
| 102 |
+
@defun_wrapped
|
| 103 |
+
def coth(ctx, z): return ctx.one / ctx.tanh(z)
|
| 104 |
+
|
| 105 |
+
@defun_wrapped
|
| 106 |
+
def sech(ctx, z): return ctx.one / ctx.cosh(z)
|
| 107 |
+
|
| 108 |
+
@defun_wrapped
|
| 109 |
+
def csch(ctx, z): return ctx.one / ctx.sinh(z)
|
| 110 |
+
|
| 111 |
+
@defun_wrapped
|
| 112 |
+
def acot(ctx, z):
|
| 113 |
+
if not z:
|
| 114 |
+
return ctx.pi * 0.5
|
| 115 |
+
else:
|
| 116 |
+
return ctx.atan(ctx.one / z)
|
| 117 |
+
|
| 118 |
+
@defun_wrapped
|
| 119 |
+
def asec(ctx, z): return ctx.acos(ctx.one / z)
|
| 120 |
+
|
| 121 |
+
@defun_wrapped
|
| 122 |
+
def acsc(ctx, z): return ctx.asin(ctx.one / z)
|
| 123 |
+
|
| 124 |
+
@defun_wrapped
|
| 125 |
+
def acoth(ctx, z):
|
| 126 |
+
if not z:
|
| 127 |
+
return ctx.pi * 0.5j
|
| 128 |
+
else:
|
| 129 |
+
return ctx.atanh(ctx.one / z)
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
@defun_wrapped
|
| 133 |
+
def asech(ctx, z): return ctx.acosh(ctx.one / z)
|
| 134 |
+
|
| 135 |
+
@defun_wrapped
|
| 136 |
+
def acsch(ctx, z): return ctx.asinh(ctx.one / z)
|
| 137 |
+
|
| 138 |
+
@defun
|
| 139 |
+
def sign(ctx, x):
|
| 140 |
+
x = ctx.convert(x)
|
| 141 |
+
if not x or ctx.isnan(x):
|
| 142 |
+
return x
|
| 143 |
+
if ctx._is_real_type(x):
|
| 144 |
+
if x > 0:
|
| 145 |
+
return ctx.one
|
| 146 |
+
else:
|
| 147 |
+
return -ctx.one
|
| 148 |
+
return x / abs(x)
|
| 149 |
+
|
| 150 |
+
@defun
|
| 151 |
+
def agm(ctx, a, b=1):
|
| 152 |
+
if b == 1:
|
| 153 |
+
return ctx.agm1(a)
|
| 154 |
+
a = ctx.convert(a)
|
| 155 |
+
b = ctx.convert(b)
|
| 156 |
+
return ctx._agm(a, b)
|
| 157 |
+
|
| 158 |
+
@defun_wrapped
|
| 159 |
+
def sinc(ctx, x):
|
| 160 |
+
if ctx.isinf(x):
|
| 161 |
+
return 1/x
|
| 162 |
+
if not x:
|
| 163 |
+
return x+1
|
| 164 |
+
return ctx.sin(x)/x
|
| 165 |
+
|
| 166 |
+
@defun_wrapped
|
| 167 |
+
def sincpi(ctx, x):
|
| 168 |
+
if ctx.isinf(x):
|
| 169 |
+
return 1/x
|
| 170 |
+
if not x:
|
| 171 |
+
return x+1
|
| 172 |
+
return ctx.sinpi(x)/(ctx.pi*x)
|
| 173 |
+
|
| 174 |
+
# TODO: tests; improve implementation
|
| 175 |
+
@defun_wrapped
|
| 176 |
+
def expm1(ctx, x):
|
| 177 |
+
if not x:
|
| 178 |
+
return ctx.zero
|
| 179 |
+
# exp(x) - 1 ~ x
|
| 180 |
+
if ctx.mag(x) < -ctx.prec:
|
| 181 |
+
return x + 0.5*x**2
|
| 182 |
+
# TODO: accurately eval the smaller of the real/imag parts
|
| 183 |
+
return ctx.sum_accurately(lambda: iter([ctx.exp(x),-1]),1)
|
| 184 |
+
|
| 185 |
+
@defun_wrapped
|
| 186 |
+
def log1p(ctx, x):
|
| 187 |
+
if not x:
|
| 188 |
+
return ctx.zero
|
| 189 |
+
if ctx.mag(x) < -ctx.prec:
|
| 190 |
+
return x - 0.5*x**2
|
| 191 |
+
return ctx.log(ctx.fadd(1, x, prec=2*ctx.prec))
|
| 192 |
+
|
| 193 |
+
@defun_wrapped
|
| 194 |
+
def powm1(ctx, x, y):
|
| 195 |
+
mag = ctx.mag
|
| 196 |
+
one = ctx.one
|
| 197 |
+
w = x**y - one
|
| 198 |
+
M = mag(w)
|
| 199 |
+
# Only moderate cancellation
|
| 200 |
+
if M > -8:
|
| 201 |
+
return w
|
| 202 |
+
# Check for the only possible exact cases
|
| 203 |
+
if not w:
|
| 204 |
+
if (not y) or (x in (1, -1, 1j, -1j) and ctx.isint(y)):
|
| 205 |
+
return w
|
| 206 |
+
x1 = x - one
|
| 207 |
+
magy = mag(y)
|
| 208 |
+
lnx = ctx.ln(x)
|
| 209 |
+
# Small y: x^y - 1 ~ log(x)*y + O(log(x)^2 * y^2)
|
| 210 |
+
if magy + mag(lnx) < -ctx.prec:
|
| 211 |
+
return lnx*y + (lnx*y)**2/2
|
| 212 |
+
# TODO: accurately eval the smaller of the real/imag part
|
| 213 |
+
return ctx.sum_accurately(lambda: iter([x**y, -1]), 1)
|
| 214 |
+
|
| 215 |
+
@defun
|
| 216 |
+
def _rootof1(ctx, k, n):
|
| 217 |
+
k = int(k)
|
| 218 |
+
n = int(n)
|
| 219 |
+
k %= n
|
| 220 |
+
if not k:
|
| 221 |
+
return ctx.one
|
| 222 |
+
elif 2*k == n:
|
| 223 |
+
return -ctx.one
|
| 224 |
+
elif 4*k == n:
|
| 225 |
+
return ctx.j
|
| 226 |
+
elif 4*k == 3*n:
|
| 227 |
+
return -ctx.j
|
| 228 |
+
return ctx.expjpi(2*ctx.mpf(k)/n)
|
| 229 |
+
|
| 230 |
+
@defun
|
| 231 |
+
def root(ctx, x, n, k=0):
|
| 232 |
+
n = int(n)
|
| 233 |
+
x = ctx.convert(x)
|
| 234 |
+
if k:
|
| 235 |
+
# Special case: there is an exact real root
|
| 236 |
+
if (n & 1 and 2*k == n-1) and (not ctx.im(x)) and (ctx.re(x) < 0):
|
| 237 |
+
return -ctx.root(-x, n)
|
| 238 |
+
# Multiply by root of unity
|
| 239 |
+
prec = ctx.prec
|
| 240 |
+
try:
|
| 241 |
+
ctx.prec += 10
|
| 242 |
+
v = ctx.root(x, n, 0) * ctx._rootof1(k, n)
|
| 243 |
+
finally:
|
| 244 |
+
ctx.prec = prec
|
| 245 |
+
return +v
|
| 246 |
+
return ctx._nthroot(x, n)
|
| 247 |
+
|
| 248 |
+
@defun
|
| 249 |
+
def unitroots(ctx, n, primitive=False):
|
| 250 |
+
gcd = ctx._gcd
|
| 251 |
+
prec = ctx.prec
|
| 252 |
+
try:
|
| 253 |
+
ctx.prec += 10
|
| 254 |
+
if primitive:
|
| 255 |
+
v = [ctx._rootof1(k,n) for k in range(n) if gcd(k,n) == 1]
|
| 256 |
+
else:
|
| 257 |
+
# TODO: this can be done *much* faster
|
| 258 |
+
v = [ctx._rootof1(k,n) for k in range(n)]
|
| 259 |
+
finally:
|
| 260 |
+
ctx.prec = prec
|
| 261 |
+
return [+x for x in v]
|
| 262 |
+
|
| 263 |
+
@defun
|
| 264 |
+
def arg(ctx, x):
|
| 265 |
+
x = ctx.convert(x)
|
| 266 |
+
re = ctx._re(x)
|
| 267 |
+
im = ctx._im(x)
|
| 268 |
+
return ctx.atan2(im, re)
|
| 269 |
+
|
| 270 |
+
@defun
|
| 271 |
+
def fabs(ctx, x):
|
| 272 |
+
return abs(ctx.convert(x))
|
| 273 |
+
|
| 274 |
+
@defun
|
| 275 |
+
def re(ctx, x):
|
| 276 |
+
x = ctx.convert(x)
|
| 277 |
+
if hasattr(x, "real"): # py2.5 doesn't have .real/.imag for all numbers
|
| 278 |
+
return x.real
|
| 279 |
+
return x
|
| 280 |
+
|
| 281 |
+
@defun
|
| 282 |
+
def im(ctx, x):
|
| 283 |
+
x = ctx.convert(x)
|
| 284 |
+
if hasattr(x, "imag"): # py2.5 doesn't have .real/.imag for all numbers
|
| 285 |
+
return x.imag
|
| 286 |
+
return ctx.zero
|
| 287 |
+
|
| 288 |
+
@defun
|
| 289 |
+
def conj(ctx, x):
|
| 290 |
+
x = ctx.convert(x)
|
| 291 |
+
try:
|
| 292 |
+
return x.conjugate()
|
| 293 |
+
except AttributeError:
|
| 294 |
+
return x
|
| 295 |
+
|
| 296 |
+
@defun
|
| 297 |
+
def polar(ctx, z):
|
| 298 |
+
return (ctx.fabs(z), ctx.arg(z))
|
| 299 |
+
|
| 300 |
+
@defun_wrapped
|
| 301 |
+
def rect(ctx, r, phi):
|
| 302 |
+
return r * ctx.mpc(*ctx.cos_sin(phi))
|
| 303 |
+
|
| 304 |
+
@defun
|
| 305 |
+
def log(ctx, x, b=None):
|
| 306 |
+
if b is None:
|
| 307 |
+
return ctx.ln(x)
|
| 308 |
+
wp = ctx.prec + 20
|
| 309 |
+
return ctx.ln(x, prec=wp) / ctx.ln(b, prec=wp)
|
| 310 |
+
|
| 311 |
+
@defun
|
| 312 |
+
def log10(ctx, x):
|
| 313 |
+
return ctx.log(x, 10)
|
| 314 |
+
|
| 315 |
+
@defun
|
| 316 |
+
def fmod(ctx, x, y):
|
| 317 |
+
return ctx.convert(x) % ctx.convert(y)
|
| 318 |
+
|
| 319 |
+
@defun
|
| 320 |
+
def degrees(ctx, x):
|
| 321 |
+
return x / ctx.degree
|
| 322 |
+
|
| 323 |
+
@defun
|
| 324 |
+
def radians(ctx, x):
|
| 325 |
+
return x * ctx.degree
|
| 326 |
+
|
| 327 |
+
def _lambertw_special(ctx, z, k):
|
| 328 |
+
# W(0,0) = 0; all other branches are singular
|
| 329 |
+
if not z:
|
| 330 |
+
if not k:
|
| 331 |
+
return z
|
| 332 |
+
return ctx.ninf + z
|
| 333 |
+
if z == ctx.inf:
|
| 334 |
+
if k == 0:
|
| 335 |
+
return z
|
| 336 |
+
else:
|
| 337 |
+
return z + 2*k*ctx.pi*ctx.j
|
| 338 |
+
if z == ctx.ninf:
|
| 339 |
+
return (-z) + (2*k+1)*ctx.pi*ctx.j
|
| 340 |
+
# Some kind of nan or complex inf/nan?
|
| 341 |
+
return ctx.ln(z)
|
| 342 |
+
|
| 343 |
+
import math
|
| 344 |
+
import cmath
|
| 345 |
+
|
| 346 |
+
def _lambertw_approx_hybrid(z, k):
|
| 347 |
+
imag_sign = 0
|
| 348 |
+
if hasattr(z, "imag"):
|
| 349 |
+
x = float(z.real)
|
| 350 |
+
y = z.imag
|
| 351 |
+
if y:
|
| 352 |
+
imag_sign = (-1) ** (y < 0)
|
| 353 |
+
y = float(y)
|
| 354 |
+
else:
|
| 355 |
+
x = float(z)
|
| 356 |
+
y = 0.0
|
| 357 |
+
imag_sign = 0
|
| 358 |
+
# hack to work regardless of whether Python supports -0.0
|
| 359 |
+
if not y:
|
| 360 |
+
y = 0.0
|
| 361 |
+
z = complex(x,y)
|
| 362 |
+
if k == 0:
|
| 363 |
+
if -4.0 < y < 4.0 and -1.0 < x < 2.5:
|
| 364 |
+
if imag_sign:
|
| 365 |
+
# Taylor series in upper/lower half-plane
|
| 366 |
+
if y > 1.00: return (0.876+0.645j) + (0.118-0.174j)*(z-(0.75+2.5j))
|
| 367 |
+
if y > 0.25: return (0.505+0.204j) + (0.375-0.132j)*(z-(0.75+0.5j))
|
| 368 |
+
if y < -1.00: return (0.876-0.645j) + (0.118+0.174j)*(z-(0.75-2.5j))
|
| 369 |
+
if y < -0.25: return (0.505-0.204j) + (0.375+0.132j)*(z-(0.75-0.5j))
|
| 370 |
+
# Taylor series near -1
|
| 371 |
+
if x < -0.5:
|
| 372 |
+
if imag_sign >= 0:
|
| 373 |
+
return (-0.318+1.34j) + (-0.697-0.593j)*(z+1)
|
| 374 |
+
else:
|
| 375 |
+
return (-0.318-1.34j) + (-0.697+0.593j)*(z+1)
|
| 376 |
+
# return real type
|
| 377 |
+
r = -0.367879441171442
|
| 378 |
+
if (not imag_sign) and x > r:
|
| 379 |
+
z = x
|
| 380 |
+
# Singularity near -1/e
|
| 381 |
+
if x < -0.2:
|
| 382 |
+
return -1 + 2.33164398159712*(z-r)**0.5 - 1.81218788563936*(z-r)
|
| 383 |
+
# Taylor series near 0
|
| 384 |
+
if x < 0.5: return z
|
| 385 |
+
# Simple linear approximation
|
| 386 |
+
return 0.2 + 0.3*z
|
| 387 |
+
if (not imag_sign) and x > 0.0:
|
| 388 |
+
L1 = math.log(x); L2 = math.log(L1)
|
| 389 |
+
else:
|
| 390 |
+
L1 = cmath.log(z); L2 = cmath.log(L1)
|
| 391 |
+
elif k == -1:
|
| 392 |
+
# return real type
|
| 393 |
+
r = -0.367879441171442
|
| 394 |
+
if (not imag_sign) and r < x < 0.0:
|
| 395 |
+
z = x
|
| 396 |
+
if (imag_sign >= 0) and y < 0.1 and -0.6 < x < -0.2:
|
| 397 |
+
return -1 - 2.33164398159712*(z-r)**0.5 - 1.81218788563936*(z-r)
|
| 398 |
+
if (not imag_sign) and -0.2 <= x < 0.0:
|
| 399 |
+
L1 = math.log(-x)
|
| 400 |
+
return L1 - math.log(-L1)
|
| 401 |
+
else:
|
| 402 |
+
if imag_sign == -1 and (not y) and x < 0.0:
|
| 403 |
+
L1 = cmath.log(z) - 3.1415926535897932j
|
| 404 |
+
else:
|
| 405 |
+
L1 = cmath.log(z) - 6.2831853071795865j
|
| 406 |
+
L2 = cmath.log(L1)
|
| 407 |
+
return L1 - L2 + L2/L1 + L2*(L2-2)/(2*L1**2)
|
| 408 |
+
|
| 409 |
+
def _lambertw_series(ctx, z, k, tol):
|
| 410 |
+
"""
|
| 411 |
+
Return rough approximation for W_k(z) from an asymptotic series,
|
| 412 |
+
sufficiently accurate for the Halley iteration to converge to
|
| 413 |
+
the correct value.
|
| 414 |
+
"""
|
| 415 |
+
magz = ctx.mag(z)
|
| 416 |
+
if (-10 < magz < 900) and (-1000 < k < 1000):
|
| 417 |
+
# Near the branch point at -1/e
|
| 418 |
+
if magz < 1 and abs(z+0.36787944117144) < 0.05:
|
| 419 |
+
if k == 0 or (k == -1 and ctx._im(z) >= 0) or \
|
| 420 |
+
(k == 1 and ctx._im(z) < 0):
|
| 421 |
+
delta = ctx.sum_accurately(lambda: [z, ctx.exp(-1)])
|
| 422 |
+
cancellation = -ctx.mag(delta)
|
| 423 |
+
ctx.prec += cancellation
|
| 424 |
+
# Use series given in Corless et al.
|
| 425 |
+
p = ctx.sqrt(2*(ctx.e*z+1))
|
| 426 |
+
ctx.prec -= cancellation
|
| 427 |
+
u = {0:ctx.mpf(-1), 1:ctx.mpf(1)}
|
| 428 |
+
a = {0:ctx.mpf(2), 1:ctx.mpf(-1)}
|
| 429 |
+
if k != 0:
|
| 430 |
+
p = -p
|
| 431 |
+
s = ctx.zero
|
| 432 |
+
# The series converges, so we could use it directly, but unless
|
| 433 |
+
# *extremely* close, it is better to just use the first few
|
| 434 |
+
# terms to get a good approximation for the iteration
|
| 435 |
+
for l in xrange(max(2,cancellation)):
|
| 436 |
+
if l not in u:
|
| 437 |
+
a[l] = ctx.fsum(u[j]*u[l+1-j] for j in xrange(2,l))
|
| 438 |
+
u[l] = (l-1)*(u[l-2]/2+a[l-2]/4)/(l+1)-a[l]/2-u[l-1]/(l+1)
|
| 439 |
+
term = u[l] * p**l
|
| 440 |
+
s += term
|
| 441 |
+
if ctx.mag(term) < -tol:
|
| 442 |
+
return s, True
|
| 443 |
+
l += 1
|
| 444 |
+
ctx.prec += cancellation//2
|
| 445 |
+
return s, False
|
| 446 |
+
if k == 0 or k == -1:
|
| 447 |
+
return _lambertw_approx_hybrid(z, k), False
|
| 448 |
+
if k == 0:
|
| 449 |
+
if magz < -1:
|
| 450 |
+
return z*(1-z), False
|
| 451 |
+
L1 = ctx.ln(z)
|
| 452 |
+
L2 = ctx.ln(L1)
|
| 453 |
+
elif k == -1 and (not ctx._im(z)) and (-0.36787944117144 < ctx._re(z) < 0):
|
| 454 |
+
L1 = ctx.ln(-z)
|
| 455 |
+
return L1 - ctx.ln(-L1), False
|
| 456 |
+
else:
|
| 457 |
+
# This holds both as z -> 0 and z -> inf.
|
| 458 |
+
# Relative error is O(1/log(z)).
|
| 459 |
+
L1 = ctx.ln(z) + 2j*ctx.pi*k
|
| 460 |
+
L2 = ctx.ln(L1)
|
| 461 |
+
return L1 - L2 + L2/L1 + L2*(L2-2)/(2*L1**2), False
|
| 462 |
+
|
| 463 |
+
@defun
|
| 464 |
+
def lambertw(ctx, z, k=0):
|
| 465 |
+
z = ctx.convert(z)
|
| 466 |
+
k = int(k)
|
| 467 |
+
if not ctx.isnormal(z):
|
| 468 |
+
return _lambertw_special(ctx, z, k)
|
| 469 |
+
prec = ctx.prec
|
| 470 |
+
ctx.prec += 20 + ctx.mag(k or 1)
|
| 471 |
+
wp = ctx.prec
|
| 472 |
+
tol = wp - 5
|
| 473 |
+
w, done = _lambertw_series(ctx, z, k, tol)
|
| 474 |
+
if not done:
|
| 475 |
+
# Use Halley iteration to solve w*exp(w) = z
|
| 476 |
+
two = ctx.mpf(2)
|
| 477 |
+
for i in xrange(100):
|
| 478 |
+
ew = ctx.exp(w)
|
| 479 |
+
wew = w*ew
|
| 480 |
+
wewz = wew-z
|
| 481 |
+
wn = w - wewz/(wew+ew-(w+two)*wewz/(two*w+two))
|
| 482 |
+
if ctx.mag(wn-w) <= ctx.mag(wn) - tol:
|
| 483 |
+
w = wn
|
| 484 |
+
break
|
| 485 |
+
else:
|
| 486 |
+
w = wn
|
| 487 |
+
if i == 100:
|
| 488 |
+
ctx.warn("Lambert W iteration failed to converge for z = %s" % z)
|
| 489 |
+
ctx.prec = prec
|
| 490 |
+
return +w
|
| 491 |
+
|
| 492 |
+
@defun_wrapped
|
| 493 |
+
def bell(ctx, n, x=1):
|
| 494 |
+
x = ctx.convert(x)
|
| 495 |
+
if not n:
|
| 496 |
+
if ctx.isnan(x):
|
| 497 |
+
return x
|
| 498 |
+
return type(x)(1)
|
| 499 |
+
if ctx.isinf(x) or ctx.isinf(n) or ctx.isnan(x) or ctx.isnan(n):
|
| 500 |
+
return x**n
|
| 501 |
+
if n == 1: return x
|
| 502 |
+
if n == 2: return x*(x+1)
|
| 503 |
+
if x == 0: return ctx.sincpi(n)
|
| 504 |
+
return _polyexp(ctx, n, x, True) / ctx.exp(x)
|
| 505 |
+
|
| 506 |
+
def _polyexp(ctx, n, x, extra=False):
|
| 507 |
+
def _terms():
|
| 508 |
+
if extra:
|
| 509 |
+
yield ctx.sincpi(n)
|
| 510 |
+
t = x
|
| 511 |
+
k = 1
|
| 512 |
+
while 1:
|
| 513 |
+
yield k**n * t
|
| 514 |
+
k += 1
|
| 515 |
+
t = t*x/k
|
| 516 |
+
return ctx.sum_accurately(_terms, check_step=4)
|
| 517 |
+
|
| 518 |
+
@defun_wrapped
|
| 519 |
+
def polyexp(ctx, s, z):
|
| 520 |
+
if ctx.isinf(z) or ctx.isinf(s) or ctx.isnan(z) or ctx.isnan(s):
|
| 521 |
+
return z**s
|
| 522 |
+
if z == 0: return z*s
|
| 523 |
+
if s == 0: return ctx.expm1(z)
|
| 524 |
+
if s == 1: return ctx.exp(z)*z
|
| 525 |
+
if s == 2: return ctx.exp(z)*z*(z+1)
|
| 526 |
+
return _polyexp(ctx, s, z)
|
| 527 |
+
|
| 528 |
+
@defun_wrapped
|
| 529 |
+
def cyclotomic(ctx, n, z):
|
| 530 |
+
n = int(n)
|
| 531 |
+
if n < 0:
|
| 532 |
+
raise ValueError("n cannot be negative")
|
| 533 |
+
p = ctx.one
|
| 534 |
+
if n == 0:
|
| 535 |
+
return p
|
| 536 |
+
if n == 1:
|
| 537 |
+
return z - p
|
| 538 |
+
if n == 2:
|
| 539 |
+
return z + p
|
| 540 |
+
# Use divisor product representation. Unfortunately, this sometimes
|
| 541 |
+
# includes singularities for roots of unity, which we have to cancel out.
|
| 542 |
+
# Matching zeros/poles pairwise, we have (1-z^a)/(1-z^b) ~ a/b + O(z-1).
|
| 543 |
+
a_prod = 1
|
| 544 |
+
b_prod = 1
|
| 545 |
+
num_zeros = 0
|
| 546 |
+
num_poles = 0
|
| 547 |
+
for d in range(1,n+1):
|
| 548 |
+
if not n % d:
|
| 549 |
+
w = ctx.moebius(n//d)
|
| 550 |
+
# Use powm1 because it is important that we get 0 only
|
| 551 |
+
# if it really is exactly 0
|
| 552 |
+
b = -ctx.powm1(z, d)
|
| 553 |
+
if b:
|
| 554 |
+
p *= b**w
|
| 555 |
+
else:
|
| 556 |
+
if w == 1:
|
| 557 |
+
a_prod *= d
|
| 558 |
+
num_zeros += 1
|
| 559 |
+
elif w == -1:
|
| 560 |
+
b_prod *= d
|
| 561 |
+
num_poles += 1
|
| 562 |
+
#print n, num_zeros, num_poles
|
| 563 |
+
if num_zeros:
|
| 564 |
+
if num_zeros > num_poles:
|
| 565 |
+
p *= 0
|
| 566 |
+
else:
|
| 567 |
+
p *= a_prod
|
| 568 |
+
p /= b_prod
|
| 569 |
+
return p
|
| 570 |
+
|
| 571 |
+
@defun
|
| 572 |
+
def mangoldt(ctx, n):
|
| 573 |
+
r"""
|
| 574 |
+
Evaluates the von Mangoldt function `\Lambda(n) = \log p`
|
| 575 |
+
if `n = p^k` a power of a prime, and `\Lambda(n) = 0` otherwise.
|
| 576 |
+
|
| 577 |
+
**Examples**
|
| 578 |
+
|
| 579 |
+
>>> from mpmath import *
|
| 580 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 581 |
+
>>> [mangoldt(n) for n in range(-2,3)]
|
| 582 |
+
[0.0, 0.0, 0.0, 0.0, 0.6931471805599453094172321]
|
| 583 |
+
>>> mangoldt(6)
|
| 584 |
+
0.0
|
| 585 |
+
>>> mangoldt(7)
|
| 586 |
+
1.945910149055313305105353
|
| 587 |
+
>>> mangoldt(8)
|
| 588 |
+
0.6931471805599453094172321
|
| 589 |
+
>>> fsum(mangoldt(n) for n in range(101))
|
| 590 |
+
94.04531122935739224600493
|
| 591 |
+
>>> fsum(mangoldt(n) for n in range(10001))
|
| 592 |
+
10013.39669326311478372032
|
| 593 |
+
|
| 594 |
+
"""
|
| 595 |
+
n = int(n)
|
| 596 |
+
if n < 2:
|
| 597 |
+
return ctx.zero
|
| 598 |
+
if n % 2 == 0:
|
| 599 |
+
# Must be a power of two
|
| 600 |
+
if n & (n-1) == 0:
|
| 601 |
+
return +ctx.ln2
|
| 602 |
+
else:
|
| 603 |
+
return ctx.zero
|
| 604 |
+
# TODO: the following could be generalized into a perfect
|
| 605 |
+
# power testing function
|
| 606 |
+
# ---
|
| 607 |
+
# Look for a small factor
|
| 608 |
+
for p in (3,5,7,11,13,17,19,23,29,31):
|
| 609 |
+
if not n % p:
|
| 610 |
+
q, r = n // p, 0
|
| 611 |
+
while q > 1:
|
| 612 |
+
q, r = divmod(q, p)
|
| 613 |
+
if r:
|
| 614 |
+
return ctx.zero
|
| 615 |
+
return ctx.ln(p)
|
| 616 |
+
if ctx.isprime(n):
|
| 617 |
+
return ctx.ln(n)
|
| 618 |
+
# Obviously, we could use arbitrary-precision arithmetic for this...
|
| 619 |
+
if n > 10**30:
|
| 620 |
+
raise NotImplementedError
|
| 621 |
+
k = 2
|
| 622 |
+
while 1:
|
| 623 |
+
p = int(n**(1./k) + 0.5)
|
| 624 |
+
if p < 2:
|
| 625 |
+
return ctx.zero
|
| 626 |
+
if p ** k == n:
|
| 627 |
+
if ctx.isprime(p):
|
| 628 |
+
return ctx.ln(p)
|
| 629 |
+
k += 1
|
| 630 |
+
|
| 631 |
+
@defun
|
| 632 |
+
def stirling1(ctx, n, k, exact=False):
|
| 633 |
+
v = ctx._stirling1(int(n), int(k))
|
| 634 |
+
if exact:
|
| 635 |
+
return int(v)
|
| 636 |
+
else:
|
| 637 |
+
return ctx.mpf(v)
|
| 638 |
+
|
| 639 |
+
@defun
|
| 640 |
+
def stirling2(ctx, n, k, exact=False):
|
| 641 |
+
v = ctx._stirling2(int(n), int(k))
|
| 642 |
+
if exact:
|
| 643 |
+
return int(v)
|
| 644 |
+
else:
|
| 645 |
+
return ctx.mpf(v)
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/hypergeometric.py
ADDED
|
@@ -0,0 +1,1413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ..libmp.backend import xrange
|
| 2 |
+
from .functions import defun, defun_wrapped
|
| 3 |
+
|
| 4 |
+
def _check_need_perturb(ctx, terms, prec, discard_known_zeros):
|
| 5 |
+
perturb = recompute = False
|
| 6 |
+
extraprec = 0
|
| 7 |
+
discard = []
|
| 8 |
+
for term_index, term in enumerate(terms):
|
| 9 |
+
w_s, c_s, alpha_s, beta_s, a_s, b_s, z = term
|
| 10 |
+
have_singular_nongamma_weight = False
|
| 11 |
+
# Avoid division by zero in leading factors (TODO:
|
| 12 |
+
# also check for near division by zero?)
|
| 13 |
+
for k, w in enumerate(w_s):
|
| 14 |
+
if not w:
|
| 15 |
+
if ctx.re(c_s[k]) <= 0 and c_s[k]:
|
| 16 |
+
perturb = recompute = True
|
| 17 |
+
have_singular_nongamma_weight = True
|
| 18 |
+
pole_count = [0, 0, 0]
|
| 19 |
+
# Check for gamma and series poles and near-poles
|
| 20 |
+
for data_index, data in enumerate([alpha_s, beta_s, b_s]):
|
| 21 |
+
for i, x in enumerate(data):
|
| 22 |
+
n, d = ctx.nint_distance(x)
|
| 23 |
+
# Poles
|
| 24 |
+
if n > 0:
|
| 25 |
+
continue
|
| 26 |
+
if d == ctx.ninf:
|
| 27 |
+
# OK if we have a polynomial
|
| 28 |
+
# ------------------------------
|
| 29 |
+
ok = False
|
| 30 |
+
if data_index == 2:
|
| 31 |
+
for u in a_s:
|
| 32 |
+
if ctx.isnpint(u) and u >= int(n):
|
| 33 |
+
ok = True
|
| 34 |
+
break
|
| 35 |
+
if ok:
|
| 36 |
+
continue
|
| 37 |
+
pole_count[data_index] += 1
|
| 38 |
+
# ------------------------------
|
| 39 |
+
#perturb = recompute = True
|
| 40 |
+
#return perturb, recompute, extraprec
|
| 41 |
+
elif d < -4:
|
| 42 |
+
extraprec += -d
|
| 43 |
+
recompute = True
|
| 44 |
+
if discard_known_zeros and pole_count[1] > pole_count[0] + pole_count[2] \
|
| 45 |
+
and not have_singular_nongamma_weight:
|
| 46 |
+
discard.append(term_index)
|
| 47 |
+
elif sum(pole_count):
|
| 48 |
+
perturb = recompute = True
|
| 49 |
+
return perturb, recompute, extraprec, discard
|
| 50 |
+
|
| 51 |
+
_hypercomb_msg = """
|
| 52 |
+
hypercomb() failed to converge to the requested %i bits of accuracy
|
| 53 |
+
using a working precision of %i bits. The function value may be zero or
|
| 54 |
+
infinite; try passing zeroprec=N or infprec=M to bound finite values between
|
| 55 |
+
2^(-N) and 2^M. Otherwise try a higher maxprec or maxterms.
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
@defun
|
| 59 |
+
def hypercomb(ctx, function, params=[], discard_known_zeros=True, **kwargs):
|
| 60 |
+
orig = ctx.prec
|
| 61 |
+
sumvalue = ctx.zero
|
| 62 |
+
dist = ctx.nint_distance
|
| 63 |
+
ninf = ctx.ninf
|
| 64 |
+
orig_params = params[:]
|
| 65 |
+
verbose = kwargs.get('verbose', False)
|
| 66 |
+
maxprec = kwargs.get('maxprec', ctx._default_hyper_maxprec(orig))
|
| 67 |
+
kwargs['maxprec'] = maxprec # For calls to hypsum
|
| 68 |
+
zeroprec = kwargs.get('zeroprec')
|
| 69 |
+
infprec = kwargs.get('infprec')
|
| 70 |
+
perturbed_reference_value = None
|
| 71 |
+
hextra = 0
|
| 72 |
+
try:
|
| 73 |
+
while 1:
|
| 74 |
+
ctx.prec += 10
|
| 75 |
+
if ctx.prec > maxprec:
|
| 76 |
+
raise ValueError(_hypercomb_msg % (orig, ctx.prec))
|
| 77 |
+
orig2 = ctx.prec
|
| 78 |
+
params = orig_params[:]
|
| 79 |
+
terms = function(*params)
|
| 80 |
+
if verbose:
|
| 81 |
+
print()
|
| 82 |
+
print("ENTERING hypercomb main loop")
|
| 83 |
+
print("prec =", ctx.prec)
|
| 84 |
+
print("hextra", hextra)
|
| 85 |
+
perturb, recompute, extraprec, discard = \
|
| 86 |
+
_check_need_perturb(ctx, terms, orig, discard_known_zeros)
|
| 87 |
+
ctx.prec += extraprec
|
| 88 |
+
if perturb:
|
| 89 |
+
if "hmag" in kwargs:
|
| 90 |
+
hmag = kwargs["hmag"]
|
| 91 |
+
elif ctx._fixed_precision:
|
| 92 |
+
hmag = int(ctx.prec*0.3)
|
| 93 |
+
else:
|
| 94 |
+
hmag = orig + 10 + hextra
|
| 95 |
+
h = ctx.ldexp(ctx.one, -hmag)
|
| 96 |
+
ctx.prec = orig2 + 10 + hmag + 10
|
| 97 |
+
for k in range(len(params)):
|
| 98 |
+
params[k] += h
|
| 99 |
+
# Heuristically ensure that the perturbations
|
| 100 |
+
# are "independent" so that two perturbations
|
| 101 |
+
# don't accidentally cancel each other out
|
| 102 |
+
# in a subtraction.
|
| 103 |
+
h += h/(k+1)
|
| 104 |
+
if recompute:
|
| 105 |
+
terms = function(*params)
|
| 106 |
+
if discard_known_zeros:
|
| 107 |
+
terms = [term for (i, term) in enumerate(terms) if i not in discard]
|
| 108 |
+
if not terms:
|
| 109 |
+
return ctx.zero
|
| 110 |
+
evaluated_terms = []
|
| 111 |
+
for term_index, term_data in enumerate(terms):
|
| 112 |
+
w_s, c_s, alpha_s, beta_s, a_s, b_s, z = term_data
|
| 113 |
+
if verbose:
|
| 114 |
+
print()
|
| 115 |
+
print(" Evaluating term %i/%i : %iF%i" % \
|
| 116 |
+
(term_index+1, len(terms), len(a_s), len(b_s)))
|
| 117 |
+
print(" powers", ctx.nstr(w_s), ctx.nstr(c_s))
|
| 118 |
+
print(" gamma", ctx.nstr(alpha_s), ctx.nstr(beta_s))
|
| 119 |
+
print(" hyper", ctx.nstr(a_s), ctx.nstr(b_s))
|
| 120 |
+
print(" z", ctx.nstr(z))
|
| 121 |
+
#v = ctx.hyper(a_s, b_s, z, **kwargs)
|
| 122 |
+
#for a in alpha_s: v *= ctx.gamma(a)
|
| 123 |
+
#for b in beta_s: v *= ctx.rgamma(b)
|
| 124 |
+
#for w, c in zip(w_s, c_s): v *= ctx.power(w, c)
|
| 125 |
+
v = ctx.fprod([ctx.hyper(a_s, b_s, z, **kwargs)] + \
|
| 126 |
+
[ctx.gamma(a) for a in alpha_s] + \
|
| 127 |
+
[ctx.rgamma(b) for b in beta_s] + \
|
| 128 |
+
[ctx.power(w,c) for (w,c) in zip(w_s,c_s)])
|
| 129 |
+
if verbose:
|
| 130 |
+
print(" Value:", v)
|
| 131 |
+
evaluated_terms.append(v)
|
| 132 |
+
|
| 133 |
+
if len(terms) == 1 and (not perturb):
|
| 134 |
+
sumvalue = evaluated_terms[0]
|
| 135 |
+
break
|
| 136 |
+
|
| 137 |
+
if ctx._fixed_precision:
|
| 138 |
+
sumvalue = ctx.fsum(evaluated_terms)
|
| 139 |
+
break
|
| 140 |
+
|
| 141 |
+
sumvalue = ctx.fsum(evaluated_terms)
|
| 142 |
+
term_magnitudes = [ctx.mag(x) for x in evaluated_terms]
|
| 143 |
+
max_magnitude = max(term_magnitudes)
|
| 144 |
+
sum_magnitude = ctx.mag(sumvalue)
|
| 145 |
+
cancellation = max_magnitude - sum_magnitude
|
| 146 |
+
if verbose:
|
| 147 |
+
print()
|
| 148 |
+
print(" Cancellation:", cancellation, "bits")
|
| 149 |
+
print(" Increased precision:", ctx.prec - orig, "bits")
|
| 150 |
+
|
| 151 |
+
precision_ok = cancellation < ctx.prec - orig
|
| 152 |
+
|
| 153 |
+
if zeroprec is None:
|
| 154 |
+
zero_ok = False
|
| 155 |
+
else:
|
| 156 |
+
zero_ok = max_magnitude - ctx.prec < -zeroprec
|
| 157 |
+
if infprec is None:
|
| 158 |
+
inf_ok = False
|
| 159 |
+
else:
|
| 160 |
+
inf_ok = max_magnitude > infprec
|
| 161 |
+
|
| 162 |
+
if precision_ok and (not perturb) or ctx.isnan(cancellation):
|
| 163 |
+
break
|
| 164 |
+
elif precision_ok:
|
| 165 |
+
if perturbed_reference_value is None:
|
| 166 |
+
hextra += 20
|
| 167 |
+
perturbed_reference_value = sumvalue
|
| 168 |
+
continue
|
| 169 |
+
elif ctx.mag(sumvalue - perturbed_reference_value) <= \
|
| 170 |
+
ctx.mag(sumvalue) - orig:
|
| 171 |
+
break
|
| 172 |
+
elif zero_ok:
|
| 173 |
+
sumvalue = ctx.zero
|
| 174 |
+
break
|
| 175 |
+
elif inf_ok:
|
| 176 |
+
sumvalue = ctx.inf
|
| 177 |
+
break
|
| 178 |
+
elif 'hmag' in kwargs:
|
| 179 |
+
break
|
| 180 |
+
else:
|
| 181 |
+
hextra *= 2
|
| 182 |
+
perturbed_reference_value = sumvalue
|
| 183 |
+
# Increase precision
|
| 184 |
+
else:
|
| 185 |
+
increment = min(max(cancellation, orig//2), max(extraprec,orig))
|
| 186 |
+
ctx.prec += increment
|
| 187 |
+
if verbose:
|
| 188 |
+
print(" Must start over with increased precision")
|
| 189 |
+
continue
|
| 190 |
+
finally:
|
| 191 |
+
ctx.prec = orig
|
| 192 |
+
return +sumvalue
|
| 193 |
+
|
| 194 |
+
@defun
|
| 195 |
+
def hyper(ctx, a_s, b_s, z, **kwargs):
|
| 196 |
+
"""
|
| 197 |
+
Hypergeometric function, general case.
|
| 198 |
+
"""
|
| 199 |
+
z = ctx.convert(z)
|
| 200 |
+
p = len(a_s)
|
| 201 |
+
q = len(b_s)
|
| 202 |
+
a_s = [ctx._convert_param(a) for a in a_s]
|
| 203 |
+
b_s = [ctx._convert_param(b) for b in b_s]
|
| 204 |
+
# Reduce degree by eliminating common parameters
|
| 205 |
+
if kwargs.get('eliminate', True):
|
| 206 |
+
elim_nonpositive = kwargs.get('eliminate_all', False)
|
| 207 |
+
i = 0
|
| 208 |
+
while i < q and a_s:
|
| 209 |
+
b = b_s[i]
|
| 210 |
+
if b in a_s and (elim_nonpositive or not ctx.isnpint(b[0])):
|
| 211 |
+
a_s.remove(b)
|
| 212 |
+
b_s.remove(b)
|
| 213 |
+
p -= 1
|
| 214 |
+
q -= 1
|
| 215 |
+
else:
|
| 216 |
+
i += 1
|
| 217 |
+
# Handle special cases
|
| 218 |
+
if p == 0:
|
| 219 |
+
if q == 1: return ctx._hyp0f1(b_s, z, **kwargs)
|
| 220 |
+
elif q == 0: return ctx.exp(z)
|
| 221 |
+
elif p == 1:
|
| 222 |
+
if q == 1: return ctx._hyp1f1(a_s, b_s, z, **kwargs)
|
| 223 |
+
elif q == 2: return ctx._hyp1f2(a_s, b_s, z, **kwargs)
|
| 224 |
+
elif q == 0: return ctx._hyp1f0(a_s[0][0], z)
|
| 225 |
+
elif p == 2:
|
| 226 |
+
if q == 1: return ctx._hyp2f1(a_s, b_s, z, **kwargs)
|
| 227 |
+
elif q == 2: return ctx._hyp2f2(a_s, b_s, z, **kwargs)
|
| 228 |
+
elif q == 3: return ctx._hyp2f3(a_s, b_s, z, **kwargs)
|
| 229 |
+
elif q == 0: return ctx._hyp2f0(a_s, b_s, z, **kwargs)
|
| 230 |
+
elif p == q+1:
|
| 231 |
+
return ctx._hypq1fq(p, q, a_s, b_s, z, **kwargs)
|
| 232 |
+
elif p > q+1 and not kwargs.get('force_series'):
|
| 233 |
+
return ctx._hyp_borel(p, q, a_s, b_s, z, **kwargs)
|
| 234 |
+
coeffs, types = zip(*(a_s+b_s))
|
| 235 |
+
return ctx.hypsum(p, q, types, coeffs, z, **kwargs)
|
| 236 |
+
|
| 237 |
+
@defun
|
| 238 |
+
def hyp0f1(ctx,b,z,**kwargs):
|
| 239 |
+
return ctx.hyper([],[b],z,**kwargs)
|
| 240 |
+
|
| 241 |
+
@defun
|
| 242 |
+
def hyp1f1(ctx,a,b,z,**kwargs):
|
| 243 |
+
return ctx.hyper([a],[b],z,**kwargs)
|
| 244 |
+
|
| 245 |
+
@defun
|
| 246 |
+
def hyp1f2(ctx,a1,b1,b2,z,**kwargs):
|
| 247 |
+
return ctx.hyper([a1],[b1,b2],z,**kwargs)
|
| 248 |
+
|
| 249 |
+
@defun
|
| 250 |
+
def hyp2f1(ctx,a,b,c,z,**kwargs):
|
| 251 |
+
return ctx.hyper([a,b],[c],z,**kwargs)
|
| 252 |
+
|
| 253 |
+
@defun
|
| 254 |
+
def hyp2f2(ctx,a1,a2,b1,b2,z,**kwargs):
|
| 255 |
+
return ctx.hyper([a1,a2],[b1,b2],z,**kwargs)
|
| 256 |
+
|
| 257 |
+
@defun
|
| 258 |
+
def hyp2f3(ctx,a1,a2,b1,b2,b3,z,**kwargs):
|
| 259 |
+
return ctx.hyper([a1,a2],[b1,b2,b3],z,**kwargs)
|
| 260 |
+
|
| 261 |
+
@defun
|
| 262 |
+
def hyp2f0(ctx,a,b,z,**kwargs):
|
| 263 |
+
return ctx.hyper([a,b],[],z,**kwargs)
|
| 264 |
+
|
| 265 |
+
@defun
|
| 266 |
+
def hyp3f2(ctx,a1,a2,a3,b1,b2,z,**kwargs):
|
| 267 |
+
return ctx.hyper([a1,a2,a3],[b1,b2],z,**kwargs)
|
| 268 |
+
|
| 269 |
+
@defun_wrapped
|
| 270 |
+
def _hyp1f0(ctx, a, z):
|
| 271 |
+
return (1-z) ** (-a)
|
| 272 |
+
|
| 273 |
+
@defun
|
| 274 |
+
def _hyp0f1(ctx, b_s, z, **kwargs):
|
| 275 |
+
(b, btype), = b_s
|
| 276 |
+
if z:
|
| 277 |
+
magz = ctx.mag(z)
|
| 278 |
+
else:
|
| 279 |
+
magz = 0
|
| 280 |
+
if magz >= 8 and not kwargs.get('force_series'):
|
| 281 |
+
try:
|
| 282 |
+
# http://functions.wolfram.com/HypergeometricFunctions/
|
| 283 |
+
# Hypergeometric0F1/06/02/03/0004/
|
| 284 |
+
# TODO: handle the all-real case more efficiently!
|
| 285 |
+
# TODO: figure out how much precision is needed (exponential growth)
|
| 286 |
+
orig = ctx.prec
|
| 287 |
+
try:
|
| 288 |
+
ctx.prec += 12 + magz//2
|
| 289 |
+
def h():
|
| 290 |
+
w = ctx.sqrt(-z)
|
| 291 |
+
jw = ctx.j*w
|
| 292 |
+
u = 1/(4*jw)
|
| 293 |
+
c = ctx.mpq_1_2 - b
|
| 294 |
+
E = ctx.exp(2*jw)
|
| 295 |
+
T1 = ([-jw,E], [c,-1], [], [], [b-ctx.mpq_1_2, ctx.mpq_3_2-b], [], -u)
|
| 296 |
+
T2 = ([jw,E], [c,1], [], [], [b-ctx.mpq_1_2, ctx.mpq_3_2-b], [], u)
|
| 297 |
+
return T1, T2
|
| 298 |
+
v = ctx.hypercomb(h, [], force_series=True)
|
| 299 |
+
v = ctx.gamma(b)/(2*ctx.sqrt(ctx.pi))*v
|
| 300 |
+
finally:
|
| 301 |
+
ctx.prec = orig
|
| 302 |
+
if ctx._is_real_type(b) and ctx._is_real_type(z):
|
| 303 |
+
v = ctx._re(v)
|
| 304 |
+
return +v
|
| 305 |
+
except ctx.NoConvergence:
|
| 306 |
+
pass
|
| 307 |
+
return ctx.hypsum(0, 1, (btype,), [b], z, **kwargs)
|
| 308 |
+
|
| 309 |
+
@defun
|
| 310 |
+
def _hyp1f1(ctx, a_s, b_s, z, **kwargs):
|
| 311 |
+
(a, atype), = a_s
|
| 312 |
+
(b, btype), = b_s
|
| 313 |
+
if not z:
|
| 314 |
+
return ctx.one+z
|
| 315 |
+
magz = ctx.mag(z)
|
| 316 |
+
if magz >= 7 and not (ctx.isint(a) and ctx.re(a) <= 0):
|
| 317 |
+
if ctx.isinf(z):
|
| 318 |
+
if ctx.sign(a) == ctx.sign(b) == ctx.sign(z) == 1:
|
| 319 |
+
return ctx.inf
|
| 320 |
+
return ctx.nan * z
|
| 321 |
+
try:
|
| 322 |
+
try:
|
| 323 |
+
ctx.prec += magz
|
| 324 |
+
sector = ctx._im(z) < 0
|
| 325 |
+
def h(a,b):
|
| 326 |
+
if sector:
|
| 327 |
+
E = ctx.expjpi(ctx.fneg(a, exact=True))
|
| 328 |
+
else:
|
| 329 |
+
E = ctx.expjpi(a)
|
| 330 |
+
rz = 1/z
|
| 331 |
+
T1 = ([E,z], [1,-a], [b], [b-a], [a, 1+a-b], [], -rz)
|
| 332 |
+
T2 = ([ctx.exp(z),z], [1,a-b], [b], [a], [b-a, 1-a], [], rz)
|
| 333 |
+
return T1, T2
|
| 334 |
+
v = ctx.hypercomb(h, [a,b], force_series=True)
|
| 335 |
+
if ctx._is_real_type(a) and ctx._is_real_type(b) and ctx._is_real_type(z):
|
| 336 |
+
v = ctx._re(v)
|
| 337 |
+
return +v
|
| 338 |
+
except ctx.NoConvergence:
|
| 339 |
+
pass
|
| 340 |
+
finally:
|
| 341 |
+
ctx.prec -= magz
|
| 342 |
+
v = ctx.hypsum(1, 1, (atype, btype), [a, b], z, **kwargs)
|
| 343 |
+
return v
|
| 344 |
+
|
| 345 |
+
def _hyp2f1_gosper(ctx,a,b,c,z,**kwargs):
|
| 346 |
+
# Use Gosper's recurrence
|
| 347 |
+
# See http://www.math.utexas.edu/pipermail/maxima/2006/000126.html
|
| 348 |
+
_a,_b,_c,_z = a, b, c, z
|
| 349 |
+
orig = ctx.prec
|
| 350 |
+
maxprec = kwargs.get('maxprec', 100*orig)
|
| 351 |
+
extra = 10
|
| 352 |
+
while 1:
|
| 353 |
+
ctx.prec = orig + extra
|
| 354 |
+
#a = ctx.convert(_a)
|
| 355 |
+
#b = ctx.convert(_b)
|
| 356 |
+
#c = ctx.convert(_c)
|
| 357 |
+
z = ctx.convert(_z)
|
| 358 |
+
d = ctx.mpf(0)
|
| 359 |
+
e = ctx.mpf(1)
|
| 360 |
+
f = ctx.mpf(0)
|
| 361 |
+
k = 0
|
| 362 |
+
# Common subexpression elimination, unfortunately making
|
| 363 |
+
# things a bit unreadable. The formula is quite messy to begin
|
| 364 |
+
# with, though...
|
| 365 |
+
abz = a*b*z
|
| 366 |
+
ch = c * ctx.mpq_1_2
|
| 367 |
+
c1h = (c+1) * ctx.mpq_1_2
|
| 368 |
+
nz = 1-z
|
| 369 |
+
g = z/nz
|
| 370 |
+
abg = a*b*g
|
| 371 |
+
cba = c-b-a
|
| 372 |
+
z2 = z-2
|
| 373 |
+
tol = -ctx.prec - 10
|
| 374 |
+
nstr = ctx.nstr
|
| 375 |
+
nprint = ctx.nprint
|
| 376 |
+
mag = ctx.mag
|
| 377 |
+
maxmag = ctx.ninf
|
| 378 |
+
while 1:
|
| 379 |
+
kch = k+ch
|
| 380 |
+
kakbz = (k+a)*(k+b)*z / (4*(k+1)*kch*(k+c1h))
|
| 381 |
+
d1 = kakbz*(e-(k+cba)*d*g)
|
| 382 |
+
e1 = kakbz*(d*abg+(k+c)*e)
|
| 383 |
+
ft = d*(k*(cba*z+k*z2-c)-abz)/(2*kch*nz)
|
| 384 |
+
f1 = f + e - ft
|
| 385 |
+
maxmag = max(maxmag, mag(f1))
|
| 386 |
+
if mag(f1-f) < tol:
|
| 387 |
+
break
|
| 388 |
+
d, e, f = d1, e1, f1
|
| 389 |
+
k += 1
|
| 390 |
+
cancellation = maxmag - mag(f1)
|
| 391 |
+
if cancellation < extra:
|
| 392 |
+
break
|
| 393 |
+
else:
|
| 394 |
+
extra += cancellation
|
| 395 |
+
if extra > maxprec:
|
| 396 |
+
raise ctx.NoConvergence
|
| 397 |
+
return f1
|
| 398 |
+
|
| 399 |
+
@defun
|
| 400 |
+
def _hyp2f1(ctx, a_s, b_s, z, **kwargs):
|
| 401 |
+
(a, atype), (b, btype) = a_s
|
| 402 |
+
(c, ctype), = b_s
|
| 403 |
+
if z == 1:
|
| 404 |
+
# TODO: the following logic can be simplified
|
| 405 |
+
convergent = ctx.re(c-a-b) > 0
|
| 406 |
+
finite = (ctx.isint(a) and a <= 0) or (ctx.isint(b) and b <= 0)
|
| 407 |
+
zerodiv = ctx.isint(c) and c <= 0 and not \
|
| 408 |
+
((ctx.isint(a) and c <= a <= 0) or (ctx.isint(b) and c <= b <= 0))
|
| 409 |
+
#print "bz", a, b, c, z, convergent, finite, zerodiv
|
| 410 |
+
# Gauss's theorem gives the value if convergent
|
| 411 |
+
if (convergent or finite) and not zerodiv:
|
| 412 |
+
return ctx.gammaprod([c, c-a-b], [c-a, c-b], _infsign=True)
|
| 413 |
+
# Otherwise, there is a pole and we take the
|
| 414 |
+
# sign to be that when approaching from below
|
| 415 |
+
# XXX: this evaluation is not necessarily correct in all cases
|
| 416 |
+
return ctx.hyp2f1(a,b,c,1-ctx.eps*2) * ctx.inf
|
| 417 |
+
|
| 418 |
+
# Equal to 1 (first term), unless there is a subsequent
|
| 419 |
+
# division by zero
|
| 420 |
+
if not z:
|
| 421 |
+
# Division by zero but power of z is higher than
|
| 422 |
+
# first order so cancels
|
| 423 |
+
if c or a == 0 or b == 0:
|
| 424 |
+
return 1+z
|
| 425 |
+
# Indeterminate
|
| 426 |
+
return ctx.nan
|
| 427 |
+
|
| 428 |
+
# Hit zero denominator unless numerator goes to 0 first
|
| 429 |
+
if ctx.isint(c) and c <= 0:
|
| 430 |
+
if (ctx.isint(a) and c <= a <= 0) or \
|
| 431 |
+
(ctx.isint(b) and c <= b <= 0):
|
| 432 |
+
pass
|
| 433 |
+
else:
|
| 434 |
+
# Pole in series
|
| 435 |
+
return ctx.inf
|
| 436 |
+
|
| 437 |
+
absz = abs(z)
|
| 438 |
+
|
| 439 |
+
# Fast case: standard series converges rapidly,
|
| 440 |
+
# possibly in finitely many terms
|
| 441 |
+
if absz <= 0.8 or (ctx.isint(a) and a <= 0 and a >= -1000) or \
|
| 442 |
+
(ctx.isint(b) and b <= 0 and b >= -1000):
|
| 443 |
+
return ctx.hypsum(2, 1, (atype, btype, ctype), [a, b, c], z, **kwargs)
|
| 444 |
+
|
| 445 |
+
orig = ctx.prec
|
| 446 |
+
try:
|
| 447 |
+
ctx.prec += 10
|
| 448 |
+
|
| 449 |
+
# Use 1/z transformation
|
| 450 |
+
if absz >= 1.3:
|
| 451 |
+
def h(a,b):
|
| 452 |
+
t = ctx.mpq_1-c; ab = a-b; rz = 1/z
|
| 453 |
+
T1 = ([-z],[-a], [c,-ab],[b,c-a], [a,t+a],[ctx.mpq_1+ab], rz)
|
| 454 |
+
T2 = ([-z],[-b], [c,ab],[a,c-b], [b,t+b],[ctx.mpq_1-ab], rz)
|
| 455 |
+
return T1, T2
|
| 456 |
+
v = ctx.hypercomb(h, [a,b], **kwargs)
|
| 457 |
+
|
| 458 |
+
# Use 1-z transformation
|
| 459 |
+
elif abs(1-z) <= 0.75:
|
| 460 |
+
def h(a,b):
|
| 461 |
+
t = c-a-b; ca = c-a; cb = c-b; rz = 1-z
|
| 462 |
+
T1 = [], [], [c,t], [ca,cb], [a,b], [1-t], rz
|
| 463 |
+
T2 = [rz], [t], [c,a+b-c], [a,b], [ca,cb], [1+t], rz
|
| 464 |
+
return T1, T2
|
| 465 |
+
v = ctx.hypercomb(h, [a,b], **kwargs)
|
| 466 |
+
|
| 467 |
+
# Use z/(z-1) transformation
|
| 468 |
+
elif abs(z/(z-1)) <= 0.75:
|
| 469 |
+
v = ctx.hyp2f1(a, c-b, c, z/(z-1)) / (1-z)**a
|
| 470 |
+
|
| 471 |
+
# Remaining part of unit circle
|
| 472 |
+
else:
|
| 473 |
+
v = _hyp2f1_gosper(ctx,a,b,c,z,**kwargs)
|
| 474 |
+
|
| 475 |
+
finally:
|
| 476 |
+
ctx.prec = orig
|
| 477 |
+
return +v
|
| 478 |
+
|
| 479 |
+
@defun
|
| 480 |
+
def _hypq1fq(ctx, p, q, a_s, b_s, z, **kwargs):
|
| 481 |
+
r"""
|
| 482 |
+
Evaluates 3F2, 4F3, 5F4, ...
|
| 483 |
+
"""
|
| 484 |
+
a_s, a_types = zip(*a_s)
|
| 485 |
+
b_s, b_types = zip(*b_s)
|
| 486 |
+
a_s = list(a_s)
|
| 487 |
+
b_s = list(b_s)
|
| 488 |
+
absz = abs(z)
|
| 489 |
+
ispoly = False
|
| 490 |
+
for a in a_s:
|
| 491 |
+
if ctx.isint(a) and a <= 0:
|
| 492 |
+
ispoly = True
|
| 493 |
+
break
|
| 494 |
+
# Direct summation
|
| 495 |
+
if absz < 1 or ispoly:
|
| 496 |
+
try:
|
| 497 |
+
return ctx.hypsum(p, q, a_types+b_types, a_s+b_s, z, **kwargs)
|
| 498 |
+
except ctx.NoConvergence:
|
| 499 |
+
if absz > 1.1 or ispoly:
|
| 500 |
+
raise
|
| 501 |
+
# Use expansion at |z-1| -> 0.
|
| 502 |
+
# Reference: Wolfgang Buhring, "Generalized Hypergeometric Functions at
|
| 503 |
+
# Unit Argument", Proc. Amer. Math. Soc., Vol. 114, No. 1 (Jan. 1992),
|
| 504 |
+
# pp.145-153
|
| 505 |
+
# The current implementation has several problems:
|
| 506 |
+
# 1. We only implement it for 3F2. The expansion coefficients are
|
| 507 |
+
# given by extremely messy nested sums in the higher degree cases
|
| 508 |
+
# (see reference). Is efficient sequential generation of the coefficients
|
| 509 |
+
# possible in the > 3F2 case?
|
| 510 |
+
# 2. Although the series converges, it may do so slowly, so we need
|
| 511 |
+
# convergence acceleration. The acceleration implemented by
|
| 512 |
+
# nsum does not always help, so results returned are sometimes
|
| 513 |
+
# inaccurate! Can we do better?
|
| 514 |
+
# 3. We should check conditions for convergence, and possibly
|
| 515 |
+
# do a better job of cancelling out gamma poles if possible.
|
| 516 |
+
if z == 1:
|
| 517 |
+
# XXX: should also check for division by zero in the
|
| 518 |
+
# denominator of the series (cf. hyp2f1)
|
| 519 |
+
S = ctx.re(sum(b_s)-sum(a_s))
|
| 520 |
+
if S <= 0:
|
| 521 |
+
#return ctx.hyper(a_s, b_s, 1-ctx.eps*2, **kwargs) * ctx.inf
|
| 522 |
+
return ctx.hyper(a_s, b_s, 0.9, **kwargs) * ctx.inf
|
| 523 |
+
if (p,q) == (3,2) and abs(z-1) < 0.05: # and kwargs.get('sum1')
|
| 524 |
+
#print "Using alternate summation (experimental)"
|
| 525 |
+
a1,a2,a3 = a_s
|
| 526 |
+
b1,b2 = b_s
|
| 527 |
+
u = b1+b2-a3
|
| 528 |
+
initial = ctx.gammaprod([b2-a3,b1-a3,a1,a2],[b2-a3,b1-a3,1,u])
|
| 529 |
+
def term(k, _cache={0:initial}):
|
| 530 |
+
u = b1+b2-a3+k
|
| 531 |
+
if k in _cache:
|
| 532 |
+
t = _cache[k]
|
| 533 |
+
else:
|
| 534 |
+
t = _cache[k-1]
|
| 535 |
+
t *= (b1+k-a3-1)*(b2+k-a3-1)
|
| 536 |
+
t /= k*(u-1)
|
| 537 |
+
_cache[k] = t
|
| 538 |
+
return t * ctx.hyp2f1(a1,a2,u,z)
|
| 539 |
+
try:
|
| 540 |
+
S = ctx.nsum(term, [0,ctx.inf], verbose=kwargs.get('verbose'),
|
| 541 |
+
strict=kwargs.get('strict', True))
|
| 542 |
+
return S * ctx.gammaprod([b1,b2],[a1,a2,a3])
|
| 543 |
+
except ctx.NoConvergence:
|
| 544 |
+
pass
|
| 545 |
+
# Try to use convergence acceleration on and close to the unit circle.
|
| 546 |
+
# Problem: the convergence acceleration degenerates as |z-1| -> 0,
|
| 547 |
+
# except for special cases. Everywhere else, the Shanks transformation
|
| 548 |
+
# is very efficient.
|
| 549 |
+
if absz < 1.1 and ctx._re(z) <= 1:
|
| 550 |
+
|
| 551 |
+
def term(kk, _cache={0:ctx.one}):
|
| 552 |
+
k = int(kk)
|
| 553 |
+
if k != kk:
|
| 554 |
+
t = z ** ctx.mpf(kk) / ctx.fac(kk)
|
| 555 |
+
for a in a_s: t *= ctx.rf(a,kk)
|
| 556 |
+
for b in b_s: t /= ctx.rf(b,kk)
|
| 557 |
+
return t
|
| 558 |
+
if k in _cache:
|
| 559 |
+
return _cache[k]
|
| 560 |
+
t = term(k-1)
|
| 561 |
+
m = k-1
|
| 562 |
+
for j in xrange(p): t *= (a_s[j]+m)
|
| 563 |
+
for j in xrange(q): t /= (b_s[j]+m)
|
| 564 |
+
t *= z
|
| 565 |
+
t /= k
|
| 566 |
+
_cache[k] = t
|
| 567 |
+
return t
|
| 568 |
+
|
| 569 |
+
sum_method = kwargs.get('sum_method', 'r+s+e')
|
| 570 |
+
|
| 571 |
+
try:
|
| 572 |
+
return ctx.nsum(term, [0,ctx.inf], verbose=kwargs.get('verbose'),
|
| 573 |
+
strict=kwargs.get('strict', True),
|
| 574 |
+
method=sum_method.replace('e',''))
|
| 575 |
+
except ctx.NoConvergence:
|
| 576 |
+
if 'e' not in sum_method:
|
| 577 |
+
raise
|
| 578 |
+
pass
|
| 579 |
+
|
| 580 |
+
if kwargs.get('verbose'):
|
| 581 |
+
print("Attempting Euler-Maclaurin summation")
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
"""
|
| 585 |
+
Somewhat slower version (one diffs_exp for each factor).
|
| 586 |
+
However, this would be faster with fast direct derivatives
|
| 587 |
+
of the gamma function.
|
| 588 |
+
|
| 589 |
+
def power_diffs(k0):
|
| 590 |
+
r = 0
|
| 591 |
+
l = ctx.log(z)
|
| 592 |
+
while 1:
|
| 593 |
+
yield z**ctx.mpf(k0) * l**r
|
| 594 |
+
r += 1
|
| 595 |
+
|
| 596 |
+
def loggamma_diffs(x, reciprocal=False):
|
| 597 |
+
sign = (-1) ** reciprocal
|
| 598 |
+
yield sign * ctx.loggamma(x)
|
| 599 |
+
i = 0
|
| 600 |
+
while 1:
|
| 601 |
+
yield sign * ctx.psi(i,x)
|
| 602 |
+
i += 1
|
| 603 |
+
|
| 604 |
+
def hyper_diffs(k0):
|
| 605 |
+
b2 = b_s + [1]
|
| 606 |
+
A = [ctx.diffs_exp(loggamma_diffs(a+k0)) for a in a_s]
|
| 607 |
+
B = [ctx.diffs_exp(loggamma_diffs(b+k0,True)) for b in b2]
|
| 608 |
+
Z = [power_diffs(k0)]
|
| 609 |
+
C = ctx.gammaprod([b for b in b2], [a for a in a_s])
|
| 610 |
+
for d in ctx.diffs_prod(A + B + Z):
|
| 611 |
+
v = C * d
|
| 612 |
+
yield v
|
| 613 |
+
"""
|
| 614 |
+
|
| 615 |
+
def log_diffs(k0):
|
| 616 |
+
b2 = b_s + [1]
|
| 617 |
+
yield sum(ctx.loggamma(a+k0) for a in a_s) - \
|
| 618 |
+
sum(ctx.loggamma(b+k0) for b in b2) + k0*ctx.log(z)
|
| 619 |
+
i = 0
|
| 620 |
+
while 1:
|
| 621 |
+
v = sum(ctx.psi(i,a+k0) for a in a_s) - \
|
| 622 |
+
sum(ctx.psi(i,b+k0) for b in b2)
|
| 623 |
+
if i == 0:
|
| 624 |
+
v += ctx.log(z)
|
| 625 |
+
yield v
|
| 626 |
+
i += 1
|
| 627 |
+
|
| 628 |
+
def hyper_diffs(k0):
|
| 629 |
+
C = ctx.gammaprod([b for b in b_s], [a for a in a_s])
|
| 630 |
+
for d in ctx.diffs_exp(log_diffs(k0)):
|
| 631 |
+
v = C * d
|
| 632 |
+
yield v
|
| 633 |
+
|
| 634 |
+
tol = ctx.eps / 1024
|
| 635 |
+
prec = ctx.prec
|
| 636 |
+
try:
|
| 637 |
+
trunc = 50 * ctx.dps
|
| 638 |
+
ctx.prec += 20
|
| 639 |
+
for i in xrange(5):
|
| 640 |
+
head = ctx.fsum(term(k) for k in xrange(trunc))
|
| 641 |
+
tail, err = ctx.sumem(term, [trunc, ctx.inf], tol=tol,
|
| 642 |
+
adiffs=hyper_diffs(trunc),
|
| 643 |
+
verbose=kwargs.get('verbose'),
|
| 644 |
+
error=True,
|
| 645 |
+
_fast_abort=True)
|
| 646 |
+
if err < tol:
|
| 647 |
+
v = head + tail
|
| 648 |
+
break
|
| 649 |
+
trunc *= 2
|
| 650 |
+
# Need to increase precision because calculation of
|
| 651 |
+
# derivatives may be inaccurate
|
| 652 |
+
ctx.prec += ctx.prec//2
|
| 653 |
+
if i == 4:
|
| 654 |
+
raise ctx.NoConvergence(\
|
| 655 |
+
"Euler-Maclaurin summation did not converge")
|
| 656 |
+
finally:
|
| 657 |
+
ctx.prec = prec
|
| 658 |
+
return +v
|
| 659 |
+
|
| 660 |
+
# Use 1/z transformation
|
| 661 |
+
# http://functions.wolfram.com/HypergeometricFunctions/
|
| 662 |
+
# HypergeometricPFQ/06/01/05/02/0004/
|
| 663 |
+
def h(*args):
|
| 664 |
+
a_s = list(args[:p])
|
| 665 |
+
b_s = list(args[p:])
|
| 666 |
+
Ts = []
|
| 667 |
+
recz = ctx.one/z
|
| 668 |
+
negz = ctx.fneg(z, exact=True)
|
| 669 |
+
for k in range(q+1):
|
| 670 |
+
ak = a_s[k]
|
| 671 |
+
C = [negz]
|
| 672 |
+
Cp = [-ak]
|
| 673 |
+
Gn = b_s + [ak] + [a_s[j]-ak for j in range(q+1) if j != k]
|
| 674 |
+
Gd = a_s + [b_s[j]-ak for j in range(q)]
|
| 675 |
+
Fn = [ak] + [ak-b_s[j]+1 for j in range(q)]
|
| 676 |
+
Fd = [1-a_s[j]+ak for j in range(q+1) if j != k]
|
| 677 |
+
Ts.append((C, Cp, Gn, Gd, Fn, Fd, recz))
|
| 678 |
+
return Ts
|
| 679 |
+
return ctx.hypercomb(h, a_s+b_s, **kwargs)
|
| 680 |
+
|
| 681 |
+
@defun
|
| 682 |
+
def _hyp_borel(ctx, p, q, a_s, b_s, z, **kwargs):
|
| 683 |
+
if a_s:
|
| 684 |
+
a_s, a_types = zip(*a_s)
|
| 685 |
+
a_s = list(a_s)
|
| 686 |
+
else:
|
| 687 |
+
a_s, a_types = [], ()
|
| 688 |
+
if b_s:
|
| 689 |
+
b_s, b_types = zip(*b_s)
|
| 690 |
+
b_s = list(b_s)
|
| 691 |
+
else:
|
| 692 |
+
b_s, b_types = [], ()
|
| 693 |
+
kwargs['maxterms'] = kwargs.get('maxterms', ctx.prec)
|
| 694 |
+
try:
|
| 695 |
+
return ctx.hypsum(p, q, a_types+b_types, a_s+b_s, z, **kwargs)
|
| 696 |
+
except ctx.NoConvergence:
|
| 697 |
+
pass
|
| 698 |
+
prec = ctx.prec
|
| 699 |
+
try:
|
| 700 |
+
tol = kwargs.get('asymp_tol', ctx.eps/4)
|
| 701 |
+
ctx.prec += 10
|
| 702 |
+
# hypsum is has a conservative tolerance. So we try again:
|
| 703 |
+
def term(k, cache={0:ctx.one}):
|
| 704 |
+
if k in cache:
|
| 705 |
+
return cache[k]
|
| 706 |
+
t = term(k-1)
|
| 707 |
+
for a in a_s: t *= (a+(k-1))
|
| 708 |
+
for b in b_s: t /= (b+(k-1))
|
| 709 |
+
t *= z
|
| 710 |
+
t /= k
|
| 711 |
+
cache[k] = t
|
| 712 |
+
return t
|
| 713 |
+
s = ctx.one
|
| 714 |
+
for k in xrange(1, ctx.prec):
|
| 715 |
+
t = term(k)
|
| 716 |
+
s += t
|
| 717 |
+
if abs(t) <= tol:
|
| 718 |
+
return s
|
| 719 |
+
finally:
|
| 720 |
+
ctx.prec = prec
|
| 721 |
+
if p <= q+3:
|
| 722 |
+
contour = kwargs.get('contour')
|
| 723 |
+
if not contour:
|
| 724 |
+
if ctx.arg(z) < 0.25:
|
| 725 |
+
u = z / max(1, abs(z))
|
| 726 |
+
if ctx.arg(z) >= 0:
|
| 727 |
+
contour = [0, 2j, (2j+2)/u, 2/u, ctx.inf]
|
| 728 |
+
else:
|
| 729 |
+
contour = [0, -2j, (-2j+2)/u, 2/u, ctx.inf]
|
| 730 |
+
#contour = [0, 2j/z, 2/z, ctx.inf]
|
| 731 |
+
#contour = [0, 2j, 2/z, ctx.inf]
|
| 732 |
+
#contour = [0, 2j, ctx.inf]
|
| 733 |
+
else:
|
| 734 |
+
contour = [0, ctx.inf]
|
| 735 |
+
quad_kwargs = kwargs.get('quad_kwargs', {})
|
| 736 |
+
def g(t):
|
| 737 |
+
return ctx.exp(-t)*ctx.hyper(a_s, b_s+[1], t*z)
|
| 738 |
+
I, err = ctx.quad(g, contour, error=True, **quad_kwargs)
|
| 739 |
+
if err <= abs(I)*ctx.eps*8:
|
| 740 |
+
return I
|
| 741 |
+
raise ctx.NoConvergence
|
| 742 |
+
|
| 743 |
+
|
| 744 |
+
@defun
|
| 745 |
+
def _hyp2f2(ctx, a_s, b_s, z, **kwargs):
|
| 746 |
+
(a1, a1type), (a2, a2type) = a_s
|
| 747 |
+
(b1, b1type), (b2, b2type) = b_s
|
| 748 |
+
|
| 749 |
+
absz = abs(z)
|
| 750 |
+
magz = ctx.mag(z)
|
| 751 |
+
orig = ctx.prec
|
| 752 |
+
|
| 753 |
+
# Asymptotic expansion is ~ exp(z)
|
| 754 |
+
asymp_extraprec = magz
|
| 755 |
+
|
| 756 |
+
# Asymptotic series is in terms of 3F1
|
| 757 |
+
can_use_asymptotic = (not kwargs.get('force_series')) and \
|
| 758 |
+
(ctx.mag(absz) > 3)
|
| 759 |
+
|
| 760 |
+
# TODO: much of the following could be shared with 2F3 instead of
|
| 761 |
+
# copypasted
|
| 762 |
+
if can_use_asymptotic:
|
| 763 |
+
#print "using asymp"
|
| 764 |
+
try:
|
| 765 |
+
try:
|
| 766 |
+
ctx.prec += asymp_extraprec
|
| 767 |
+
# http://functions.wolfram.com/HypergeometricFunctions/
|
| 768 |
+
# Hypergeometric2F2/06/02/02/0002/
|
| 769 |
+
def h(a1,a2,b1,b2):
|
| 770 |
+
X = a1+a2-b1-b2
|
| 771 |
+
A2 = a1+a2
|
| 772 |
+
B2 = b1+b2
|
| 773 |
+
c = {}
|
| 774 |
+
c[0] = ctx.one
|
| 775 |
+
c[1] = (A2-1)*X+b1*b2-a1*a2
|
| 776 |
+
s1 = 0
|
| 777 |
+
k = 0
|
| 778 |
+
tprev = 0
|
| 779 |
+
while 1:
|
| 780 |
+
if k not in c:
|
| 781 |
+
uu1 = 1-B2+2*a1+a1**2+2*a2+a2**2-A2*B2+a1*a2+b1*b2+(2*B2-3*(A2+1))*k+2*k**2
|
| 782 |
+
uu2 = (k-A2+b1-1)*(k-A2+b2-1)*(k-X-2)
|
| 783 |
+
c[k] = ctx.one/k * (uu1*c[k-1]-uu2*c[k-2])
|
| 784 |
+
t1 = c[k] * z**(-k)
|
| 785 |
+
if abs(t1) < 0.1*ctx.eps:
|
| 786 |
+
#print "Convergence :)"
|
| 787 |
+
break
|
| 788 |
+
# Quit if the series doesn't converge quickly enough
|
| 789 |
+
if k > 5 and abs(tprev) / abs(t1) < 1.5:
|
| 790 |
+
#print "No convergence :("
|
| 791 |
+
raise ctx.NoConvergence
|
| 792 |
+
s1 += t1
|
| 793 |
+
tprev = t1
|
| 794 |
+
k += 1
|
| 795 |
+
S = ctx.exp(z)*s1
|
| 796 |
+
T1 = [z,S], [X,1], [b1,b2],[a1,a2],[],[],0
|
| 797 |
+
T2 = [-z],[-a1],[b1,b2,a2-a1],[a2,b1-a1,b2-a1],[a1,a1-b1+1,a1-b2+1],[a1-a2+1],-1/z
|
| 798 |
+
T3 = [-z],[-a2],[b1,b2,a1-a2],[a1,b1-a2,b2-a2],[a2,a2-b1+1,a2-b2+1],[-a1+a2+1],-1/z
|
| 799 |
+
return T1, T2, T3
|
| 800 |
+
v = ctx.hypercomb(h, [a1,a2,b1,b2], force_series=True, maxterms=4*ctx.prec)
|
| 801 |
+
if sum(ctx._is_real_type(u) for u in [a1,a2,b1,b2,z]) == 5:
|
| 802 |
+
v = ctx.re(v)
|
| 803 |
+
return v
|
| 804 |
+
except ctx.NoConvergence:
|
| 805 |
+
pass
|
| 806 |
+
finally:
|
| 807 |
+
ctx.prec = orig
|
| 808 |
+
|
| 809 |
+
return ctx.hypsum(2, 2, (a1type, a2type, b1type, b2type), [a1, a2, b1, b2], z, **kwargs)
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
|
| 813 |
+
@defun
|
| 814 |
+
def _hyp1f2(ctx, a_s, b_s, z, **kwargs):
|
| 815 |
+
(a1, a1type), = a_s
|
| 816 |
+
(b1, b1type), (b2, b2type) = b_s
|
| 817 |
+
|
| 818 |
+
absz = abs(z)
|
| 819 |
+
magz = ctx.mag(z)
|
| 820 |
+
orig = ctx.prec
|
| 821 |
+
|
| 822 |
+
# Asymptotic expansion is ~ exp(sqrt(z))
|
| 823 |
+
asymp_extraprec = z and magz//2
|
| 824 |
+
|
| 825 |
+
# Asymptotic series is in terms of 3F0
|
| 826 |
+
can_use_asymptotic = (not kwargs.get('force_series')) and \
|
| 827 |
+
(ctx.mag(absz) > 19) and \
|
| 828 |
+
(ctx.sqrt(absz) > 1.5*orig) # and \
|
| 829 |
+
# ctx._hyp_check_convergence([a1, a1-b1+1, a1-b2+1], [],
|
| 830 |
+
# 1/absz, orig+40+asymp_extraprec)
|
| 831 |
+
|
| 832 |
+
# TODO: much of the following could be shared with 2F3 instead of
|
| 833 |
+
# copypasted
|
| 834 |
+
if can_use_asymptotic:
|
| 835 |
+
#print "using asymp"
|
| 836 |
+
try:
|
| 837 |
+
try:
|
| 838 |
+
ctx.prec += asymp_extraprec
|
| 839 |
+
# http://functions.wolfram.com/HypergeometricFunctions/
|
| 840 |
+
# Hypergeometric1F2/06/02/03/
|
| 841 |
+
def h(a1,b1,b2):
|
| 842 |
+
X = ctx.mpq_1_2*(a1-b1-b2+ctx.mpq_1_2)
|
| 843 |
+
c = {}
|
| 844 |
+
c[0] = ctx.one
|
| 845 |
+
c[1] = 2*(ctx.mpq_1_4*(3*a1+b1+b2-2)*(a1-b1-b2)+b1*b2-ctx.mpq_3_16)
|
| 846 |
+
c[2] = 2*(b1*b2+ctx.mpq_1_4*(a1-b1-b2)*(3*a1+b1+b2-2)-ctx.mpq_3_16)**2+\
|
| 847 |
+
ctx.mpq_1_16*(-16*(2*a1-3)*b1*b2 + \
|
| 848 |
+
4*(a1-b1-b2)*(-8*a1**2+11*a1+b1+b2-2)-3)
|
| 849 |
+
s1 = 0
|
| 850 |
+
s2 = 0
|
| 851 |
+
k = 0
|
| 852 |
+
tprev = 0
|
| 853 |
+
while 1:
|
| 854 |
+
if k not in c:
|
| 855 |
+
uu1 = (3*k**2+(-6*a1+2*b1+2*b2-4)*k + 3*a1**2 - \
|
| 856 |
+
(b1-b2)**2 - 2*a1*(b1+b2-2) + ctx.mpq_1_4)
|
| 857 |
+
uu2 = (k-a1+b1-b2-ctx.mpq_1_2)*(k-a1-b1+b2-ctx.mpq_1_2)*\
|
| 858 |
+
(k-a1+b1+b2-ctx.mpq_5_2)
|
| 859 |
+
c[k] = ctx.one/(2*k)*(uu1*c[k-1]-uu2*c[k-2])
|
| 860 |
+
w = c[k] * (-z)**(-0.5*k)
|
| 861 |
+
t1 = (-ctx.j)**k * ctx.mpf(2)**(-k) * w
|
| 862 |
+
t2 = ctx.j**k * ctx.mpf(2)**(-k) * w
|
| 863 |
+
if abs(t1) < 0.1*ctx.eps:
|
| 864 |
+
#print "Convergence :)"
|
| 865 |
+
break
|
| 866 |
+
# Quit if the series doesn't converge quickly enough
|
| 867 |
+
if k > 5 and abs(tprev) / abs(t1) < 1.5:
|
| 868 |
+
#print "No convergence :("
|
| 869 |
+
raise ctx.NoConvergence
|
| 870 |
+
s1 += t1
|
| 871 |
+
s2 += t2
|
| 872 |
+
tprev = t1
|
| 873 |
+
k += 1
|
| 874 |
+
S = ctx.expj(ctx.pi*X+2*ctx.sqrt(-z))*s1 + \
|
| 875 |
+
ctx.expj(-(ctx.pi*X+2*ctx.sqrt(-z)))*s2
|
| 876 |
+
T1 = [0.5*S, ctx.pi, -z], [1, -0.5, X], [b1, b2], [a1],\
|
| 877 |
+
[], [], 0
|
| 878 |
+
T2 = [-z], [-a1], [b1,b2],[b1-a1,b2-a1], \
|
| 879 |
+
[a1,a1-b1+1,a1-b2+1], [], 1/z
|
| 880 |
+
return T1, T2
|
| 881 |
+
v = ctx.hypercomb(h, [a1,b1,b2], force_series=True, maxterms=4*ctx.prec)
|
| 882 |
+
if sum(ctx._is_real_type(u) for u in [a1,b1,b2,z]) == 4:
|
| 883 |
+
v = ctx.re(v)
|
| 884 |
+
return v
|
| 885 |
+
except ctx.NoConvergence:
|
| 886 |
+
pass
|
| 887 |
+
finally:
|
| 888 |
+
ctx.prec = orig
|
| 889 |
+
|
| 890 |
+
#print "not using asymp"
|
| 891 |
+
return ctx.hypsum(1, 2, (a1type, b1type, b2type), [a1, b1, b2], z, **kwargs)
|
| 892 |
+
|
| 893 |
+
|
| 894 |
+
|
| 895 |
+
@defun
|
| 896 |
+
def _hyp2f3(ctx, a_s, b_s, z, **kwargs):
|
| 897 |
+
(a1, a1type), (a2, a2type) = a_s
|
| 898 |
+
(b1, b1type), (b2, b2type), (b3, b3type) = b_s
|
| 899 |
+
|
| 900 |
+
absz = abs(z)
|
| 901 |
+
magz = ctx.mag(z)
|
| 902 |
+
|
| 903 |
+
# Asymptotic expansion is ~ exp(sqrt(z))
|
| 904 |
+
asymp_extraprec = z and magz//2
|
| 905 |
+
orig = ctx.prec
|
| 906 |
+
|
| 907 |
+
# Asymptotic series is in terms of 4F1
|
| 908 |
+
# The square root below empirically provides a plausible criterion
|
| 909 |
+
# for the leading series to converge
|
| 910 |
+
can_use_asymptotic = (not kwargs.get('force_series')) and \
|
| 911 |
+
(ctx.mag(absz) > 19) and (ctx.sqrt(absz) > 1.5*orig)
|
| 912 |
+
|
| 913 |
+
if can_use_asymptotic:
|
| 914 |
+
#print "using asymp"
|
| 915 |
+
try:
|
| 916 |
+
try:
|
| 917 |
+
ctx.prec += asymp_extraprec
|
| 918 |
+
# http://functions.wolfram.com/HypergeometricFunctions/
|
| 919 |
+
# Hypergeometric2F3/06/02/03/01/0002/
|
| 920 |
+
def h(a1,a2,b1,b2,b3):
|
| 921 |
+
X = ctx.mpq_1_2*(a1+a2-b1-b2-b3+ctx.mpq_1_2)
|
| 922 |
+
A2 = a1+a2
|
| 923 |
+
B3 = b1+b2+b3
|
| 924 |
+
A = a1*a2
|
| 925 |
+
B = b1*b2+b3*b2+b1*b3
|
| 926 |
+
R = b1*b2*b3
|
| 927 |
+
c = {}
|
| 928 |
+
c[0] = ctx.one
|
| 929 |
+
c[1] = 2*(B - A + ctx.mpq_1_4*(3*A2+B3-2)*(A2-B3) - ctx.mpq_3_16)
|
| 930 |
+
c[2] = ctx.mpq_1_2*c[1]**2 + ctx.mpq_1_16*(-16*(2*A2-3)*(B-A) + 32*R +\
|
| 931 |
+
4*(-8*A2**2 + 11*A2 + 8*A + B3 - 2)*(A2-B3)-3)
|
| 932 |
+
s1 = 0
|
| 933 |
+
s2 = 0
|
| 934 |
+
k = 0
|
| 935 |
+
tprev = 0
|
| 936 |
+
while 1:
|
| 937 |
+
if k not in c:
|
| 938 |
+
uu1 = (k-2*X-3)*(k-2*X-2*b1-1)*(k-2*X-2*b2-1)*\
|
| 939 |
+
(k-2*X-2*b3-1)
|
| 940 |
+
uu2 = (4*(k-1)**3 - 6*(4*X+B3)*(k-1)**2 + \
|
| 941 |
+
2*(24*X**2+12*B3*X+4*B+B3-1)*(k-1) - 32*X**3 - \
|
| 942 |
+
24*B3*X**2 - 4*B - 8*R - 4*(4*B+B3-1)*X + 2*B3-1)
|
| 943 |
+
uu3 = (5*(k-1)**2+2*(-10*X+A2-3*B3+3)*(k-1)+2*c[1])
|
| 944 |
+
c[k] = ctx.one/(2*k)*(uu1*c[k-3]-uu2*c[k-2]+uu3*c[k-1])
|
| 945 |
+
w = c[k] * ctx.power(-z, -0.5*k)
|
| 946 |
+
t1 = (-ctx.j)**k * ctx.mpf(2)**(-k) * w
|
| 947 |
+
t2 = ctx.j**k * ctx.mpf(2)**(-k) * w
|
| 948 |
+
if abs(t1) < 0.1*ctx.eps:
|
| 949 |
+
break
|
| 950 |
+
# Quit if the series doesn't converge quickly enough
|
| 951 |
+
if k > 5 and abs(tprev) / abs(t1) < 1.5:
|
| 952 |
+
raise ctx.NoConvergence
|
| 953 |
+
s1 += t1
|
| 954 |
+
s2 += t2
|
| 955 |
+
tprev = t1
|
| 956 |
+
k += 1
|
| 957 |
+
S = ctx.expj(ctx.pi*X+2*ctx.sqrt(-z))*s1 + \
|
| 958 |
+
ctx.expj(-(ctx.pi*X+2*ctx.sqrt(-z)))*s2
|
| 959 |
+
T1 = [0.5*S, ctx.pi, -z], [1, -0.5, X], [b1, b2, b3], [a1, a2],\
|
| 960 |
+
[], [], 0
|
| 961 |
+
T2 = [-z], [-a1], [b1,b2,b3,a2-a1],[a2,b1-a1,b2-a1,b3-a1], \
|
| 962 |
+
[a1,a1-b1+1,a1-b2+1,a1-b3+1], [a1-a2+1], 1/z
|
| 963 |
+
T3 = [-z], [-a2], [b1,b2,b3,a1-a2],[a1,b1-a2,b2-a2,b3-a2], \
|
| 964 |
+
[a2,a2-b1+1,a2-b2+1,a2-b3+1],[-a1+a2+1], 1/z
|
| 965 |
+
return T1, T2, T3
|
| 966 |
+
v = ctx.hypercomb(h, [a1,a2,b1,b2,b3], force_series=True, maxterms=4*ctx.prec)
|
| 967 |
+
if sum(ctx._is_real_type(u) for u in [a1,a2,b1,b2,b3,z]) == 6:
|
| 968 |
+
v = ctx.re(v)
|
| 969 |
+
return v
|
| 970 |
+
except ctx.NoConvergence:
|
| 971 |
+
pass
|
| 972 |
+
finally:
|
| 973 |
+
ctx.prec = orig
|
| 974 |
+
|
| 975 |
+
return ctx.hypsum(2, 3, (a1type, a2type, b1type, b2type, b3type), [a1, a2, b1, b2, b3], z, **kwargs)
|
| 976 |
+
|
| 977 |
+
@defun
|
| 978 |
+
def _hyp2f0(ctx, a_s, b_s, z, **kwargs):
|
| 979 |
+
(a, atype), (b, btype) = a_s
|
| 980 |
+
# We want to try aggressively to use the asymptotic expansion,
|
| 981 |
+
# and fall back only when absolutely necessary
|
| 982 |
+
try:
|
| 983 |
+
kwargsb = kwargs.copy()
|
| 984 |
+
kwargsb['maxterms'] = kwargsb.get('maxterms', ctx.prec)
|
| 985 |
+
return ctx.hypsum(2, 0, (atype,btype), [a,b], z, **kwargsb)
|
| 986 |
+
except ctx.NoConvergence:
|
| 987 |
+
if kwargs.get('force_series'):
|
| 988 |
+
raise
|
| 989 |
+
pass
|
| 990 |
+
def h(a, b):
|
| 991 |
+
w = ctx.sinpi(b)
|
| 992 |
+
rz = -1/z
|
| 993 |
+
T1 = ([ctx.pi,w,rz],[1,-1,a],[],[a-b+1,b],[a],[b],rz)
|
| 994 |
+
T2 = ([-ctx.pi,w,rz],[1,-1,1+a-b],[],[a,2-b],[a-b+1],[2-b],rz)
|
| 995 |
+
return T1, T2
|
| 996 |
+
return ctx.hypercomb(h, [a, 1+a-b], **kwargs)
|
| 997 |
+
|
| 998 |
+
@defun
|
| 999 |
+
def meijerg(ctx, a_s, b_s, z, r=1, series=None, **kwargs):
|
| 1000 |
+
an, ap = a_s
|
| 1001 |
+
bm, bq = b_s
|
| 1002 |
+
n = len(an)
|
| 1003 |
+
p = n + len(ap)
|
| 1004 |
+
m = len(bm)
|
| 1005 |
+
q = m + len(bq)
|
| 1006 |
+
a = an+ap
|
| 1007 |
+
b = bm+bq
|
| 1008 |
+
a = [ctx.convert(_) for _ in a]
|
| 1009 |
+
b = [ctx.convert(_) for _ in b]
|
| 1010 |
+
z = ctx.convert(z)
|
| 1011 |
+
if series is None:
|
| 1012 |
+
if p < q: series = 1
|
| 1013 |
+
if p > q: series = 2
|
| 1014 |
+
if p == q:
|
| 1015 |
+
if m+n == p and abs(z) > 1:
|
| 1016 |
+
series = 2
|
| 1017 |
+
else:
|
| 1018 |
+
series = 1
|
| 1019 |
+
if kwargs.get('verbose'):
|
| 1020 |
+
print("Meijer G m,n,p,q,series =", m,n,p,q,series)
|
| 1021 |
+
if series == 1:
|
| 1022 |
+
def h(*args):
|
| 1023 |
+
a = args[:p]
|
| 1024 |
+
b = args[p:]
|
| 1025 |
+
terms = []
|
| 1026 |
+
for k in range(m):
|
| 1027 |
+
bases = [z]
|
| 1028 |
+
expts = [b[k]/r]
|
| 1029 |
+
gn = [b[j]-b[k] for j in range(m) if j != k]
|
| 1030 |
+
gn += [1-a[j]+b[k] for j in range(n)]
|
| 1031 |
+
gd = [a[j]-b[k] for j in range(n,p)]
|
| 1032 |
+
gd += [1-b[j]+b[k] for j in range(m,q)]
|
| 1033 |
+
hn = [1-a[j]+b[k] for j in range(p)]
|
| 1034 |
+
hd = [1-b[j]+b[k] for j in range(q) if j != k]
|
| 1035 |
+
hz = (-ctx.one)**(p-m-n) * z**(ctx.one/r)
|
| 1036 |
+
terms.append((bases, expts, gn, gd, hn, hd, hz))
|
| 1037 |
+
return terms
|
| 1038 |
+
else:
|
| 1039 |
+
def h(*args):
|
| 1040 |
+
a = args[:p]
|
| 1041 |
+
b = args[p:]
|
| 1042 |
+
terms = []
|
| 1043 |
+
for k in range(n):
|
| 1044 |
+
bases = [z]
|
| 1045 |
+
if r == 1:
|
| 1046 |
+
expts = [a[k]-1]
|
| 1047 |
+
else:
|
| 1048 |
+
expts = [(a[k]-1)/ctx.convert(r)]
|
| 1049 |
+
gn = [a[k]-a[j] for j in range(n) if j != k]
|
| 1050 |
+
gn += [1-a[k]+b[j] for j in range(m)]
|
| 1051 |
+
gd = [a[k]-b[j] for j in range(m,q)]
|
| 1052 |
+
gd += [1-a[k]+a[j] for j in range(n,p)]
|
| 1053 |
+
hn = [1-a[k]+b[j] for j in range(q)]
|
| 1054 |
+
hd = [1+a[j]-a[k] for j in range(p) if j != k]
|
| 1055 |
+
hz = (-ctx.one)**(q-m-n) / z**(ctx.one/r)
|
| 1056 |
+
terms.append((bases, expts, gn, gd, hn, hd, hz))
|
| 1057 |
+
return terms
|
| 1058 |
+
return ctx.hypercomb(h, a+b, **kwargs)
|
| 1059 |
+
|
| 1060 |
+
@defun_wrapped
|
| 1061 |
+
def appellf1(ctx,a,b1,b2,c,x,y,**kwargs):
|
| 1062 |
+
# Assume x smaller
|
| 1063 |
+
# We will use x for the outer loop
|
| 1064 |
+
if abs(x) > abs(y):
|
| 1065 |
+
x, y = y, x
|
| 1066 |
+
b1, b2 = b2, b1
|
| 1067 |
+
def ok(x):
|
| 1068 |
+
return abs(x) < 0.99
|
| 1069 |
+
# Finite cases
|
| 1070 |
+
if ctx.isnpint(a):
|
| 1071 |
+
pass
|
| 1072 |
+
elif ctx.isnpint(b1):
|
| 1073 |
+
pass
|
| 1074 |
+
elif ctx.isnpint(b2):
|
| 1075 |
+
x, y, b1, b2 = y, x, b2, b1
|
| 1076 |
+
else:
|
| 1077 |
+
#print x, y
|
| 1078 |
+
# Note: ok if |y| > 1, because
|
| 1079 |
+
# 2F1 implements analytic continuation
|
| 1080 |
+
if not ok(x):
|
| 1081 |
+
u1 = (x-y)/(x-1)
|
| 1082 |
+
if not ok(u1):
|
| 1083 |
+
raise ValueError("Analytic continuation not implemented")
|
| 1084 |
+
#print "Using analytic continuation"
|
| 1085 |
+
return (1-x)**(-b1)*(1-y)**(c-a-b2)*\
|
| 1086 |
+
ctx.appellf1(c-a,b1,c-b1-b2,c,u1,y,**kwargs)
|
| 1087 |
+
return ctx.hyper2d({'m+n':[a],'m':[b1],'n':[b2]}, {'m+n':[c]}, x,y, **kwargs)
|
| 1088 |
+
|
| 1089 |
+
@defun
|
| 1090 |
+
def appellf2(ctx,a,b1,b2,c1,c2,x,y,**kwargs):
|
| 1091 |
+
# TODO: continuation
|
| 1092 |
+
return ctx.hyper2d({'m+n':[a],'m':[b1],'n':[b2]},
|
| 1093 |
+
{'m':[c1],'n':[c2]}, x,y, **kwargs)
|
| 1094 |
+
|
| 1095 |
+
@defun
|
| 1096 |
+
def appellf3(ctx,a1,a2,b1,b2,c,x,y,**kwargs):
|
| 1097 |
+
outer_polynomial = ctx.isnpint(a1) or ctx.isnpint(b1)
|
| 1098 |
+
inner_polynomial = ctx.isnpint(a2) or ctx.isnpint(b2)
|
| 1099 |
+
if not outer_polynomial:
|
| 1100 |
+
if inner_polynomial or abs(x) > abs(y):
|
| 1101 |
+
x, y = y, x
|
| 1102 |
+
a1,a2,b1,b2 = a2,a1,b2,b1
|
| 1103 |
+
return ctx.hyper2d({'m':[a1,b1],'n':[a2,b2]}, {'m+n':[c]},x,y,**kwargs)
|
| 1104 |
+
|
| 1105 |
+
@defun
|
| 1106 |
+
def appellf4(ctx,a,b,c1,c2,x,y,**kwargs):
|
| 1107 |
+
# TODO: continuation
|
| 1108 |
+
return ctx.hyper2d({'m+n':[a,b]}, {'m':[c1],'n':[c2]},x,y,**kwargs)
|
| 1109 |
+
|
| 1110 |
+
@defun
|
| 1111 |
+
def hyper2d(ctx, a, b, x, y, **kwargs):
|
| 1112 |
+
r"""
|
| 1113 |
+
Sums the generalized 2D hypergeometric series
|
| 1114 |
+
|
| 1115 |
+
.. math ::
|
| 1116 |
+
|
| 1117 |
+
\sum_{m=0}^{\infty} \sum_{n=0}^{\infty}
|
| 1118 |
+
\frac{P((a),m,n)}{Q((b),m,n)}
|
| 1119 |
+
\frac{x^m y^n} {m! n!}
|
| 1120 |
+
|
| 1121 |
+
where `(a) = (a_1,\ldots,a_r)`, `(b) = (b_1,\ldots,b_s)` and where
|
| 1122 |
+
`P` and `Q` are products of rising factorials such as `(a_j)_n` or
|
| 1123 |
+
`(a_j)_{m+n}`. `P` and `Q` are specified in the form of dicts, with
|
| 1124 |
+
the `m` and `n` dependence as keys and parameter lists as values.
|
| 1125 |
+
The supported rising factorials are given in the following table
|
| 1126 |
+
(note that only a few are supported in `Q`):
|
| 1127 |
+
|
| 1128 |
+
+------------+-------------------+--------+
|
| 1129 |
+
| Key | Rising factorial | `Q` |
|
| 1130 |
+
+============+===================+========+
|
| 1131 |
+
| ``'m'`` | `(a_j)_m` | Yes |
|
| 1132 |
+
+------------+-------------------+--------+
|
| 1133 |
+
| ``'n'`` | `(a_j)_n` | Yes |
|
| 1134 |
+
+------------+-------------------+--------+
|
| 1135 |
+
| ``'m+n'`` | `(a_j)_{m+n}` | Yes |
|
| 1136 |
+
+------------+-------------------+--------+
|
| 1137 |
+
| ``'m-n'`` | `(a_j)_{m-n}` | No |
|
| 1138 |
+
+------------+-------------------+--------+
|
| 1139 |
+
| ``'n-m'`` | `(a_j)_{n-m}` | No |
|
| 1140 |
+
+------------+-------------------+--------+
|
| 1141 |
+
| ``'2m+n'`` | `(a_j)_{2m+n}` | No |
|
| 1142 |
+
+------------+-------------------+--------+
|
| 1143 |
+
| ``'2m-n'`` | `(a_j)_{2m-n}` | No |
|
| 1144 |
+
+------------+-------------------+--------+
|
| 1145 |
+
| ``'2n-m'`` | `(a_j)_{2n-m}` | No |
|
| 1146 |
+
+------------+-------------------+--------+
|
| 1147 |
+
|
| 1148 |
+
For example, the Appell F1 and F4 functions
|
| 1149 |
+
|
| 1150 |
+
.. math ::
|
| 1151 |
+
|
| 1152 |
+
F_1 = \sum_{m=0}^{\infty} \sum_{n=0}^{\infty}
|
| 1153 |
+
\frac{(a)_{m+n} (b)_m (c)_n}{(d)_{m+n}}
|
| 1154 |
+
\frac{x^m y^n}{m! n!}
|
| 1155 |
+
|
| 1156 |
+
F_4 = \sum_{m=0}^{\infty} \sum_{n=0}^{\infty}
|
| 1157 |
+
\frac{(a)_{m+n} (b)_{m+n}}{(c)_m (d)_{n}}
|
| 1158 |
+
\frac{x^m y^n}{m! n!}
|
| 1159 |
+
|
| 1160 |
+
can be represented respectively as
|
| 1161 |
+
|
| 1162 |
+
``hyper2d({'m+n':[a], 'm':[b], 'n':[c]}, {'m+n':[d]}, x, y)``
|
| 1163 |
+
|
| 1164 |
+
``hyper2d({'m+n':[a,b]}, {'m':[c], 'n':[d]}, x, y)``
|
| 1165 |
+
|
| 1166 |
+
More generally, :func:`~mpmath.hyper2d` can evaluate any of the 34 distinct
|
| 1167 |
+
convergent second-order (generalized Gaussian) hypergeometric
|
| 1168 |
+
series enumerated by Horn, as well as the Kampe de Feriet
|
| 1169 |
+
function.
|
| 1170 |
+
|
| 1171 |
+
The series is computed by rewriting it so that the inner
|
| 1172 |
+
series (i.e. the series containing `n` and `y`) has the form of an
|
| 1173 |
+
ordinary generalized hypergeometric series and thereby can be
|
| 1174 |
+
evaluated efficiently using :func:`~mpmath.hyper`. If possible,
|
| 1175 |
+
manually swapping `x` and `y` and the corresponding parameters
|
| 1176 |
+
can sometimes give better results.
|
| 1177 |
+
|
| 1178 |
+
**Examples**
|
| 1179 |
+
|
| 1180 |
+
Two separable cases: a product of two geometric series, and a
|
| 1181 |
+
product of two Gaussian hypergeometric functions::
|
| 1182 |
+
|
| 1183 |
+
>>> from mpmath import *
|
| 1184 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 1185 |
+
>>> x, y = mpf(0.25), mpf(0.5)
|
| 1186 |
+
>>> hyper2d({'m':1,'n':1}, {}, x,y)
|
| 1187 |
+
2.666666666666666666666667
|
| 1188 |
+
>>> 1/(1-x)/(1-y)
|
| 1189 |
+
2.666666666666666666666667
|
| 1190 |
+
>>> hyper2d({'m':[1,2],'n':[3,4]}, {'m':[5],'n':[6]}, x,y)
|
| 1191 |
+
4.164358531238938319669856
|
| 1192 |
+
>>> hyp2f1(1,2,5,x)*hyp2f1(3,4,6,y)
|
| 1193 |
+
4.164358531238938319669856
|
| 1194 |
+
|
| 1195 |
+
Some more series that can be done in closed form::
|
| 1196 |
+
|
| 1197 |
+
>>> hyper2d({'m':1,'n':1},{'m+n':1},x,y)
|
| 1198 |
+
2.013417124712514809623881
|
| 1199 |
+
>>> (exp(x)*x-exp(y)*y)/(x-y)
|
| 1200 |
+
2.013417124712514809623881
|
| 1201 |
+
|
| 1202 |
+
Six of the 34 Horn functions, G1-G3 and H1-H3::
|
| 1203 |
+
|
| 1204 |
+
>>> from mpmath import *
|
| 1205 |
+
>>> mp.dps = 10; mp.pretty = True
|
| 1206 |
+
>>> x, y = 0.0625, 0.125
|
| 1207 |
+
>>> a1,a2,b1,b2,c1,c2,d = 1.1,-1.2,-1.3,-1.4,1.5,-1.6,1.7
|
| 1208 |
+
>>> hyper2d({'m+n':a1,'n-m':b1,'m-n':b2},{},x,y) # G1
|
| 1209 |
+
1.139090746
|
| 1210 |
+
>>> nsum(lambda m,n: rf(a1,m+n)*rf(b1,n-m)*rf(b2,m-n)*\
|
| 1211 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1212 |
+
1.139090746
|
| 1213 |
+
>>> hyper2d({'m':a1,'n':a2,'n-m':b1,'m-n':b2},{},x,y) # G2
|
| 1214 |
+
0.9503682696
|
| 1215 |
+
>>> nsum(lambda m,n: rf(a1,m)*rf(a2,n)*rf(b1,n-m)*rf(b2,m-n)*\
|
| 1216 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1217 |
+
0.9503682696
|
| 1218 |
+
>>> hyper2d({'2n-m':a1,'2m-n':a2},{},x,y) # G3
|
| 1219 |
+
1.029372029
|
| 1220 |
+
>>> nsum(lambda m,n: rf(a1,2*n-m)*rf(a2,2*m-n)*\
|
| 1221 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1222 |
+
1.029372029
|
| 1223 |
+
>>> hyper2d({'m-n':a1,'m+n':b1,'n':c1},{'m':d},x,y) # H1
|
| 1224 |
+
-1.605331256
|
| 1225 |
+
>>> nsum(lambda m,n: rf(a1,m-n)*rf(b1,m+n)*rf(c1,n)/rf(d,m)*\
|
| 1226 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1227 |
+
-1.605331256
|
| 1228 |
+
>>> hyper2d({'m-n':a1,'m':b1,'n':[c1,c2]},{'m':d},x,y) # H2
|
| 1229 |
+
-2.35405404
|
| 1230 |
+
>>> nsum(lambda m,n: rf(a1,m-n)*rf(b1,m)*rf(c1,n)*rf(c2,n)/rf(d,m)*\
|
| 1231 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1232 |
+
-2.35405404
|
| 1233 |
+
>>> hyper2d({'2m+n':a1,'n':b1},{'m+n':c1},x,y) # H3
|
| 1234 |
+
0.974479074
|
| 1235 |
+
>>> nsum(lambda m,n: rf(a1,2*m+n)*rf(b1,n)/rf(c1,m+n)*\
|
| 1236 |
+
... x**m*y**n/fac(m)/fac(n), [0,inf], [0,inf])
|
| 1237 |
+
0.974479074
|
| 1238 |
+
|
| 1239 |
+
**References**
|
| 1240 |
+
|
| 1241 |
+
1. [SrivastavaKarlsson]_
|
| 1242 |
+
2. [Weisstein]_ http://mathworld.wolfram.com/HornFunction.html
|
| 1243 |
+
3. [Weisstein]_ http://mathworld.wolfram.com/AppellHypergeometricFunction.html
|
| 1244 |
+
|
| 1245 |
+
"""
|
| 1246 |
+
x = ctx.convert(x)
|
| 1247 |
+
y = ctx.convert(y)
|
| 1248 |
+
def parse(dct, key):
|
| 1249 |
+
args = dct.pop(key, [])
|
| 1250 |
+
try:
|
| 1251 |
+
args = list(args)
|
| 1252 |
+
except TypeError:
|
| 1253 |
+
args = [args]
|
| 1254 |
+
return [ctx.convert(arg) for arg in args]
|
| 1255 |
+
a_s = dict(a)
|
| 1256 |
+
b_s = dict(b)
|
| 1257 |
+
a_m = parse(a, 'm')
|
| 1258 |
+
a_n = parse(a, 'n')
|
| 1259 |
+
a_m_add_n = parse(a, 'm+n')
|
| 1260 |
+
a_m_sub_n = parse(a, 'm-n')
|
| 1261 |
+
a_n_sub_m = parse(a, 'n-m')
|
| 1262 |
+
a_2m_add_n = parse(a, '2m+n')
|
| 1263 |
+
a_2m_sub_n = parse(a, '2m-n')
|
| 1264 |
+
a_2n_sub_m = parse(a, '2n-m')
|
| 1265 |
+
b_m = parse(b, 'm')
|
| 1266 |
+
b_n = parse(b, 'n')
|
| 1267 |
+
b_m_add_n = parse(b, 'm+n')
|
| 1268 |
+
if a: raise ValueError("unsupported key: %r" % a.keys()[0])
|
| 1269 |
+
if b: raise ValueError("unsupported key: %r" % b.keys()[0])
|
| 1270 |
+
s = 0
|
| 1271 |
+
outer = ctx.one
|
| 1272 |
+
m = ctx.mpf(0)
|
| 1273 |
+
ok_count = 0
|
| 1274 |
+
prec = ctx.prec
|
| 1275 |
+
maxterms = kwargs.get('maxterms', 20*prec)
|
| 1276 |
+
try:
|
| 1277 |
+
ctx.prec += 10
|
| 1278 |
+
tol = +ctx.eps
|
| 1279 |
+
while 1:
|
| 1280 |
+
inner_sign = 1
|
| 1281 |
+
outer_sign = 1
|
| 1282 |
+
inner_a = list(a_n)
|
| 1283 |
+
inner_b = list(b_n)
|
| 1284 |
+
outer_a = [a+m for a in a_m]
|
| 1285 |
+
outer_b = [b+m for b in b_m]
|
| 1286 |
+
# (a)_{m+n} = (a)_m (a+m)_n
|
| 1287 |
+
for a in a_m_add_n:
|
| 1288 |
+
a = a+m
|
| 1289 |
+
inner_a.append(a)
|
| 1290 |
+
outer_a.append(a)
|
| 1291 |
+
# (b)_{m+n} = (b)_m (b+m)_n
|
| 1292 |
+
for b in b_m_add_n:
|
| 1293 |
+
b = b+m
|
| 1294 |
+
inner_b.append(b)
|
| 1295 |
+
outer_b.append(b)
|
| 1296 |
+
# (a)_{n-m} = (a-m)_n / (a-m)_m
|
| 1297 |
+
for a in a_n_sub_m:
|
| 1298 |
+
inner_a.append(a-m)
|
| 1299 |
+
outer_b.append(a-m-1)
|
| 1300 |
+
# (a)_{m-n} = (-1)^(m+n) (1-a-m)_m / (1-a-m)_n
|
| 1301 |
+
for a in a_m_sub_n:
|
| 1302 |
+
inner_sign *= (-1)
|
| 1303 |
+
outer_sign *= (-1)**(m)
|
| 1304 |
+
inner_b.append(1-a-m)
|
| 1305 |
+
outer_a.append(-a-m)
|
| 1306 |
+
# (a)_{2m+n} = (a)_{2m} (a+2m)_n
|
| 1307 |
+
for a in a_2m_add_n:
|
| 1308 |
+
inner_a.append(a+2*m)
|
| 1309 |
+
outer_a.append((a+2*m)*(1+a+2*m))
|
| 1310 |
+
# (a)_{2m-n} = (-1)^(2m+n) (1-a-2m)_{2m} / (1-a-2m)_n
|
| 1311 |
+
for a in a_2m_sub_n:
|
| 1312 |
+
inner_sign *= (-1)
|
| 1313 |
+
inner_b.append(1-a-2*m)
|
| 1314 |
+
outer_a.append((a+2*m)*(1+a+2*m))
|
| 1315 |
+
# (a)_{2n-m} = 4^n ((a-m)/2)_n ((a-m+1)/2)_n / (a-m)_m
|
| 1316 |
+
for a in a_2n_sub_m:
|
| 1317 |
+
inner_sign *= 4
|
| 1318 |
+
inner_a.append(0.5*(a-m))
|
| 1319 |
+
inner_a.append(0.5*(a-m+1))
|
| 1320 |
+
outer_b.append(a-m-1)
|
| 1321 |
+
inner = ctx.hyper(inner_a, inner_b, inner_sign*y,
|
| 1322 |
+
zeroprec=ctx.prec, **kwargs)
|
| 1323 |
+
term = outer * inner * outer_sign
|
| 1324 |
+
if abs(term) < tol:
|
| 1325 |
+
ok_count += 1
|
| 1326 |
+
else:
|
| 1327 |
+
ok_count = 0
|
| 1328 |
+
if ok_count >= 3 or not outer:
|
| 1329 |
+
break
|
| 1330 |
+
s += term
|
| 1331 |
+
for a in outer_a: outer *= a
|
| 1332 |
+
for b in outer_b: outer /= b
|
| 1333 |
+
m += 1
|
| 1334 |
+
outer = outer * x / m
|
| 1335 |
+
if m > maxterms:
|
| 1336 |
+
raise ctx.NoConvergence("maxterms exceeded in hyper2d")
|
| 1337 |
+
finally:
|
| 1338 |
+
ctx.prec = prec
|
| 1339 |
+
return +s
|
| 1340 |
+
|
| 1341 |
+
"""
|
| 1342 |
+
@defun
|
| 1343 |
+
def kampe_de_feriet(ctx,a,b,c,d,e,f,x,y,**kwargs):
|
| 1344 |
+
return ctx.hyper2d({'m+n':a,'m':b,'n':c},
|
| 1345 |
+
{'m+n':d,'m':e,'n':f}, x,y, **kwargs)
|
| 1346 |
+
"""
|
| 1347 |
+
|
| 1348 |
+
@defun
|
| 1349 |
+
def bihyper(ctx, a_s, b_s, z, **kwargs):
|
| 1350 |
+
r"""
|
| 1351 |
+
Evaluates the bilateral hypergeometric series
|
| 1352 |
+
|
| 1353 |
+
.. math ::
|
| 1354 |
+
|
| 1355 |
+
\,_AH_B(a_1, \ldots, a_k; b_1, \ldots, b_B; z) =
|
| 1356 |
+
\sum_{n=-\infty}^{\infty}
|
| 1357 |
+
\frac{(a_1)_n \ldots (a_A)_n}
|
| 1358 |
+
{(b_1)_n \ldots (b_B)_n} \, z^n
|
| 1359 |
+
|
| 1360 |
+
where, for direct convergence, `A = B` and `|z| = 1`, although a
|
| 1361 |
+
regularized sum exists more generally by considering the
|
| 1362 |
+
bilateral series as a sum of two ordinary hypergeometric
|
| 1363 |
+
functions. In order for the series to make sense, none of the
|
| 1364 |
+
parameters may be integers.
|
| 1365 |
+
|
| 1366 |
+
**Examples**
|
| 1367 |
+
|
| 1368 |
+
The value of `\,_2H_2` at `z = 1` is given by Dougall's formula::
|
| 1369 |
+
|
| 1370 |
+
>>> from mpmath import *
|
| 1371 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 1372 |
+
>>> a,b,c,d = 0.5, 1.5, 2.25, 3.25
|
| 1373 |
+
>>> bihyper([a,b],[c,d],1)
|
| 1374 |
+
-14.49118026212345786148847
|
| 1375 |
+
>>> gammaprod([c,d,1-a,1-b,c+d-a-b-1],[c-a,d-a,c-b,d-b])
|
| 1376 |
+
-14.49118026212345786148847
|
| 1377 |
+
|
| 1378 |
+
The regularized function `\,_1H_0` can be expressed as the
|
| 1379 |
+
sum of one `\,_2F_0` function and one `\,_1F_1` function::
|
| 1380 |
+
|
| 1381 |
+
>>> a = mpf(0.25)
|
| 1382 |
+
>>> z = mpf(0.75)
|
| 1383 |
+
>>> bihyper([a], [], z)
|
| 1384 |
+
(0.2454393389657273841385582 + 0.2454393389657273841385582j)
|
| 1385 |
+
>>> hyper([a,1],[],z) + (hyper([1],[1-a],-1/z)-1)
|
| 1386 |
+
(0.2454393389657273841385582 + 0.2454393389657273841385582j)
|
| 1387 |
+
>>> hyper([a,1],[],z) + hyper([1],[2-a],-1/z)/z/(a-1)
|
| 1388 |
+
(0.2454393389657273841385582 + 0.2454393389657273841385582j)
|
| 1389 |
+
|
| 1390 |
+
**References**
|
| 1391 |
+
|
| 1392 |
+
1. [Slater]_ (chapter 6: "Bilateral Series", pp. 180-189)
|
| 1393 |
+
2. [Wikipedia]_ http://en.wikipedia.org/wiki/Bilateral_hypergeometric_series
|
| 1394 |
+
|
| 1395 |
+
"""
|
| 1396 |
+
z = ctx.convert(z)
|
| 1397 |
+
c_s = a_s + b_s
|
| 1398 |
+
p = len(a_s)
|
| 1399 |
+
q = len(b_s)
|
| 1400 |
+
if (p, q) == (0,0) or (p, q) == (1,1):
|
| 1401 |
+
return ctx.zero * z
|
| 1402 |
+
neg = (p-q) % 2
|
| 1403 |
+
def h(*c_s):
|
| 1404 |
+
a_s = list(c_s[:p])
|
| 1405 |
+
b_s = list(c_s[p:])
|
| 1406 |
+
aa_s = [2-b for b in b_s]
|
| 1407 |
+
bb_s = [2-a for a in a_s]
|
| 1408 |
+
rp = [(-1)**neg * z] + [1-b for b in b_s] + [1-a for a in a_s]
|
| 1409 |
+
rc = [-1] + [1]*len(b_s) + [-1]*len(a_s)
|
| 1410 |
+
T1 = [], [], [], [], a_s + [1], b_s, z
|
| 1411 |
+
T2 = rp, rc, [], [], aa_s + [1], bb_s, (-1)**neg / z
|
| 1412 |
+
return T1, T2
|
| 1413 |
+
return ctx.hypercomb(h, c_s, **kwargs)
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/theta.py
ADDED
|
@@ -0,0 +1,1049 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 = 20
|
| 7 |
+
# the loops below break when the fixed precision quantities
|
| 8 |
+
# a and b go to zero;
|
| 9 |
+
# right shifting small negative numbers by wp one obtains -1, not zero,
|
| 10 |
+
# so the condition a**2 + b**2 > MIN is used to break the loops.
|
| 11 |
+
MIN = 2
|
| 12 |
+
if z == ctx.zero:
|
| 13 |
+
if (not ctx._im(q)):
|
| 14 |
+
wp = ctx.prec + extra1
|
| 15 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 16 |
+
x2 = (x*x) >> wp
|
| 17 |
+
a = b = x2
|
| 18 |
+
s = x2
|
| 19 |
+
while abs(a) > MIN:
|
| 20 |
+
b = (b*x2) >> wp
|
| 21 |
+
a = (a*b) >> wp
|
| 22 |
+
s += a
|
| 23 |
+
s = (1 << (wp+1)) + (s << 1)
|
| 24 |
+
s = ctx.ldexp(s, -wp)
|
| 25 |
+
else:
|
| 26 |
+
wp = ctx.prec + extra1
|
| 27 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 28 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 29 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 30 |
+
x2im = (xre*xim) >> (wp-1)
|
| 31 |
+
are = bre = x2re
|
| 32 |
+
aim = bim = x2im
|
| 33 |
+
sre = (1<<wp) + are
|
| 34 |
+
sim = aim
|
| 35 |
+
while are**2 + aim**2 > MIN:
|
| 36 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 37 |
+
(bre * x2im + bim * x2re) >> wp
|
| 38 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 39 |
+
(are * bim + aim * bre) >> wp
|
| 40 |
+
sre += are
|
| 41 |
+
sim += aim
|
| 42 |
+
sre = (sre << 1)
|
| 43 |
+
sim = (sim << 1)
|
| 44 |
+
sre = ctx.ldexp(sre, -wp)
|
| 45 |
+
sim = ctx.ldexp(sim, -wp)
|
| 46 |
+
s = ctx.mpc(sre, sim)
|
| 47 |
+
else:
|
| 48 |
+
if (not ctx._im(q)) and (not ctx._im(z)):
|
| 49 |
+
wp = ctx.prec + extra1
|
| 50 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 51 |
+
x2 = (x*x) >> wp
|
| 52 |
+
a = b = x2
|
| 53 |
+
c1, s1 = ctx.cos_sin(ctx._re(z), prec=wp)
|
| 54 |
+
cn = c1 = ctx.to_fixed(c1, wp)
|
| 55 |
+
sn = s1 = ctx.to_fixed(s1, wp)
|
| 56 |
+
c2 = (c1*c1 - s1*s1) >> wp
|
| 57 |
+
s2 = (c1 * s1) >> (wp - 1)
|
| 58 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 59 |
+
s = c1 + ((a * cn) >> wp)
|
| 60 |
+
while abs(a) > MIN:
|
| 61 |
+
b = (b*x2) >> wp
|
| 62 |
+
a = (a*b) >> wp
|
| 63 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 64 |
+
s += (a * cn) >> wp
|
| 65 |
+
s = (s << 1)
|
| 66 |
+
s = ctx.ldexp(s, -wp)
|
| 67 |
+
s *= ctx.nthroot(q, 4)
|
| 68 |
+
return s
|
| 69 |
+
# case z real, q complex
|
| 70 |
+
elif not ctx._im(z):
|
| 71 |
+
wp = ctx.prec + extra2
|
| 72 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 73 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 74 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 75 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 76 |
+
are = bre = x2re
|
| 77 |
+
aim = bim = x2im
|
| 78 |
+
c1, s1 = ctx.cos_sin(ctx._re(z), prec=wp)
|
| 79 |
+
cn = c1 = ctx.to_fixed(c1, wp)
|
| 80 |
+
sn = s1 = ctx.to_fixed(s1, wp)
|
| 81 |
+
c2 = (c1*c1 - s1*s1) >> wp
|
| 82 |
+
s2 = (c1 * s1) >> (wp - 1)
|
| 83 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 84 |
+
sre = c1 + ((are * cn) >> wp)
|
| 85 |
+
sim = ((aim * cn) >> wp)
|
| 86 |
+
while are**2 + aim**2 > MIN:
|
| 87 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 88 |
+
(bre * x2im + bim * x2re) >> wp
|
| 89 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 90 |
+
(are * bim + aim * bre) >> wp
|
| 91 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 92 |
+
sre += ((are * cn) >> wp)
|
| 93 |
+
sim += ((aim * cn) >> wp)
|
| 94 |
+
sre = (sre << 1)
|
| 95 |
+
sim = (sim << 1)
|
| 96 |
+
sre = ctx.ldexp(sre, -wp)
|
| 97 |
+
sim = ctx.ldexp(sim, -wp)
|
| 98 |
+
s = ctx.mpc(sre, sim)
|
| 99 |
+
#case z complex, q real
|
| 100 |
+
elif not ctx._im(q):
|
| 101 |
+
wp = ctx.prec + extra2
|
| 102 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 103 |
+
x2 = (x*x) >> wp
|
| 104 |
+
a = b = x2
|
| 105 |
+
prec0 = ctx.prec
|
| 106 |
+
ctx.prec = wp
|
| 107 |
+
c1, s1 = ctx.cos_sin(z)
|
| 108 |
+
ctx.prec = prec0
|
| 109 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 110 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 111 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 112 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 113 |
+
#c2 = (c1*c1 - s1*s1) >> wp
|
| 114 |
+
c2re = (c1re*c1re - c1im*c1im - s1re*s1re + s1im*s1im) >> wp
|
| 115 |
+
c2im = (c1re*c1im - s1re*s1im) >> (wp - 1)
|
| 116 |
+
#s2 = (c1 * s1) >> (wp - 1)
|
| 117 |
+
s2re = (c1re*s1re - c1im*s1im) >> (wp - 1)
|
| 118 |
+
s2im = (c1re*s1im + c1im*s1re) >> (wp - 1)
|
| 119 |
+
#cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 120 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 121 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 122 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 123 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 124 |
+
cnre = t1
|
| 125 |
+
cnim = t2
|
| 126 |
+
snre = t3
|
| 127 |
+
snim = t4
|
| 128 |
+
sre = c1re + ((a * cnre) >> wp)
|
| 129 |
+
sim = c1im + ((a * cnim) >> wp)
|
| 130 |
+
while abs(a) > MIN:
|
| 131 |
+
b = (b*x2) >> wp
|
| 132 |
+
a = (a*b) >> wp
|
| 133 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 134 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 135 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 136 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 137 |
+
cnre = t1
|
| 138 |
+
cnim = t2
|
| 139 |
+
snre = t3
|
| 140 |
+
snim = t4
|
| 141 |
+
sre += ((a * cnre) >> wp)
|
| 142 |
+
sim += ((a * cnim) >> wp)
|
| 143 |
+
sre = (sre << 1)
|
| 144 |
+
sim = (sim << 1)
|
| 145 |
+
sre = ctx.ldexp(sre, -wp)
|
| 146 |
+
sim = ctx.ldexp(sim, -wp)
|
| 147 |
+
s = ctx.mpc(sre, sim)
|
| 148 |
+
# case z and q complex
|
| 149 |
+
else:
|
| 150 |
+
wp = ctx.prec + extra2
|
| 151 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 152 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 153 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 154 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 155 |
+
are = bre = x2re
|
| 156 |
+
aim = bim = x2im
|
| 157 |
+
prec0 = ctx.prec
|
| 158 |
+
ctx.prec = wp
|
| 159 |
+
# cos(z), sin(z) with z complex
|
| 160 |
+
c1, s1 = ctx.cos_sin(z)
|
| 161 |
+
ctx.prec = prec0
|
| 162 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 163 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 164 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 165 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 166 |
+
c2re = (c1re*c1re - c1im*c1im - s1re*s1re + s1im*s1im) >> wp
|
| 167 |
+
c2im = (c1re*c1im - s1re*s1im) >> (wp - 1)
|
| 168 |
+
s2re = (c1re*s1re - c1im*s1im) >> (wp - 1)
|
| 169 |
+
s2im = (c1re*s1im + c1im*s1re) >> (wp - 1)
|
| 170 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 171 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 172 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 173 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 174 |
+
cnre = t1
|
| 175 |
+
cnim = t2
|
| 176 |
+
snre = t3
|
| 177 |
+
snim = t4
|
| 178 |
+
n = 1
|
| 179 |
+
termre = c1re
|
| 180 |
+
termim = c1im
|
| 181 |
+
sre = c1re + ((are * cnre - aim * cnim) >> wp)
|
| 182 |
+
sim = c1im + ((are * cnim + aim * cnre) >> wp)
|
| 183 |
+
n = 3
|
| 184 |
+
termre = ((are * cnre - aim * cnim) >> wp)
|
| 185 |
+
termim = ((are * cnim + aim * cnre) >> wp)
|
| 186 |
+
sre = c1re + ((are * cnre - aim * cnim) >> wp)
|
| 187 |
+
sim = c1im + ((are * cnim + aim * cnre) >> wp)
|
| 188 |
+
n = 5
|
| 189 |
+
while are**2 + aim**2 > MIN:
|
| 190 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 191 |
+
(bre * x2im + bim * x2re) >> wp
|
| 192 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 193 |
+
(are * bim + aim * bre) >> wp
|
| 194 |
+
#cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 195 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 196 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 197 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 198 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 199 |
+
cnre = t1
|
| 200 |
+
cnim = t2
|
| 201 |
+
snre = t3
|
| 202 |
+
snim = t4
|
| 203 |
+
termre = ((are * cnre - aim * cnim) >> wp)
|
| 204 |
+
termim = ((aim * cnre + are * cnim) >> wp)
|
| 205 |
+
sre += ((are * cnre - aim * cnim) >> wp)
|
| 206 |
+
sim += ((aim * cnre + are * cnim) >> wp)
|
| 207 |
+
n += 2
|
| 208 |
+
sre = (sre << 1)
|
| 209 |
+
sim = (sim << 1)
|
| 210 |
+
sre = ctx.ldexp(sre, -wp)
|
| 211 |
+
sim = ctx.ldexp(sim, -wp)
|
| 212 |
+
s = ctx.mpc(sre, sim)
|
| 213 |
+
s *= ctx.nthroot(q, 4)
|
| 214 |
+
return s
|
| 215 |
+
|
| 216 |
+
@defun
|
| 217 |
+
def _djacobi_theta2(ctx, z, q, nd):
|
| 218 |
+
MIN = 2
|
| 219 |
+
extra1 = 10
|
| 220 |
+
extra2 = 20
|
| 221 |
+
if (not ctx._im(q)) and (not ctx._im(z)):
|
| 222 |
+
wp = ctx.prec + extra1
|
| 223 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 224 |
+
x2 = (x*x) >> wp
|
| 225 |
+
a = b = x2
|
| 226 |
+
c1, s1 = ctx.cos_sin(ctx._re(z), prec=wp)
|
| 227 |
+
cn = c1 = ctx.to_fixed(c1, wp)
|
| 228 |
+
sn = s1 = ctx.to_fixed(s1, wp)
|
| 229 |
+
c2 = (c1*c1 - s1*s1) >> wp
|
| 230 |
+
s2 = (c1 * s1) >> (wp - 1)
|
| 231 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 232 |
+
if (nd&1):
|
| 233 |
+
s = s1 + ((a * sn * 3**nd) >> wp)
|
| 234 |
+
else:
|
| 235 |
+
s = c1 + ((a * cn * 3**nd) >> wp)
|
| 236 |
+
n = 2
|
| 237 |
+
while abs(a) > MIN:
|
| 238 |
+
b = (b*x2) >> wp
|
| 239 |
+
a = (a*b) >> wp
|
| 240 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 241 |
+
if nd&1:
|
| 242 |
+
s += (a * sn * (2*n+1)**nd) >> wp
|
| 243 |
+
else:
|
| 244 |
+
s += (a * cn * (2*n+1)**nd) >> wp
|
| 245 |
+
n += 1
|
| 246 |
+
s = -(s << 1)
|
| 247 |
+
s = ctx.ldexp(s, -wp)
|
| 248 |
+
# case z real, q complex
|
| 249 |
+
elif not ctx._im(z):
|
| 250 |
+
wp = ctx.prec + extra2
|
| 251 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 252 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 253 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 254 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 255 |
+
are = bre = x2re
|
| 256 |
+
aim = bim = x2im
|
| 257 |
+
c1, s1 = ctx.cos_sin(ctx._re(z), prec=wp)
|
| 258 |
+
cn = c1 = ctx.to_fixed(c1, wp)
|
| 259 |
+
sn = s1 = ctx.to_fixed(s1, wp)
|
| 260 |
+
c2 = (c1*c1 - s1*s1) >> wp
|
| 261 |
+
s2 = (c1 * s1) >> (wp - 1)
|
| 262 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 263 |
+
if (nd&1):
|
| 264 |
+
sre = s1 + ((are * sn * 3**nd) >> wp)
|
| 265 |
+
sim = ((aim * sn * 3**nd) >> wp)
|
| 266 |
+
else:
|
| 267 |
+
sre = c1 + ((are * cn * 3**nd) >> wp)
|
| 268 |
+
sim = ((aim * cn * 3**nd) >> wp)
|
| 269 |
+
n = 5
|
| 270 |
+
while are**2 + aim**2 > MIN:
|
| 271 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 272 |
+
(bre * x2im + bim * x2re) >> wp
|
| 273 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 274 |
+
(are * bim + aim * bre) >> wp
|
| 275 |
+
cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 276 |
+
|
| 277 |
+
if (nd&1):
|
| 278 |
+
sre += ((are * sn * n**nd) >> wp)
|
| 279 |
+
sim += ((aim * sn * n**nd) >> wp)
|
| 280 |
+
else:
|
| 281 |
+
sre += ((are * cn * n**nd) >> wp)
|
| 282 |
+
sim += ((aim * cn * n**nd) >> wp)
|
| 283 |
+
n += 2
|
| 284 |
+
sre = -(sre << 1)
|
| 285 |
+
sim = -(sim << 1)
|
| 286 |
+
sre = ctx.ldexp(sre, -wp)
|
| 287 |
+
sim = ctx.ldexp(sim, -wp)
|
| 288 |
+
s = ctx.mpc(sre, sim)
|
| 289 |
+
#case z complex, q real
|
| 290 |
+
elif not ctx._im(q):
|
| 291 |
+
wp = ctx.prec + extra2
|
| 292 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 293 |
+
x2 = (x*x) >> wp
|
| 294 |
+
a = b = x2
|
| 295 |
+
prec0 = ctx.prec
|
| 296 |
+
ctx.prec = wp
|
| 297 |
+
c1, s1 = ctx.cos_sin(z)
|
| 298 |
+
ctx.prec = prec0
|
| 299 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 300 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 301 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 302 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 303 |
+
#c2 = (c1*c1 - s1*s1) >> wp
|
| 304 |
+
c2re = (c1re*c1re - c1im*c1im - s1re*s1re + s1im*s1im) >> wp
|
| 305 |
+
c2im = (c1re*c1im - s1re*s1im) >> (wp - 1)
|
| 306 |
+
#s2 = (c1 * s1) >> (wp - 1)
|
| 307 |
+
s2re = (c1re*s1re - c1im*s1im) >> (wp - 1)
|
| 308 |
+
s2im = (c1re*s1im + c1im*s1re) >> (wp - 1)
|
| 309 |
+
#cn, sn = (cn*c2 - sn*s2) >> wp, (sn*c2 + cn*s2) >> wp
|
| 310 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 311 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 312 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 313 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 314 |
+
cnre = t1
|
| 315 |
+
cnim = t2
|
| 316 |
+
snre = t3
|
| 317 |
+
snim = t4
|
| 318 |
+
if (nd&1):
|
| 319 |
+
sre = s1re + ((a * snre * 3**nd) >> wp)
|
| 320 |
+
sim = s1im + ((a * snim * 3**nd) >> wp)
|
| 321 |
+
else:
|
| 322 |
+
sre = c1re + ((a * cnre * 3**nd) >> wp)
|
| 323 |
+
sim = c1im + ((a * cnim * 3**nd) >> wp)
|
| 324 |
+
n = 5
|
| 325 |
+
while abs(a) > MIN:
|
| 326 |
+
b = (b*x2) >> wp
|
| 327 |
+
a = (a*b) >> wp
|
| 328 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 329 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 330 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 331 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 332 |
+
cnre = t1
|
| 333 |
+
cnim = t2
|
| 334 |
+
snre = t3
|
| 335 |
+
snim = t4
|
| 336 |
+
if (nd&1):
|
| 337 |
+
sre += ((a * snre * n**nd) >> wp)
|
| 338 |
+
sim += ((a * snim * n**nd) >> wp)
|
| 339 |
+
else:
|
| 340 |
+
sre += ((a * cnre * n**nd) >> wp)
|
| 341 |
+
sim += ((a * cnim * n**nd) >> wp)
|
| 342 |
+
n += 2
|
| 343 |
+
sre = -(sre << 1)
|
| 344 |
+
sim = -(sim << 1)
|
| 345 |
+
sre = ctx.ldexp(sre, -wp)
|
| 346 |
+
sim = ctx.ldexp(sim, -wp)
|
| 347 |
+
s = ctx.mpc(sre, sim)
|
| 348 |
+
# case z and q complex
|
| 349 |
+
else:
|
| 350 |
+
wp = ctx.prec + extra2
|
| 351 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 352 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 353 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 354 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 355 |
+
are = bre = x2re
|
| 356 |
+
aim = bim = x2im
|
| 357 |
+
prec0 = ctx.prec
|
| 358 |
+
ctx.prec = wp
|
| 359 |
+
# cos(2*z), sin(2*z) with z complex
|
| 360 |
+
c1, s1 = ctx.cos_sin(z)
|
| 361 |
+
ctx.prec = prec0
|
| 362 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 363 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 364 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 365 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 366 |
+
c2re = (c1re*c1re - c1im*c1im - s1re*s1re + s1im*s1im) >> wp
|
| 367 |
+
c2im = (c1re*c1im - s1re*s1im) >> (wp - 1)
|
| 368 |
+
s2re = (c1re*s1re - c1im*s1im) >> (wp - 1)
|
| 369 |
+
s2im = (c1re*s1im + c1im*s1re) >> (wp - 1)
|
| 370 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 371 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 372 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 373 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 374 |
+
cnre = t1
|
| 375 |
+
cnim = t2
|
| 376 |
+
snre = t3
|
| 377 |
+
snim = t4
|
| 378 |
+
if (nd&1):
|
| 379 |
+
sre = s1re + (((are * snre - aim * snim) * 3**nd) >> wp)
|
| 380 |
+
sim = s1im + (((are * snim + aim * snre)* 3**nd) >> wp)
|
| 381 |
+
else:
|
| 382 |
+
sre = c1re + (((are * cnre - aim * cnim) * 3**nd) >> wp)
|
| 383 |
+
sim = c1im + (((are * cnim + aim * cnre)* 3**nd) >> wp)
|
| 384 |
+
n = 5
|
| 385 |
+
while are**2 + aim**2 > MIN:
|
| 386 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 387 |
+
(bre * x2im + bim * x2re) >> wp
|
| 388 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 389 |
+
(are * bim + aim * bre) >> wp
|
| 390 |
+
#cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 391 |
+
t1 = (cnre*c2re - cnim*c2im - snre*s2re + snim*s2im) >> wp
|
| 392 |
+
t2 = (cnre*c2im + cnim*c2re - snre*s2im - snim*s2re) >> wp
|
| 393 |
+
t3 = (snre*c2re - snim*c2im + cnre*s2re - cnim*s2im) >> wp
|
| 394 |
+
t4 = (snre*c2im + snim*c2re + cnre*s2im + cnim*s2re) >> wp
|
| 395 |
+
cnre = t1
|
| 396 |
+
cnim = t2
|
| 397 |
+
snre = t3
|
| 398 |
+
snim = t4
|
| 399 |
+
if (nd&1):
|
| 400 |
+
sre += (((are * snre - aim * snim) * n**nd) >> wp)
|
| 401 |
+
sim += (((aim * snre + are * snim) * n**nd) >> wp)
|
| 402 |
+
else:
|
| 403 |
+
sre += (((are * cnre - aim * cnim) * n**nd) >> wp)
|
| 404 |
+
sim += (((aim * cnre + are * cnim) * n**nd) >> wp)
|
| 405 |
+
n += 2
|
| 406 |
+
sre = -(sre << 1)
|
| 407 |
+
sim = -(sim << 1)
|
| 408 |
+
sre = ctx.ldexp(sre, -wp)
|
| 409 |
+
sim = ctx.ldexp(sim, -wp)
|
| 410 |
+
s = ctx.mpc(sre, sim)
|
| 411 |
+
s *= ctx.nthroot(q, 4)
|
| 412 |
+
if (nd&1):
|
| 413 |
+
return (-1)**(nd//2) * s
|
| 414 |
+
else:
|
| 415 |
+
return (-1)**(1 + nd//2) * s
|
| 416 |
+
|
| 417 |
+
@defun
|
| 418 |
+
def _jacobi_theta3(ctx, z, q):
|
| 419 |
+
extra1 = 10
|
| 420 |
+
extra2 = 20
|
| 421 |
+
MIN = 2
|
| 422 |
+
if z == ctx.zero:
|
| 423 |
+
if not ctx._im(q):
|
| 424 |
+
wp = ctx.prec + extra1
|
| 425 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 426 |
+
s = x
|
| 427 |
+
a = b = x
|
| 428 |
+
x2 = (x*x) >> wp
|
| 429 |
+
while abs(a) > MIN:
|
| 430 |
+
b = (b*x2) >> wp
|
| 431 |
+
a = (a*b) >> wp
|
| 432 |
+
s += a
|
| 433 |
+
s = (1 << wp) + (s << 1)
|
| 434 |
+
s = ctx.ldexp(s, -wp)
|
| 435 |
+
return s
|
| 436 |
+
else:
|
| 437 |
+
wp = ctx.prec + extra1
|
| 438 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 439 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 440 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 441 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 442 |
+
sre = are = bre = xre
|
| 443 |
+
sim = aim = bim = xim
|
| 444 |
+
while are**2 + aim**2 > MIN:
|
| 445 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 446 |
+
(bre * x2im + bim * x2re) >> wp
|
| 447 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 448 |
+
(are * bim + aim * bre) >> wp
|
| 449 |
+
sre += are
|
| 450 |
+
sim += aim
|
| 451 |
+
sre = (1 << wp) + (sre << 1)
|
| 452 |
+
sim = (sim << 1)
|
| 453 |
+
sre = ctx.ldexp(sre, -wp)
|
| 454 |
+
sim = ctx.ldexp(sim, -wp)
|
| 455 |
+
s = ctx.mpc(sre, sim)
|
| 456 |
+
return s
|
| 457 |
+
else:
|
| 458 |
+
if (not ctx._im(q)) and (not ctx._im(z)):
|
| 459 |
+
s = 0
|
| 460 |
+
wp = ctx.prec + extra1
|
| 461 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 462 |
+
a = b = x
|
| 463 |
+
x2 = (x*x) >> wp
|
| 464 |
+
c1, s1 = ctx.cos_sin(ctx._re(z)*2, prec=wp)
|
| 465 |
+
c1 = ctx.to_fixed(c1, wp)
|
| 466 |
+
s1 = ctx.to_fixed(s1, wp)
|
| 467 |
+
cn = c1
|
| 468 |
+
sn = s1
|
| 469 |
+
s += (a * cn) >> wp
|
| 470 |
+
while abs(a) > MIN:
|
| 471 |
+
b = (b*x2) >> wp
|
| 472 |
+
a = (a*b) >> wp
|
| 473 |
+
cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 474 |
+
s += (a * cn) >> wp
|
| 475 |
+
s = (1 << wp) + (s << 1)
|
| 476 |
+
s = ctx.ldexp(s, -wp)
|
| 477 |
+
return s
|
| 478 |
+
# case z real, q complex
|
| 479 |
+
elif not ctx._im(z):
|
| 480 |
+
wp = ctx.prec + extra2
|
| 481 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 482 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 483 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 484 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 485 |
+
are = bre = xre
|
| 486 |
+
aim = bim = xim
|
| 487 |
+
c1, s1 = ctx.cos_sin(ctx._re(z)*2, prec=wp)
|
| 488 |
+
c1 = ctx.to_fixed(c1, wp)
|
| 489 |
+
s1 = ctx.to_fixed(s1, wp)
|
| 490 |
+
cn = c1
|
| 491 |
+
sn = s1
|
| 492 |
+
sre = (are * cn) >> wp
|
| 493 |
+
sim = (aim * cn) >> wp
|
| 494 |
+
while are**2 + aim**2 > MIN:
|
| 495 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 496 |
+
(bre * x2im + bim * x2re) >> wp
|
| 497 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 498 |
+
(are * bim + aim * bre) >> wp
|
| 499 |
+
cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 500 |
+
sre += (are * cn) >> wp
|
| 501 |
+
sim += (aim * cn) >> wp
|
| 502 |
+
sre = (1 << wp) + (sre << 1)
|
| 503 |
+
sim = (sim << 1)
|
| 504 |
+
sre = ctx.ldexp(sre, -wp)
|
| 505 |
+
sim = ctx.ldexp(sim, -wp)
|
| 506 |
+
s = ctx.mpc(sre, sim)
|
| 507 |
+
return s
|
| 508 |
+
#case z complex, q real
|
| 509 |
+
elif not ctx._im(q):
|
| 510 |
+
wp = ctx.prec + extra2
|
| 511 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 512 |
+
a = b = x
|
| 513 |
+
x2 = (x*x) >> wp
|
| 514 |
+
prec0 = ctx.prec
|
| 515 |
+
ctx.prec = wp
|
| 516 |
+
c1, s1 = ctx.cos_sin(2*z)
|
| 517 |
+
ctx.prec = prec0
|
| 518 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 519 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 520 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 521 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 522 |
+
sre = (a * cnre) >> wp
|
| 523 |
+
sim = (a * cnim) >> wp
|
| 524 |
+
while abs(a) > MIN:
|
| 525 |
+
b = (b*x2) >> wp
|
| 526 |
+
a = (a*b) >> wp
|
| 527 |
+
t1 = (cnre*c1re - cnim*c1im - snre*s1re + snim*s1im) >> wp
|
| 528 |
+
t2 = (cnre*c1im + cnim*c1re - snre*s1im - snim*s1re) >> wp
|
| 529 |
+
t3 = (snre*c1re - snim*c1im + cnre*s1re - cnim*s1im) >> wp
|
| 530 |
+
t4 = (snre*c1im + snim*c1re + cnre*s1im + cnim*s1re) >> wp
|
| 531 |
+
cnre = t1
|
| 532 |
+
cnim = t2
|
| 533 |
+
snre = t3
|
| 534 |
+
snim = t4
|
| 535 |
+
sre += (a * cnre) >> wp
|
| 536 |
+
sim += (a * cnim) >> wp
|
| 537 |
+
sre = (1 << wp) + (sre << 1)
|
| 538 |
+
sim = (sim << 1)
|
| 539 |
+
sre = ctx.ldexp(sre, -wp)
|
| 540 |
+
sim = ctx.ldexp(sim, -wp)
|
| 541 |
+
s = ctx.mpc(sre, sim)
|
| 542 |
+
return s
|
| 543 |
+
# case z and q complex
|
| 544 |
+
else:
|
| 545 |
+
wp = ctx.prec + extra2
|
| 546 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 547 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 548 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 549 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 550 |
+
are = bre = xre
|
| 551 |
+
aim = bim = xim
|
| 552 |
+
prec0 = ctx.prec
|
| 553 |
+
ctx.prec = wp
|
| 554 |
+
# cos(2*z), sin(2*z) with z complex
|
| 555 |
+
c1, s1 = ctx.cos_sin(2*z)
|
| 556 |
+
ctx.prec = prec0
|
| 557 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 558 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 559 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 560 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 561 |
+
sre = (are * cnre - aim * cnim) >> wp
|
| 562 |
+
sim = (aim * cnre + are * cnim) >> wp
|
| 563 |
+
while are**2 + aim**2 > MIN:
|
| 564 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 565 |
+
(bre * x2im + bim * x2re) >> wp
|
| 566 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 567 |
+
(are * bim + aim * bre) >> wp
|
| 568 |
+
t1 = (cnre*c1re - cnim*c1im - snre*s1re + snim*s1im) >> wp
|
| 569 |
+
t2 = (cnre*c1im + cnim*c1re - snre*s1im - snim*s1re) >> wp
|
| 570 |
+
t3 = (snre*c1re - snim*c1im + cnre*s1re - cnim*s1im) >> wp
|
| 571 |
+
t4 = (snre*c1im + snim*c1re + cnre*s1im + cnim*s1re) >> wp
|
| 572 |
+
cnre = t1
|
| 573 |
+
cnim = t2
|
| 574 |
+
snre = t3
|
| 575 |
+
snim = t4
|
| 576 |
+
sre += (are * cnre - aim * cnim) >> wp
|
| 577 |
+
sim += (aim * cnre + are * cnim) >> wp
|
| 578 |
+
sre = (1 << wp) + (sre << 1)
|
| 579 |
+
sim = (sim << 1)
|
| 580 |
+
sre = ctx.ldexp(sre, -wp)
|
| 581 |
+
sim = ctx.ldexp(sim, -wp)
|
| 582 |
+
s = ctx.mpc(sre, sim)
|
| 583 |
+
return s
|
| 584 |
+
|
| 585 |
+
@defun
|
| 586 |
+
def _djacobi_theta3(ctx, z, q, nd):
|
| 587 |
+
"""nd=1,2,3 order of the derivative with respect to z"""
|
| 588 |
+
MIN = 2
|
| 589 |
+
extra1 = 10
|
| 590 |
+
extra2 = 20
|
| 591 |
+
if (not ctx._im(q)) and (not ctx._im(z)):
|
| 592 |
+
s = 0
|
| 593 |
+
wp = ctx.prec + extra1
|
| 594 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 595 |
+
a = b = x
|
| 596 |
+
x2 = (x*x) >> wp
|
| 597 |
+
c1, s1 = ctx.cos_sin(ctx._re(z)*2, prec=wp)
|
| 598 |
+
c1 = ctx.to_fixed(c1, wp)
|
| 599 |
+
s1 = ctx.to_fixed(s1, wp)
|
| 600 |
+
cn = c1
|
| 601 |
+
sn = s1
|
| 602 |
+
if (nd&1):
|
| 603 |
+
s += (a * sn) >> wp
|
| 604 |
+
else:
|
| 605 |
+
s += (a * cn) >> wp
|
| 606 |
+
n = 2
|
| 607 |
+
while abs(a) > MIN:
|
| 608 |
+
b = (b*x2) >> wp
|
| 609 |
+
a = (a*b) >> wp
|
| 610 |
+
cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 611 |
+
if nd&1:
|
| 612 |
+
s += (a * sn * n**nd) >> wp
|
| 613 |
+
else:
|
| 614 |
+
s += (a * cn * n**nd) >> wp
|
| 615 |
+
n += 1
|
| 616 |
+
s = -(s << (nd+1))
|
| 617 |
+
s = ctx.ldexp(s, -wp)
|
| 618 |
+
# case z real, q complex
|
| 619 |
+
elif not ctx._im(z):
|
| 620 |
+
wp = ctx.prec + extra2
|
| 621 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 622 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 623 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 624 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 625 |
+
are = bre = xre
|
| 626 |
+
aim = bim = xim
|
| 627 |
+
c1, s1 = ctx.cos_sin(ctx._re(z)*2, prec=wp)
|
| 628 |
+
c1 = ctx.to_fixed(c1, wp)
|
| 629 |
+
s1 = ctx.to_fixed(s1, wp)
|
| 630 |
+
cn = c1
|
| 631 |
+
sn = s1
|
| 632 |
+
if (nd&1):
|
| 633 |
+
sre = (are * sn) >> wp
|
| 634 |
+
sim = (aim * sn) >> wp
|
| 635 |
+
else:
|
| 636 |
+
sre = (are * cn) >> wp
|
| 637 |
+
sim = (aim * cn) >> wp
|
| 638 |
+
n = 2
|
| 639 |
+
while are**2 + aim**2 > MIN:
|
| 640 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 641 |
+
(bre * x2im + bim * x2re) >> wp
|
| 642 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 643 |
+
(are * bim + aim * bre) >> wp
|
| 644 |
+
cn, sn = (cn*c1 - sn*s1) >> wp, (sn*c1 + cn*s1) >> wp
|
| 645 |
+
if nd&1:
|
| 646 |
+
sre += (are * sn * n**nd) >> wp
|
| 647 |
+
sim += (aim * sn * n**nd) >> wp
|
| 648 |
+
else:
|
| 649 |
+
sre += (are * cn * n**nd) >> wp
|
| 650 |
+
sim += (aim * cn * n**nd) >> wp
|
| 651 |
+
n += 1
|
| 652 |
+
sre = -(sre << (nd+1))
|
| 653 |
+
sim = -(sim << (nd+1))
|
| 654 |
+
sre = ctx.ldexp(sre, -wp)
|
| 655 |
+
sim = ctx.ldexp(sim, -wp)
|
| 656 |
+
s = ctx.mpc(sre, sim)
|
| 657 |
+
#case z complex, q real
|
| 658 |
+
elif not ctx._im(q):
|
| 659 |
+
wp = ctx.prec + extra2
|
| 660 |
+
x = ctx.to_fixed(ctx._re(q), wp)
|
| 661 |
+
a = b = x
|
| 662 |
+
x2 = (x*x) >> wp
|
| 663 |
+
prec0 = ctx.prec
|
| 664 |
+
ctx.prec = wp
|
| 665 |
+
c1, s1 = ctx.cos_sin(2*z)
|
| 666 |
+
ctx.prec = prec0
|
| 667 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 668 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 669 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 670 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 671 |
+
if (nd&1):
|
| 672 |
+
sre = (a * snre) >> wp
|
| 673 |
+
sim = (a * snim) >> wp
|
| 674 |
+
else:
|
| 675 |
+
sre = (a * cnre) >> wp
|
| 676 |
+
sim = (a * cnim) >> wp
|
| 677 |
+
n = 2
|
| 678 |
+
while abs(a) > MIN:
|
| 679 |
+
b = (b*x2) >> wp
|
| 680 |
+
a = (a*b) >> wp
|
| 681 |
+
t1 = (cnre*c1re - cnim*c1im - snre*s1re + snim*s1im) >> wp
|
| 682 |
+
t2 = (cnre*c1im + cnim*c1re - snre*s1im - snim*s1re) >> wp
|
| 683 |
+
t3 = (snre*c1re - snim*c1im + cnre*s1re - cnim*s1im) >> wp
|
| 684 |
+
t4 = (snre*c1im + snim*c1re + cnre*s1im + cnim*s1re) >> wp
|
| 685 |
+
cnre = t1
|
| 686 |
+
cnim = t2
|
| 687 |
+
snre = t3
|
| 688 |
+
snim = t4
|
| 689 |
+
if (nd&1):
|
| 690 |
+
sre += (a * snre * n**nd) >> wp
|
| 691 |
+
sim += (a * snim * n**nd) >> wp
|
| 692 |
+
else:
|
| 693 |
+
sre += (a * cnre * n**nd) >> wp
|
| 694 |
+
sim += (a * cnim * n**nd) >> wp
|
| 695 |
+
n += 1
|
| 696 |
+
sre = -(sre << (nd+1))
|
| 697 |
+
sim = -(sim << (nd+1))
|
| 698 |
+
sre = ctx.ldexp(sre, -wp)
|
| 699 |
+
sim = ctx.ldexp(sim, -wp)
|
| 700 |
+
s = ctx.mpc(sre, sim)
|
| 701 |
+
# case z and q complex
|
| 702 |
+
else:
|
| 703 |
+
wp = ctx.prec + extra2
|
| 704 |
+
xre = ctx.to_fixed(ctx._re(q), wp)
|
| 705 |
+
xim = ctx.to_fixed(ctx._im(q), wp)
|
| 706 |
+
x2re = (xre*xre - xim*xim) >> wp
|
| 707 |
+
x2im = (xre*xim) >> (wp - 1)
|
| 708 |
+
are = bre = xre
|
| 709 |
+
aim = bim = xim
|
| 710 |
+
prec0 = ctx.prec
|
| 711 |
+
ctx.prec = wp
|
| 712 |
+
# cos(2*z), sin(2*z) with z complex
|
| 713 |
+
c1, s1 = ctx.cos_sin(2*z)
|
| 714 |
+
ctx.prec = prec0
|
| 715 |
+
cnre = c1re = ctx.to_fixed(ctx._re(c1), wp)
|
| 716 |
+
cnim = c1im = ctx.to_fixed(ctx._im(c1), wp)
|
| 717 |
+
snre = s1re = ctx.to_fixed(ctx._re(s1), wp)
|
| 718 |
+
snim = s1im = ctx.to_fixed(ctx._im(s1), wp)
|
| 719 |
+
if (nd&1):
|
| 720 |
+
sre = (are * snre - aim * snim) >> wp
|
| 721 |
+
sim = (aim * snre + are * snim) >> wp
|
| 722 |
+
else:
|
| 723 |
+
sre = (are * cnre - aim * cnim) >> wp
|
| 724 |
+
sim = (aim * cnre + are * cnim) >> wp
|
| 725 |
+
n = 2
|
| 726 |
+
while are**2 + aim**2 > MIN:
|
| 727 |
+
bre, bim = (bre * x2re - bim * x2im) >> wp, \
|
| 728 |
+
(bre * x2im + bim * x2re) >> wp
|
| 729 |
+
are, aim = (are * bre - aim * bim) >> wp, \
|
| 730 |
+
(are * bim + aim * bre) >> wp
|
| 731 |
+
t1 = (cnre*c1re - cnim*c1im - snre*s1re + snim*s1im) >> wp
|
| 732 |
+
t2 = (cnre*c1im + cnim*c1re - snre*s1im - snim*s1re) >> wp
|
| 733 |
+
t3 = (snre*c1re - snim*c1im + cnre*s1re - cnim*s1im) >> wp
|
| 734 |
+
t4 = (snre*c1im + snim*c1re + cnre*s1im + cnim*s1re) >> wp
|
| 735 |
+
cnre = t1
|
| 736 |
+
cnim = t2
|
| 737 |
+
snre = t3
|
| 738 |
+
snim = t4
|
| 739 |
+
if(nd&1):
|
| 740 |
+
sre += ((are * snre - aim * snim) * n**nd) >> wp
|
| 741 |
+
sim += ((aim * snre + are * snim) * n**nd) >> wp
|
| 742 |
+
else:
|
| 743 |
+
sre += ((are * cnre - aim * cnim) * n**nd) >> wp
|
| 744 |
+
sim += ((aim * cnre + are * cnim) * n**nd) >> wp
|
| 745 |
+
n += 1
|
| 746 |
+
sre = -(sre << (nd+1))
|
| 747 |
+
sim = -(sim << (nd+1))
|
| 748 |
+
sre = ctx.ldexp(sre, -wp)
|
| 749 |
+
sim = ctx.ldexp(sim, -wp)
|
| 750 |
+
s = ctx.mpc(sre, sim)
|
| 751 |
+
if (nd&1):
|
| 752 |
+
return (-1)**(nd//2) * s
|
| 753 |
+
else:
|
| 754 |
+
return (-1)**(1 + nd//2) * s
|
| 755 |
+
|
| 756 |
+
@defun
|
| 757 |
+
def _jacobi_theta2a(ctx, z, q):
|
| 758 |
+
"""
|
| 759 |
+
case ctx._im(z) != 0
|
| 760 |
+
theta(2, z, q) =
|
| 761 |
+
q**1/4 * Sum(q**(n*n + n) * exp(j*(2*n + 1)*z), n=-inf, inf)
|
| 762 |
+
max term for minimum (2*n+1)*log(q).real - 2* ctx._im(z)
|
| 763 |
+
n0 = int(ctx._im(z)/log(q).real - 1/2)
|
| 764 |
+
theta(2, z, q) =
|
| 765 |
+
q**1/4 * Sum(q**(n*n + n) * exp(j*(2*n + 1)*z), n=n0, inf) +
|
| 766 |
+
q**1/4 * Sum(q**(n*n + n) * exp(j*(2*n + 1)*z), n, n0-1, -inf)
|
| 767 |
+
"""
|
| 768 |
+
n = n0 = int(ctx._im(z)/ctx._re(ctx.log(q)) - 1/2)
|
| 769 |
+
e2 = ctx.expj(2*z)
|
| 770 |
+
e = e0 = ctx.expj((2*n+1)*z)
|
| 771 |
+
a = q**(n*n + n)
|
| 772 |
+
# leading term
|
| 773 |
+
term = a * e
|
| 774 |
+
s = term
|
| 775 |
+
eps1 = ctx.eps*abs(term)
|
| 776 |
+
while 1:
|
| 777 |
+
n += 1
|
| 778 |
+
e = e * e2
|
| 779 |
+
term = q**(n*n + n) * e
|
| 780 |
+
if abs(term) < eps1:
|
| 781 |
+
break
|
| 782 |
+
s += term
|
| 783 |
+
e = e0
|
| 784 |
+
e2 = ctx.expj(-2*z)
|
| 785 |
+
n = n0
|
| 786 |
+
while 1:
|
| 787 |
+
n -= 1
|
| 788 |
+
e = e * e2
|
| 789 |
+
term = q**(n*n + n) * e
|
| 790 |
+
if abs(term) < eps1:
|
| 791 |
+
break
|
| 792 |
+
s += term
|
| 793 |
+
s = s * ctx.nthroot(q, 4)
|
| 794 |
+
return s
|
| 795 |
+
|
| 796 |
+
@defun
|
| 797 |
+
def _jacobi_theta3a(ctx, z, q):
|
| 798 |
+
"""
|
| 799 |
+
case ctx._im(z) != 0
|
| 800 |
+
theta3(z, q) = Sum(q**(n*n) * exp(j*2*n*z), n, -inf, inf)
|
| 801 |
+
max term for n*abs(log(q).real) + ctx._im(z) ~= 0
|
| 802 |
+
n0 = int(- ctx._im(z)/abs(log(q).real))
|
| 803 |
+
"""
|
| 804 |
+
n = n0 = int(-ctx._im(z)/abs(ctx._re(ctx.log(q))))
|
| 805 |
+
e2 = ctx.expj(2*z)
|
| 806 |
+
e = e0 = ctx.expj(2*n*z)
|
| 807 |
+
s = term = q**(n*n) * e
|
| 808 |
+
eps1 = ctx.eps*abs(term)
|
| 809 |
+
while 1:
|
| 810 |
+
n += 1
|
| 811 |
+
e = e * e2
|
| 812 |
+
term = q**(n*n) * e
|
| 813 |
+
if abs(term) < eps1:
|
| 814 |
+
break
|
| 815 |
+
s += term
|
| 816 |
+
e = e0
|
| 817 |
+
e2 = ctx.expj(-2*z)
|
| 818 |
+
n = n0
|
| 819 |
+
while 1:
|
| 820 |
+
n -= 1
|
| 821 |
+
e = e * e2
|
| 822 |
+
term = q**(n*n) * e
|
| 823 |
+
if abs(term) < eps1:
|
| 824 |
+
break
|
| 825 |
+
s += term
|
| 826 |
+
return s
|
| 827 |
+
|
| 828 |
+
@defun
|
| 829 |
+
def _djacobi_theta2a(ctx, z, q, nd):
|
| 830 |
+
"""
|
| 831 |
+
case ctx._im(z) != 0
|
| 832 |
+
dtheta(2, z, q, nd) =
|
| 833 |
+
j* q**1/4 * Sum(q**(n*n + n) * (2*n+1)*exp(j*(2*n + 1)*z), n=-inf, inf)
|
| 834 |
+
max term for (2*n0+1)*log(q).real - 2* ctx._im(z) ~= 0
|
| 835 |
+
n0 = int(ctx._im(z)/log(q).real - 1/2)
|
| 836 |
+
"""
|
| 837 |
+
n = n0 = int(ctx._im(z)/ctx._re(ctx.log(q)) - 1/2)
|
| 838 |
+
e2 = ctx.expj(2*z)
|
| 839 |
+
e = e0 = ctx.expj((2*n + 1)*z)
|
| 840 |
+
a = q**(n*n + n)
|
| 841 |
+
# leading term
|
| 842 |
+
term = (2*n+1)**nd * a * e
|
| 843 |
+
s = term
|
| 844 |
+
eps1 = ctx.eps*abs(term)
|
| 845 |
+
while 1:
|
| 846 |
+
n += 1
|
| 847 |
+
e = e * e2
|
| 848 |
+
term = (2*n+1)**nd * q**(n*n + n) * e
|
| 849 |
+
if abs(term) < eps1:
|
| 850 |
+
break
|
| 851 |
+
s += term
|
| 852 |
+
e = e0
|
| 853 |
+
e2 = ctx.expj(-2*z)
|
| 854 |
+
n = n0
|
| 855 |
+
while 1:
|
| 856 |
+
n -= 1
|
| 857 |
+
e = e * e2
|
| 858 |
+
term = (2*n+1)**nd * q**(n*n + n) * e
|
| 859 |
+
if abs(term) < eps1:
|
| 860 |
+
break
|
| 861 |
+
s += term
|
| 862 |
+
return ctx.j**nd * s * ctx.nthroot(q, 4)
|
| 863 |
+
|
| 864 |
+
@defun
|
| 865 |
+
def _djacobi_theta3a(ctx, z, q, nd):
|
| 866 |
+
"""
|
| 867 |
+
case ctx._im(z) != 0
|
| 868 |
+
djtheta3(z, q, nd) = (2*j)**nd *
|
| 869 |
+
Sum(q**(n*n) * n**nd * exp(j*2*n*z), n, -inf, inf)
|
| 870 |
+
max term for minimum n*abs(log(q).real) + ctx._im(z)
|
| 871 |
+
"""
|
| 872 |
+
n = n0 = int(-ctx._im(z)/abs(ctx._re(ctx.log(q))))
|
| 873 |
+
e2 = ctx.expj(2*z)
|
| 874 |
+
e = e0 = ctx.expj(2*n*z)
|
| 875 |
+
a = q**(n*n) * e
|
| 876 |
+
s = term = n**nd * a
|
| 877 |
+
if n != 0:
|
| 878 |
+
eps1 = ctx.eps*abs(term)
|
| 879 |
+
else:
|
| 880 |
+
eps1 = ctx.eps*abs(a)
|
| 881 |
+
while 1:
|
| 882 |
+
n += 1
|
| 883 |
+
e = e * e2
|
| 884 |
+
a = q**(n*n) * e
|
| 885 |
+
term = n**nd * a
|
| 886 |
+
if n != 0:
|
| 887 |
+
aterm = abs(term)
|
| 888 |
+
else:
|
| 889 |
+
aterm = abs(a)
|
| 890 |
+
if aterm < eps1:
|
| 891 |
+
break
|
| 892 |
+
s += term
|
| 893 |
+
e = e0
|
| 894 |
+
e2 = ctx.expj(-2*z)
|
| 895 |
+
n = n0
|
| 896 |
+
while 1:
|
| 897 |
+
n -= 1
|
| 898 |
+
e = e * e2
|
| 899 |
+
a = q**(n*n) * e
|
| 900 |
+
term = n**nd * a
|
| 901 |
+
if n != 0:
|
| 902 |
+
aterm = abs(term)
|
| 903 |
+
else:
|
| 904 |
+
aterm = abs(a)
|
| 905 |
+
if aterm < eps1:
|
| 906 |
+
break
|
| 907 |
+
s += term
|
| 908 |
+
return (2*ctx.j)**nd * s
|
| 909 |
+
|
| 910 |
+
@defun
|
| 911 |
+
def jtheta(ctx, n, z, q, derivative=0):
|
| 912 |
+
if derivative:
|
| 913 |
+
return ctx._djtheta(n, z, q, derivative)
|
| 914 |
+
|
| 915 |
+
z = ctx.convert(z)
|
| 916 |
+
q = ctx.convert(q)
|
| 917 |
+
|
| 918 |
+
# Implementation note
|
| 919 |
+
# If ctx._im(z) is close to zero, _jacobi_theta2 and _jacobi_theta3
|
| 920 |
+
# are used,
|
| 921 |
+
# which compute the series starting from n=0 using fixed precision
|
| 922 |
+
# numbers;
|
| 923 |
+
# otherwise _jacobi_theta2a and _jacobi_theta3a are used, which compute
|
| 924 |
+
# the series starting from n=n0, which is the largest term.
|
| 925 |
+
|
| 926 |
+
# TODO: write _jacobi_theta2a and _jacobi_theta3a using fixed-point
|
| 927 |
+
|
| 928 |
+
if abs(q) > ctx.THETA_Q_LIM:
|
| 929 |
+
raise ValueError('abs(q) > THETA_Q_LIM = %f' % ctx.THETA_Q_LIM)
|
| 930 |
+
|
| 931 |
+
extra = 10
|
| 932 |
+
if z:
|
| 933 |
+
M = ctx.mag(z)
|
| 934 |
+
if M > 5 or (n == 1 and M < -5):
|
| 935 |
+
extra += 2*abs(M)
|
| 936 |
+
cz = 0.5
|
| 937 |
+
extra2 = 50
|
| 938 |
+
prec0 = ctx.prec
|
| 939 |
+
try:
|
| 940 |
+
ctx.prec += extra
|
| 941 |
+
if n == 1:
|
| 942 |
+
if ctx._im(z):
|
| 943 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 944 |
+
ctx.dps += extra2
|
| 945 |
+
res = ctx._jacobi_theta2(z - ctx.pi/2, q)
|
| 946 |
+
else:
|
| 947 |
+
ctx.dps += 10
|
| 948 |
+
res = ctx._jacobi_theta2a(z - ctx.pi/2, q)
|
| 949 |
+
else:
|
| 950 |
+
res = ctx._jacobi_theta2(z - ctx.pi/2, q)
|
| 951 |
+
elif n == 2:
|
| 952 |
+
if ctx._im(z):
|
| 953 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 954 |
+
ctx.dps += extra2
|
| 955 |
+
res = ctx._jacobi_theta2(z, q)
|
| 956 |
+
else:
|
| 957 |
+
ctx.dps += 10
|
| 958 |
+
res = ctx._jacobi_theta2a(z, q)
|
| 959 |
+
else:
|
| 960 |
+
res = ctx._jacobi_theta2(z, q)
|
| 961 |
+
elif n == 3:
|
| 962 |
+
if ctx._im(z):
|
| 963 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 964 |
+
ctx.dps += extra2
|
| 965 |
+
res = ctx._jacobi_theta3(z, q)
|
| 966 |
+
else:
|
| 967 |
+
ctx.dps += 10
|
| 968 |
+
res = ctx._jacobi_theta3a(z, q)
|
| 969 |
+
else:
|
| 970 |
+
res = ctx._jacobi_theta3(z, q)
|
| 971 |
+
elif n == 4:
|
| 972 |
+
if ctx._im(z):
|
| 973 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 974 |
+
ctx.dps += extra2
|
| 975 |
+
res = ctx._jacobi_theta3(z, -q)
|
| 976 |
+
else:
|
| 977 |
+
ctx.dps += 10
|
| 978 |
+
res = ctx._jacobi_theta3a(z, -q)
|
| 979 |
+
else:
|
| 980 |
+
res = ctx._jacobi_theta3(z, -q)
|
| 981 |
+
else:
|
| 982 |
+
raise ValueError
|
| 983 |
+
finally:
|
| 984 |
+
ctx.prec = prec0
|
| 985 |
+
return res
|
| 986 |
+
|
| 987 |
+
@defun
|
| 988 |
+
def _djtheta(ctx, n, z, q, derivative=1):
|
| 989 |
+
z = ctx.convert(z)
|
| 990 |
+
q = ctx.convert(q)
|
| 991 |
+
nd = int(derivative)
|
| 992 |
+
|
| 993 |
+
if abs(q) > ctx.THETA_Q_LIM:
|
| 994 |
+
raise ValueError('abs(q) > THETA_Q_LIM = %f' % ctx.THETA_Q_LIM)
|
| 995 |
+
extra = 10 + ctx.prec * nd // 10
|
| 996 |
+
if z:
|
| 997 |
+
M = ctx.mag(z)
|
| 998 |
+
if M > 5 or (n != 1 and M < -5):
|
| 999 |
+
extra += 2*abs(M)
|
| 1000 |
+
cz = 0.5
|
| 1001 |
+
extra2 = 50
|
| 1002 |
+
prec0 = ctx.prec
|
| 1003 |
+
try:
|
| 1004 |
+
ctx.prec += extra
|
| 1005 |
+
if n == 1:
|
| 1006 |
+
if ctx._im(z):
|
| 1007 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 1008 |
+
ctx.dps += extra2
|
| 1009 |
+
res = ctx._djacobi_theta2(z - ctx.pi/2, q, nd)
|
| 1010 |
+
else:
|
| 1011 |
+
ctx.dps += 10
|
| 1012 |
+
res = ctx._djacobi_theta2a(z - ctx.pi/2, q, nd)
|
| 1013 |
+
else:
|
| 1014 |
+
res = ctx._djacobi_theta2(z - ctx.pi/2, q, nd)
|
| 1015 |
+
elif n == 2:
|
| 1016 |
+
if ctx._im(z):
|
| 1017 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 1018 |
+
ctx.dps += extra2
|
| 1019 |
+
res = ctx._djacobi_theta2(z, q, nd)
|
| 1020 |
+
else:
|
| 1021 |
+
ctx.dps += 10
|
| 1022 |
+
res = ctx._djacobi_theta2a(z, q, nd)
|
| 1023 |
+
else:
|
| 1024 |
+
res = ctx._djacobi_theta2(z, q, nd)
|
| 1025 |
+
elif n == 3:
|
| 1026 |
+
if ctx._im(z):
|
| 1027 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 1028 |
+
ctx.dps += extra2
|
| 1029 |
+
res = ctx._djacobi_theta3(z, q, nd)
|
| 1030 |
+
else:
|
| 1031 |
+
ctx.dps += 10
|
| 1032 |
+
res = ctx._djacobi_theta3a(z, q, nd)
|
| 1033 |
+
else:
|
| 1034 |
+
res = ctx._djacobi_theta3(z, q, nd)
|
| 1035 |
+
elif n == 4:
|
| 1036 |
+
if ctx._im(z):
|
| 1037 |
+
if abs(ctx._im(z)) < cz * abs(ctx._re(ctx.log(q))):
|
| 1038 |
+
ctx.dps += extra2
|
| 1039 |
+
res = ctx._djacobi_theta3(z, -q, nd)
|
| 1040 |
+
else:
|
| 1041 |
+
ctx.dps += 10
|
| 1042 |
+
res = ctx._djacobi_theta3a(z, -q, nd)
|
| 1043 |
+
else:
|
| 1044 |
+
res = ctx._djacobi_theta3(z, -q, nd)
|
| 1045 |
+
else:
|
| 1046 |
+
raise ValueError
|
| 1047 |
+
finally:
|
| 1048 |
+
ctx.prec = prec0
|
| 1049 |
+
return +res
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/functions/zetazeros.py
ADDED
|
@@ -0,0 +1,1018 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The function zetazero(n) computes the n-th nontrivial zero of zeta(s).
|
| 3 |
+
|
| 4 |
+
The general strategy is to locate a block of Gram intervals B where we
|
| 5 |
+
know exactly the number of zeros contained and which of those zeros
|
| 6 |
+
is that which we search.
|
| 7 |
+
|
| 8 |
+
If n <= 400 000 000 we know exactly the Rosser exceptions, contained
|
| 9 |
+
in a list in this file. Hence for n<=400 000 000 we simply
|
| 10 |
+
look at these list of exceptions. If our zero is implicated in one of
|
| 11 |
+
these exceptions we have our block B. In other case we simply locate
|
| 12 |
+
the good Rosser block containing our zero.
|
| 13 |
+
|
| 14 |
+
For n > 400 000 000 we apply the method of Turing, as complemented by
|
| 15 |
+
Lehman, Brent and Trudgian to find a suitable B.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from .functions import defun, defun_wrapped
|
| 19 |
+
|
| 20 |
+
def find_rosser_block_zero(ctx, n):
|
| 21 |
+
"""for n<400 000 000 determines a block were one find our zero"""
|
| 22 |
+
for k in range(len(_ROSSER_EXCEPTIONS)//2):
|
| 23 |
+
a=_ROSSER_EXCEPTIONS[2*k][0]
|
| 24 |
+
b=_ROSSER_EXCEPTIONS[2*k][1]
|
| 25 |
+
if ((a<= n-2) and (n-1 <= b)):
|
| 26 |
+
t0 = ctx.grampoint(a)
|
| 27 |
+
t1 = ctx.grampoint(b)
|
| 28 |
+
v0 = ctx._fp.siegelz(t0)
|
| 29 |
+
v1 = ctx._fp.siegelz(t1)
|
| 30 |
+
my_zero_number = n-a-1
|
| 31 |
+
zero_number_block = b-a
|
| 32 |
+
pattern = _ROSSER_EXCEPTIONS[2*k+1]
|
| 33 |
+
return (my_zero_number, [a,b], [t0,t1], [v0,v1])
|
| 34 |
+
k = n-2
|
| 35 |
+
t,v,b = compute_triple_tvb(ctx, k)
|
| 36 |
+
T = [t]
|
| 37 |
+
V = [v]
|
| 38 |
+
while b < 0:
|
| 39 |
+
k -= 1
|
| 40 |
+
t,v,b = compute_triple_tvb(ctx, k)
|
| 41 |
+
T.insert(0,t)
|
| 42 |
+
V.insert(0,v)
|
| 43 |
+
my_zero_number = n-k-1
|
| 44 |
+
m = n-1
|
| 45 |
+
t,v,b = compute_triple_tvb(ctx, m)
|
| 46 |
+
T.append(t)
|
| 47 |
+
V.append(v)
|
| 48 |
+
while b < 0:
|
| 49 |
+
m += 1
|
| 50 |
+
t,v,b = compute_triple_tvb(ctx, m)
|
| 51 |
+
T.append(t)
|
| 52 |
+
V.append(v)
|
| 53 |
+
return (my_zero_number, [k,m], T, V)
|
| 54 |
+
|
| 55 |
+
def wpzeros(t):
|
| 56 |
+
"""Precision needed to compute higher zeros"""
|
| 57 |
+
wp = 53
|
| 58 |
+
if t > 3*10**8:
|
| 59 |
+
wp = 63
|
| 60 |
+
if t > 10**11:
|
| 61 |
+
wp = 70
|
| 62 |
+
if t > 10**14:
|
| 63 |
+
wp = 83
|
| 64 |
+
return wp
|
| 65 |
+
|
| 66 |
+
def separate_zeros_in_block(ctx, zero_number_block, T, V, limitloop=None,
|
| 67 |
+
fp_tolerance=None):
|
| 68 |
+
"""Separate the zeros contained in the block T, limitloop
|
| 69 |
+
determines how long one must search"""
|
| 70 |
+
if limitloop is None:
|
| 71 |
+
limitloop = ctx.inf
|
| 72 |
+
loopnumber = 0
|
| 73 |
+
variations = count_variations(V)
|
| 74 |
+
while ((variations < zero_number_block) and (loopnumber <limitloop)):
|
| 75 |
+
a = T[0]
|
| 76 |
+
v = V[0]
|
| 77 |
+
newT = [a]
|
| 78 |
+
newV = [v]
|
| 79 |
+
variations = 0
|
| 80 |
+
for n in range(1,len(T)):
|
| 81 |
+
b2 = T[n]
|
| 82 |
+
u = V[n]
|
| 83 |
+
if (u*v>0):
|
| 84 |
+
alpha = ctx.sqrt(u/v)
|
| 85 |
+
b= (alpha*a+b2)/(alpha+1)
|
| 86 |
+
else:
|
| 87 |
+
b = (a+b2)/2
|
| 88 |
+
if fp_tolerance < 10:
|
| 89 |
+
w = ctx._fp.siegelz(b)
|
| 90 |
+
if abs(w)<fp_tolerance:
|
| 91 |
+
w = ctx.siegelz(b)
|
| 92 |
+
else:
|
| 93 |
+
w=ctx.siegelz(b)
|
| 94 |
+
if v*w<0:
|
| 95 |
+
variations += 1
|
| 96 |
+
newT.append(b)
|
| 97 |
+
newV.append(w)
|
| 98 |
+
u = V[n]
|
| 99 |
+
if u*w <0:
|
| 100 |
+
variations += 1
|
| 101 |
+
newT.append(b2)
|
| 102 |
+
newV.append(u)
|
| 103 |
+
a = b2
|
| 104 |
+
v = u
|
| 105 |
+
T = newT
|
| 106 |
+
V = newV
|
| 107 |
+
loopnumber +=1
|
| 108 |
+
if (limitloop>ITERATION_LIMIT)and(loopnumber>2)and(variations+2==zero_number_block):
|
| 109 |
+
dtMax=0
|
| 110 |
+
dtSec=0
|
| 111 |
+
kMax = 0
|
| 112 |
+
for k1 in range(1,len(T)):
|
| 113 |
+
dt = T[k1]-T[k1-1]
|
| 114 |
+
if dt > dtMax:
|
| 115 |
+
kMax=k1
|
| 116 |
+
dtSec = dtMax
|
| 117 |
+
dtMax = dt
|
| 118 |
+
elif (dt<dtMax) and(dt >dtSec):
|
| 119 |
+
dtSec = dt
|
| 120 |
+
if dtMax>3*dtSec:
|
| 121 |
+
f = lambda x: ctx.rs_z(x,derivative=1)
|
| 122 |
+
t0=T[kMax-1]
|
| 123 |
+
t1 = T[kMax]
|
| 124 |
+
t=ctx.findroot(f, (t0,t1), solver ='illinois',verify=False, verbose=False)
|
| 125 |
+
v = ctx.siegelz(t)
|
| 126 |
+
if (t0<t) and (t<t1) and (v*V[kMax]<0):
|
| 127 |
+
T.insert(kMax,t)
|
| 128 |
+
V.insert(kMax,v)
|
| 129 |
+
variations = count_variations(V)
|
| 130 |
+
if variations == zero_number_block:
|
| 131 |
+
separated = True
|
| 132 |
+
else:
|
| 133 |
+
separated = False
|
| 134 |
+
return (T,V, separated)
|
| 135 |
+
|
| 136 |
+
def separate_my_zero(ctx, my_zero_number, zero_number_block, T, V, prec):
|
| 137 |
+
"""If we know which zero of this block is mine,
|
| 138 |
+
the function separates the zero"""
|
| 139 |
+
variations = 0
|
| 140 |
+
v0 = V[0]
|
| 141 |
+
for k in range(1,len(V)):
|
| 142 |
+
v1 = V[k]
|
| 143 |
+
if v0*v1 < 0:
|
| 144 |
+
variations +=1
|
| 145 |
+
if variations == my_zero_number:
|
| 146 |
+
k0 = k
|
| 147 |
+
leftv = v0
|
| 148 |
+
rightv = v1
|
| 149 |
+
v0 = v1
|
| 150 |
+
t1 = T[k0]
|
| 151 |
+
t0 = T[k0-1]
|
| 152 |
+
ctx.prec = prec
|
| 153 |
+
wpz = wpzeros(my_zero_number*ctx.log(my_zero_number))
|
| 154 |
+
|
| 155 |
+
guard = 4*ctx.mag(my_zero_number)
|
| 156 |
+
precs = [ctx.prec+4]
|
| 157 |
+
index=0
|
| 158 |
+
while precs[0] > 2*wpz:
|
| 159 |
+
index +=1
|
| 160 |
+
precs = [precs[0] // 2 +3+2*index] + precs
|
| 161 |
+
ctx.prec = precs[0] + guard
|
| 162 |
+
r = ctx.findroot(lambda x:ctx.siegelz(x), (t0,t1), solver ='illinois', verbose=False)
|
| 163 |
+
#print "first step at", ctx.dps, "digits"
|
| 164 |
+
z=ctx.mpc(0.5,r)
|
| 165 |
+
for prec in precs[1:]:
|
| 166 |
+
ctx.prec = prec + guard
|
| 167 |
+
#print "refining to", ctx.dps, "digits"
|
| 168 |
+
znew = z - ctx.zeta(z) / ctx.zeta(z, derivative=1)
|
| 169 |
+
#print "difference", ctx.nstr(abs(z-znew))
|
| 170 |
+
z=ctx.mpc(0.5,ctx.im(znew))
|
| 171 |
+
return ctx.im(z)
|
| 172 |
+
|
| 173 |
+
def sure_number_block(ctx, n):
|
| 174 |
+
"""The number of good Rosser blocks needed to apply
|
| 175 |
+
Turing method
|
| 176 |
+
References:
|
| 177 |
+
R. P. Brent, On the Zeros of the Riemann Zeta Function
|
| 178 |
+
in the Critical Strip, Math. Comp. 33 (1979) 1361--1372
|
| 179 |
+
T. Trudgian, Improvements to Turing Method, Math. Comp."""
|
| 180 |
+
if n < 9*10**5:
|
| 181 |
+
return(2)
|
| 182 |
+
g = ctx.grampoint(n-100)
|
| 183 |
+
lg = ctx._fp.ln(g)
|
| 184 |
+
brent = 0.0061 * lg**2 +0.08*lg
|
| 185 |
+
trudgian = 0.0031 * lg**2 +0.11*lg
|
| 186 |
+
N = ctx.ceil(min(brent,trudgian))
|
| 187 |
+
N = int(N)
|
| 188 |
+
return N
|
| 189 |
+
|
| 190 |
+
def compute_triple_tvb(ctx, n):
|
| 191 |
+
t = ctx.grampoint(n)
|
| 192 |
+
v = ctx._fp.siegelz(t)
|
| 193 |
+
if ctx.mag(abs(v))<ctx.mag(t)-45:
|
| 194 |
+
v = ctx.siegelz(t)
|
| 195 |
+
b = v*(-1)**n
|
| 196 |
+
return t,v,b
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
ITERATION_LIMIT = 4
|
| 201 |
+
|
| 202 |
+
def search_supergood_block(ctx, n, fp_tolerance):
|
| 203 |
+
"""To use for n>400 000 000"""
|
| 204 |
+
sb = sure_number_block(ctx, n)
|
| 205 |
+
number_goodblocks = 0
|
| 206 |
+
m2 = n-1
|
| 207 |
+
t, v, b = compute_triple_tvb(ctx, m2)
|
| 208 |
+
Tf = [t]
|
| 209 |
+
Vf = [v]
|
| 210 |
+
while b < 0:
|
| 211 |
+
m2 += 1
|
| 212 |
+
t,v,b = compute_triple_tvb(ctx, m2)
|
| 213 |
+
Tf.append(t)
|
| 214 |
+
Vf.append(v)
|
| 215 |
+
goodpoints = [m2]
|
| 216 |
+
T = [t]
|
| 217 |
+
V = [v]
|
| 218 |
+
while number_goodblocks < 2*sb:
|
| 219 |
+
m2 += 1
|
| 220 |
+
t, v, b = compute_triple_tvb(ctx, m2)
|
| 221 |
+
T.append(t)
|
| 222 |
+
V.append(v)
|
| 223 |
+
while b < 0:
|
| 224 |
+
m2 += 1
|
| 225 |
+
t,v,b = compute_triple_tvb(ctx, m2)
|
| 226 |
+
T.append(t)
|
| 227 |
+
V.append(v)
|
| 228 |
+
goodpoints.append(m2)
|
| 229 |
+
zn = len(T)-1
|
| 230 |
+
A, B, separated =\
|
| 231 |
+
separate_zeros_in_block(ctx, zn, T, V, limitloop=ITERATION_LIMIT,
|
| 232 |
+
fp_tolerance=fp_tolerance)
|
| 233 |
+
Tf.pop()
|
| 234 |
+
Tf.extend(A)
|
| 235 |
+
Vf.pop()
|
| 236 |
+
Vf.extend(B)
|
| 237 |
+
if separated:
|
| 238 |
+
number_goodblocks += 1
|
| 239 |
+
else:
|
| 240 |
+
number_goodblocks = 0
|
| 241 |
+
T = [t]
|
| 242 |
+
V = [v]
|
| 243 |
+
# Now the same procedure to the left
|
| 244 |
+
number_goodblocks = 0
|
| 245 |
+
m2 = n-2
|
| 246 |
+
t, v, b = compute_triple_tvb(ctx, m2)
|
| 247 |
+
Tf.insert(0,t)
|
| 248 |
+
Vf.insert(0,v)
|
| 249 |
+
while b < 0:
|
| 250 |
+
m2 -= 1
|
| 251 |
+
t,v,b = compute_triple_tvb(ctx, m2)
|
| 252 |
+
Tf.insert(0,t)
|
| 253 |
+
Vf.insert(0,v)
|
| 254 |
+
goodpoints.insert(0,m2)
|
| 255 |
+
T = [t]
|
| 256 |
+
V = [v]
|
| 257 |
+
while number_goodblocks < 2*sb:
|
| 258 |
+
m2 -= 1
|
| 259 |
+
t, v, b = compute_triple_tvb(ctx, m2)
|
| 260 |
+
T.insert(0,t)
|
| 261 |
+
V.insert(0,v)
|
| 262 |
+
while b < 0:
|
| 263 |
+
m2 -= 1
|
| 264 |
+
t,v,b = compute_triple_tvb(ctx, m2)
|
| 265 |
+
T.insert(0,t)
|
| 266 |
+
V.insert(0,v)
|
| 267 |
+
goodpoints.insert(0,m2)
|
| 268 |
+
zn = len(T)-1
|
| 269 |
+
A, B, separated =\
|
| 270 |
+
separate_zeros_in_block(ctx, zn, T, V, limitloop=ITERATION_LIMIT, fp_tolerance=fp_tolerance)
|
| 271 |
+
A.pop()
|
| 272 |
+
Tf = A+Tf
|
| 273 |
+
B.pop()
|
| 274 |
+
Vf = B+Vf
|
| 275 |
+
if separated:
|
| 276 |
+
number_goodblocks += 1
|
| 277 |
+
else:
|
| 278 |
+
number_goodblocks = 0
|
| 279 |
+
T = [t]
|
| 280 |
+
V = [v]
|
| 281 |
+
r = goodpoints[2*sb]
|
| 282 |
+
lg = len(goodpoints)
|
| 283 |
+
s = goodpoints[lg-2*sb-1]
|
| 284 |
+
tr, vr, br = compute_triple_tvb(ctx, r)
|
| 285 |
+
ar = Tf.index(tr)
|
| 286 |
+
ts, vs, bs = compute_triple_tvb(ctx, s)
|
| 287 |
+
as1 = Tf.index(ts)
|
| 288 |
+
T = Tf[ar:as1+1]
|
| 289 |
+
V = Vf[ar:as1+1]
|
| 290 |
+
zn = s-r
|
| 291 |
+
A, B, separated =\
|
| 292 |
+
separate_zeros_in_block(ctx, zn,T,V,limitloop=ITERATION_LIMIT, fp_tolerance=fp_tolerance)
|
| 293 |
+
if separated:
|
| 294 |
+
return (n-r-1,[r,s],A,B)
|
| 295 |
+
q = goodpoints[sb]
|
| 296 |
+
lg = len(goodpoints)
|
| 297 |
+
t = goodpoints[lg-sb-1]
|
| 298 |
+
tq, vq, bq = compute_triple_tvb(ctx, q)
|
| 299 |
+
aq = Tf.index(tq)
|
| 300 |
+
tt, vt, bt = compute_triple_tvb(ctx, t)
|
| 301 |
+
at = Tf.index(tt)
|
| 302 |
+
T = Tf[aq:at+1]
|
| 303 |
+
V = Vf[aq:at+1]
|
| 304 |
+
return (n-q-1,[q,t],T,V)
|
| 305 |
+
|
| 306 |
+
def count_variations(V):
|
| 307 |
+
count = 0
|
| 308 |
+
vold = V[0]
|
| 309 |
+
for n in range(1, len(V)):
|
| 310 |
+
vnew = V[n]
|
| 311 |
+
if vold*vnew < 0:
|
| 312 |
+
count +=1
|
| 313 |
+
vold = vnew
|
| 314 |
+
return count
|
| 315 |
+
|
| 316 |
+
def pattern_construct(ctx, block, T, V):
|
| 317 |
+
pattern = '('
|
| 318 |
+
a = block[0]
|
| 319 |
+
b = block[1]
|
| 320 |
+
t0,v0,b0 = compute_triple_tvb(ctx, a)
|
| 321 |
+
k = 0
|
| 322 |
+
k0 = 0
|
| 323 |
+
for n in range(a+1,b+1):
|
| 324 |
+
t1,v1,b1 = compute_triple_tvb(ctx, n)
|
| 325 |
+
lgT =len(T)
|
| 326 |
+
while (k < lgT) and (T[k] <= t1):
|
| 327 |
+
k += 1
|
| 328 |
+
L = V[k0:k]
|
| 329 |
+
L.append(v1)
|
| 330 |
+
L.insert(0,v0)
|
| 331 |
+
count = count_variations(L)
|
| 332 |
+
pattern = pattern + ("%s" % count)
|
| 333 |
+
if b1 > 0:
|
| 334 |
+
pattern = pattern + ')('
|
| 335 |
+
k0 = k
|
| 336 |
+
t0,v0,b0 = t1,v1,b1
|
| 337 |
+
pattern = pattern[:-1]
|
| 338 |
+
return pattern
|
| 339 |
+
|
| 340 |
+
@defun
|
| 341 |
+
def zetazero(ctx, n, info=False, round=True):
|
| 342 |
+
r"""
|
| 343 |
+
Computes the `n`-th nontrivial zero of `\zeta(s)` on the critical line,
|
| 344 |
+
i.e. returns an approximation of the `n`-th largest complex number
|
| 345 |
+
`s = \frac{1}{2} + ti` for which `\zeta(s) = 0`. Equivalently, the
|
| 346 |
+
imaginary part `t` is a zero of the Z-function (:func:`~mpmath.siegelz`).
|
| 347 |
+
|
| 348 |
+
**Examples**
|
| 349 |
+
|
| 350 |
+
The first few zeros::
|
| 351 |
+
|
| 352 |
+
>>> from mpmath import *
|
| 353 |
+
>>> mp.dps = 25; mp.pretty = True
|
| 354 |
+
>>> zetazero(1)
|
| 355 |
+
(0.5 + 14.13472514173469379045725j)
|
| 356 |
+
>>> zetazero(2)
|
| 357 |
+
(0.5 + 21.02203963877155499262848j)
|
| 358 |
+
>>> zetazero(20)
|
| 359 |
+
(0.5 + 77.14484006887480537268266j)
|
| 360 |
+
|
| 361 |
+
Verifying that the values are zeros::
|
| 362 |
+
|
| 363 |
+
>>> for n in range(1,5):
|
| 364 |
+
... s = zetazero(n)
|
| 365 |
+
... chop(zeta(s)), chop(siegelz(s.imag))
|
| 366 |
+
...
|
| 367 |
+
(0.0, 0.0)
|
| 368 |
+
(0.0, 0.0)
|
| 369 |
+
(0.0, 0.0)
|
| 370 |
+
(0.0, 0.0)
|
| 371 |
+
|
| 372 |
+
Negative indices give the conjugate zeros (`n = 0` is undefined)::
|
| 373 |
+
|
| 374 |
+
>>> zetazero(-1)
|
| 375 |
+
(0.5 - 14.13472514173469379045725j)
|
| 376 |
+
|
| 377 |
+
:func:`~mpmath.zetazero` supports arbitrarily large `n` and arbitrary precision::
|
| 378 |
+
|
| 379 |
+
>>> mp.dps = 15
|
| 380 |
+
>>> zetazero(1234567)
|
| 381 |
+
(0.5 + 727690.906948208j)
|
| 382 |
+
>>> mp.dps = 50
|
| 383 |
+
>>> zetazero(1234567)
|
| 384 |
+
(0.5 + 727690.9069482075392389420041147142092708393819935j)
|
| 385 |
+
>>> chop(zeta(_)/_)
|
| 386 |
+
0.0
|
| 387 |
+
|
| 388 |
+
with *info=True*, :func:`~mpmath.zetazero` gives additional information::
|
| 389 |
+
|
| 390 |
+
>>> mp.dps = 15
|
| 391 |
+
>>> zetazero(542964976,info=True)
|
| 392 |
+
((0.5 + 209039046.578535j), [542964969, 542964978], 6, '(013111110)')
|
| 393 |
+
|
| 394 |
+
This means that the zero is between Gram points 542964969 and 542964978;
|
| 395 |
+
it is the 6-th zero between them. Finally (01311110) is the pattern
|
| 396 |
+
of zeros in this interval. The numbers indicate the number of zeros
|
| 397 |
+
in each Gram interval (Rosser blocks between parenthesis). In this case
|
| 398 |
+
there is only one Rosser block of length nine.
|
| 399 |
+
"""
|
| 400 |
+
n = int(n)
|
| 401 |
+
if n < 0:
|
| 402 |
+
return ctx.zetazero(-n).conjugate()
|
| 403 |
+
if n == 0:
|
| 404 |
+
raise ValueError("n must be nonzero")
|
| 405 |
+
wpinitial = ctx.prec
|
| 406 |
+
try:
|
| 407 |
+
wpz, fp_tolerance = comp_fp_tolerance(ctx, n)
|
| 408 |
+
ctx.prec = wpz
|
| 409 |
+
if n < 400000000:
|
| 410 |
+
my_zero_number, block, T, V =\
|
| 411 |
+
find_rosser_block_zero(ctx, n)
|
| 412 |
+
else:
|
| 413 |
+
my_zero_number, block, T, V =\
|
| 414 |
+
search_supergood_block(ctx, n, fp_tolerance)
|
| 415 |
+
zero_number_block = block[1]-block[0]
|
| 416 |
+
T, V, separated = separate_zeros_in_block(ctx, zero_number_block, T, V,
|
| 417 |
+
limitloop=ctx.inf, fp_tolerance=fp_tolerance)
|
| 418 |
+
if info:
|
| 419 |
+
pattern = pattern_construct(ctx,block,T,V)
|
| 420 |
+
prec = max(wpinitial, wpz)
|
| 421 |
+
t = separate_my_zero(ctx, my_zero_number, zero_number_block,T,V,prec)
|
| 422 |
+
v = ctx.mpc(0.5,t)
|
| 423 |
+
finally:
|
| 424 |
+
ctx.prec = wpinitial
|
| 425 |
+
if round:
|
| 426 |
+
v =+v
|
| 427 |
+
if info:
|
| 428 |
+
return (v,block,my_zero_number,pattern)
|
| 429 |
+
else:
|
| 430 |
+
return v
|
| 431 |
+
|
| 432 |
+
def gram_index(ctx, t):
|
| 433 |
+
if t > 10**13:
|
| 434 |
+
wp = 3*ctx.log(t, 10)
|
| 435 |
+
else:
|
| 436 |
+
wp = 0
|
| 437 |
+
prec = ctx.prec
|
| 438 |
+
try:
|
| 439 |
+
ctx.prec += wp
|
| 440 |
+
h = int(ctx.siegeltheta(t)/ctx.pi)
|
| 441 |
+
finally:
|
| 442 |
+
ctx.prec = prec
|
| 443 |
+
return(h)
|
| 444 |
+
|
| 445 |
+
def count_to(ctx, t, T, V):
|
| 446 |
+
count = 0
|
| 447 |
+
vold = V[0]
|
| 448 |
+
told = T[0]
|
| 449 |
+
tnew = T[1]
|
| 450 |
+
k = 1
|
| 451 |
+
while tnew < t:
|
| 452 |
+
vnew = V[k]
|
| 453 |
+
if vold*vnew < 0:
|
| 454 |
+
count += 1
|
| 455 |
+
vold = vnew
|
| 456 |
+
k += 1
|
| 457 |
+
tnew = T[k]
|
| 458 |
+
a = ctx.siegelz(t)
|
| 459 |
+
if a*vold < 0:
|
| 460 |
+
count += 1
|
| 461 |
+
return count
|
| 462 |
+
|
| 463 |
+
def comp_fp_tolerance(ctx, n):
|
| 464 |
+
wpz = wpzeros(n*ctx.log(n))
|
| 465 |
+
if n < 15*10**8:
|
| 466 |
+
fp_tolerance = 0.0005
|
| 467 |
+
elif n <= 10**14:
|
| 468 |
+
fp_tolerance = 0.1
|
| 469 |
+
else:
|
| 470 |
+
fp_tolerance = 100
|
| 471 |
+
return wpz, fp_tolerance
|
| 472 |
+
|
| 473 |
+
@defun
|
| 474 |
+
def nzeros(ctx, t):
|
| 475 |
+
r"""
|
| 476 |
+
Computes the number of zeros of the Riemann zeta function in
|
| 477 |
+
`(0,1) \times (0,t]`, usually denoted by `N(t)`.
|
| 478 |
+
|
| 479 |
+
**Examples**
|
| 480 |
+
|
| 481 |
+
The first zero has imaginary part between 14 and 15::
|
| 482 |
+
|
| 483 |
+
>>> from mpmath import *
|
| 484 |
+
>>> mp.dps = 15; mp.pretty = True
|
| 485 |
+
>>> nzeros(14)
|
| 486 |
+
0
|
| 487 |
+
>>> nzeros(15)
|
| 488 |
+
1
|
| 489 |
+
>>> zetazero(1)
|
| 490 |
+
(0.5 + 14.1347251417347j)
|
| 491 |
+
|
| 492 |
+
Some closely spaced zeros::
|
| 493 |
+
|
| 494 |
+
>>> nzeros(10**7)
|
| 495 |
+
21136125
|
| 496 |
+
>>> zetazero(21136125)
|
| 497 |
+
(0.5 + 9999999.32718175j)
|
| 498 |
+
>>> zetazero(21136126)
|
| 499 |
+
(0.5 + 10000000.2400236j)
|
| 500 |
+
>>> nzeros(545439823.215)
|
| 501 |
+
1500000001
|
| 502 |
+
>>> zetazero(1500000001)
|
| 503 |
+
(0.5 + 545439823.201985j)
|
| 504 |
+
>>> zetazero(1500000002)
|
| 505 |
+
(0.5 + 545439823.325697j)
|
| 506 |
+
|
| 507 |
+
This confirms the data given by J. van de Lune,
|
| 508 |
+
H. J. J. te Riele and D. T. Winter in 1986.
|
| 509 |
+
"""
|
| 510 |
+
if t < 14.1347251417347:
|
| 511 |
+
return 0
|
| 512 |
+
x = gram_index(ctx, t)
|
| 513 |
+
k = int(ctx.floor(x))
|
| 514 |
+
wpinitial = ctx.prec
|
| 515 |
+
wpz, fp_tolerance = comp_fp_tolerance(ctx, k)
|
| 516 |
+
ctx.prec = wpz
|
| 517 |
+
a = ctx.siegelz(t)
|
| 518 |
+
if k == -1 and a < 0:
|
| 519 |
+
return 0
|
| 520 |
+
elif k == -1 and a > 0:
|
| 521 |
+
return 1
|
| 522 |
+
if k+2 < 400000000:
|
| 523 |
+
Rblock = find_rosser_block_zero(ctx, k+2)
|
| 524 |
+
else:
|
| 525 |
+
Rblock = search_supergood_block(ctx, k+2, fp_tolerance)
|
| 526 |
+
n1, n2 = Rblock[1]
|
| 527 |
+
if n2-n1 == 1:
|
| 528 |
+
b = Rblock[3][0]
|
| 529 |
+
if a*b > 0:
|
| 530 |
+
ctx.prec = wpinitial
|
| 531 |
+
return k+1
|
| 532 |
+
else:
|
| 533 |
+
ctx.prec = wpinitial
|
| 534 |
+
return k+2
|
| 535 |
+
my_zero_number,block, T, V = Rblock
|
| 536 |
+
zero_number_block = n2-n1
|
| 537 |
+
T, V, separated = separate_zeros_in_block(ctx,\
|
| 538 |
+
zero_number_block, T, V,\
|
| 539 |
+
limitloop=ctx.inf,\
|
| 540 |
+
fp_tolerance=fp_tolerance)
|
| 541 |
+
n = count_to(ctx, t, T, V)
|
| 542 |
+
ctx.prec = wpinitial
|
| 543 |
+
return n+n1+1
|
| 544 |
+
|
| 545 |
+
@defun_wrapped
|
| 546 |
+
def backlunds(ctx, t):
|
| 547 |
+
r"""
|
| 548 |
+
Computes the function
|
| 549 |
+
`S(t) = \operatorname{arg} \zeta(\frac{1}{2} + it) / \pi`.
|
| 550 |
+
|
| 551 |
+
See Titchmarsh Section 9.3 for details of the definition.
|
| 552 |
+
|
| 553 |
+
**Examples**
|
| 554 |
+
|
| 555 |
+
>>> from mpmath import *
|
| 556 |
+
>>> mp.dps = 15; mp.pretty = True
|
| 557 |
+
>>> backlunds(217.3)
|
| 558 |
+
0.16302205431184
|
| 559 |
+
|
| 560 |
+
Generally, the value is a small number. At Gram points it is an integer,
|
| 561 |
+
frequently equal to 0::
|
| 562 |
+
|
| 563 |
+
>>> chop(backlunds(grampoint(200)))
|
| 564 |
+
0.0
|
| 565 |
+
>>> backlunds(extraprec(10)(grampoint)(211))
|
| 566 |
+
1.0
|
| 567 |
+
>>> backlunds(extraprec(10)(grampoint)(232))
|
| 568 |
+
-1.0
|
| 569 |
+
|
| 570 |
+
The number of zeros of the Riemann zeta function up to height `t`
|
| 571 |
+
satisfies `N(t) = \theta(t)/\pi + 1 + S(t)` (see :func:nzeros` and
|
| 572 |
+
:func:`siegeltheta`)::
|
| 573 |
+
|
| 574 |
+
>>> t = 1234.55
|
| 575 |
+
>>> nzeros(t)
|
| 576 |
+
842
|
| 577 |
+
>>> siegeltheta(t)/pi+1+backlunds(t)
|
| 578 |
+
842.0
|
| 579 |
+
|
| 580 |
+
"""
|
| 581 |
+
return ctx.nzeros(t)-1-ctx.siegeltheta(t)/ctx.pi
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
"""
|
| 585 |
+
_ROSSER_EXCEPTIONS is a list of all exceptions to
|
| 586 |
+
Rosser's rule for n <= 400 000 000.
|
| 587 |
+
|
| 588 |
+
Alternately the entry is of type [n,m], or a string.
|
| 589 |
+
The string is the zero pattern of the Block and the relevant
|
| 590 |
+
adjacent. For example (010)3 corresponds to a block
|
| 591 |
+
composed of three Gram intervals, the first ant third without
|
| 592 |
+
a zero and the intermediate with a zero. The next Gram interval
|
| 593 |
+
contain three zeros. So that in total we have 4 zeros in 4 Gram
|
| 594 |
+
blocks. n and m are the indices of the Gram points of this
|
| 595 |
+
interval of four Gram intervals. The Rosser exception is therefore
|
| 596 |
+
formed by the three Gram intervals that are signaled between
|
| 597 |
+
parenthesis.
|
| 598 |
+
|
| 599 |
+
We have included also some Rosser's exceptions beyond n=400 000 000
|
| 600 |
+
that are noted in the literature by some reason.
|
| 601 |
+
|
| 602 |
+
The list is composed from the data published in the references:
|
| 603 |
+
|
| 604 |
+
R. P. Brent, J. van de Lune, H. J. J. te Riele, D. T. Winter,
|
| 605 |
+
'On the Zeros of the Riemann Zeta Function in the Critical Strip. II',
|
| 606 |
+
Math. Comp. 39 (1982) 681--688.
|
| 607 |
+
See also Corrigenda in Math. Comp. 46 (1986) 771.
|
| 608 |
+
|
| 609 |
+
J. van de Lune, H. J. J. te Riele,
|
| 610 |
+
'On the Zeros of the Riemann Zeta Function in the Critical Strip. III',
|
| 611 |
+
Math. Comp. 41 (1983) 759--767.
|
| 612 |
+
See also Corrigenda in Math. Comp. 46 (1986) 771.
|
| 613 |
+
|
| 614 |
+
J. van de Lune,
|
| 615 |
+
'Sums of Equal Powers of Positive Integers',
|
| 616 |
+
Dissertation,
|
| 617 |
+
Vrije Universiteit te Amsterdam, Centrum voor Wiskunde en Informatica,
|
| 618 |
+
Amsterdam, 1984.
|
| 619 |
+
|
| 620 |
+
Thanks to the authors all this papers and those others that have
|
| 621 |
+
contributed to make this possible.
|
| 622 |
+
"""
|
| 623 |
+
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
_ROSSER_EXCEPTIONS = \
|
| 631 |
+
[[13999525, 13999528], '(00)3',
|
| 632 |
+
[30783329, 30783332], '(00)3',
|
| 633 |
+
[30930926, 30930929], '3(00)',
|
| 634 |
+
[37592215, 37592218], '(00)3',
|
| 635 |
+
[40870156, 40870159], '(00)3',
|
| 636 |
+
[43628107, 43628110], '(00)3',
|
| 637 |
+
[46082042, 46082045], '(00)3',
|
| 638 |
+
[46875667, 46875670], '(00)3',
|
| 639 |
+
[49624540, 49624543], '3(00)',
|
| 640 |
+
[50799238, 50799241], '(00)3',
|
| 641 |
+
[55221453, 55221456], '3(00)',
|
| 642 |
+
[56948779, 56948782], '3(00)',
|
| 643 |
+
[60515663, 60515666], '(00)3',
|
| 644 |
+
[61331766, 61331770], '(00)40',
|
| 645 |
+
[69784843, 69784846], '3(00)',
|
| 646 |
+
[75052114, 75052117], '(00)3',
|
| 647 |
+
[79545240, 79545243], '3(00)',
|
| 648 |
+
[79652247, 79652250], '3(00)',
|
| 649 |
+
[83088043, 83088046], '(00)3',
|
| 650 |
+
[83689522, 83689525], '3(00)',
|
| 651 |
+
[85348958, 85348961], '(00)3',
|
| 652 |
+
[86513820, 86513823], '(00)3',
|
| 653 |
+
[87947596, 87947599], '3(00)',
|
| 654 |
+
[88600095, 88600098], '(00)3',
|
| 655 |
+
[93681183, 93681186], '(00)3',
|
| 656 |
+
[100316551, 100316554], '3(00)',
|
| 657 |
+
[100788444, 100788447], '(00)3',
|
| 658 |
+
[106236172, 106236175], '(00)3',
|
| 659 |
+
[106941327, 106941330], '3(00)',
|
| 660 |
+
[107287955, 107287958], '(00)3',
|
| 661 |
+
[107532016, 107532019], '3(00)',
|
| 662 |
+
[110571044, 110571047], '(00)3',
|
| 663 |
+
[111885253, 111885256], '3(00)',
|
| 664 |
+
[113239783, 113239786], '(00)3',
|
| 665 |
+
[120159903, 120159906], '(00)3',
|
| 666 |
+
[121424391, 121424394], '3(00)',
|
| 667 |
+
[121692931, 121692934], '3(00)',
|
| 668 |
+
[121934170, 121934173], '3(00)',
|
| 669 |
+
[122612848, 122612851], '3(00)',
|
| 670 |
+
[126116567, 126116570], '(00)3',
|
| 671 |
+
[127936513, 127936516], '(00)3',
|
| 672 |
+
[128710277, 128710280], '3(00)',
|
| 673 |
+
[129398902, 129398905], '3(00)',
|
| 674 |
+
[130461096, 130461099], '3(00)',
|
| 675 |
+
[131331947, 131331950], '3(00)',
|
| 676 |
+
[137334071, 137334074], '3(00)',
|
| 677 |
+
[137832603, 137832606], '(00)3',
|
| 678 |
+
[138799471, 138799474], '3(00)',
|
| 679 |
+
[139027791, 139027794], '(00)3',
|
| 680 |
+
[141617806, 141617809], '(00)3',
|
| 681 |
+
[144454931, 144454934], '(00)3',
|
| 682 |
+
[145402379, 145402382], '3(00)',
|
| 683 |
+
[146130245, 146130248], '3(00)',
|
| 684 |
+
[147059770, 147059773], '(00)3',
|
| 685 |
+
[147896099, 147896102], '3(00)',
|
| 686 |
+
[151097113, 151097116], '(00)3',
|
| 687 |
+
[152539438, 152539441], '(00)3',
|
| 688 |
+
[152863168, 152863171], '3(00)',
|
| 689 |
+
[153522726, 153522729], '3(00)',
|
| 690 |
+
[155171524, 155171527], '3(00)',
|
| 691 |
+
[155366607, 155366610], '(00)3',
|
| 692 |
+
[157260686, 157260689], '3(00)',
|
| 693 |
+
[157269224, 157269227], '(00)3',
|
| 694 |
+
[157755123, 157755126], '(00)3',
|
| 695 |
+
[158298484, 158298487], '3(00)',
|
| 696 |
+
[160369050, 160369053], '3(00)',
|
| 697 |
+
[162962787, 162962790], '(00)3',
|
| 698 |
+
[163724709, 163724712], '(00)3',
|
| 699 |
+
[164198113, 164198116], '3(00)',
|
| 700 |
+
[164689301, 164689305], '(00)40',
|
| 701 |
+
[164880228, 164880231], '3(00)',
|
| 702 |
+
[166201932, 166201935], '(00)3',
|
| 703 |
+
[168573836, 168573839], '(00)3',
|
| 704 |
+
[169750763, 169750766], '(00)3',
|
| 705 |
+
[170375507, 170375510], '(00)3',
|
| 706 |
+
[170704879, 170704882], '3(00)',
|
| 707 |
+
[172000992, 172000995], '3(00)',
|
| 708 |
+
[173289941, 173289944], '(00)3',
|
| 709 |
+
[173737613, 173737616], '3(00)',
|
| 710 |
+
[174102513, 174102516], '(00)3',
|
| 711 |
+
[174284990, 174284993], '(00)3',
|
| 712 |
+
[174500513, 174500516], '(00)3',
|
| 713 |
+
[175710609, 175710612], '(00)3',
|
| 714 |
+
[176870843, 176870846], '3(00)',
|
| 715 |
+
[177332732, 177332735], '3(00)',
|
| 716 |
+
[177902861, 177902864], '3(00)',
|
| 717 |
+
[179979095, 179979098], '(00)3',
|
| 718 |
+
[181233726, 181233729], '3(00)',
|
| 719 |
+
[181625435, 181625438], '(00)3',
|
| 720 |
+
[182105255, 182105259], '22(00)',
|
| 721 |
+
[182223559, 182223562], '3(00)',
|
| 722 |
+
[191116404, 191116407], '3(00)',
|
| 723 |
+
[191165599, 191165602], '3(00)',
|
| 724 |
+
[191297535, 191297539], '(00)22',
|
| 725 |
+
[192485616, 192485619], '(00)3',
|
| 726 |
+
[193264634, 193264638], '22(00)',
|
| 727 |
+
[194696968, 194696971], '(00)3',
|
| 728 |
+
[195876805, 195876808], '(00)3',
|
| 729 |
+
[195916548, 195916551], '3(00)',
|
| 730 |
+
[196395160, 196395163], '3(00)',
|
| 731 |
+
[196676303, 196676306], '(00)3',
|
| 732 |
+
[197889882, 197889885], '3(00)',
|
| 733 |
+
[198014122, 198014125], '(00)3',
|
| 734 |
+
[199235289, 199235292], '(00)3',
|
| 735 |
+
[201007375, 201007378], '(00)3',
|
| 736 |
+
[201030605, 201030608], '3(00)',
|
| 737 |
+
[201184290, 201184293], '3(00)',
|
| 738 |
+
[201685414, 201685418], '(00)22',
|
| 739 |
+
[202762875, 202762878], '3(00)',
|
| 740 |
+
[202860957, 202860960], '3(00)',
|
| 741 |
+
[203832577, 203832580], '3(00)',
|
| 742 |
+
[205880544, 205880547], '(00)3',
|
| 743 |
+
[206357111, 206357114], '(00)3',
|
| 744 |
+
[207159767, 207159770], '3(00)',
|
| 745 |
+
[207167343, 207167346], '3(00)',
|
| 746 |
+
[207482539, 207482543], '3(010)',
|
| 747 |
+
[207669540, 207669543], '3(00)',
|
| 748 |
+
[208053426, 208053429], '(00)3',
|
| 749 |
+
[208110027, 208110030], '3(00)',
|
| 750 |
+
[209513826, 209513829], '3(00)',
|
| 751 |
+
[212623522, 212623525], '(00)3',
|
| 752 |
+
[213841715, 213841718], '(00)3',
|
| 753 |
+
[214012333, 214012336], '(00)3',
|
| 754 |
+
[214073567, 214073570], '(00)3',
|
| 755 |
+
[215170600, 215170603], '3(00)',
|
| 756 |
+
[215881039, 215881042], '3(00)',
|
| 757 |
+
[216274604, 216274607], '3(00)',
|
| 758 |
+
[216957120, 216957123], '3(00)',
|
| 759 |
+
[217323208, 217323211], '(00)3',
|
| 760 |
+
[218799264, 218799267], '(00)3',
|
| 761 |
+
[218803557, 218803560], '3(00)',
|
| 762 |
+
[219735146, 219735149], '(00)3',
|
| 763 |
+
[219830062, 219830065], '3(00)',
|
| 764 |
+
[219897904, 219897907], '(00)3',
|
| 765 |
+
[221205545, 221205548], '(00)3',
|
| 766 |
+
[223601929, 223601932], '(00)3',
|
| 767 |
+
[223907076, 223907079], '3(00)',
|
| 768 |
+
[223970397, 223970400], '(00)3',
|
| 769 |
+
[224874044, 224874048], '22(00)',
|
| 770 |
+
[225291157, 225291160], '(00)3',
|
| 771 |
+
[227481734, 227481737], '(00)3',
|
| 772 |
+
[228006442, 228006445], '3(00)',
|
| 773 |
+
[228357900, 228357903], '(00)3',
|
| 774 |
+
[228386399, 228386402], '(00)3',
|
| 775 |
+
[228907446, 228907449], '(00)3',
|
| 776 |
+
[228984552, 228984555], '3(00)',
|
| 777 |
+
[229140285, 229140288], '3(00)',
|
| 778 |
+
[231810024, 231810027], '(00)3',
|
| 779 |
+
[232838062, 232838065], '3(00)',
|
| 780 |
+
[234389088, 234389091], '3(00)',
|
| 781 |
+
[235588194, 235588197], '(00)3',
|
| 782 |
+
[236645695, 236645698], '(00)3',
|
| 783 |
+
[236962876, 236962879], '3(00)',
|
| 784 |
+
[237516723, 237516727], '04(00)',
|
| 785 |
+
[240004911, 240004914], '(00)3',
|
| 786 |
+
[240221306, 240221309], '3(00)',
|
| 787 |
+
[241389213, 241389217], '(010)3',
|
| 788 |
+
[241549003, 241549006], '(00)3',
|
| 789 |
+
[241729717, 241729720], '(00)3',
|
| 790 |
+
[241743684, 241743687], '3(00)',
|
| 791 |
+
[243780200, 243780203], '3(00)',
|
| 792 |
+
[243801317, 243801320], '(00)3',
|
| 793 |
+
[244122072, 244122075], '(00)3',
|
| 794 |
+
[244691224, 244691227], '3(00)',
|
| 795 |
+
[244841577, 244841580], '(00)3',
|
| 796 |
+
[245813461, 245813464], '(00)3',
|
| 797 |
+
[246299475, 246299478], '(00)3',
|
| 798 |
+
[246450176, 246450179], '3(00)',
|
| 799 |
+
[249069349, 249069352], '(00)3',
|
| 800 |
+
[250076378, 250076381], '(00)3',
|
| 801 |
+
[252442157, 252442160], '3(00)',
|
| 802 |
+
[252904231, 252904234], '3(00)',
|
| 803 |
+
[255145220, 255145223], '(00)3',
|
| 804 |
+
[255285971, 255285974], '3(00)',
|
| 805 |
+
[256713230, 256713233], '(00)3',
|
| 806 |
+
[257992082, 257992085], '(00)3',
|
| 807 |
+
[258447955, 258447959], '22(00)',
|
| 808 |
+
[259298045, 259298048], '3(00)',
|
| 809 |
+
[262141503, 262141506], '(00)3',
|
| 810 |
+
[263681743, 263681746], '3(00)',
|
| 811 |
+
[266527881, 266527885], '(010)3',
|
| 812 |
+
[266617122, 266617125], '(00)3',
|
| 813 |
+
[266628044, 266628047], '3(00)',
|
| 814 |
+
[267305763, 267305766], '(00)3',
|
| 815 |
+
[267388404, 267388407], '3(00)',
|
| 816 |
+
[267441672, 267441675], '3(00)',
|
| 817 |
+
[267464886, 267464889], '(00)3',
|
| 818 |
+
[267554907, 267554910], '3(00)',
|
| 819 |
+
[269787480, 269787483], '(00)3',
|
| 820 |
+
[270881434, 270881437], '(00)3',
|
| 821 |
+
[270997583, 270997586], '3(00)',
|
| 822 |
+
[272096378, 272096381], '3(00)',
|
| 823 |
+
[272583009, 272583012], '(00)3',
|
| 824 |
+
[274190881, 274190884], '3(00)',
|
| 825 |
+
[274268747, 274268750], '(00)3',
|
| 826 |
+
[275297429, 275297432], '3(00)',
|
| 827 |
+
[275545476, 275545479], '3(00)',
|
| 828 |
+
[275898479, 275898482], '3(00)',
|
| 829 |
+
[275953000, 275953003], '(00)3',
|
| 830 |
+
[277117197, 277117201], '(00)22',
|
| 831 |
+
[277447310, 277447313], '3(00)',
|
| 832 |
+
[279059657, 279059660], '3(00)',
|
| 833 |
+
[279259144, 279259147], '3(00)',
|
| 834 |
+
[279513636, 279513639], '3(00)',
|
| 835 |
+
[279849069, 279849072], '3(00)',
|
| 836 |
+
[280291419, 280291422], '(00)3',
|
| 837 |
+
[281449425, 281449428], '3(00)',
|
| 838 |
+
[281507953, 281507956], '3(00)',
|
| 839 |
+
[281825600, 281825603], '(00)3',
|
| 840 |
+
[282547093, 282547096], '3(00)',
|
| 841 |
+
[283120963, 283120966], '3(00)',
|
| 842 |
+
[283323493, 283323496], '(00)3',
|
| 843 |
+
[284764535, 284764538], '3(00)',
|
| 844 |
+
[286172639, 286172642], '3(00)',
|
| 845 |
+
[286688824, 286688827], '(00)3',
|
| 846 |
+
[287222172, 287222175], '3(00)',
|
| 847 |
+
[287235534, 287235537], '3(00)',
|
| 848 |
+
[287304861, 287304864], '3(00)',
|
| 849 |
+
[287433571, 287433574], '(00)3',
|
| 850 |
+
[287823551, 287823554], '(00)3',
|
| 851 |
+
[287872422, 287872425], '3(00)',
|
| 852 |
+
[288766615, 288766618], '3(00)',
|
| 853 |
+
[290122963, 290122966], '3(00)',
|
| 854 |
+
[290450849, 290450853], '(00)22',
|
| 855 |
+
[291426141, 291426144], '3(00)',
|
| 856 |
+
[292810353, 292810356], '3(00)',
|
| 857 |
+
[293109861, 293109864], '3(00)',
|
| 858 |
+
[293398054, 293398057], '3(00)',
|
| 859 |
+
[294134426, 294134429], '3(00)',
|
| 860 |
+
[294216438, 294216441], '(00)3',
|
| 861 |
+
[295367141, 295367144], '3(00)',
|
| 862 |
+
[297834111, 297834114], '3(00)',
|
| 863 |
+
[299099969, 299099972], '3(00)',
|
| 864 |
+
[300746958, 300746961], '3(00)',
|
| 865 |
+
[301097423, 301097426], '(00)3',
|
| 866 |
+
[301834209, 301834212], '(00)3',
|
| 867 |
+
[302554791, 302554794], '(00)3',
|
| 868 |
+
[303497445, 303497448], '3(00)',
|
| 869 |
+
[304165344, 304165347], '3(00)',
|
| 870 |
+
[304790218, 304790222], '3(010)',
|
| 871 |
+
[305302352, 305302355], '(00)3',
|
| 872 |
+
[306785996, 306785999], '3(00)',
|
| 873 |
+
[307051443, 307051446], '3(00)',
|
| 874 |
+
[307481539, 307481542], '3(00)',
|
| 875 |
+
[308605569, 308605572], '3(00)',
|
| 876 |
+
[309237610, 309237613], '3(00)',
|
| 877 |
+
[310509287, 310509290], '(00)3',
|
| 878 |
+
[310554057, 310554060], '3(00)',
|
| 879 |
+
[310646345, 310646348], '3(00)',
|
| 880 |
+
[311274896, 311274899], '(00)3',
|
| 881 |
+
[311894272, 311894275], '3(00)',
|
| 882 |
+
[312269470, 312269473], '(00)3',
|
| 883 |
+
[312306601, 312306605], '(00)40',
|
| 884 |
+
[312683193, 312683196], '3(00)',
|
| 885 |
+
[314499804, 314499807], '3(00)',
|
| 886 |
+
[314636802, 314636805], '(00)3',
|
| 887 |
+
[314689897, 314689900], '3(00)',
|
| 888 |
+
[314721319, 314721322], '3(00)',
|
| 889 |
+
[316132890, 316132893], '3(00)',
|
| 890 |
+
[316217470, 316217474], '(010)3',
|
| 891 |
+
[316465705, 316465708], '3(00)',
|
| 892 |
+
[316542790, 316542793], '(00)3',
|
| 893 |
+
[320822347, 320822350], '3(00)',
|
| 894 |
+
[321733242, 321733245], '3(00)',
|
| 895 |
+
[324413970, 324413973], '(00)3',
|
| 896 |
+
[325950140, 325950143], '(00)3',
|
| 897 |
+
[326675884, 326675887], '(00)3',
|
| 898 |
+
[326704208, 326704211], '3(00)',
|
| 899 |
+
[327596247, 327596250], '3(00)',
|
| 900 |
+
[328123172, 328123175], '3(00)',
|
| 901 |
+
[328182212, 328182215], '(00)3',
|
| 902 |
+
[328257498, 328257501], '3(00)',
|
| 903 |
+
[328315836, 328315839], '(00)3',
|
| 904 |
+
[328800974, 328800977], '(00)3',
|
| 905 |
+
[328998509, 328998512], '3(00)',
|
| 906 |
+
[329725370, 329725373], '(00)3',
|
| 907 |
+
[332080601, 332080604], '(00)3',
|
| 908 |
+
[332221246, 332221249], '(00)3',
|
| 909 |
+
[332299899, 332299902], '(00)3',
|
| 910 |
+
[332532822, 332532825], '(00)3',
|
| 911 |
+
[333334544, 333334548], '(00)22',
|
| 912 |
+
[333881266, 333881269], '3(00)',
|
| 913 |
+
[334703267, 334703270], '3(00)',
|
| 914 |
+
[334875138, 334875141], '3(00)',
|
| 915 |
+
[336531451, 336531454], '3(00)',
|
| 916 |
+
[336825907, 336825910], '(00)3',
|
| 917 |
+
[336993167, 336993170], '(00)3',
|
| 918 |
+
[337493998, 337494001], '3(00)',
|
| 919 |
+
[337861034, 337861037], '3(00)',
|
| 920 |
+
[337899191, 337899194], '(00)3',
|
| 921 |
+
[337958123, 337958126], '(00)3',
|
| 922 |
+
[342331982, 342331985], '3(00)',
|
| 923 |
+
[342676068, 342676071], '3(00)',
|
| 924 |
+
[347063781, 347063784], '3(00)',
|
| 925 |
+
[347697348, 347697351], '3(00)',
|
| 926 |
+
[347954319, 347954322], '3(00)',
|
| 927 |
+
[348162775, 348162778], '3(00)',
|
| 928 |
+
[349210702, 349210705], '(00)3',
|
| 929 |
+
[349212913, 349212916], '3(00)',
|
| 930 |
+
[349248650, 349248653], '(00)3',
|
| 931 |
+
[349913500, 349913503], '3(00)',
|
| 932 |
+
[350891529, 350891532], '3(00)',
|
| 933 |
+
[351089323, 351089326], '3(00)',
|
| 934 |
+
[351826158, 351826161], '3(00)',
|
| 935 |
+
[352228580, 352228583], '(00)3',
|
| 936 |
+
[352376244, 352376247], '3(00)',
|
| 937 |
+
[352853758, 352853761], '(00)3',
|
| 938 |
+
[355110439, 355110442], '(00)3',
|
| 939 |
+
[355808090, 355808094], '(00)40',
|
| 940 |
+
[355941556, 355941559], '3(00)',
|
| 941 |
+
[356360231, 356360234], '(00)3',
|
| 942 |
+
[356586657, 356586660], '3(00)',
|
| 943 |
+
[356892926, 356892929], '(00)3',
|
| 944 |
+
[356908232, 356908235], '3(00)',
|
| 945 |
+
[357912730, 357912733], '3(00)',
|
| 946 |
+
[358120344, 358120347], '3(00)',
|
| 947 |
+
[359044096, 359044099], '(00)3',
|
| 948 |
+
[360819357, 360819360], '3(00)',
|
| 949 |
+
[361399662, 361399666], '(010)3',
|
| 950 |
+
[362361315, 362361318], '(00)3',
|
| 951 |
+
[363610112, 363610115], '(00)3',
|
| 952 |
+
[363964804, 363964807], '3(00)',
|
| 953 |
+
[364527375, 364527378], '(00)3',
|
| 954 |
+
[365090327, 365090330], '(00)3',
|
| 955 |
+
[365414539, 365414542], '3(00)',
|
| 956 |
+
[366738474, 366738477], '3(00)',
|
| 957 |
+
[368714778, 368714783], '04(010)',
|
| 958 |
+
[368831545, 368831548], '(00)3',
|
| 959 |
+
[368902387, 368902390], '(00)3',
|
| 960 |
+
[370109769, 370109772], '3(00)',
|
| 961 |
+
[370963333, 370963336], '3(00)',
|
| 962 |
+
[372541136, 372541140], '3(010)',
|
| 963 |
+
[372681562, 372681565], '(00)3',
|
| 964 |
+
[373009410, 373009413], '(00)3',
|
| 965 |
+
[373458970, 373458973], '3(00)',
|
| 966 |
+
[375648658, 375648661], '3(00)',
|
| 967 |
+
[376834728, 376834731], '3(00)',
|
| 968 |
+
[377119945, 377119948], '(00)3',
|
| 969 |
+
[377335703, 377335706], '(00)3',
|
| 970 |
+
[378091745, 378091748], '3(00)',
|
| 971 |
+
[379139522, 379139525], '3(00)',
|
| 972 |
+
[380279160, 380279163], '(00)3',
|
| 973 |
+
[380619442, 380619445], '3(00)',
|
| 974 |
+
[381244231, 381244234], '3(00)',
|
| 975 |
+
[382327446, 382327450], '(010)3',
|
| 976 |
+
[382357073, 382357076], '3(00)',
|
| 977 |
+
[383545479, 383545482], '3(00)',
|
| 978 |
+
[384363766, 384363769], '(00)3',
|
| 979 |
+
[384401786, 384401790], '22(00)',
|
| 980 |
+
[385198212, 385198215], '3(00)',
|
| 981 |
+
[385824476, 385824479], '(00)3',
|
| 982 |
+
[385908194, 385908197], '3(00)',
|
| 983 |
+
[386946806, 386946809], '3(00)',
|
| 984 |
+
[387592175, 387592179], '22(00)',
|
| 985 |
+
[388329293, 388329296], '(00)3',
|
| 986 |
+
[388679566, 388679569], '3(00)',
|
| 987 |
+
[388832142, 388832145], '3(00)',
|
| 988 |
+
[390087103, 390087106], '(00)3',
|
| 989 |
+
[390190926, 390190930], '(00)22',
|
| 990 |
+
[390331207, 390331210], '3(00)',
|
| 991 |
+
[391674495, 391674498], '3(00)',
|
| 992 |
+
[391937831, 391937834], '3(00)',
|
| 993 |
+
[391951632, 391951636], '(00)22',
|
| 994 |
+
[392963986, 392963989], '(00)3',
|
| 995 |
+
[393007921, 393007924], '3(00)',
|
| 996 |
+
[393373210, 393373213], '3(00)',
|
| 997 |
+
[393759572, 393759575], '(00)3',
|
| 998 |
+
[394036662, 394036665], '(00)3',
|
| 999 |
+
[395813866, 395813869], '(00)3',
|
| 1000 |
+
[395956690, 395956693], '3(00)',
|
| 1001 |
+
[396031670, 396031673], '3(00)',
|
| 1002 |
+
[397076433, 397076436], '3(00)',
|
| 1003 |
+
[397470601, 397470604], '3(00)',
|
| 1004 |
+
[398289458, 398289461], '3(00)',
|
| 1005 |
+
#
|
| 1006 |
+
[368714778, 368714783], '04(010)',
|
| 1007 |
+
[437953499, 437953504], '04(010)',
|
| 1008 |
+
[526196233, 526196238], '032(00)',
|
| 1009 |
+
[744719566, 744719571], '(010)40',
|
| 1010 |
+
[750375857, 750375862], '032(00)',
|
| 1011 |
+
[958241932, 958241937], '04(010)',
|
| 1012 |
+
[983377342, 983377347], '(00)410',
|
| 1013 |
+
[1003780080, 1003780085], '04(010)',
|
| 1014 |
+
[1070232754, 1070232759], '(00)230',
|
| 1015 |
+
[1209834865, 1209834870], '032(00)',
|
| 1016 |
+
[1257209100, 1257209105], '(00)410',
|
| 1017 |
+
[1368002233, 1368002238], '(00)230'
|
| 1018 |
+
]
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/__init__.py
ADDED
|
File without changes
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_basic_ops.py
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import mpmath
|
| 2 |
+
from mpmath import *
|
| 3 |
+
from mpmath.libmp import *
|
| 4 |
+
import random
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
long = long
|
| 9 |
+
except NameError:
|
| 10 |
+
long = int
|
| 11 |
+
|
| 12 |
+
def test_type_compare():
|
| 13 |
+
assert mpf(2) == mpc(2,0)
|
| 14 |
+
assert mpf(0) == mpc(0)
|
| 15 |
+
assert mpf(2) != mpc(2, 0.00001)
|
| 16 |
+
assert mpf(2) == 2.0
|
| 17 |
+
assert mpf(2) != 3.0
|
| 18 |
+
assert mpf(2) == 2
|
| 19 |
+
assert mpf(2) != '2.0'
|
| 20 |
+
assert mpc(2) != '2.0'
|
| 21 |
+
|
| 22 |
+
def test_add():
|
| 23 |
+
assert mpf(2.5) + mpf(3) == 5.5
|
| 24 |
+
assert mpf(2.5) + 3 == 5.5
|
| 25 |
+
assert mpf(2.5) + 3.0 == 5.5
|
| 26 |
+
assert 3 + mpf(2.5) == 5.5
|
| 27 |
+
assert 3.0 + mpf(2.5) == 5.5
|
| 28 |
+
assert (3+0j) + mpf(2.5) == 5.5
|
| 29 |
+
assert mpc(2.5) + mpf(3) == 5.5
|
| 30 |
+
assert mpc(2.5) + 3 == 5.5
|
| 31 |
+
assert mpc(2.5) + 3.0 == 5.5
|
| 32 |
+
assert mpc(2.5) + (3+0j) == 5.5
|
| 33 |
+
assert 3 + mpc(2.5) == 5.5
|
| 34 |
+
assert 3.0 + mpc(2.5) == 5.5
|
| 35 |
+
assert (3+0j) + mpc(2.5) == 5.5
|
| 36 |
+
|
| 37 |
+
def test_sub():
|
| 38 |
+
assert mpf(2.5) - mpf(3) == -0.5
|
| 39 |
+
assert mpf(2.5) - 3 == -0.5
|
| 40 |
+
assert mpf(2.5) - 3.0 == -0.5
|
| 41 |
+
assert 3 - mpf(2.5) == 0.5
|
| 42 |
+
assert 3.0 - mpf(2.5) == 0.5
|
| 43 |
+
assert (3+0j) - mpf(2.5) == 0.5
|
| 44 |
+
assert mpc(2.5) - mpf(3) == -0.5
|
| 45 |
+
assert mpc(2.5) - 3 == -0.5
|
| 46 |
+
assert mpc(2.5) - 3.0 == -0.5
|
| 47 |
+
assert mpc(2.5) - (3+0j) == -0.5
|
| 48 |
+
assert 3 - mpc(2.5) == 0.5
|
| 49 |
+
assert 3.0 - mpc(2.5) == 0.5
|
| 50 |
+
assert (3+0j) - mpc(2.5) == 0.5
|
| 51 |
+
|
| 52 |
+
def test_mul():
|
| 53 |
+
assert mpf(2.5) * mpf(3) == 7.5
|
| 54 |
+
assert mpf(2.5) * 3 == 7.5
|
| 55 |
+
assert mpf(2.5) * 3.0 == 7.5
|
| 56 |
+
assert 3 * mpf(2.5) == 7.5
|
| 57 |
+
assert 3.0 * mpf(2.5) == 7.5
|
| 58 |
+
assert (3+0j) * mpf(2.5) == 7.5
|
| 59 |
+
assert mpc(2.5) * mpf(3) == 7.5
|
| 60 |
+
assert mpc(2.5) * 3 == 7.5
|
| 61 |
+
assert mpc(2.5) * 3.0 == 7.5
|
| 62 |
+
assert mpc(2.5) * (3+0j) == 7.5
|
| 63 |
+
assert 3 * mpc(2.5) == 7.5
|
| 64 |
+
assert 3.0 * mpc(2.5) == 7.5
|
| 65 |
+
assert (3+0j) * mpc(2.5) == 7.5
|
| 66 |
+
|
| 67 |
+
def test_div():
|
| 68 |
+
assert mpf(6) / mpf(3) == 2.0
|
| 69 |
+
assert mpf(6) / 3 == 2.0
|
| 70 |
+
assert mpf(6) / 3.0 == 2.0
|
| 71 |
+
assert 6 / mpf(3) == 2.0
|
| 72 |
+
assert 6.0 / mpf(3) == 2.0
|
| 73 |
+
assert (6+0j) / mpf(3.0) == 2.0
|
| 74 |
+
assert mpc(6) / mpf(3) == 2.0
|
| 75 |
+
assert mpc(6) / 3 == 2.0
|
| 76 |
+
assert mpc(6) / 3.0 == 2.0
|
| 77 |
+
assert mpc(6) / (3+0j) == 2.0
|
| 78 |
+
assert 6 / mpc(3) == 2.0
|
| 79 |
+
assert 6.0 / mpc(3) == 2.0
|
| 80 |
+
assert (6+0j) / mpc(3) == 2.0
|
| 81 |
+
|
| 82 |
+
def test_pow():
|
| 83 |
+
assert mpf(6) ** mpf(3) == 216.0
|
| 84 |
+
assert mpf(6) ** 3 == 216.0
|
| 85 |
+
assert mpf(6) ** 3.0 == 216.0
|
| 86 |
+
assert 6 ** mpf(3) == 216.0
|
| 87 |
+
assert 6.0 ** mpf(3) == 216.0
|
| 88 |
+
assert (6+0j) ** mpf(3.0) == 216.0
|
| 89 |
+
assert mpc(6) ** mpf(3) == 216.0
|
| 90 |
+
assert mpc(6) ** 3 == 216.0
|
| 91 |
+
assert mpc(6) ** 3.0 == 216.0
|
| 92 |
+
assert mpc(6) ** (3+0j) == 216.0
|
| 93 |
+
assert 6 ** mpc(3) == 216.0
|
| 94 |
+
assert 6.0 ** mpc(3) == 216.0
|
| 95 |
+
assert (6+0j) ** mpc(3) == 216.0
|
| 96 |
+
|
| 97 |
+
def test_mixed_misc():
|
| 98 |
+
assert 1 + mpf(3) == mpf(3) + 1 == 4
|
| 99 |
+
assert 1 - mpf(3) == -(mpf(3) - 1) == -2
|
| 100 |
+
assert 3 * mpf(2) == mpf(2) * 3 == 6
|
| 101 |
+
assert 6 / mpf(2) == mpf(6) / 2 == 3
|
| 102 |
+
assert 1.0 + mpf(3) == mpf(3) + 1.0 == 4
|
| 103 |
+
assert 1.0 - mpf(3) == -(mpf(3) - 1.0) == -2
|
| 104 |
+
assert 3.0 * mpf(2) == mpf(2) * 3.0 == 6
|
| 105 |
+
assert 6.0 / mpf(2) == mpf(6) / 2.0 == 3
|
| 106 |
+
|
| 107 |
+
def test_add_misc():
|
| 108 |
+
mp.dps = 15
|
| 109 |
+
assert mpf(4) + mpf(-70) == -66
|
| 110 |
+
assert mpf(1) + mpf(1.1)/80 == 1 + 1.1/80
|
| 111 |
+
assert mpf((1, 10000000000)) + mpf(3) == mpf((1, 10000000000))
|
| 112 |
+
assert mpf(3) + mpf((1, 10000000000)) == mpf((1, 10000000000))
|
| 113 |
+
assert mpf((1, -10000000000)) + mpf(3) == mpf(3)
|
| 114 |
+
assert mpf(3) + mpf((1, -10000000000)) == mpf(3)
|
| 115 |
+
assert mpf(1) + 1e-15 != 1
|
| 116 |
+
assert mpf(1) + 1e-20 == 1
|
| 117 |
+
assert mpf(1.07e-22) + 0 == mpf(1.07e-22)
|
| 118 |
+
assert mpf(0) + mpf(1.07e-22) == mpf(1.07e-22)
|
| 119 |
+
|
| 120 |
+
def test_complex_misc():
|
| 121 |
+
# many more tests needed
|
| 122 |
+
assert 1 + mpc(2) == 3
|
| 123 |
+
assert not mpc(2).ae(2 + 1e-13)
|
| 124 |
+
assert mpc(2+1e-15j).ae(2)
|
| 125 |
+
|
| 126 |
+
def test_complex_zeros():
|
| 127 |
+
for a in [0,2]:
|
| 128 |
+
for b in [0,3]:
|
| 129 |
+
for c in [0,4]:
|
| 130 |
+
for d in [0,5]:
|
| 131 |
+
assert mpc(a,b)*mpc(c,d) == complex(a,b)*complex(c,d)
|
| 132 |
+
|
| 133 |
+
def test_hash():
|
| 134 |
+
for i in range(-256, 256):
|
| 135 |
+
assert hash(mpf(i)) == hash(i)
|
| 136 |
+
assert hash(mpf(0.5)) == hash(0.5)
|
| 137 |
+
assert hash(mpc(2,3)) == hash(2+3j)
|
| 138 |
+
# Check that this doesn't fail
|
| 139 |
+
assert hash(inf)
|
| 140 |
+
# Check that overflow doesn't assign equal hashes to large numbers
|
| 141 |
+
assert hash(mpf('1e1000')) != hash('1e10000')
|
| 142 |
+
assert hash(mpc(100,'1e1000')) != hash(mpc(200,'1e1000'))
|
| 143 |
+
from mpmath.rational import mpq
|
| 144 |
+
assert hash(mp.mpq(1,3))
|
| 145 |
+
assert hash(mp.mpq(0,1)) == 0
|
| 146 |
+
assert hash(mp.mpq(-1,1)) == hash(-1)
|
| 147 |
+
assert hash(mp.mpq(1,1)) == hash(1)
|
| 148 |
+
assert hash(mp.mpq(5,1)) == hash(5)
|
| 149 |
+
assert hash(mp.mpq(1,2)) == hash(0.5)
|
| 150 |
+
if sys.version_info >= (3, 2):
|
| 151 |
+
assert hash(mpf(1)*2**2000) == hash(2**2000)
|
| 152 |
+
assert hash(mpf(1)/2**2000) == hash(mpq(1,2**2000))
|
| 153 |
+
|
| 154 |
+
# Advanced rounding test
|
| 155 |
+
def test_add_rounding():
|
| 156 |
+
mp.dps = 15
|
| 157 |
+
a = from_float(1e-50)
|
| 158 |
+
assert mpf_sub(mpf_add(fone, a, 53, round_up), fone, 53, round_up) == from_float(2.2204460492503131e-16)
|
| 159 |
+
assert mpf_sub(fone, a, 53, round_up) == fone
|
| 160 |
+
assert mpf_sub(fone, mpf_sub(fone, a, 53, round_down), 53, round_down) == from_float(1.1102230246251565e-16)
|
| 161 |
+
assert mpf_add(fone, a, 53, round_down) == fone
|
| 162 |
+
|
| 163 |
+
def test_almost_equal():
|
| 164 |
+
assert mpf(1.2).ae(mpf(1.20000001), 1e-7)
|
| 165 |
+
assert not mpf(1.2).ae(mpf(1.20000001), 1e-9)
|
| 166 |
+
assert not mpf(-0.7818314824680298).ae(mpf(-0.774695868667929))
|
| 167 |
+
|
| 168 |
+
def test_arithmetic_functions():
|
| 169 |
+
import operator
|
| 170 |
+
ops = [(operator.add, fadd), (operator.sub, fsub), (operator.mul, fmul),
|
| 171 |
+
(operator.truediv, fdiv)]
|
| 172 |
+
a = mpf(0.27)
|
| 173 |
+
b = mpf(1.13)
|
| 174 |
+
c = mpc(0.51+2.16j)
|
| 175 |
+
d = mpc(1.08-0.99j)
|
| 176 |
+
for x in [a,b,c,d]:
|
| 177 |
+
for y in [a,b,c,d]:
|
| 178 |
+
for op, fop in ops:
|
| 179 |
+
if fop is not fdiv:
|
| 180 |
+
mp.prec = 200
|
| 181 |
+
z0 = op(x,y)
|
| 182 |
+
mp.prec = 60
|
| 183 |
+
z1 = op(x,y)
|
| 184 |
+
mp.prec = 53
|
| 185 |
+
z2 = op(x,y)
|
| 186 |
+
assert fop(x, y, prec=60) == z1
|
| 187 |
+
assert fop(x, y) == z2
|
| 188 |
+
if fop is not fdiv:
|
| 189 |
+
assert fop(x, y, prec=inf) == z0
|
| 190 |
+
assert fop(x, y, dps=inf) == z0
|
| 191 |
+
assert fop(x, y, exact=True) == z0
|
| 192 |
+
assert fneg(fneg(z1, exact=True), prec=inf) == z1
|
| 193 |
+
assert fneg(z1) == -(+z1)
|
| 194 |
+
mp.dps = 15
|
| 195 |
+
|
| 196 |
+
def test_exact_integer_arithmetic():
|
| 197 |
+
# XXX: re-fix this so that all operations are tested with all rounding modes
|
| 198 |
+
random.seed(0)
|
| 199 |
+
for prec in [6, 10, 25, 40, 100, 250, 725]:
|
| 200 |
+
for rounding in ['d', 'u', 'f', 'c', 'n']:
|
| 201 |
+
mp.dps = prec
|
| 202 |
+
M = 10**(prec-2)
|
| 203 |
+
M2 = 10**(prec//2-2)
|
| 204 |
+
for i in range(10):
|
| 205 |
+
a = random.randint(-M, M)
|
| 206 |
+
b = random.randint(-M, M)
|
| 207 |
+
assert mpf(a, rounding=rounding) == a
|
| 208 |
+
assert int(mpf(a, rounding=rounding)) == a
|
| 209 |
+
assert int(mpf(str(a), rounding=rounding)) == a
|
| 210 |
+
assert mpf(a) + mpf(b) == a + b
|
| 211 |
+
assert mpf(a) - mpf(b) == a - b
|
| 212 |
+
assert -mpf(a) == -a
|
| 213 |
+
a = random.randint(-M2, M2)
|
| 214 |
+
b = random.randint(-M2, M2)
|
| 215 |
+
assert mpf(a) * mpf(b) == a*b
|
| 216 |
+
assert mpf_mul(from_int(a), from_int(b), mp.prec, rounding) == from_int(a*b)
|
| 217 |
+
mp.dps = 15
|
| 218 |
+
|
| 219 |
+
def test_odd_int_bug():
|
| 220 |
+
assert to_int(from_int(3), round_nearest) == 3
|
| 221 |
+
|
| 222 |
+
def test_str_1000_digits():
|
| 223 |
+
mp.dps = 1001
|
| 224 |
+
# last digit may be wrong
|
| 225 |
+
assert str(mpf(2)**0.5)[-10:-1] == '9518488472'[:9]
|
| 226 |
+
assert str(pi)[-10:-1] == '2164201989'[:9]
|
| 227 |
+
mp.dps = 15
|
| 228 |
+
|
| 229 |
+
def test_str_10000_digits():
|
| 230 |
+
mp.dps = 10001
|
| 231 |
+
# last digit may be wrong
|
| 232 |
+
assert str(mpf(2)**0.5)[-10:-1] == '5873258351'[:9]
|
| 233 |
+
assert str(pi)[-10:-1] == '5256375678'[:9]
|
| 234 |
+
mp.dps = 15
|
| 235 |
+
|
| 236 |
+
def test_monitor():
|
| 237 |
+
f = lambda x: x**2
|
| 238 |
+
a = []
|
| 239 |
+
b = []
|
| 240 |
+
g = monitor(f, a.append, b.append)
|
| 241 |
+
assert g(3) == 9
|
| 242 |
+
assert g(4) == 16
|
| 243 |
+
assert a[0] == ((3,), {})
|
| 244 |
+
assert b[0] == 9
|
| 245 |
+
|
| 246 |
+
def test_nint_distance():
|
| 247 |
+
assert nint_distance(mpf(-3)) == (-3, -inf)
|
| 248 |
+
assert nint_distance(mpc(-3)) == (-3, -inf)
|
| 249 |
+
assert nint_distance(mpf(-3.1)) == (-3, -3)
|
| 250 |
+
assert nint_distance(mpf(-3.01)) == (-3, -6)
|
| 251 |
+
assert nint_distance(mpf(-3.001)) == (-3, -9)
|
| 252 |
+
assert nint_distance(mpf(-3.0001)) == (-3, -13)
|
| 253 |
+
assert nint_distance(mpf(-2.9)) == (-3, -3)
|
| 254 |
+
assert nint_distance(mpf(-2.99)) == (-3, -6)
|
| 255 |
+
assert nint_distance(mpf(-2.999)) == (-3, -9)
|
| 256 |
+
assert nint_distance(mpf(-2.9999)) == (-3, -13)
|
| 257 |
+
assert nint_distance(mpc(-3+0.1j)) == (-3, -3)
|
| 258 |
+
assert nint_distance(mpc(-3+0.01j)) == (-3, -6)
|
| 259 |
+
assert nint_distance(mpc(-3.1+0.1j)) == (-3, -3)
|
| 260 |
+
assert nint_distance(mpc(-3.01+0.01j)) == (-3, -6)
|
| 261 |
+
assert nint_distance(mpc(-3.001+0.001j)) == (-3, -9)
|
| 262 |
+
assert nint_distance(mpf(0)) == (0, -inf)
|
| 263 |
+
assert nint_distance(mpf(0.01)) == (0, -6)
|
| 264 |
+
assert nint_distance(mpf('1e-100')) == (0, -332)
|
| 265 |
+
|
| 266 |
+
def test_floor_ceil_nint_frac():
|
| 267 |
+
mp.dps = 15
|
| 268 |
+
for n in range(-10,10):
|
| 269 |
+
assert floor(n) == n
|
| 270 |
+
assert floor(n+0.5) == n
|
| 271 |
+
assert ceil(n) == n
|
| 272 |
+
assert ceil(n+0.5) == n+1
|
| 273 |
+
assert nint(n) == n
|
| 274 |
+
# nint rounds to even
|
| 275 |
+
if n % 2 == 1:
|
| 276 |
+
assert nint(n+0.5) == n+1
|
| 277 |
+
else:
|
| 278 |
+
assert nint(n+0.5) == n
|
| 279 |
+
assert floor(inf) == inf
|
| 280 |
+
assert floor(ninf) == ninf
|
| 281 |
+
assert isnan(floor(nan))
|
| 282 |
+
assert ceil(inf) == inf
|
| 283 |
+
assert ceil(ninf) == ninf
|
| 284 |
+
assert isnan(ceil(nan))
|
| 285 |
+
assert nint(inf) == inf
|
| 286 |
+
assert nint(ninf) == ninf
|
| 287 |
+
assert isnan(nint(nan))
|
| 288 |
+
assert floor(0.1) == 0
|
| 289 |
+
assert floor(0.9) == 0
|
| 290 |
+
assert floor(-0.1) == -1
|
| 291 |
+
assert floor(-0.9) == -1
|
| 292 |
+
assert floor(10000000000.1) == 10000000000
|
| 293 |
+
assert floor(10000000000.9) == 10000000000
|
| 294 |
+
assert floor(-10000000000.1) == -10000000000-1
|
| 295 |
+
assert floor(-10000000000.9) == -10000000000-1
|
| 296 |
+
assert floor(1e-100) == 0
|
| 297 |
+
assert floor(-1e-100) == -1
|
| 298 |
+
assert floor(1e100) == 1e100
|
| 299 |
+
assert floor(-1e100) == -1e100
|
| 300 |
+
assert ceil(0.1) == 1
|
| 301 |
+
assert ceil(0.9) == 1
|
| 302 |
+
assert ceil(-0.1) == 0
|
| 303 |
+
assert ceil(-0.9) == 0
|
| 304 |
+
assert ceil(10000000000.1) == 10000000000+1
|
| 305 |
+
assert ceil(10000000000.9) == 10000000000+1
|
| 306 |
+
assert ceil(-10000000000.1) == -10000000000
|
| 307 |
+
assert ceil(-10000000000.9) == -10000000000
|
| 308 |
+
assert ceil(1e-100) == 1
|
| 309 |
+
assert ceil(-1e-100) == 0
|
| 310 |
+
assert ceil(1e100) == 1e100
|
| 311 |
+
assert ceil(-1e100) == -1e100
|
| 312 |
+
assert nint(0.1) == 0
|
| 313 |
+
assert nint(0.9) == 1
|
| 314 |
+
assert nint(-0.1) == 0
|
| 315 |
+
assert nint(-0.9) == -1
|
| 316 |
+
assert nint(10000000000.1) == 10000000000
|
| 317 |
+
assert nint(10000000000.9) == 10000000000+1
|
| 318 |
+
assert nint(-10000000000.1) == -10000000000
|
| 319 |
+
assert nint(-10000000000.9) == -10000000000-1
|
| 320 |
+
assert nint(1e-100) == 0
|
| 321 |
+
assert nint(-1e-100) == 0
|
| 322 |
+
assert nint(1e100) == 1e100
|
| 323 |
+
assert nint(-1e100) == -1e100
|
| 324 |
+
assert floor(3.2+4.6j) == 3+4j
|
| 325 |
+
assert ceil(3.2+4.6j) == 4+5j
|
| 326 |
+
assert nint(3.2+4.6j) == 3+5j
|
| 327 |
+
for n in range(-10,10):
|
| 328 |
+
assert frac(n) == 0
|
| 329 |
+
assert frac(0.25) == 0.25
|
| 330 |
+
assert frac(1.25) == 0.25
|
| 331 |
+
assert frac(2.25) == 0.25
|
| 332 |
+
assert frac(-0.25) == 0.75
|
| 333 |
+
assert frac(-1.25) == 0.75
|
| 334 |
+
assert frac(-2.25) == 0.75
|
| 335 |
+
assert frac('1e100000000000000') == 0
|
| 336 |
+
u = mpf('1e-100000000000000')
|
| 337 |
+
assert frac(u) == u
|
| 338 |
+
assert frac(-u) == 1 # rounding!
|
| 339 |
+
u = mpf('1e-400')
|
| 340 |
+
assert frac(-u, prec=0) == fsub(1, u, exact=True)
|
| 341 |
+
assert frac(3.25+4.75j) == 0.25+0.75j
|
| 342 |
+
|
| 343 |
+
def test_isnan_etc():
|
| 344 |
+
from mpmath.rational import mpq
|
| 345 |
+
assert isnan(nan) == True
|
| 346 |
+
assert isnan(3) == False
|
| 347 |
+
assert isnan(mpf(3)) == False
|
| 348 |
+
assert isnan(inf) == False
|
| 349 |
+
assert isnan(mpc(2,nan)) == True
|
| 350 |
+
assert isnan(mpc(2,nan)) == True
|
| 351 |
+
assert isnan(mpc(nan,nan)) == True
|
| 352 |
+
assert isnan(mpc(2,2)) == False
|
| 353 |
+
assert isnan(mpc(nan,inf)) == True
|
| 354 |
+
assert isnan(mpc(inf,inf)) == False
|
| 355 |
+
assert isnan(mpq((3,2))) == False
|
| 356 |
+
assert isnan(mpq((0,1))) == False
|
| 357 |
+
assert isinf(inf) == True
|
| 358 |
+
assert isinf(-inf) == True
|
| 359 |
+
assert isinf(3) == False
|
| 360 |
+
assert isinf(nan) == False
|
| 361 |
+
assert isinf(3+4j) == False
|
| 362 |
+
assert isinf(mpc(inf)) == True
|
| 363 |
+
assert isinf(mpc(3,inf)) == True
|
| 364 |
+
assert isinf(mpc(inf,3)) == True
|
| 365 |
+
assert isinf(mpc(inf,inf)) == True
|
| 366 |
+
assert isinf(mpc(nan,inf)) == True
|
| 367 |
+
assert isinf(mpc(inf,nan)) == True
|
| 368 |
+
assert isinf(mpc(nan,nan)) == False
|
| 369 |
+
assert isinf(mpq((3,2))) == False
|
| 370 |
+
assert isinf(mpq((0,1))) == False
|
| 371 |
+
assert isnormal(3) == True
|
| 372 |
+
assert isnormal(3.5) == True
|
| 373 |
+
assert isnormal(mpf(3.5)) == True
|
| 374 |
+
assert isnormal(0) == False
|
| 375 |
+
assert isnormal(mpf(0)) == False
|
| 376 |
+
assert isnormal(0.0) == False
|
| 377 |
+
assert isnormal(inf) == False
|
| 378 |
+
assert isnormal(-inf) == False
|
| 379 |
+
assert isnormal(nan) == False
|
| 380 |
+
assert isnormal(float(inf)) == False
|
| 381 |
+
assert isnormal(mpc(0,0)) == False
|
| 382 |
+
assert isnormal(mpc(3,0)) == True
|
| 383 |
+
assert isnormal(mpc(0,3)) == True
|
| 384 |
+
assert isnormal(mpc(3,3)) == True
|
| 385 |
+
assert isnormal(mpc(0,nan)) == False
|
| 386 |
+
assert isnormal(mpc(0,inf)) == False
|
| 387 |
+
assert isnormal(mpc(3,nan)) == False
|
| 388 |
+
assert isnormal(mpc(3,inf)) == False
|
| 389 |
+
assert isnormal(mpc(3,-inf)) == False
|
| 390 |
+
assert isnormal(mpc(nan,0)) == False
|
| 391 |
+
assert isnormal(mpc(inf,0)) == False
|
| 392 |
+
assert isnormal(mpc(nan,3)) == False
|
| 393 |
+
assert isnormal(mpc(inf,3)) == False
|
| 394 |
+
assert isnormal(mpc(inf,nan)) == False
|
| 395 |
+
assert isnormal(mpc(nan,inf)) == False
|
| 396 |
+
assert isnormal(mpc(nan,nan)) == False
|
| 397 |
+
assert isnormal(mpc(inf,inf)) == False
|
| 398 |
+
assert isnormal(mpq((3,2))) == True
|
| 399 |
+
assert isnormal(mpq((0,1))) == False
|
| 400 |
+
assert isint(3) == True
|
| 401 |
+
assert isint(0) == True
|
| 402 |
+
assert isint(long(3)) == True
|
| 403 |
+
assert isint(long(0)) == True
|
| 404 |
+
assert isint(mpf(3)) == True
|
| 405 |
+
assert isint(mpf(0)) == True
|
| 406 |
+
assert isint(mpf(-3)) == True
|
| 407 |
+
assert isint(mpf(3.2)) == False
|
| 408 |
+
assert isint(3.2) == False
|
| 409 |
+
assert isint(nan) == False
|
| 410 |
+
assert isint(inf) == False
|
| 411 |
+
assert isint(-inf) == False
|
| 412 |
+
assert isint(mpc(0)) == True
|
| 413 |
+
assert isint(mpc(3)) == True
|
| 414 |
+
assert isint(mpc(3.2)) == False
|
| 415 |
+
assert isint(mpc(3,inf)) == False
|
| 416 |
+
assert isint(mpc(inf)) == False
|
| 417 |
+
assert isint(mpc(3,2)) == False
|
| 418 |
+
assert isint(mpc(0,2)) == False
|
| 419 |
+
assert isint(mpc(3,2),gaussian=True) == True
|
| 420 |
+
assert isint(mpc(3,0),gaussian=True) == True
|
| 421 |
+
assert isint(mpc(0,3),gaussian=True) == True
|
| 422 |
+
assert isint(3+4j) == False
|
| 423 |
+
assert isint(3+4j, gaussian=True) == True
|
| 424 |
+
assert isint(3+0j) == True
|
| 425 |
+
assert isint(mpq((3,2))) == False
|
| 426 |
+
assert isint(mpq((3,9))) == False
|
| 427 |
+
assert isint(mpq((9,3))) == True
|
| 428 |
+
assert isint(mpq((0,4))) == True
|
| 429 |
+
assert isint(mpq((1,1))) == True
|
| 430 |
+
assert isint(mpq((-1,1))) == True
|
| 431 |
+
assert mp.isnpint(0) == True
|
| 432 |
+
assert mp.isnpint(1) == False
|
| 433 |
+
assert mp.isnpint(-1) == True
|
| 434 |
+
assert mp.isnpint(-1.1) == False
|
| 435 |
+
assert mp.isnpint(-1.0) == True
|
| 436 |
+
assert mp.isnpint(mp.mpq(1,2)) == False
|
| 437 |
+
assert mp.isnpint(mp.mpq(-1,2)) == False
|
| 438 |
+
assert mp.isnpint(mp.mpq(-3,1)) == True
|
| 439 |
+
assert mp.isnpint(mp.mpq(0,1)) == True
|
| 440 |
+
assert mp.isnpint(mp.mpq(1,1)) == False
|
| 441 |
+
assert mp.isnpint(0+0j) == True
|
| 442 |
+
assert mp.isnpint(-1+0j) == True
|
| 443 |
+
assert mp.isnpint(-1.1+0j) == False
|
| 444 |
+
assert mp.isnpint(-1+0.1j) == False
|
| 445 |
+
assert mp.isnpint(0+0.1j) == False
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
def test_issue_438():
|
| 449 |
+
assert mpf(finf) == mpf('inf')
|
| 450 |
+
assert mpf(fninf) == mpf('-inf')
|
| 451 |
+
assert mpf(fnan)._mpf_ == m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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Test bit-level integer and mpf operations
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from mpmath import *
|
| 6 |
+
from mpmath.libmp import *
|
| 7 |
+
|
| 8 |
+
def test_bitcount():
|
| 9 |
+
assert bitcount(0) == 0
|
| 10 |
+
assert bitcount(1) == 1
|
| 11 |
+
assert bitcount(7) == 3
|
| 12 |
+
assert bitcount(8) == 4
|
| 13 |
+
assert bitcount(2**100) == 101
|
| 14 |
+
assert bitcount(2**100-1) == 100
|
| 15 |
+
|
| 16 |
+
def test_trailing():
|
| 17 |
+
assert trailing(0) == 0
|
| 18 |
+
assert trailing(1) == 0
|
| 19 |
+
assert trailing(2) == 1
|
| 20 |
+
assert trailing(7) == 0
|
| 21 |
+
assert trailing(8) == 3
|
| 22 |
+
assert trailing(2**100) == 100
|
| 23 |
+
assert trailing(2**100-1) == 0
|
| 24 |
+
|
| 25 |
+
def test_round_down():
|
| 26 |
+
assert from_man_exp(0, -4, 4, round_down)[:3] == (0, 0, 0)
|
| 27 |
+
assert from_man_exp(0xf0, -4, 4, round_down)[:3] == (0, 15, 0)
|
| 28 |
+
assert from_man_exp(0xf1, -4, 4, round_down)[:3] == (0, 15, 0)
|
| 29 |
+
assert from_man_exp(0xff, -4, 4, round_down)[:3] == (0, 15, 0)
|
| 30 |
+
assert from_man_exp(-0xf0, -4, 4, round_down)[:3] == (1, 15, 0)
|
| 31 |
+
assert from_man_exp(-0xf1, -4, 4, round_down)[:3] == (1, 15, 0)
|
| 32 |
+
assert from_man_exp(-0xff, -4, 4, round_down)[:3] == (1, 15, 0)
|
| 33 |
+
|
| 34 |
+
def test_round_up():
|
| 35 |
+
assert from_man_exp(0, -4, 4, round_up)[:3] == (0, 0, 0)
|
| 36 |
+
assert from_man_exp(0xf0, -4, 4, round_up)[:3] == (0, 15, 0)
|
| 37 |
+
assert from_man_exp(0xf1, -4, 4, round_up)[:3] == (0, 1, 4)
|
| 38 |
+
assert from_man_exp(0xff, -4, 4, round_up)[:3] == (0, 1, 4)
|
| 39 |
+
assert from_man_exp(-0xf0, -4, 4, round_up)[:3] == (1, 15, 0)
|
| 40 |
+
assert from_man_exp(-0xf1, -4, 4, round_up)[:3] == (1, 1, 4)
|
| 41 |
+
assert from_man_exp(-0xff, -4, 4, round_up)[:3] == (1, 1, 4)
|
| 42 |
+
|
| 43 |
+
def test_round_floor():
|
| 44 |
+
assert from_man_exp(0, -4, 4, round_floor)[:3] == (0, 0, 0)
|
| 45 |
+
assert from_man_exp(0xf0, -4, 4, round_floor)[:3] == (0, 15, 0)
|
| 46 |
+
assert from_man_exp(0xf1, -4, 4, round_floor)[:3] == (0, 15, 0)
|
| 47 |
+
assert from_man_exp(0xff, -4, 4, round_floor)[:3] == (0, 15, 0)
|
| 48 |
+
assert from_man_exp(-0xf0, -4, 4, round_floor)[:3] == (1, 15, 0)
|
| 49 |
+
assert from_man_exp(-0xf1, -4, 4, round_floor)[:3] == (1, 1, 4)
|
| 50 |
+
assert from_man_exp(-0xff, -4, 4, round_floor)[:3] == (1, 1, 4)
|
| 51 |
+
|
| 52 |
+
def test_round_ceiling():
|
| 53 |
+
assert from_man_exp(0, -4, 4, round_ceiling)[:3] == (0, 0, 0)
|
| 54 |
+
assert from_man_exp(0xf0, -4, 4, round_ceiling)[:3] == (0, 15, 0)
|
| 55 |
+
assert from_man_exp(0xf1, -4, 4, round_ceiling)[:3] == (0, 1, 4)
|
| 56 |
+
assert from_man_exp(0xff, -4, 4, round_ceiling)[:3] == (0, 1, 4)
|
| 57 |
+
assert from_man_exp(-0xf0, -4, 4, round_ceiling)[:3] == (1, 15, 0)
|
| 58 |
+
assert from_man_exp(-0xf1, -4, 4, round_ceiling)[:3] == (1, 15, 0)
|
| 59 |
+
assert from_man_exp(-0xff, -4, 4, round_ceiling)[:3] == (1, 15, 0)
|
| 60 |
+
|
| 61 |
+
def test_round_nearest():
|
| 62 |
+
assert from_man_exp(0, -4, 4, round_nearest)[:3] == (0, 0, 0)
|
| 63 |
+
assert from_man_exp(0xf0, -4, 4, round_nearest)[:3] == (0, 15, 0)
|
| 64 |
+
assert from_man_exp(0xf7, -4, 4, round_nearest)[:3] == (0, 15, 0)
|
| 65 |
+
assert from_man_exp(0xf8, -4, 4, round_nearest)[:3] == (0, 1, 4) # 1111.1000 -> 10000.0
|
| 66 |
+
assert from_man_exp(0xf9, -4, 4, round_nearest)[:3] == (0, 1, 4) # 1111.1001 -> 10000.0
|
| 67 |
+
assert from_man_exp(0xe8, -4, 4, round_nearest)[:3] == (0, 7, 1) # 1110.1000 -> 1110.0
|
| 68 |
+
assert from_man_exp(0xe9, -4, 4, round_nearest)[:3] == (0, 15, 0) # 1110.1001 -> 1111.0
|
| 69 |
+
assert from_man_exp(-0xf0, -4, 4, round_nearest)[:3] == (1, 15, 0)
|
| 70 |
+
assert from_man_exp(-0xf7, -4, 4, round_nearest)[:3] == (1, 15, 0)
|
| 71 |
+
assert from_man_exp(-0xf8, -4, 4, round_nearest)[:3] == (1, 1, 4)
|
| 72 |
+
assert from_man_exp(-0xf9, -4, 4, round_nearest)[:3] == (1, 1, 4)
|
| 73 |
+
assert from_man_exp(-0xe8, -4, 4, round_nearest)[:3] == (1, 7, 1)
|
| 74 |
+
assert from_man_exp(-0xe9, -4, 4, round_nearest)[:3] == (1, 15, 0)
|
| 75 |
+
|
| 76 |
+
def test_rounding_bugs():
|
| 77 |
+
# 1 less than power-of-two cases
|
| 78 |
+
assert from_man_exp(72057594037927935, -56, 53, round_up) == (0, 1, 0, 1)
|
| 79 |
+
assert from_man_exp(73786976294838205979, -65, 53, round_nearest) == (0, 1, 1, 1)
|
| 80 |
+
assert from_man_exp(31, 0, 4, round_up) == (0, 1, 5, 1)
|
| 81 |
+
assert from_man_exp(-31, 0, 4, round_floor) == (1, 1, 5, 1)
|
| 82 |
+
assert from_man_exp(255, 0, 7, round_up) == (0, 1, 8, 1)
|
| 83 |
+
assert from_man_exp(-255, 0, 7, round_floor) == (1, 1, 8, 1)
|
| 84 |
+
|
| 85 |
+
def test_rounding_issue_200():
|
| 86 |
+
a = from_man_exp(9867,-100)
|
| 87 |
+
b = from_man_exp(9867,-200)
|
| 88 |
+
c = from_man_exp(-1,0)
|
| 89 |
+
z = (1, 1023, -10, 10)
|
| 90 |
+
assert mpf_add(a, c, 10, 'd') == z
|
| 91 |
+
assert mpf_add(b, c, 10, 'd') == z
|
| 92 |
+
assert mpf_add(c, a, 10, 'd') == z
|
| 93 |
+
assert mpf_add(c, b, 10, 'd') == z
|
| 94 |
+
|
| 95 |
+
def test_perturb():
|
| 96 |
+
a = fone
|
| 97 |
+
b = from_float(0.99999999999999989)
|
| 98 |
+
c = from_float(1.0000000000000002)
|
| 99 |
+
assert mpf_perturb(a, 0, 53, round_nearest) == a
|
| 100 |
+
assert mpf_perturb(a, 1, 53, round_nearest) == a
|
| 101 |
+
assert mpf_perturb(a, 0, 53, round_up) == c
|
| 102 |
+
assert mpf_perturb(a, 0, 53, round_ceiling) == c
|
| 103 |
+
assert mpf_perturb(a, 0, 53, round_down) == a
|
| 104 |
+
assert mpf_perturb(a, 0, 53, round_floor) == a
|
| 105 |
+
assert mpf_perturb(a, 1, 53, round_up) == a
|
| 106 |
+
assert mpf_perturb(a, 1, 53, round_ceiling) == a
|
| 107 |
+
assert mpf_perturb(a, 1, 53, round_down) == b
|
| 108 |
+
assert mpf_perturb(a, 1, 53, round_floor) == b
|
| 109 |
+
a = mpf_neg(a)
|
| 110 |
+
b = mpf_neg(b)
|
| 111 |
+
c = mpf_neg(c)
|
| 112 |
+
assert mpf_perturb(a, 0, 53, round_nearest) == a
|
| 113 |
+
assert mpf_perturb(a, 1, 53, round_nearest) == a
|
| 114 |
+
assert mpf_perturb(a, 0, 53, round_up) == a
|
| 115 |
+
assert mpf_perturb(a, 0, 53, round_floor) == a
|
| 116 |
+
assert mpf_perturb(a, 0, 53, round_down) == b
|
| 117 |
+
assert mpf_perturb(a, 0, 53, round_ceiling) == b
|
| 118 |
+
assert mpf_perturb(a, 1, 53, round_up) == c
|
| 119 |
+
assert mpf_perturb(a, 1, 53, round_floor) == c
|
| 120 |
+
assert mpf_perturb(a, 1, 53, round_down) == a
|
| 121 |
+
assert mpf_perturb(a, 1, 53, round_ceiling) == a
|
| 122 |
+
|
| 123 |
+
def test_add_exact():
|
| 124 |
+
ff = from_float
|
| 125 |
+
assert mpf_add(ff(3.0), ff(2.5)) == ff(5.5)
|
| 126 |
+
assert mpf_add(ff(3.0), ff(-2.5)) == ff(0.5)
|
| 127 |
+
assert mpf_add(ff(-3.0), ff(2.5)) == ff(-0.5)
|
| 128 |
+
assert mpf_add(ff(-3.0), ff(-2.5)) == ff(-5.5)
|
| 129 |
+
assert mpf_sub(mpf_add(fone, ff(1e-100)), fone) == ff(1e-100)
|
| 130 |
+
assert mpf_sub(mpf_add(ff(1e-100), fone), fone) == ff(1e-100)
|
| 131 |
+
assert mpf_sub(mpf_add(fone, ff(-1e-100)), fone) == ff(-1e-100)
|
| 132 |
+
assert mpf_sub(mpf_add(ff(-1e-100), fone), fone) == ff(-1e-100)
|
| 133 |
+
assert mpf_add(fone, fzero) == fone
|
| 134 |
+
assert mpf_add(fzero, fone) == fone
|
| 135 |
+
assert mpf_add(fzero, fzero) == fzero
|
| 136 |
+
|
| 137 |
+
def test_long_exponent_shifts():
|
| 138 |
+
mp.dps = 15
|
| 139 |
+
# Check for possible bugs due to exponent arithmetic overflow
|
| 140 |
+
# in a C implementation
|
| 141 |
+
x = mpf(1)
|
| 142 |
+
for p in [32, 64]:
|
| 143 |
+
a = ldexp(1,2**(p-1))
|
| 144 |
+
b = ldexp(1,2**p)
|
| 145 |
+
c = ldexp(1,2**(p+1))
|
| 146 |
+
d = ldexp(1,-2**(p-1))
|
| 147 |
+
e = ldexp(1,-2**p)
|
| 148 |
+
f = ldexp(1,-2**(p+1))
|
| 149 |
+
assert (x+a) == a
|
| 150 |
+
assert (x+b) == b
|
| 151 |
+
assert (x+c) == c
|
| 152 |
+
assert (x+d) == x
|
| 153 |
+
assert (x+e) == x
|
| 154 |
+
assert (x+f) == x
|
| 155 |
+
assert (a+x) == a
|
| 156 |
+
assert (b+x) == b
|
| 157 |
+
assert (c+x) == c
|
| 158 |
+
assert (d+x) == x
|
| 159 |
+
assert (e+x) == x
|
| 160 |
+
assert (f+x) == x
|
| 161 |
+
assert (x-a) == -a
|
| 162 |
+
assert (x-b) == -b
|
| 163 |
+
assert (x-c) == -c
|
| 164 |
+
assert (x-d) == x
|
| 165 |
+
assert (x-e) == x
|
| 166 |
+
assert (x-f) == x
|
| 167 |
+
assert (a-x) == a
|
| 168 |
+
assert (b-x) == b
|
| 169 |
+
assert (c-x) == c
|
| 170 |
+
assert (d-x) == -x
|
| 171 |
+
assert (e-x) == -x
|
| 172 |
+
assert (f-x) == -x
|
| 173 |
+
|
| 174 |
+
def test_float_rounding():
|
| 175 |
+
mp.prec = 64
|
| 176 |
+
for x in [mpf(1), mpf(1)+eps, mpf(1)-eps, -mpf(1)+eps, -mpf(1)-eps]:
|
| 177 |
+
fa = float(x)
|
| 178 |
+
fb = float(fadd(x,0,prec=53,rounding='n'))
|
| 179 |
+
assert fa == fb
|
| 180 |
+
z = mpc(x,x)
|
| 181 |
+
ca = complex(z)
|
| 182 |
+
cb = complex(fadd(z,0,prec=53,rounding='n'))
|
| 183 |
+
assert ca == cb
|
| 184 |
+
for rnd in ['n', 'd', 'u', 'f', 'c']:
|
| 185 |
+
fa = to_float(x._mpf_, rnd=rnd)
|
| 186 |
+
fb = to_float(fadd(x,0,prec=53,rounding=rnd)._mpf_, rnd=rnd)
|
| 187 |
+
assert fa == fb
|
| 188 |
+
mp.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
from mpmath import *
|
| 3 |
+
from mpmath.libmp import *
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def test_basic_string():
|
| 7 |
+
"""
|
| 8 |
+
Test basic string conversion
|
| 9 |
+
"""
|
| 10 |
+
mp.dps = 15
|
| 11 |
+
assert mpf('3') == mpf('3.0') == mpf('0003.') == mpf('0.03e2') == mpf(3.0)
|
| 12 |
+
assert mpf('30') == mpf('30.0') == mpf('00030.') == mpf(30.0)
|
| 13 |
+
for i in range(10):
|
| 14 |
+
for j in range(10):
|
| 15 |
+
assert mpf('%ie%i' % (i,j)) == i * 10**j
|
| 16 |
+
assert str(mpf('25000.0')) == '25000.0'
|
| 17 |
+
assert str(mpf('2500.0')) == '2500.0'
|
| 18 |
+
assert str(mpf('250.0')) == '250.0'
|
| 19 |
+
assert str(mpf('25.0')) == '25.0'
|
| 20 |
+
assert str(mpf('2.5')) == '2.5'
|
| 21 |
+
assert str(mpf('0.25')) == '0.25'
|
| 22 |
+
assert str(mpf('0.025')) == '0.025'
|
| 23 |
+
assert str(mpf('0.0025')) == '0.0025'
|
| 24 |
+
assert str(mpf('0.00025')) == '0.00025'
|
| 25 |
+
assert str(mpf('0.000025')) == '2.5e-5'
|
| 26 |
+
assert str(mpf(0)) == '0.0'
|
| 27 |
+
assert str(mpf('2.5e1000000000000000000000')) == '2.5e+1000000000000000000000'
|
| 28 |
+
assert str(mpf('2.6e-1000000000000000000000')) == '2.6e-1000000000000000000000'
|
| 29 |
+
assert str(mpf(1.23402834e-15)) == '1.23402834e-15'
|
| 30 |
+
assert str(mpf(-1.23402834e-15)) == '-1.23402834e-15'
|
| 31 |
+
assert str(mpf(-1.2344e-15)) == '-1.2344e-15'
|
| 32 |
+
assert repr(mpf(-1.2344e-15)) == "mpf('-1.2343999999999999e-15')"
|
| 33 |
+
assert str(mpf("2163048125L")) == '2163048125.0'
|
| 34 |
+
assert str(mpf("-2163048125l")) == '-2163048125.0'
|
| 35 |
+
assert str(mpf("-2163048125L/1088391168")) == '-1.98738118113799'
|
| 36 |
+
assert str(mpf("2163048125/1088391168l")) == '1.98738118113799'
|
| 37 |
+
|
| 38 |
+
def test_pretty():
|
| 39 |
+
mp.pretty = True
|
| 40 |
+
assert repr(mpf(2.5)) == '2.5'
|
| 41 |
+
assert repr(mpc(2.5,3.5)) == '(2.5 + 3.5j)'
|
| 42 |
+
mp.pretty = False
|
| 43 |
+
iv.pretty = True
|
| 44 |
+
assert repr(mpi(2.5,3.5)) == '[2.5, 3.5]'
|
| 45 |
+
iv.pretty = False
|
| 46 |
+
|
| 47 |
+
def test_str_whitespace():
|
| 48 |
+
assert mpf('1.26 ') == 1.26
|
| 49 |
+
|
| 50 |
+
def test_unicode():
|
| 51 |
+
mp.dps = 15
|
| 52 |
+
try:
|
| 53 |
+
unicode = unicode
|
| 54 |
+
except NameError:
|
| 55 |
+
unicode = str
|
| 56 |
+
assert mpf(unicode('2.76')) == 2.76
|
| 57 |
+
assert mpf(unicode('inf')) == inf
|
| 58 |
+
|
| 59 |
+
def test_str_format():
|
| 60 |
+
assert to_str(from_float(0.1),15,strip_zeros=False) == '0.100000000000000'
|
| 61 |
+
assert to_str(from_float(0.0),15,show_zero_exponent=True) == '0.0e+0'
|
| 62 |
+
assert to_str(from_float(0.0),0,show_zero_exponent=True) == '.0e+0'
|
| 63 |
+
assert to_str(from_float(0.0),0,show_zero_exponent=False) == '.0'
|
| 64 |
+
assert to_str(from_float(0.0),1,show_zero_exponent=True) == '0.0e+0'
|
| 65 |
+
assert to_str(from_float(0.0),1,show_zero_exponent=False) == '0.0'
|
| 66 |
+
assert to_str(from_float(1.23),3,show_zero_exponent=True) == '1.23e+0'
|
| 67 |
+
assert to_str(from_float(1.23456789000000e-2),15,strip_zeros=False,min_fixed=0,max_fixed=0) == '1.23456789000000e-2'
|
| 68 |
+
assert to_str(from_float(1.23456789000000e+2),15,strip_zeros=False,min_fixed=0,max_fixed=0) == '1.23456789000000e+2'
|
| 69 |
+
assert to_str(from_float(2.1287e14), 15, max_fixed=1000) == '212870000000000.0'
|
| 70 |
+
assert to_str(from_float(2.1287e15), 15, max_fixed=1000) == '2128700000000000.0'
|
| 71 |
+
assert to_str(from_float(2.1287e16), 15, max_fixed=1000) == '21287000000000000.0'
|
| 72 |
+
assert to_str(from_float(2.1287e30), 15, max_fixed=1000) == '2128700000000000000000000000000.0'
|
| 73 |
+
|
| 74 |
+
def test_tight_string_conversion():
|
| 75 |
+
mp.dps = 15
|
| 76 |
+
# In an old version, '0.5' wasn't recognized as representing
|
| 77 |
+
# an exact binary number and was erroneously rounded up or down
|
| 78 |
+
assert from_str('0.5', 10, round_floor) == fhalf
|
| 79 |
+
assert from_str('0.5', 10, round_ceiling) == fhalf
|
| 80 |
+
|
| 81 |
+
def test_eval_repr_invariant():
|
| 82 |
+
"""Test that eval(repr(x)) == x"""
|
| 83 |
+
random.seed(123)
|
| 84 |
+
for dps in [10, 15, 20, 50, 100]:
|
| 85 |
+
mp.dps = dps
|
| 86 |
+
for i in range(1000):
|
| 87 |
+
a = mpf(random.random())**0.5 * 10**random.randint(-100, 100)
|
| 88 |
+
assert eval(repr(a)) == a
|
| 89 |
+
mp.dps = 15
|
| 90 |
+
|
| 91 |
+
def test_str_bugs():
|
| 92 |
+
mp.dps = 15
|
| 93 |
+
# Decimal rounding used to give the wrong exponent in some cases
|
| 94 |
+
assert str(mpf('1e600')) == '1.0e+600'
|
| 95 |
+
assert str(mpf('1e10000')) == '1.0e+10000'
|
| 96 |
+
|
| 97 |
+
def test_str_prec0():
|
| 98 |
+
assert to_str(from_float(1.234), 0) == '.0e+0'
|
| 99 |
+
assert to_str(from_float(1e-15), 0) == '.0e-15'
|
| 100 |
+
assert to_str(from_float(1e+15), 0) == '.0e+15'
|
| 101 |
+
assert to_str(from_float(-1e-15), 0) == '-.0e-15'
|
| 102 |
+
assert to_str(from_float(-1e+15), 0) == '-.0e+15'
|
| 103 |
+
|
| 104 |
+
def test_convert_rational():
|
| 105 |
+
mp.dps = 15
|
| 106 |
+
assert from_rational(30, 5, 53, round_nearest) == (0, 3, 1, 2)
|
| 107 |
+
assert from_rational(-7, 4, 53, round_nearest) == (1, 7, -2, 3)
|
| 108 |
+
assert to_rational((0, 1, -1, 1)) == (1, 2)
|
| 109 |
+
|
| 110 |
+
def test_custom_class():
|
| 111 |
+
class mympf:
|
| 112 |
+
@property
|
| 113 |
+
def _mpf_(self):
|
| 114 |
+
return mpf(3.5)._mpf_
|
| 115 |
+
class mympc:
|
| 116 |
+
@property
|
| 117 |
+
def _mpc_(self):
|
| 118 |
+
return mpf(3.5)._mpf_, mpf(2.5)._mpf_
|
| 119 |
+
assert mpf(2) + mympf() == 5.5
|
| 120 |
+
assert mympf() + mpf(2) == 5.5
|
| 121 |
+
assert mpf(mympf()) == 3.5
|
| 122 |
+
assert mympc() + mpc(2) == mpc(5.5, 2.5)
|
| 123 |
+
assert mpc(2) + mympc() == mpc(5.5, 2.5)
|
| 124 |
+
assert mpc(mympc()) == (3.5+2.5j)
|
| 125 |
+
|
| 126 |
+
def test_conversion_methods():
|
| 127 |
+
class SomethingRandom:
|
| 128 |
+
pass
|
| 129 |
+
class SomethingReal:
|
| 130 |
+
def _mpmath_(self, prec, rounding):
|
| 131 |
+
return mp.make_mpf(from_str('1.3', prec, rounding))
|
| 132 |
+
class SomethingComplex:
|
| 133 |
+
def _mpmath_(self, prec, rounding):
|
| 134 |
+
return mp.make_mpc((from_str('1.3', prec, rounding), \
|
| 135 |
+
from_str('1.7', prec, rounding)))
|
| 136 |
+
x = mpf(3)
|
| 137 |
+
z = mpc(3)
|
| 138 |
+
a = SomethingRandom()
|
| 139 |
+
y = SomethingReal()
|
| 140 |
+
w = SomethingComplex()
|
| 141 |
+
for d in [15, 45]:
|
| 142 |
+
mp.dps = d
|
| 143 |
+
assert (x+y).ae(mpf('4.3'))
|
| 144 |
+
assert (y+x).ae(mpf('4.3'))
|
| 145 |
+
assert (x+w).ae(mpc('4.3', '1.7'))
|
| 146 |
+
assert (w+x).ae(mpc('4.3', '1.7'))
|
| 147 |
+
assert (z+y).ae(mpc('4.3'))
|
| 148 |
+
assert (y+z).ae(mpc('4.3'))
|
| 149 |
+
assert (z+w).ae(mpc('4.3', '1.7'))
|
| 150 |
+
assert (w+z).ae(mpc('4.3', '1.7'))
|
| 151 |
+
x-y; y-x; x-w; w-x; z-y; y-z; z-w; w-z
|
| 152 |
+
x*y; y*x; x*w; w*x; z*y; y*z; z*w; w*z
|
| 153 |
+
x/y; y/x; x/w; w/x; z/y; y/z; z/w; w/z
|
| 154 |
+
x**y; y**x; x**w; w**x; z**y; y**z; z**w; w**z
|
| 155 |
+
x==y; y==x; x==w; w==x; z==y; y==z; z==w; w==z
|
| 156 |
+
mp.dps = 15
|
| 157 |
+
assert x.__add__(a) is NotImplemented
|
| 158 |
+
assert x.__radd__(a) is NotImplemented
|
| 159 |
+
assert x.__lt__(a) is NotImplemented
|
| 160 |
+
assert x.__gt__(a) is NotImplemented
|
| 161 |
+
assert x.__le__(a) is NotImplemented
|
| 162 |
+
assert x.__ge__(a) is NotImplemented
|
| 163 |
+
assert x.__eq__(a) is NotImplemented
|
| 164 |
+
assert x.__ne__(a) is NotImplemented
|
| 165 |
+
# implementation detail
|
| 166 |
+
if hasattr(x, "__cmp__"):
|
| 167 |
+
assert x.__cmp__(a) is NotImplemented
|
| 168 |
+
assert x.__sub__(a) is NotImplemented
|
| 169 |
+
assert x.__rsub__(a) is NotImplemented
|
| 170 |
+
assert x.__mul__(a) is NotImplemented
|
| 171 |
+
assert x.__rmul__(a) is NotImplemented
|
| 172 |
+
assert x.__div__(a) is NotImplemented
|
| 173 |
+
assert x.__rdiv__(a) is NotImplemented
|
| 174 |
+
assert x.__mod__(a) is NotImplemented
|
| 175 |
+
assert x.__rmod__(a) is NotImplemented
|
| 176 |
+
assert x.__pow__(a) is NotImplemented
|
| 177 |
+
assert x.__rpow__(a) is NotImplemented
|
| 178 |
+
assert z.__add__(a) is NotImplemented
|
| 179 |
+
assert z.__radd__(a) is NotImplemented
|
| 180 |
+
assert z.__eq__(a) is NotImplemented
|
| 181 |
+
assert z.__ne__(a) is NotImplemented
|
| 182 |
+
assert z.__sub__(a) is NotImplemented
|
| 183 |
+
assert z.__rsub__(a) is NotImplemented
|
| 184 |
+
assert z.__mul__(a) is NotImplemented
|
| 185 |
+
assert z.__rmul__(a) is NotImplemented
|
| 186 |
+
assert z.__div__(a) is NotImplemented
|
| 187 |
+
assert z.__rdiv__(a) is NotImplemented
|
| 188 |
+
assert z.__pow__(a) is NotImplemented
|
| 189 |
+
assert z.__rpow__(a) is NotImplemented
|
| 190 |
+
|
| 191 |
+
def test_mpmathify():
|
| 192 |
+
assert mpmathify('1/2') == 0.5
|
| 193 |
+
assert mpmathify('(1.0+1.0j)') == mpc(1, 1)
|
| 194 |
+
assert mpmathify('(1.2e-10 - 3.4e5j)') == mpc('1.2e-10', '-3.4e5')
|
| 195 |
+
assert mpmathify('1j') == mpc(1j)
|
| 196 |
+
|
| 197 |
+
def test_issue548():
|
| 198 |
+
try:
|
| 199 |
+
# This expression is invalid, but may trigger the ReDOS vulnerability
|
| 200 |
+
# in the regular expression for parsing complex numbers.
|
| 201 |
+
mpmathify('(' + '1' * 5000 + '!j')
|
| 202 |
+
except:
|
| 203 |
+
return
|
| 204 |
+
# The expression is invalid and should raise an exception.
|
| 205 |
+
assert False
|
| 206 |
+
|
| 207 |
+
def test_compatibility():
|
| 208 |
+
try:
|
| 209 |
+
import numpy as np
|
| 210 |
+
from fractions import Fraction
|
| 211 |
+
from decimal import Decimal
|
| 212 |
+
import decimal
|
| 213 |
+
except ImportError:
|
| 214 |
+
return
|
| 215 |
+
# numpy types
|
| 216 |
+
for nptype in np.core.numerictypes.typeDict.values():
|
| 217 |
+
if issubclass(nptype, np.complexfloating):
|
| 218 |
+
x = nptype(complex(0.5, -0.5))
|
| 219 |
+
elif issubclass(nptype, np.floating):
|
| 220 |
+
x = nptype(0.5)
|
| 221 |
+
elif issubclass(nptype, np.integer):
|
| 222 |
+
x = nptype(2)
|
| 223 |
+
# Handle the weird types
|
| 224 |
+
try: diff = np.abs(type(np.sqrt(x))(sqrt(x)) - np.sqrt(x))
|
| 225 |
+
except: continue
|
| 226 |
+
assert diff < 2.0**-53
|
| 227 |
+
#Fraction and Decimal
|
| 228 |
+
oldprec = mp.prec
|
| 229 |
+
mp.prec = 1000
|
| 230 |
+
decimal.getcontext().prec = mp.dps
|
| 231 |
+
assert sqrt(Fraction(2, 3)).ae(sqrt(mpf('2/3')))
|
| 232 |
+
assert sqrt(Decimal(2)/Decimal(3)).ae(sqrt(mpf('2/3')))
|
| 233 |
+
mp.prec = oldprec
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_eigen.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 7 |
+
xrange = libmp.backend.xrange
|
| 8 |
+
|
| 9 |
+
def run_hessenberg(A, verbose = 0):
|
| 10 |
+
if verbose > 1:
|
| 11 |
+
print("original matrix (hessenberg):\n", A)
|
| 12 |
+
|
| 13 |
+
n = A.rows
|
| 14 |
+
|
| 15 |
+
Q, H = mp.hessenberg(A)
|
| 16 |
+
|
| 17 |
+
if verbose > 1:
|
| 18 |
+
print("Q:\n",Q)
|
| 19 |
+
print("H:\n",H)
|
| 20 |
+
|
| 21 |
+
B = Q * H * Q.transpose_conj()
|
| 22 |
+
|
| 23 |
+
eps = mp.exp(0.8 * mp.log(mp.eps))
|
| 24 |
+
|
| 25 |
+
err0 = 0
|
| 26 |
+
for x in xrange(n):
|
| 27 |
+
for y in xrange(n):
|
| 28 |
+
err0 += abs(A[y,x] - B[y,x])
|
| 29 |
+
err0 /= n * n
|
| 30 |
+
|
| 31 |
+
err1 = 0
|
| 32 |
+
for x in xrange(n):
|
| 33 |
+
for y in xrange(x + 2, n):
|
| 34 |
+
err1 += abs(H[y,x])
|
| 35 |
+
|
| 36 |
+
if verbose > 0:
|
| 37 |
+
print("difference (H):", err0, err1)
|
| 38 |
+
|
| 39 |
+
if verbose > 1:
|
| 40 |
+
print("B:\n", B)
|
| 41 |
+
|
| 42 |
+
assert err0 < eps
|
| 43 |
+
assert err1 == 0
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def run_schur(A, verbose = 0):
|
| 47 |
+
if verbose > 1:
|
| 48 |
+
print("original matrix (schur):\n", A)
|
| 49 |
+
|
| 50 |
+
n = A.rows
|
| 51 |
+
|
| 52 |
+
Q, R = mp.schur(A)
|
| 53 |
+
|
| 54 |
+
if verbose > 1:
|
| 55 |
+
print("Q:\n", Q)
|
| 56 |
+
print("R:\n", R)
|
| 57 |
+
|
| 58 |
+
B = Q * R * Q.transpose_conj()
|
| 59 |
+
C = Q * Q.transpose_conj()
|
| 60 |
+
|
| 61 |
+
eps = mp.exp(0.8 * mp.log(mp.eps))
|
| 62 |
+
|
| 63 |
+
err0 = 0
|
| 64 |
+
for x in xrange(n):
|
| 65 |
+
for y in xrange(n):
|
| 66 |
+
err0 += abs(A[y,x] - B[y,x])
|
| 67 |
+
err0 /= n * n
|
| 68 |
+
|
| 69 |
+
err1 = 0
|
| 70 |
+
for x in xrange(n):
|
| 71 |
+
for y in xrange(n):
|
| 72 |
+
if x == y:
|
| 73 |
+
C[y,x] -= 1
|
| 74 |
+
err1 += abs(C[y,x])
|
| 75 |
+
err1 /= n * n
|
| 76 |
+
|
| 77 |
+
err2 = 0
|
| 78 |
+
for x in xrange(n):
|
| 79 |
+
for y in xrange(x + 1, n):
|
| 80 |
+
err2 += abs(R[y,x])
|
| 81 |
+
|
| 82 |
+
if verbose > 0:
|
| 83 |
+
print("difference (S):", err0, err1, err2)
|
| 84 |
+
|
| 85 |
+
if verbose > 1:
|
| 86 |
+
print("B:\n", B)
|
| 87 |
+
|
| 88 |
+
assert err0 < eps
|
| 89 |
+
assert err1 < eps
|
| 90 |
+
assert err2 == 0
|
| 91 |
+
|
| 92 |
+
def run_eig(A, verbose = 0):
|
| 93 |
+
if verbose > 1:
|
| 94 |
+
print("original matrix (eig):\n", A)
|
| 95 |
+
|
| 96 |
+
n = A.rows
|
| 97 |
+
|
| 98 |
+
E, EL, ER = mp.eig(A, left = True, right = True)
|
| 99 |
+
|
| 100 |
+
if verbose > 1:
|
| 101 |
+
print("E:\n", E)
|
| 102 |
+
print("EL:\n", EL)
|
| 103 |
+
print("ER:\n", ER)
|
| 104 |
+
|
| 105 |
+
eps = mp.exp(0.8 * mp.log(mp.eps))
|
| 106 |
+
|
| 107 |
+
err0 = 0
|
| 108 |
+
for i in xrange(n):
|
| 109 |
+
B = A * ER[:,i] - E[i] * ER[:,i]
|
| 110 |
+
err0 = max(err0, mp.mnorm(B))
|
| 111 |
+
|
| 112 |
+
B = EL[i,:] * A - EL[i,:] * E[i]
|
| 113 |
+
err0 = max(err0, mp.mnorm(B))
|
| 114 |
+
|
| 115 |
+
err0 /= n * n
|
| 116 |
+
|
| 117 |
+
if verbose > 0:
|
| 118 |
+
print("difference (E):", err0)
|
| 119 |
+
|
| 120 |
+
assert err0 < eps
|
| 121 |
+
|
| 122 |
+
#####################
|
| 123 |
+
|
| 124 |
+
def test_eig_dyn():
|
| 125 |
+
v = 0
|
| 126 |
+
for i in xrange(5):
|
| 127 |
+
n = 1 + int(mp.rand() * 5)
|
| 128 |
+
if mp.rand() > 0.5:
|
| 129 |
+
# real
|
| 130 |
+
A = 2 * mp.randmatrix(n, n) - 1
|
| 131 |
+
if mp.rand() > 0.5:
|
| 132 |
+
A *= 10
|
| 133 |
+
for x in xrange(n):
|
| 134 |
+
for y in xrange(n):
|
| 135 |
+
A[x,y] = int(A[x,y])
|
| 136 |
+
else:
|
| 137 |
+
A = (2 * mp.randmatrix(n, n) - 1) + 1j * (2 * mp.randmatrix(n, n) - 1)
|
| 138 |
+
if mp.rand() > 0.5:
|
| 139 |
+
A *= 10
|
| 140 |
+
for x in xrange(n):
|
| 141 |
+
for y in xrange(n):
|
| 142 |
+
A[x,y] = int(mp.re(A[x,y])) + 1j * int(mp.im(A[x,y]))
|
| 143 |
+
|
| 144 |
+
run_hessenberg(A, verbose = v)
|
| 145 |
+
run_schur(A, verbose = v)
|
| 146 |
+
run_eig(A, verbose = v)
|
| 147 |
+
|
| 148 |
+
def test_eig():
|
| 149 |
+
v = 0
|
| 150 |
+
AS = []
|
| 151 |
+
|
| 152 |
+
A = mp.matrix([[2, 1, 0], # jordan block of size 3
|
| 153 |
+
[0, 2, 1],
|
| 154 |
+
[0, 0, 2]])
|
| 155 |
+
AS.append(A)
|
| 156 |
+
AS.append(A.transpose())
|
| 157 |
+
|
| 158 |
+
A = mp.matrix([[2, 0, 0], # jordan block of size 2
|
| 159 |
+
[0, 2, 1],
|
| 160 |
+
[0, 0, 2]])
|
| 161 |
+
AS.append(A)
|
| 162 |
+
AS.append(A.transpose())
|
| 163 |
+
|
| 164 |
+
A = mp.matrix([[2, 0, 1], # jordan block of size 2
|
| 165 |
+
[0, 2, 0],
|
| 166 |
+
[0, 0, 2]])
|
| 167 |
+
AS.append(A)
|
| 168 |
+
AS.append(A.transpose())
|
| 169 |
+
|
| 170 |
+
A= mp.matrix([[0, 0, 1], # cyclic
|
| 171 |
+
[1, 0, 0],
|
| 172 |
+
[0, 1, 0]])
|
| 173 |
+
AS.append(A)
|
| 174 |
+
AS.append(A.transpose())
|
| 175 |
+
|
| 176 |
+
for A in AS:
|
| 177 |
+
run_hessenberg(A, verbose = v)
|
| 178 |
+
run_schur(A, verbose = v)
|
| 179 |
+
run_eig(A, verbose = v)
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_fp.py
ADDED
|
@@ -0,0 +1,1671 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Easy-to-use test-generating code:
|
| 3 |
+
|
| 4 |
+
cases = '''
|
| 5 |
+
exp 2.25
|
| 6 |
+
log 2.25
|
| 7 |
+
'''
|
| 8 |
+
|
| 9 |
+
from mpmath import *
|
| 10 |
+
mp.dps = 20
|
| 11 |
+
for test in cases.splitlines():
|
| 12 |
+
if not test:
|
| 13 |
+
continue
|
| 14 |
+
words = test.split()
|
| 15 |
+
fname = words[0]
|
| 16 |
+
args = words[1:]
|
| 17 |
+
argstr = ", ".join(args)
|
| 18 |
+
testline = "%s(%s)" % (fname, argstr)
|
| 19 |
+
ans = str(eval(testline))
|
| 20 |
+
print " assert ae(fp.%s, %s)" % (testline, ans)
|
| 21 |
+
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
from mpmath import fp
|
| 25 |
+
|
| 26 |
+
def ae(x, y, tol=1e-12):
|
| 27 |
+
if x == y:
|
| 28 |
+
return True
|
| 29 |
+
return abs(x-y) <= tol*abs(y)
|
| 30 |
+
|
| 31 |
+
def test_conj():
|
| 32 |
+
assert fp.conj(4) == 4
|
| 33 |
+
assert fp.conj(3+4j) == 3-4j
|
| 34 |
+
assert fp.fdot([1,2],[3,2+1j], conjugate=True) == 7-2j
|
| 35 |
+
|
| 36 |
+
def test_fp_number_parts():
|
| 37 |
+
assert ae(fp.arg(3), 0.0)
|
| 38 |
+
assert ae(fp.arg(-3), 3.1415926535897932385)
|
| 39 |
+
assert ae(fp.arg(3j), 1.5707963267948966192)
|
| 40 |
+
assert ae(fp.arg(-3j), -1.5707963267948966192)
|
| 41 |
+
assert ae(fp.arg(2+3j), 0.98279372324732906799)
|
| 42 |
+
assert ae(fp.arg(-1-1j), -2.3561944901923449288)
|
| 43 |
+
assert ae(fp.re(2.5), 2.5)
|
| 44 |
+
assert ae(fp.re(2.5+3j), 2.5)
|
| 45 |
+
assert ae(fp.im(2.5), 0.0)
|
| 46 |
+
assert ae(fp.im(2.5+3j), 3.0)
|
| 47 |
+
assert ae(fp.floor(2.5), 2.0)
|
| 48 |
+
assert ae(fp.floor(2), 2.0)
|
| 49 |
+
assert ae(fp.floor(2.0+0j), (2.0 + 0.0j))
|
| 50 |
+
assert ae(fp.floor(-1.5-0.5j), (-2.0 - 1.0j))
|
| 51 |
+
assert ae(fp.ceil(2.5), 3.0)
|
| 52 |
+
assert ae(fp.ceil(2), 2.0)
|
| 53 |
+
assert ae(fp.ceil(2.0+0j), (2.0 + 0.0j))
|
| 54 |
+
assert ae(fp.ceil(-1.5-0.5j), (-1.0 + 0.0j))
|
| 55 |
+
|
| 56 |
+
def test_fp_cospi_sinpi():
|
| 57 |
+
assert ae(fp.sinpi(0), 0.0)
|
| 58 |
+
assert ae(fp.sinpi(0.25), 0.7071067811865475244)
|
| 59 |
+
assert ae(fp.sinpi(0.5), 1.0)
|
| 60 |
+
assert ae(fp.sinpi(0.75), 0.7071067811865475244)
|
| 61 |
+
assert ae(fp.sinpi(1), 0.0)
|
| 62 |
+
assert ae(fp.sinpi(1.25), -0.7071067811865475244)
|
| 63 |
+
assert ae(fp.sinpi(1.5), -1.0)
|
| 64 |
+
assert ae(fp.sinpi(1.75), -0.7071067811865475244)
|
| 65 |
+
assert ae(fp.sinpi(2), 0.0)
|
| 66 |
+
assert ae(fp.sinpi(2.25), 0.7071067811865475244)
|
| 67 |
+
assert ae(fp.sinpi(0+3j), (0.0 + 6195.8238636085899556j))
|
| 68 |
+
assert ae(fp.sinpi(0.25+3j), (4381.1091260582448033 + 4381.1090689950686908j))
|
| 69 |
+
assert ae(fp.sinpi(0.5+3j), (6195.8239443081075259 + 0.0j))
|
| 70 |
+
assert ae(fp.sinpi(0.75+3j), (4381.1091260582448033 - 4381.1090689950686908j))
|
| 71 |
+
assert ae(fp.sinpi(1+3j), (0.0 - 6195.8238636085899556j))
|
| 72 |
+
assert ae(fp.sinpi(1.25+3j), (-4381.1091260582448033 - 4381.1090689950686908j))
|
| 73 |
+
assert ae(fp.sinpi(1.5+3j), (-6195.8239443081075259 + 0.0j))
|
| 74 |
+
assert ae(fp.sinpi(1.75+3j), (-4381.1091260582448033 + 4381.1090689950686908j))
|
| 75 |
+
assert ae(fp.sinpi(2+3j), (0.0 + 6195.8238636085899556j))
|
| 76 |
+
assert ae(fp.sinpi(2.25+3j), (4381.1091260582448033 + 4381.1090689950686908j))
|
| 77 |
+
assert ae(fp.sinpi(-0.75), -0.7071067811865475244)
|
| 78 |
+
assert ae(fp.sinpi(-1e-10), -3.1415926535897933529e-10)
|
| 79 |
+
assert ae(fp.sinpi(1e-10), 3.1415926535897933529e-10)
|
| 80 |
+
assert ae(fp.sinpi(1e-10+1e-10j), (3.141592653589793353e-10 + 3.1415926535897933528e-10j))
|
| 81 |
+
assert ae(fp.sinpi(1e-10-1e-10j), (3.141592653589793353e-10 - 3.1415926535897933528e-10j))
|
| 82 |
+
assert ae(fp.sinpi(-1e-10+1e-10j), (-3.141592653589793353e-10 + 3.1415926535897933528e-10j))
|
| 83 |
+
assert ae(fp.sinpi(-1e-10-1e-10j), (-3.141592653589793353e-10 - 3.1415926535897933528e-10j))
|
| 84 |
+
assert ae(fp.cospi(0), 1.0)
|
| 85 |
+
assert ae(fp.cospi(0.25), 0.7071067811865475244)
|
| 86 |
+
assert ae(fp.cospi(0.5), 0.0)
|
| 87 |
+
assert ae(fp.cospi(0.75), -0.7071067811865475244)
|
| 88 |
+
assert ae(fp.cospi(1), -1.0)
|
| 89 |
+
assert ae(fp.cospi(1.25), -0.7071067811865475244)
|
| 90 |
+
assert ae(fp.cospi(1.5), 0.0)
|
| 91 |
+
assert ae(fp.cospi(1.75), 0.7071067811865475244)
|
| 92 |
+
assert ae(fp.cospi(2), 1.0)
|
| 93 |
+
assert ae(fp.cospi(2.25), 0.7071067811865475244)
|
| 94 |
+
assert ae(fp.cospi(0+3j), (6195.8239443081075259 + 0.0j))
|
| 95 |
+
assert ae(fp.cospi(0.25+3j), (4381.1091260582448033 - 4381.1090689950686908j))
|
| 96 |
+
assert ae(fp.cospi(0.5+3j), (0.0 - 6195.8238636085899556j))
|
| 97 |
+
assert ae(fp.cospi(0.75+3j), (-4381.1091260582448033 - 4381.1090689950686908j))
|
| 98 |
+
assert ae(fp.cospi(1+3j), (-6195.8239443081075259 + 0.0j))
|
| 99 |
+
assert ae(fp.cospi(1.25+3j), (-4381.1091260582448033 + 4381.1090689950686908j))
|
| 100 |
+
assert ae(fp.cospi(1.5+3j), (0.0 + 6195.8238636085899556j))
|
| 101 |
+
assert ae(fp.cospi(1.75+3j), (4381.1091260582448033 + 4381.1090689950686908j))
|
| 102 |
+
assert ae(fp.cospi(2+3j), (6195.8239443081075259 + 0.0j))
|
| 103 |
+
assert ae(fp.cospi(2.25+3j), (4381.1091260582448033 - 4381.1090689950686908j))
|
| 104 |
+
assert ae(fp.cospi(-0.75), -0.7071067811865475244)
|
| 105 |
+
assert ae(fp.sinpi(-0.7), -0.80901699437494750611)
|
| 106 |
+
assert ae(fp.cospi(-0.7), -0.5877852522924730163)
|
| 107 |
+
assert ae(fp.cospi(-3+2j), (-267.74676148374822225 + 0.0j))
|
| 108 |
+
assert ae(fp.sinpi(-3+2j), (0.0 - 267.74489404101651426j))
|
| 109 |
+
assert ae(fp.sinpi(-0.7+2j), (-216.6116802292079471 - 157.37650009392034693j))
|
| 110 |
+
assert ae(fp.cospi(-0.7+2j), (-157.37759774921754565 + 216.61016943630197336j))
|
| 111 |
+
|
| 112 |
+
def test_fp_expj():
|
| 113 |
+
assert ae(fp.expj(0), (1.0 + 0.0j))
|
| 114 |
+
assert ae(fp.expj(1), (0.5403023058681397174 + 0.84147098480789650665j))
|
| 115 |
+
assert ae(fp.expj(2), (-0.416146836547142387 + 0.9092974268256816954j))
|
| 116 |
+
assert ae(fp.expj(0.75), (0.73168886887382088631 + 0.68163876002333416673j))
|
| 117 |
+
assert ae(fp.expj(2+3j), (-0.020718731002242879378 + 0.045271253156092975488j))
|
| 118 |
+
assert ae(fp.expjpi(0), (1.0 + 0.0j))
|
| 119 |
+
assert ae(fp.expjpi(1), (-1.0 + 0.0j))
|
| 120 |
+
assert ae(fp.expjpi(2), (1.0 + 0.0j))
|
| 121 |
+
assert ae(fp.expjpi(0.75), (-0.7071067811865475244 + 0.7071067811865475244j))
|
| 122 |
+
assert ae(fp.expjpi(2+3j), (0.000080699517570304599239 + 0.0j))
|
| 123 |
+
|
| 124 |
+
def test_fp_bernoulli():
|
| 125 |
+
assert ae(fp.bernoulli(0), 1.0)
|
| 126 |
+
assert ae(fp.bernoulli(1), -0.5)
|
| 127 |
+
assert ae(fp.bernoulli(2), 0.16666666666666666667)
|
| 128 |
+
assert ae(fp.bernoulli(10), 0.075757575757575757576)
|
| 129 |
+
assert ae(fp.bernoulli(11), 0.0)
|
| 130 |
+
|
| 131 |
+
def test_fp_gamma():
|
| 132 |
+
assert ae(fp.gamma(1), 1.0)
|
| 133 |
+
assert ae(fp.gamma(1.5), 0.88622692545275801365)
|
| 134 |
+
assert ae(fp.gamma(10), 362880.0)
|
| 135 |
+
assert ae(fp.gamma(-0.5), -3.5449077018110320546)
|
| 136 |
+
assert ae(fp.gamma(-7.1), 0.0016478244570263333622)
|
| 137 |
+
assert ae(fp.gamma(12.3), 83385367.899970000963)
|
| 138 |
+
assert ae(fp.gamma(2+0j), (1.0 + 0.0j))
|
| 139 |
+
assert ae(fp.gamma(-2.5+0j), (-0.94530872048294188123 + 0.0j))
|
| 140 |
+
assert ae(fp.gamma(3+4j), (0.0052255384713692141947 - 0.17254707929430018772j))
|
| 141 |
+
assert ae(fp.gamma(-3-4j), (0.00001460997305874775607 - 0.000020760733311509070396j))
|
| 142 |
+
assert ae(fp.fac(0), 1.0)
|
| 143 |
+
assert ae(fp.fac(1), 1.0)
|
| 144 |
+
assert ae(fp.fac(20), 2432902008176640000.0)
|
| 145 |
+
assert ae(fp.fac(-3.5), -0.94530872048294188123)
|
| 146 |
+
assert ae(fp.fac(2+3j), (-0.44011340763700171113 - 0.06363724312631702183j))
|
| 147 |
+
assert ae(fp.loggamma(1.0), 0.0)
|
| 148 |
+
assert ae(fp.loggamma(2.0), 0.0)
|
| 149 |
+
assert ae(fp.loggamma(3.0), 0.69314718055994530942)
|
| 150 |
+
assert ae(fp.loggamma(7.25), 7.0521854507385394449)
|
| 151 |
+
assert ae(fp.loggamma(1000.0), 5905.2204232091812118)
|
| 152 |
+
assert ae(fp.loggamma(1e50), 1.1412925464970229298e+52)
|
| 153 |
+
assert ae(fp.loggamma(1e25+1e25j), (5.6125802751733671621e+26 + 5.7696599078528568383e+26j))
|
| 154 |
+
assert ae(fp.loggamma(3+4j), (-1.7566267846037841105 + 4.7426644380346579282j))
|
| 155 |
+
assert ae(fp.loggamma(-0.5), (1.2655121234846453965 - 3.1415926535897932385j))
|
| 156 |
+
assert ae(fp.loggamma(-1.25), (1.3664317612369762346 - 6.2831853071795864769j))
|
| 157 |
+
assert ae(fp.loggamma(-2.75), (0.0044878975359557733115 - 9.4247779607693797154j))
|
| 158 |
+
assert ae(fp.loggamma(-3.5), (-1.3090066849930420464 - 12.566370614359172954j))
|
| 159 |
+
assert ae(fp.loggamma(-4.5), (-2.8130840817693161197 - 15.707963267948966192j))
|
| 160 |
+
assert ae(fp.loggamma(-2+3j), (-6.776523813485657093 - 4.568791367260286402j))
|
| 161 |
+
assert ae(fp.loggamma(-1000.3), (-5912.8440347785205041 - 3144.7342462433830317j))
|
| 162 |
+
assert ae(fp.loggamma(-100-100j), (-632.35117666833135562 - 158.37641469650352462j))
|
| 163 |
+
assert ae(fp.loggamma(1e-10), 23.025850929882735237)
|
| 164 |
+
assert ae(fp.loggamma(-1e-10), (23.02585092999817837 - 3.1415926535897932385j))
|
| 165 |
+
assert ae(fp.loggamma(1e-10j), (23.025850929940456804 - 1.5707963268526181857j))
|
| 166 |
+
assert ae(fp.loggamma(1e-10j-1e-10), (22.679277339718205716 - 2.3561944902500664954j))
|
| 167 |
+
|
| 168 |
+
def test_fp_psi():
|
| 169 |
+
assert ae(fp.psi(0, 3.7), 1.1671535393615114409)
|
| 170 |
+
assert ae(fp.psi(0, 0.5), -1.9635100260214234794)
|
| 171 |
+
assert ae(fp.psi(0, 1), -0.57721566490153286061)
|
| 172 |
+
assert ae(fp.psi(0, -2.5), 1.1031566406452431872)
|
| 173 |
+
assert ae(fp.psi(0, 12.9), 2.5179671503279156347)
|
| 174 |
+
assert ae(fp.psi(0, 100), 4.6001618527380874002)
|
| 175 |
+
assert ae(fp.psi(0, 2500.3), 7.8239660143238547877)
|
| 176 |
+
assert ae(fp.psi(0, 1e40), 92.103403719761827391)
|
| 177 |
+
assert ae(fp.psi(0, 1e200), 460.51701859880913677)
|
| 178 |
+
assert ae(fp.psi(0, 3.7+0j), (1.1671535393615114409 + 0.0j))
|
| 179 |
+
assert ae(fp.psi(1, 3), 0.39493406684822643647)
|
| 180 |
+
assert ae(fp.psi(3, 2+3j), (-0.05383196209159972116 + 0.0076890935247364805218j))
|
| 181 |
+
assert ae(fp.psi(4, -0.5+1j), (1.2719531355492328195 - 18.211833410936276774j))
|
| 182 |
+
assert ae(fp.harmonic(0), 0.0)
|
| 183 |
+
assert ae(fp.harmonic(1), 1.0)
|
| 184 |
+
assert ae(fp.harmonic(2), 1.5)
|
| 185 |
+
assert ae(fp.harmonic(100), 5.1873775176396202608)
|
| 186 |
+
assert ae(fp.harmonic(-2.5), 1.2803723055467760478)
|
| 187 |
+
assert ae(fp.harmonic(2+3j), (1.9390425294578375875 + 0.87336044981834544043j))
|
| 188 |
+
assert ae(fp.harmonic(-5-4j), (2.3725754822349437733 - 2.4160904444801621j))
|
| 189 |
+
|
| 190 |
+
def test_fp_zeta():
|
| 191 |
+
assert ae(fp.zeta(1e100), 1.0)
|
| 192 |
+
assert ae(fp.zeta(3), 1.2020569031595942854)
|
| 193 |
+
assert ae(fp.zeta(2+0j), (1.6449340668482264365 + 0.0j))
|
| 194 |
+
assert ae(fp.zeta(0.93), -13.713619351638164784)
|
| 195 |
+
assert ae(fp.zeta(1.74), 1.9796863545771774095)
|
| 196 |
+
assert ae(fp.zeta(0.0), -0.5)
|
| 197 |
+
assert ae(fp.zeta(-1.0), -0.083333333333333333333)
|
| 198 |
+
assert ae(fp.zeta(-2.0), 0.0)
|
| 199 |
+
assert ae(fp.zeta(-3.0), 0.0083333333333333333333)
|
| 200 |
+
assert ae(fp.zeta(-500.0), 0.0)
|
| 201 |
+
assert ae(fp.zeta(-7.4), 0.0036537321227995882447)
|
| 202 |
+
assert ae(fp.zeta(2.1), 1.5602165335033620158)
|
| 203 |
+
assert ae(fp.zeta(26.9), 1.0000000079854809935)
|
| 204 |
+
assert ae(fp.zeta(26), 1.0000000149015548284)
|
| 205 |
+
assert ae(fp.zeta(27), 1.0000000074507117898)
|
| 206 |
+
assert ae(fp.zeta(28), 1.0000000037253340248)
|
| 207 |
+
assert ae(fp.zeta(27.1), 1.000000006951755045)
|
| 208 |
+
assert ae(fp.zeta(32.7), 1.0000000001433243232)
|
| 209 |
+
assert ae(fp.zeta(100), 1.0)
|
| 210 |
+
assert ae(fp.altzeta(3.5), 0.92755357777394803511)
|
| 211 |
+
assert ae(fp.altzeta(1), 0.69314718055994530942)
|
| 212 |
+
assert ae(fp.altzeta(2), 0.82246703342411321824)
|
| 213 |
+
assert ae(fp.altzeta(0), 0.5)
|
| 214 |
+
assert ae(fp.zeta(-2+3j, 1), (0.13297115587929864827 + 0.12305330040458776494j))
|
| 215 |
+
assert ae(fp.zeta(-2+3j, 5), (18.384866151867576927 - 11.377015110597711009j))
|
| 216 |
+
assert ae(fp.zeta(1.0000000001), 9999999173.1735741337)
|
| 217 |
+
assert ae(fp.zeta(0.9999999999), -9999999172.0191428039)
|
| 218 |
+
assert ae(fp.zeta(1+0.000000001j), (0.57721566490153286061 - 999999999.99999993765j))
|
| 219 |
+
assert ae(fp.primezeta(2.5+4j), (-0.16922458243438033385 - 0.010847965298387727811j))
|
| 220 |
+
assert ae(fp.primezeta(4), 0.076993139764246844943)
|
| 221 |
+
assert ae(fp.riemannr(3.7), 2.3034079839110855717)
|
| 222 |
+
assert ae(fp.riemannr(8), 3.9011860449341499474)
|
| 223 |
+
assert ae(fp.riemannr(3+4j), (2.2369653314259991796 + 1.6339943856990281694j))
|
| 224 |
+
|
| 225 |
+
def test_fp_hyp2f1():
|
| 226 |
+
assert ae(fp.hyp2f1(1, (3,2), 3.25, 5.0), (-0.46600275923108143059 - 0.74393667908854842325j))
|
| 227 |
+
assert ae(fp.hyp2f1(1+1j, (3,2), 3.25, 5.0), (-5.9208875603806515987 - 2.3813557707889590686j))
|
| 228 |
+
assert ae(fp.hyp2f1(1+1j, (3,2), 3.25, 2+3j), (0.17174552030925080445 + 0.19589781970539389999j))
|
| 229 |
+
|
| 230 |
+
def test_fp_erf():
|
| 231 |
+
assert fp.erf(2) == fp.erf(2.0) == fp.erf(2.0+0.0j)
|
| 232 |
+
assert fp.erf(fp.inf) == 1.0
|
| 233 |
+
assert fp.erf(fp.ninf) == -1.0
|
| 234 |
+
assert ae(fp.erf(0), 0.0)
|
| 235 |
+
assert ae(fp.erf(-0), -0.0)
|
| 236 |
+
assert ae(fp.erf(0.3), 0.32862675945912741619)
|
| 237 |
+
assert ae(fp.erf(-0.3), -0.32862675945912741619)
|
| 238 |
+
assert ae(fp.erf(0.9), 0.79690821242283213966)
|
| 239 |
+
assert ae(fp.erf(-0.9), -0.79690821242283213966)
|
| 240 |
+
assert ae(fp.erf(1.0), 0.84270079294971486934)
|
| 241 |
+
assert ae(fp.erf(-1.0), -0.84270079294971486934)
|
| 242 |
+
assert ae(fp.erf(1.1), 0.88020506957408172966)
|
| 243 |
+
assert ae(fp.erf(-1.1), -0.88020506957408172966)
|
| 244 |
+
assert ae(fp.erf(8.5), 1.0)
|
| 245 |
+
assert ae(fp.erf(-8.5), -1.0)
|
| 246 |
+
assert ae(fp.erf(9.1), 1.0)
|
| 247 |
+
assert ae(fp.erf(-9.1), -1.0)
|
| 248 |
+
assert ae(fp.erf(20.0), 1.0)
|
| 249 |
+
assert ae(fp.erf(-20.0), -1.0)
|
| 250 |
+
assert ae(fp.erf(10000.0), 1.0)
|
| 251 |
+
assert ae(fp.erf(-10000.0), -1.0)
|
| 252 |
+
assert ae(fp.erf(1e+50), 1.0)
|
| 253 |
+
assert ae(fp.erf(-1e+50), -1.0)
|
| 254 |
+
assert ae(fp.erf(1j), 1.650425758797542876j)
|
| 255 |
+
assert ae(fp.erf(-1j), -1.650425758797542876j)
|
| 256 |
+
assert ae(fp.erf((2+3j)), (-20.829461427614568389 + 8.6873182714701631444j))
|
| 257 |
+
assert ae(fp.erf(-(2+3j)), -(-20.829461427614568389 + 8.6873182714701631444j))
|
| 258 |
+
assert ae(fp.erf((8+9j)), (-1072004.2525062051158 + 364149.91954310255423j))
|
| 259 |
+
assert ae(fp.erf(-(8+9j)), -(-1072004.2525062051158 + 364149.91954310255423j))
|
| 260 |
+
assert fp.erfc(fp.inf) == 0.0
|
| 261 |
+
assert fp.erfc(fp.ninf) == 2.0
|
| 262 |
+
assert fp.erfc(0) == 1
|
| 263 |
+
assert fp.erfc(-0.0) == 1
|
| 264 |
+
assert fp.erfc(0+0j) == 1
|
| 265 |
+
assert ae(fp.erfc(0.3), 0.67137324054087258381)
|
| 266 |
+
assert ae(fp.erfc(-0.3), 1.3286267594591274162)
|
| 267 |
+
assert ae(fp.erfc(0.9), 0.20309178757716786034)
|
| 268 |
+
assert ae(fp.erfc(-0.9), 1.7969082124228321397)
|
| 269 |
+
assert ae(fp.erfc(1.0), 0.15729920705028513066)
|
| 270 |
+
assert ae(fp.erfc(-1.0), 1.8427007929497148693)
|
| 271 |
+
assert ae(fp.erfc(1.1), 0.11979493042591827034)
|
| 272 |
+
assert ae(fp.erfc(-1.1), 1.8802050695740817297)
|
| 273 |
+
assert ae(fp.erfc(8.5), 2.7623240713337714461e-33)
|
| 274 |
+
assert ae(fp.erfc(-8.5), 2.0)
|
| 275 |
+
assert ae(fp.erfc(9.1), 6.6969004279886077452e-38)
|
| 276 |
+
assert ae(fp.erfc(-9.1), 2.0)
|
| 277 |
+
assert ae(fp.erfc(20.0), 5.3958656116079009289e-176)
|
| 278 |
+
assert ae(fp.erfc(-20.0), 2.0)
|
| 279 |
+
assert ae(fp.erfc(10000.0), 0.0)
|
| 280 |
+
assert ae(fp.erfc(-10000.0), 2.0)
|
| 281 |
+
assert ae(fp.erfc(1e+50), 0.0)
|
| 282 |
+
assert ae(fp.erfc(-1e+50), 2.0)
|
| 283 |
+
assert ae(fp.erfc(1j), (1.0 - 1.650425758797542876j))
|
| 284 |
+
assert ae(fp.erfc(-1j), (1.0 + 1.650425758797542876j))
|
| 285 |
+
assert ae(fp.erfc((2+3j)), (21.829461427614568389 - 8.6873182714701631444j), 1e-13)
|
| 286 |
+
assert ae(fp.erfc(-(2+3j)), (-19.829461427614568389 + 8.6873182714701631444j), 1e-13)
|
| 287 |
+
assert ae(fp.erfc((8+9j)), (1072005.2525062051158 - 364149.91954310255423j))
|
| 288 |
+
assert ae(fp.erfc(-(8+9j)), (-1072003.2525062051158 + 364149.91954310255423j))
|
| 289 |
+
assert ae(fp.erfc(20+0j), (5.3958656116079009289e-176 + 0.0j))
|
| 290 |
+
|
| 291 |
+
def test_fp_lambertw():
|
| 292 |
+
assert ae(fp.lambertw(0.0), 0.0)
|
| 293 |
+
assert ae(fp.lambertw(1.0), 0.567143290409783873)
|
| 294 |
+
assert ae(fp.lambertw(7.5), 1.5662309537823875394)
|
| 295 |
+
assert ae(fp.lambertw(-0.25), -0.35740295618138890307)
|
| 296 |
+
assert ae(fp.lambertw(-10.0), (1.3699809685212708156 + 2.140194527074713196j))
|
| 297 |
+
assert ae(fp.lambertw(0+0j), (0.0 + 0.0j))
|
| 298 |
+
assert ae(fp.lambertw(4+0j), (1.2021678731970429392 + 0.0j))
|
| 299 |
+
assert ae(fp.lambertw(1000.5), 5.2500227450408980127)
|
| 300 |
+
assert ae(fp.lambertw(1e100), 224.84310644511850156)
|
| 301 |
+
assert ae(fp.lambertw(-1000.0), (5.1501630246362515223 + 2.6641981432905204596j))
|
| 302 |
+
assert ae(fp.lambertw(1e-10), 9.9999999990000003645e-11)
|
| 303 |
+
assert ae(fp.lambertw(1e-10j), (1.0000000000000000728e-20 + 1.0000000000000000364e-10j))
|
| 304 |
+
assert ae(fp.lambertw(3+4j), (1.2815618061237758782 + 0.53309522202097107131j))
|
| 305 |
+
assert ae(fp.lambertw(-3-4j), (1.0750730665692549276 - 1.3251023817343588823j))
|
| 306 |
+
assert ae(fp.lambertw(10000+1000j), (7.2361526563371602186 + 0.087567810943839352034j))
|
| 307 |
+
assert ae(fp.lambertw(0.0, -1), -fp.inf)
|
| 308 |
+
assert ae(fp.lambertw(1.0, -1), (-1.5339133197935745079 - 4.3751851530618983855j))
|
| 309 |
+
assert ae(fp.lambertw(7.5, -1), (0.44125668415098614999 - 4.8039842008452390179j))
|
| 310 |
+
assert ae(fp.lambertw(-0.25, -1), -2.1532923641103496492)
|
| 311 |
+
assert ae(fp.lambertw(-10.0, -1), (1.3699809685212708156 - 2.140194527074713196j))
|
| 312 |
+
assert ae(fp.lambertw(0+0j, -1), -fp.inf)
|
| 313 |
+
assert ae(fp.lambertw(4+0j, -1), (-0.15730793189620765317 - 4.6787800704666656212j))
|
| 314 |
+
assert ae(fp.lambertw(1000.5, -1), (4.9153765415404024736 - 5.4465682700815159569j))
|
| 315 |
+
assert ae(fp.lambertw(1e100, -1), (224.84272130101601052 - 6.2553713838167244141j))
|
| 316 |
+
assert ae(fp.lambertw(-1000.0, -1), (5.1501630246362515223 - 2.6641981432905204596j))
|
| 317 |
+
assert ae(fp.lambertw(1e-10, -1), (-26.303186778379041521 - 3.2650939117038283975j))
|
| 318 |
+
assert ae(fp.lambertw(1e-10j, -1), (-26.297238779529035028 - 1.6328071613455765135j))
|
| 319 |
+
assert ae(fp.lambertw(3+4j, -1), (0.25856740686699741676 - 3.8521166861614355895j))
|
| 320 |
+
assert ae(fp.lambertw(-3-4j, -1), (-0.32028750204310768396 - 6.8801677192091972343j))
|
| 321 |
+
assert ae(fp.lambertw(10000+1000j, -1), (7.0255308742285435567 - 5.5177506835734067601j))
|
| 322 |
+
assert ae(fp.lambertw(0.0, 2), -fp.inf)
|
| 323 |
+
assert ae(fp.lambertw(1.0, 2), (-2.4015851048680028842 + 10.776299516115070898j))
|
| 324 |
+
assert ae(fp.lambertw(7.5, 2), (-0.38003357962843791529 + 10.960916473368746184j))
|
| 325 |
+
assert ae(fp.lambertw(-0.25, 2), (-4.0558735269061511898 + 13.852334658567271386j))
|
| 326 |
+
assert ae(fp.lambertw(-10.0, 2), (-0.34479123764318858696 + 14.112740596763592363j))
|
| 327 |
+
assert ae(fp.lambertw(0+0j, 2), -fp.inf)
|
| 328 |
+
assert ae(fp.lambertw(4+0j, 2), (-1.0070343323804262788 + 10.903476551861683082j))
|
| 329 |
+
assert ae(fp.lambertw(1000.5, 2), (4.4076185165459395295 + 11.365524591091402177j))
|
| 330 |
+
assert ae(fp.lambertw(1e100, 2), (224.84156762724875878 + 12.510785262632255672j))
|
| 331 |
+
assert ae(fp.lambertw(-1000.0, 2), (4.1984245610246530756 + 14.420478573754313845j))
|
| 332 |
+
assert ae(fp.lambertw(1e-10, 2), (-26.362258095445866488 + 9.7800247407031482519j))
|
| 333 |
+
assert ae(fp.lambertw(1e-10j, 2), (-26.384250801683084252 + 11.403535950607739763j))
|
| 334 |
+
assert ae(fp.lambertw(3+4j, 2), (-0.86554679943333993562 + 11.849956798331992027j))
|
| 335 |
+
assert ae(fp.lambertw(-3-4j, 2), (-0.55792273874679112639 + 8.7173627024159324811j))
|
| 336 |
+
assert ae(fp.lambertw(10000+1000j, 2), (6.6223802254585662734 + 11.61348646825020766j))
|
| 337 |
+
|
| 338 |
+
def test_fp_stress_ei_e1():
|
| 339 |
+
# Can be tightened on recent Pythons with more accurate math/cmath
|
| 340 |
+
ATOL = 1e-13
|
| 341 |
+
PTOL = 1e-12
|
| 342 |
+
v = fp.e1(1.1641532182693481445e-10)
|
| 343 |
+
assert ae(v, 22.296641293693077672, tol=ATOL)
|
| 344 |
+
assert type(v) is float
|
| 345 |
+
v = fp.e1(0.25)
|
| 346 |
+
assert ae(v, 1.0442826344437381945, tol=ATOL)
|
| 347 |
+
assert type(v) is float
|
| 348 |
+
v = fp.e1(1.0)
|
| 349 |
+
assert ae(v, 0.21938393439552027368, tol=ATOL)
|
| 350 |
+
assert type(v) is float
|
| 351 |
+
v = fp.e1(2.0)
|
| 352 |
+
assert ae(v, 0.048900510708061119567, tol=ATOL)
|
| 353 |
+
assert type(v) is float
|
| 354 |
+
v = fp.e1(5.0)
|
| 355 |
+
assert ae(v, 0.0011482955912753257973, tol=ATOL)
|
| 356 |
+
assert type(v) is float
|
| 357 |
+
v = fp.e1(20.0)
|
| 358 |
+
assert ae(v, 9.8355252906498816904e-11, tol=ATOL)
|
| 359 |
+
assert type(v) is float
|
| 360 |
+
v = fp.e1(30.0)
|
| 361 |
+
assert ae(v, 3.0215520106888125448e-15, tol=ATOL)
|
| 362 |
+
assert type(v) is float
|
| 363 |
+
v = fp.e1(40.0)
|
| 364 |
+
assert ae(v, 1.0367732614516569722e-19, tol=ATOL)
|
| 365 |
+
assert type(v) is float
|
| 366 |
+
v = fp.e1(50.0)
|
| 367 |
+
assert ae(v, 3.7832640295504590187e-24, tol=ATOL)
|
| 368 |
+
assert type(v) is float
|
| 369 |
+
v = fp.e1(80.0)
|
| 370 |
+
assert ae(v, 2.2285432586884729112e-37, tol=ATOL)
|
| 371 |
+
assert type(v) is float
|
| 372 |
+
v = fp.e1((1.1641532182693481445e-10 + 0.0j))
|
| 373 |
+
assert ae(v, (22.296641293693077672 + 0.0j), tol=ATOL)
|
| 374 |
+
assert ae(v.real, 22.296641293693077672, tol=PTOL)
|
| 375 |
+
assert v.imag == 0
|
| 376 |
+
v = fp.e1((0.25 + 0.0j))
|
| 377 |
+
assert ae(v, (1.0442826344437381945 + 0.0j), tol=ATOL)
|
| 378 |
+
assert ae(v.real, 1.0442826344437381945, tol=PTOL)
|
| 379 |
+
assert v.imag == 0
|
| 380 |
+
v = fp.e1((1.0 + 0.0j))
|
| 381 |
+
assert ae(v, (0.21938393439552027368 + 0.0j), tol=ATOL)
|
| 382 |
+
assert ae(v.real, 0.21938393439552027368, tol=PTOL)
|
| 383 |
+
assert v.imag == 0
|
| 384 |
+
v = fp.e1((2.0 + 0.0j))
|
| 385 |
+
assert ae(v, (0.048900510708061119567 + 0.0j), tol=ATOL)
|
| 386 |
+
assert ae(v.real, 0.048900510708061119567, tol=PTOL)
|
| 387 |
+
assert v.imag == 0
|
| 388 |
+
v = fp.e1((5.0 + 0.0j))
|
| 389 |
+
assert ae(v, (0.0011482955912753257973 + 0.0j), tol=ATOL)
|
| 390 |
+
assert ae(v.real, 0.0011482955912753257973, tol=PTOL)
|
| 391 |
+
assert v.imag == 0
|
| 392 |
+
v = fp.e1((20.0 + 0.0j))
|
| 393 |
+
assert ae(v, (9.8355252906498816904e-11 + 0.0j), tol=ATOL)
|
| 394 |
+
assert ae(v.real, 9.8355252906498816904e-11, tol=PTOL)
|
| 395 |
+
assert v.imag == 0
|
| 396 |
+
v = fp.e1((30.0 + 0.0j))
|
| 397 |
+
assert ae(v, (3.0215520106888125448e-15 + 0.0j), tol=ATOL)
|
| 398 |
+
assert ae(v.real, 3.0215520106888125448e-15, tol=PTOL)
|
| 399 |
+
assert v.imag == 0
|
| 400 |
+
v = fp.e1((40.0 + 0.0j))
|
| 401 |
+
assert ae(v, (1.0367732614516569722e-19 + 0.0j), tol=ATOL)
|
| 402 |
+
assert ae(v.real, 1.0367732614516569722e-19, tol=PTOL)
|
| 403 |
+
assert v.imag == 0
|
| 404 |
+
v = fp.e1((50.0 + 0.0j))
|
| 405 |
+
assert ae(v, (3.7832640295504590187e-24 + 0.0j), tol=ATOL)
|
| 406 |
+
assert ae(v.real, 3.7832640295504590187e-24, tol=PTOL)
|
| 407 |
+
assert v.imag == 0
|
| 408 |
+
v = fp.e1((80.0 + 0.0j))
|
| 409 |
+
assert ae(v, (2.2285432586884729112e-37 + 0.0j), tol=ATOL)
|
| 410 |
+
assert ae(v.real, 2.2285432586884729112e-37, tol=PTOL)
|
| 411 |
+
assert v.imag == 0
|
| 412 |
+
v = fp.e1((4.6566128730773925781e-10 + 1.1641532182693481445e-10j))
|
| 413 |
+
assert ae(v, (20.880034622014215597 - 0.24497866301044883237j), tol=ATOL)
|
| 414 |
+
assert ae(v.real, 20.880034622014215597, tol=PTOL)
|
| 415 |
+
assert ae(v.imag, -0.24497866301044883237, tol=PTOL)
|
| 416 |
+
v = fp.e1((1.0 + 0.25j))
|
| 417 |
+
assert ae(v, (0.19731063945004229095 - 0.087366045774299963672j), tol=ATOL)
|
| 418 |
+
assert ae(v.real, 0.19731063945004229095, tol=PTOL)
|
| 419 |
+
assert ae(v.imag, -0.087366045774299963672, tol=PTOL)
|
| 420 |
+
v = fp.e1((4.0 + 1.0j))
|
| 421 |
+
assert ae(v, (0.0013106173980145506944 - 0.0034542480199350626699j), tol=ATOL)
|
| 422 |
+
assert ae(v.real, 0.0013106173980145506944, tol=PTOL)
|
| 423 |
+
assert ae(v.imag, -0.0034542480199350626699, tol=PTOL)
|
| 424 |
+
v = fp.e1((8.0 + 2.0j))
|
| 425 |
+
assert ae(v, (-0.000022278049065270225945 - 0.000029191940456521555288j), tol=ATOL)
|
| 426 |
+
assert ae(v.real, -0.000022278049065270225945, tol=PTOL)
|
| 427 |
+
assert ae(v.imag, -0.000029191940456521555288, tol=PTOL)
|
| 428 |
+
v = fp.e1((20.0 + 5.0j))
|
| 429 |
+
assert ae(v, (4.7711374515765346894e-11 + 8.2902652405126947359e-11j), tol=ATOL)
|
| 430 |
+
assert ae(v.real, 4.7711374515765346894e-11, tol=PTOL)
|
| 431 |
+
assert ae(v.imag, 8.2902652405126947359e-11, tol=PTOL)
|
| 432 |
+
v = fp.e1((80.0 + 20.0j))
|
| 433 |
+
assert ae(v, (3.8353473865788235787e-38 - 2.129247592349605139e-37j), tol=ATOL)
|
| 434 |
+
assert ae(v.real, 3.8353473865788235787e-38, tol=PTOL)
|
| 435 |
+
assert ae(v.imag, -2.129247592349605139e-37, tol=PTOL)
|
| 436 |
+
v = fp.e1((120.0 + 30.0j))
|
| 437 |
+
assert ae(v, (2.3836002337480334716e-55 + 5.6704043587126198306e-55j), tol=ATOL)
|
| 438 |
+
assert ae(v.real, 2.3836002337480334716e-55, tol=PTOL)
|
| 439 |
+
assert ae(v.imag, 5.6704043587126198306e-55, tol=PTOL)
|
| 440 |
+
v = fp.e1((160.0 + 40.0j))
|
| 441 |
+
assert ae(v, (-1.6238022898654510661e-72 - 1.104172355572287367e-72j), tol=ATOL)
|
| 442 |
+
assert ae(v.real, -1.6238022898654510661e-72, tol=PTOL)
|
| 443 |
+
assert ae(v.imag, -1.104172355572287367e-72, tol=PTOL)
|
| 444 |
+
v = fp.e1((200.0 + 50.0j))
|
| 445 |
+
assert ae(v, (6.6800061461666228487e-90 + 1.4473816083541016115e-91j), tol=ATOL)
|
| 446 |
+
assert ae(v.real, 6.6800061461666228487e-90, tol=PTOL)
|
| 447 |
+
assert ae(v.imag, 1.4473816083541016115e-91, tol=PTOL)
|
| 448 |
+
v = fp.e1((320.0 + 80.0j))
|
| 449 |
+
assert ae(v, (4.2737871527778786157e-143 + 3.1789935525785660314e-142j), tol=ATOL)
|
| 450 |
+
assert ae(v.real, 4.2737871527778786157e-143, tol=PTOL)
|
| 451 |
+
assert ae(v.imag, 3.1789935525785660314e-142, tol=PTOL)
|
| 452 |
+
v = fp.e1((1.1641532182693481445e-10 + 1.1641532182693481445e-10j))
|
| 453 |
+
assert ae(v, (21.950067703413105017 - 0.7853981632810329878j), tol=ATOL)
|
| 454 |
+
assert ae(v.real, 21.950067703413105017, tol=PTOL)
|
| 455 |
+
assert ae(v.imag, -0.7853981632810329878, tol=PTOL)
|
| 456 |
+
v = fp.e1((0.25 + 0.25j))
|
| 457 |
+
assert ae(v, (0.71092525792923287894 - 0.56491812441304194711j), tol=ATOL)
|
| 458 |
+
assert ae(v.real, 0.71092525792923287894, tol=PTOL)
|
| 459 |
+
assert ae(v.imag, -0.56491812441304194711, tol=PTOL)
|
| 460 |
+
v = fp.e1((1.0 + 1.0j))
|
| 461 |
+
assert ae(v, (0.00028162445198141832551 - 0.17932453503935894015j), tol=ATOL)
|
| 462 |
+
assert ae(v.real, 0.00028162445198141832551, tol=PTOL)
|
| 463 |
+
assert ae(v.imag, -0.17932453503935894015, tol=PTOL)
|
| 464 |
+
v = fp.e1((2.0 + 2.0j))
|
| 465 |
+
assert ae(v, (-0.033767089606562004246 - 0.018599414169750541925j), tol=ATOL)
|
| 466 |
+
assert ae(v.real, -0.033767089606562004246, tol=PTOL)
|
| 467 |
+
assert ae(v.imag, -0.018599414169750541925, tol=PTOL)
|
| 468 |
+
v = fp.e1((5.0 + 5.0j))
|
| 469 |
+
assert ae(v, (0.0007266506660356393891 + 0.00047102780163522245054j), tol=ATOL)
|
| 470 |
+
assert ae(v.real, 0.0007266506660356393891, tol=PTOL)
|
| 471 |
+
assert ae(v.imag, 0.00047102780163522245054, tol=PTOL)
|
| 472 |
+
v = fp.e1((20.0 + 20.0j))
|
| 473 |
+
assert ae(v, (-2.3824537449367396579e-11 - 6.6969873156525615158e-11j), tol=ATOL)
|
| 474 |
+
assert ae(v.real, -2.3824537449367396579e-11, tol=PTOL)
|
| 475 |
+
assert ae(v.imag, -6.6969873156525615158e-11, tol=PTOL)
|
| 476 |
+
v = fp.e1((30.0 + 30.0j))
|
| 477 |
+
assert ae(v, (1.7316045841744061617e-15 + 1.3065678019487308689e-15j), tol=ATOL)
|
| 478 |
+
assert ae(v.real, 1.7316045841744061617e-15, tol=PTOL)
|
| 479 |
+
assert ae(v.imag, 1.3065678019487308689e-15, tol=PTOL)
|
| 480 |
+
v = fp.e1((40.0 + 40.0j))
|
| 481 |
+
assert ae(v, (-7.4001043002899232182e-20 - 4.991847855336816304e-21j), tol=ATOL)
|
| 482 |
+
assert ae(v.real, -7.4001043002899232182e-20, tol=PTOL)
|
| 483 |
+
assert ae(v.imag, -4.991847855336816304e-21, tol=PTOL)
|
| 484 |
+
v = fp.e1((50.0 + 50.0j))
|
| 485 |
+
assert ae(v, (2.3566128324644641219e-24 - 1.3188326726201614778e-24j), tol=ATOL)
|
| 486 |
+
assert ae(v.real, 2.3566128324644641219e-24, tol=PTOL)
|
| 487 |
+
assert ae(v.imag, -1.3188326726201614778e-24, tol=PTOL)
|
| 488 |
+
v = fp.e1((80.0 + 80.0j))
|
| 489 |
+
assert ae(v, (9.8279750572186526673e-38 + 1.243952841288868831e-37j), tol=ATOL)
|
| 490 |
+
assert ae(v.real, 9.8279750572186526673e-38, tol=PTOL)
|
| 491 |
+
assert ae(v.imag, 1.243952841288868831e-37, tol=PTOL)
|
| 492 |
+
v = fp.e1((1.1641532182693481445e-10 + 4.6566128730773925781e-10j))
|
| 493 |
+
assert ae(v, (20.880034621664969632 - 1.3258176632023711778j), tol=ATOL)
|
| 494 |
+
assert ae(v.real, 20.880034621664969632, tol=PTOL)
|
| 495 |
+
assert ae(v.imag, -1.3258176632023711778, tol=PTOL)
|
| 496 |
+
v = fp.e1((0.25 + 1.0j))
|
| 497 |
+
assert ae(v, (-0.16868306393667788761 - 0.4858011885947426971j), tol=ATOL)
|
| 498 |
+
assert ae(v.real, -0.16868306393667788761, tol=PTOL)
|
| 499 |
+
assert ae(v.imag, -0.4858011885947426971, tol=PTOL)
|
| 500 |
+
v = fp.e1((1.0 + 4.0j))
|
| 501 |
+
assert ae(v, (0.03373591813926547318 + 0.073523452241083821877j), tol=ATOL)
|
| 502 |
+
assert ae(v.real, 0.03373591813926547318, tol=PTOL)
|
| 503 |
+
assert ae(v.imag, 0.073523452241083821877, tol=PTOL)
|
| 504 |
+
v = fp.e1((2.0 + 8.0j))
|
| 505 |
+
assert ae(v, (-0.015392833434733785143 - 0.0031747121557605415914j), tol=ATOL)
|
| 506 |
+
assert ae(v.real, -0.015392833434733785143, tol=PTOL)
|
| 507 |
+
assert ae(v.imag, -0.0031747121557605415914, tol=PTOL)
|
| 508 |
+
v = fp.e1((5.0 + 20.0j))
|
| 509 |
+
assert ae(v, (-0.00024419662286542966525 - 0.00021008322966152755674j), tol=ATOL)
|
| 510 |
+
assert ae(v.real, -0.00024419662286542966525, tol=PTOL)
|
| 511 |
+
assert ae(v.imag, -0.00021008322966152755674, tol=PTOL)
|
| 512 |
+
v = fp.e1((20.0 + 80.0j))
|
| 513 |
+
assert ae(v, (2.3255552781051330088e-11 + 8.9463918891349438007e-12j), tol=ATOL)
|
| 514 |
+
assert ae(v.real, 2.3255552781051330088e-11, tol=PTOL)
|
| 515 |
+
assert ae(v.imag, 8.9463918891349438007e-12, tol=PTOL)
|
| 516 |
+
v = fp.e1((30.0 + 120.0j))
|
| 517 |
+
assert ae(v, (-2.7068919097124652332e-16 - 7.0477762411705130239e-16j), tol=ATOL)
|
| 518 |
+
assert ae(v.real, -2.7068919097124652332e-16, tol=PTOL)
|
| 519 |
+
assert ae(v.imag, -7.0477762411705130239e-16, tol=PTOL)
|
| 520 |
+
v = fp.e1((40.0 + 160.0j))
|
| 521 |
+
assert ae(v, (-1.1695597827678024687e-20 + 2.2907401455645736661e-20j), tol=ATOL)
|
| 522 |
+
assert ae(v.real, -1.1695597827678024687e-20, tol=PTOL)
|
| 523 |
+
assert ae(v.imag, 2.2907401455645736661e-20, tol=PTOL)
|
| 524 |
+
v = fp.e1((50.0 + 200.0j))
|
| 525 |
+
assert ae(v, (9.0323746914410162531e-25 - 2.3950601790033530935e-25j), tol=ATOL)
|
| 526 |
+
assert ae(v.real, 9.0323746914410162531e-25, tol=PTOL)
|
| 527 |
+
assert ae(v.imag, -2.3950601790033530935e-25, tol=PTOL)
|
| 528 |
+
v = fp.e1((80.0 + 320.0j))
|
| 529 |
+
assert ae(v, (3.4819106748728063576e-38 - 4.215653005615772724e-38j), tol=ATOL)
|
| 530 |
+
assert ae(v.real, 3.4819106748728063576e-38, tol=PTOL)
|
| 531 |
+
assert ae(v.imag, -4.215653005615772724e-38, tol=PTOL)
|
| 532 |
+
v = fp.e1((0.0 + 1.1641532182693481445e-10j))
|
| 533 |
+
assert ae(v, (22.29664129357666235 - 1.5707963266784812974j), tol=ATOL)
|
| 534 |
+
assert ae(v.real, 22.29664129357666235, tol=PTOL)
|
| 535 |
+
assert ae(v.imag, -1.5707963266784812974, tol=PTOL)
|
| 536 |
+
v = fp.e1((0.0 + 0.25j))
|
| 537 |
+
assert ae(v, (0.82466306258094565309 - 1.3216627564751394551j), tol=ATOL)
|
| 538 |
+
assert ae(v.real, 0.82466306258094565309, tol=PTOL)
|
| 539 |
+
assert ae(v.imag, -1.3216627564751394551, tol=PTOL)
|
| 540 |
+
v = fp.e1((0.0 + 1.0j))
|
| 541 |
+
assert ae(v, (-0.33740392290096813466 - 0.62471325642771360429j), tol=ATOL)
|
| 542 |
+
assert ae(v.real, -0.33740392290096813466, tol=PTOL)
|
| 543 |
+
assert ae(v.imag, -0.62471325642771360429, tol=PTOL)
|
| 544 |
+
v = fp.e1((0.0 + 2.0j))
|
| 545 |
+
assert ae(v, (-0.4229808287748649957 + 0.034616650007798229345j), tol=ATOL)
|
| 546 |
+
assert ae(v.real, -0.4229808287748649957, tol=PTOL)
|
| 547 |
+
assert ae(v.imag, 0.034616650007798229345, tol=PTOL)
|
| 548 |
+
v = fp.e1((0.0 + 5.0j))
|
| 549 |
+
assert ae(v, (0.19002974965664387862 - 0.020865081850222481957j), tol=ATOL)
|
| 550 |
+
assert ae(v.real, 0.19002974965664387862, tol=PTOL)
|
| 551 |
+
assert ae(v.imag, -0.020865081850222481957, tol=PTOL)
|
| 552 |
+
v = fp.e1((0.0 + 20.0j))
|
| 553 |
+
assert ae(v, (-0.04441982084535331654 - 0.022554625751456779068j), tol=ATOL)
|
| 554 |
+
assert ae(v.real, -0.04441982084535331654, tol=PTOL)
|
| 555 |
+
assert ae(v.imag, -0.022554625751456779068, tol=PTOL)
|
| 556 |
+
v = fp.e1((0.0 + 30.0j))
|
| 557 |
+
assert ae(v, (0.033032417282071143779 - 0.0040397867645455082476j), tol=ATOL)
|
| 558 |
+
assert ae(v.real, 0.033032417282071143779, tol=PTOL)
|
| 559 |
+
assert ae(v.imag, -0.0040397867645455082476, tol=PTOL)
|
| 560 |
+
v = fp.e1((0.0 + 40.0j))
|
| 561 |
+
assert ae(v, (-0.019020007896208766962 + 0.016188792559887887544j), tol=ATOL)
|
| 562 |
+
assert ae(v.real, -0.019020007896208766962, tol=PTOL)
|
| 563 |
+
assert ae(v.imag, 0.016188792559887887544, tol=PTOL)
|
| 564 |
+
v = fp.e1((0.0 + 50.0j))
|
| 565 |
+
assert ae(v, (0.0056283863241163054402 - 0.019179254308960724503j), tol=ATOL)
|
| 566 |
+
assert ae(v.real, 0.0056283863241163054402, tol=PTOL)
|
| 567 |
+
assert ae(v.imag, -0.019179254308960724503, tol=PTOL)
|
| 568 |
+
v = fp.e1((0.0 + 80.0j))
|
| 569 |
+
assert ae(v, (0.012402501155070958192 + 0.0015345601175906961199j), tol=ATOL)
|
| 570 |
+
assert ae(v.real, 0.012402501155070958192, tol=PTOL)
|
| 571 |
+
assert ae(v.imag, 0.0015345601175906961199, tol=PTOL)
|
| 572 |
+
v = fp.e1((-1.1641532182693481445e-10 + 4.6566128730773925781e-10j))
|
| 573 |
+
assert ae(v, (20.880034621432138988 - 1.8157749894560994861j), tol=ATOL)
|
| 574 |
+
assert ae(v.real, 20.880034621432138988, tol=PTOL)
|
| 575 |
+
assert ae(v.imag, -1.8157749894560994861, tol=PTOL)
|
| 576 |
+
v = fp.e1((-0.25 + 1.0j))
|
| 577 |
+
assert ae(v, (-0.59066621214766308594 - 0.74474454765205036972j), tol=ATOL)
|
| 578 |
+
assert ae(v.real, -0.59066621214766308594, tol=PTOL)
|
| 579 |
+
assert ae(v.imag, -0.74474454765205036972, tol=PTOL)
|
| 580 |
+
v = fp.e1((-1.0 + 4.0j))
|
| 581 |
+
assert ae(v, (0.49739047283060471093 + 0.41543605404038863174j), tol=ATOL)
|
| 582 |
+
assert ae(v.real, 0.49739047283060471093, tol=PTOL)
|
| 583 |
+
assert ae(v.imag, 0.41543605404038863174, tol=PTOL)
|
| 584 |
+
v = fp.e1((-2.0 + 8.0j))
|
| 585 |
+
assert ae(v, (-0.8705211147733730969 + 0.24099328498605539667j), tol=ATOL)
|
| 586 |
+
assert ae(v.real, -0.8705211147733730969, tol=PTOL)
|
| 587 |
+
assert ae(v.imag, 0.24099328498605539667, tol=PTOL)
|
| 588 |
+
v = fp.e1((-5.0 + 20.0j))
|
| 589 |
+
assert ae(v, (-7.0789514293925893007 - 1.6102177171960790536j), tol=ATOL)
|
| 590 |
+
assert ae(v.real, -7.0789514293925893007, tol=PTOL)
|
| 591 |
+
assert ae(v.imag, -1.6102177171960790536, tol=PTOL)
|
| 592 |
+
v = fp.e1((-20.0 + 80.0j))
|
| 593 |
+
assert ae(v, (5855431.4907298084434 - 720920.93315409165707j), tol=ATOL)
|
| 594 |
+
assert ae(v.real, 5855431.4907298084434, tol=PTOL)
|
| 595 |
+
assert ae(v.imag, -720920.93315409165707, tol=PTOL)
|
| 596 |
+
v = fp.e1((-30.0 + 120.0j))
|
| 597 |
+
assert ae(v, (-65402491644.703470747 - 56697658399.657460294j), tol=ATOL)
|
| 598 |
+
assert ae(v.real, -65402491644.703470747, tol=PTOL)
|
| 599 |
+
assert ae(v.imag, -56697658399.657460294, tol=PTOL)
|
| 600 |
+
v = fp.e1((-40.0 + 160.0j))
|
| 601 |
+
assert ae(v, (25504929379604.776769 + 1429035198630573.2463j), tol=ATOL)
|
| 602 |
+
assert ae(v.real, 25504929379604.776769, tol=PTOL)
|
| 603 |
+
assert ae(v.imag, 1429035198630573.2463, tol=PTOL)
|
| 604 |
+
v = fp.e1((-50.0 + 200.0j))
|
| 605 |
+
assert ae(v, (18437746526988116954.0 - 17146362239046152345.0j), tol=ATOL)
|
| 606 |
+
assert ae(v.real, 18437746526988116954.0, tol=PTOL)
|
| 607 |
+
assert ae(v.imag, -17146362239046152345.0, tol=PTOL)
|
| 608 |
+
v = fp.e1((-80.0 + 320.0j))
|
| 609 |
+
assert ae(v, (3.3464697299634526706e+31 - 1.6473152633843023919e+32j), tol=ATOL)
|
| 610 |
+
assert ae(v.real, 3.3464697299634526706e+31, tol=PTOL)
|
| 611 |
+
assert ae(v.imag, -1.6473152633843023919e+32, tol=PTOL)
|
| 612 |
+
v = fp.e1((-4.6566128730773925781e-10 + 1.1641532182693481445e-10j))
|
| 613 |
+
assert ae(v, (20.880034621082893023 - 2.8966139903465137624j), tol=ATOL)
|
| 614 |
+
assert ae(v.real, 20.880034621082893023, tol=PTOL)
|
| 615 |
+
assert ae(v.imag, -2.8966139903465137624, tol=PTOL)
|
| 616 |
+
v = fp.e1((-1.0 + 0.25j))
|
| 617 |
+
assert ae(v, (-1.8942716983721074932 - 2.4689102827070540799j), tol=ATOL)
|
| 618 |
+
assert ae(v.real, -1.8942716983721074932, tol=PTOL)
|
| 619 |
+
assert ae(v.imag, -2.4689102827070540799, tol=PTOL)
|
| 620 |
+
v = fp.e1((-4.0 + 1.0j))
|
| 621 |
+
assert ae(v, (-14.806699492675420438 + 9.1384225230837893776j), tol=ATOL)
|
| 622 |
+
assert ae(v.real, -14.806699492675420438, tol=PTOL)
|
| 623 |
+
assert ae(v.imag, 9.1384225230837893776, tol=PTOL)
|
| 624 |
+
v = fp.e1((-8.0 + 2.0j))
|
| 625 |
+
assert ae(v, (54.633252667426386294 + 413.20318163814670688j), tol=ATOL)
|
| 626 |
+
assert ae(v.real, 54.633252667426386294, tol=PTOL)
|
| 627 |
+
assert ae(v.imag, 413.20318163814670688, tol=PTOL)
|
| 628 |
+
v = fp.e1((-20.0 + 5.0j))
|
| 629 |
+
assert ae(v, (-711836.97165402624643 - 24745250.939695900956j), tol=ATOL)
|
| 630 |
+
assert ae(v.real, -711836.97165402624643, tol=PTOL)
|
| 631 |
+
assert ae(v.imag, -24745250.939695900956, tol=PTOL)
|
| 632 |
+
v = fp.e1((-80.0 + 20.0j))
|
| 633 |
+
assert ae(v, (-4.2139911108612653091e+32 + 5.3367124741918251637e+32j), tol=ATOL)
|
| 634 |
+
assert ae(v.real, -4.2139911108612653091e+32, tol=PTOL)
|
| 635 |
+
assert ae(v.imag, 5.3367124741918251637e+32, tol=PTOL)
|
| 636 |
+
v = fp.e1((-120.0 + 30.0j))
|
| 637 |
+
assert ae(v, (9.7760616203707508892e+48 - 1.058257682317195792e+50j), tol=ATOL)
|
| 638 |
+
assert ae(v.real, 9.7760616203707508892e+48, tol=PTOL)
|
| 639 |
+
assert ae(v.imag, -1.058257682317195792e+50, tol=PTOL)
|
| 640 |
+
v = fp.e1((-160.0 + 40.0j))
|
| 641 |
+
assert ae(v, (8.7065541466623638861e+66 + 1.6577106725141739889e+67j), tol=ATOL)
|
| 642 |
+
assert ae(v.real, 8.7065541466623638861e+66, tol=PTOL)
|
| 643 |
+
assert ae(v.imag, 1.6577106725141739889e+67, tol=PTOL)
|
| 644 |
+
v = fp.e1((-200.0 + 50.0j))
|
| 645 |
+
assert ae(v, (-3.070744996327018106e+84 - 1.7243244846769415903e+84j), tol=ATOL)
|
| 646 |
+
assert ae(v.real, -3.070744996327018106e+84, tol=PTOL)
|
| 647 |
+
assert ae(v.imag, -1.7243244846769415903e+84, tol=PTOL)
|
| 648 |
+
v = fp.e1((-320.0 + 80.0j))
|
| 649 |
+
assert ae(v, (9.9960598637998647276e+135 - 2.6855081527595608863e+136j), tol=ATOL)
|
| 650 |
+
assert ae(v.real, 9.9960598637998647276e+135, tol=PTOL)
|
| 651 |
+
assert ae(v.imag, -2.6855081527595608863e+136, tol=PTOL)
|
| 652 |
+
v = fp.e1(-1.1641532182693481445e-10)
|
| 653 |
+
assert ae(v, (22.296641293460247028 - 3.1415926535897932385j), tol=ATOL)
|
| 654 |
+
assert ae(v.real, 22.296641293460247028, tol=PTOL)
|
| 655 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 656 |
+
v = fp.e1(-0.25)
|
| 657 |
+
assert ae(v, (0.54254326466191372953 - 3.1415926535897932385j), tol=ATOL)
|
| 658 |
+
assert ae(v.real, 0.54254326466191372953, tol=PTOL)
|
| 659 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 660 |
+
v = fp.e1(-1.0)
|
| 661 |
+
assert ae(v, (-1.8951178163559367555 - 3.1415926535897932385j), tol=ATOL)
|
| 662 |
+
assert ae(v.real, -1.8951178163559367555, tol=PTOL)
|
| 663 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 664 |
+
v = fp.e1(-2.0)
|
| 665 |
+
assert ae(v, (-4.9542343560018901634 - 3.1415926535897932385j), tol=ATOL)
|
| 666 |
+
assert ae(v.real, -4.9542343560018901634, tol=PTOL)
|
| 667 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 668 |
+
v = fp.e1(-5.0)
|
| 669 |
+
assert ae(v, (-40.185275355803177455 - 3.1415926535897932385j), tol=ATOL)
|
| 670 |
+
assert ae(v.real, -40.185275355803177455, tol=PTOL)
|
| 671 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 672 |
+
v = fp.e1(-20.0)
|
| 673 |
+
assert ae(v, (-25615652.66405658882 - 3.1415926535897932385j), tol=ATOL)
|
| 674 |
+
assert ae(v.real, -25615652.66405658882, tol=PTOL)
|
| 675 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 676 |
+
v = fp.e1(-30.0)
|
| 677 |
+
assert ae(v, (-368973209407.27419706 - 3.1415926535897932385j), tol=ATOL)
|
| 678 |
+
assert ae(v.real, -368973209407.27419706, tol=PTOL)
|
| 679 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 680 |
+
v = fp.e1(-40.0)
|
| 681 |
+
assert ae(v, (-6039718263611241.5784 - 3.1415926535897932385j), tol=ATOL)
|
| 682 |
+
assert ae(v.real, -6039718263611241.5784, tol=PTOL)
|
| 683 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 684 |
+
v = fp.e1(-50.0)
|
| 685 |
+
assert ae(v, (-1.0585636897131690963e+20 - 3.1415926535897932385j), tol=ATOL)
|
| 686 |
+
assert ae(v.real, -1.0585636897131690963e+20, tol=PTOL)
|
| 687 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 688 |
+
v = fp.e1(-80.0)
|
| 689 |
+
assert ae(v, (-7.0146000049047999696e+32 - 3.1415926535897932385j), tol=ATOL)
|
| 690 |
+
assert ae(v.real, -7.0146000049047999696e+32, tol=PTOL)
|
| 691 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 692 |
+
v = fp.e1((-1.1641532182693481445e-10 + 0.0j))
|
| 693 |
+
assert ae(v, (22.296641293460247028 - 3.1415926535897932385j), tol=ATOL)
|
| 694 |
+
assert ae(v.real, 22.296641293460247028, tol=PTOL)
|
| 695 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 696 |
+
v = fp.e1((-0.25 + 0.0j))
|
| 697 |
+
assert ae(v, (0.54254326466191372953 - 3.1415926535897932385j), tol=ATOL)
|
| 698 |
+
assert ae(v.real, 0.54254326466191372953, tol=PTOL)
|
| 699 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 700 |
+
v = fp.e1((-1.0 + 0.0j))
|
| 701 |
+
assert ae(v, (-1.8951178163559367555 - 3.1415926535897932385j), tol=ATOL)
|
| 702 |
+
assert ae(v.real, -1.8951178163559367555, tol=PTOL)
|
| 703 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 704 |
+
v = fp.e1((-2.0 + 0.0j))
|
| 705 |
+
assert ae(v, (-4.9542343560018901634 - 3.1415926535897932385j), tol=ATOL)
|
| 706 |
+
assert ae(v.real, -4.9542343560018901634, tol=PTOL)
|
| 707 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 708 |
+
v = fp.e1((-5.0 + 0.0j))
|
| 709 |
+
assert ae(v, (-40.185275355803177455 - 3.1415926535897932385j), tol=ATOL)
|
| 710 |
+
assert ae(v.real, -40.185275355803177455, tol=PTOL)
|
| 711 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 712 |
+
v = fp.e1((-20.0 + 0.0j))
|
| 713 |
+
assert ae(v, (-25615652.66405658882 - 3.1415926535897932385j), tol=ATOL)
|
| 714 |
+
assert ae(v.real, -25615652.66405658882, tol=PTOL)
|
| 715 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 716 |
+
v = fp.e1((-30.0 + 0.0j))
|
| 717 |
+
assert ae(v, (-368973209407.27419706 - 3.1415926535897932385j), tol=ATOL)
|
| 718 |
+
assert ae(v.real, -368973209407.27419706, tol=PTOL)
|
| 719 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 720 |
+
v = fp.e1((-40.0 + 0.0j))
|
| 721 |
+
assert ae(v, (-6039718263611241.5784 - 3.1415926535897932385j), tol=ATOL)
|
| 722 |
+
assert ae(v.real, -6039718263611241.5784, tol=PTOL)
|
| 723 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 724 |
+
v = fp.e1((-50.0 + 0.0j))
|
| 725 |
+
assert ae(v, (-1.0585636897131690963e+20 - 3.1415926535897932385j), tol=ATOL)
|
| 726 |
+
assert ae(v.real, -1.0585636897131690963e+20, tol=PTOL)
|
| 727 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 728 |
+
v = fp.e1((-80.0 + 0.0j))
|
| 729 |
+
assert ae(v, (-7.0146000049047999696e+32 - 3.1415926535897932385j), tol=ATOL)
|
| 730 |
+
assert ae(v.real, -7.0146000049047999696e+32, tol=PTOL)
|
| 731 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 732 |
+
v = fp.e1((-4.6566128730773925781e-10 - 1.1641532182693481445e-10j))
|
| 733 |
+
assert ae(v, (20.880034621082893023 + 2.8966139903465137624j), tol=ATOL)
|
| 734 |
+
assert ae(v.real, 20.880034621082893023, tol=PTOL)
|
| 735 |
+
assert ae(v.imag, 2.8966139903465137624, tol=PTOL)
|
| 736 |
+
v = fp.e1((-1.0 - 0.25j))
|
| 737 |
+
assert ae(v, (-1.8942716983721074932 + 2.4689102827070540799j), tol=ATOL)
|
| 738 |
+
assert ae(v.real, -1.8942716983721074932, tol=PTOL)
|
| 739 |
+
assert ae(v.imag, 2.4689102827070540799, tol=PTOL)
|
| 740 |
+
v = fp.e1((-4.0 - 1.0j))
|
| 741 |
+
assert ae(v, (-14.806699492675420438 - 9.1384225230837893776j), tol=ATOL)
|
| 742 |
+
assert ae(v.real, -14.806699492675420438, tol=PTOL)
|
| 743 |
+
assert ae(v.imag, -9.1384225230837893776, tol=PTOL)
|
| 744 |
+
v = fp.e1((-8.0 - 2.0j))
|
| 745 |
+
assert ae(v, (54.633252667426386294 - 413.20318163814670688j), tol=ATOL)
|
| 746 |
+
assert ae(v.real, 54.633252667426386294, tol=PTOL)
|
| 747 |
+
assert ae(v.imag, -413.20318163814670688, tol=PTOL)
|
| 748 |
+
v = fp.e1((-20.0 - 5.0j))
|
| 749 |
+
assert ae(v, (-711836.97165402624643 + 24745250.939695900956j), tol=ATOL)
|
| 750 |
+
assert ae(v.real, -711836.97165402624643, tol=PTOL)
|
| 751 |
+
assert ae(v.imag, 24745250.939695900956, tol=PTOL)
|
| 752 |
+
v = fp.e1((-80.0 - 20.0j))
|
| 753 |
+
assert ae(v, (-4.2139911108612653091e+32 - 5.3367124741918251637e+32j), tol=ATOL)
|
| 754 |
+
assert ae(v.real, -4.2139911108612653091e+32, tol=PTOL)
|
| 755 |
+
assert ae(v.imag, -5.3367124741918251637e+32, tol=PTOL)
|
| 756 |
+
v = fp.e1((-120.0 - 30.0j))
|
| 757 |
+
assert ae(v, (9.7760616203707508892e+48 + 1.058257682317195792e+50j), tol=ATOL)
|
| 758 |
+
assert ae(v.real, 9.7760616203707508892e+48, tol=PTOL)
|
| 759 |
+
assert ae(v.imag, 1.058257682317195792e+50, tol=PTOL)
|
| 760 |
+
v = fp.e1((-160.0 - 40.0j))
|
| 761 |
+
assert ae(v, (8.7065541466623638861e+66 - 1.6577106725141739889e+67j), tol=ATOL)
|
| 762 |
+
assert ae(v.real, 8.7065541466623638861e+66, tol=PTOL)
|
| 763 |
+
assert ae(v.imag, -1.6577106725141739889e+67, tol=PTOL)
|
| 764 |
+
v = fp.e1((-200.0 - 50.0j))
|
| 765 |
+
assert ae(v, (-3.070744996327018106e+84 + 1.7243244846769415903e+84j), tol=ATOL)
|
| 766 |
+
assert ae(v.real, -3.070744996327018106e+84, tol=PTOL)
|
| 767 |
+
assert ae(v.imag, 1.7243244846769415903e+84, tol=PTOL)
|
| 768 |
+
v = fp.e1((-320.0 - 80.0j))
|
| 769 |
+
assert ae(v, (9.9960598637998647276e+135 + 2.6855081527595608863e+136j), tol=ATOL)
|
| 770 |
+
assert ae(v.real, 9.9960598637998647276e+135, tol=PTOL)
|
| 771 |
+
assert ae(v.imag, 2.6855081527595608863e+136, tol=PTOL)
|
| 772 |
+
v = fp.e1((-1.1641532182693481445e-10 - 1.1641532182693481445e-10j))
|
| 773 |
+
assert ae(v, (21.950067703180274374 + 2.356194490075929607j), tol=ATOL)
|
| 774 |
+
assert ae(v.real, 21.950067703180274374, tol=PTOL)
|
| 775 |
+
assert ae(v.imag, 2.356194490075929607, tol=PTOL)
|
| 776 |
+
v = fp.e1((-0.25 - 0.25j))
|
| 777 |
+
assert ae(v, (0.21441047326710323254 + 2.0732153554307936389j), tol=ATOL)
|
| 778 |
+
assert ae(v.real, 0.21441047326710323254, tol=PTOL)
|
| 779 |
+
assert ae(v.imag, 2.0732153554307936389, tol=PTOL)
|
| 780 |
+
v = fp.e1((-1.0 - 1.0j))
|
| 781 |
+
assert ae(v, (-1.7646259855638540684 + 0.7538228020792708192j), tol=ATOL)
|
| 782 |
+
assert ae(v.real, -1.7646259855638540684, tol=PTOL)
|
| 783 |
+
assert ae(v.imag, 0.7538228020792708192, tol=PTOL)
|
| 784 |
+
v = fp.e1((-2.0 - 2.0j))
|
| 785 |
+
assert ae(v, (-1.8920781621855474089 - 2.1753697842428647236j), tol=ATOL)
|
| 786 |
+
assert ae(v.real, -1.8920781621855474089, tol=PTOL)
|
| 787 |
+
assert ae(v.imag, -2.1753697842428647236, tol=PTOL)
|
| 788 |
+
v = fp.e1((-5.0 - 5.0j))
|
| 789 |
+
assert ae(v, (13.470936071475245856 + 18.464085049321024206j), tol=ATOL)
|
| 790 |
+
assert ae(v.real, 13.470936071475245856, tol=PTOL)
|
| 791 |
+
assert ae(v.imag, 18.464085049321024206, tol=PTOL)
|
| 792 |
+
v = fp.e1((-20.0 - 20.0j))
|
| 793 |
+
assert ae(v, (-16589317.398788971896 - 5831702.3296441771206j), tol=ATOL)
|
| 794 |
+
assert ae(v.real, -16589317.398788971896, tol=PTOL)
|
| 795 |
+
assert ae(v.imag, -5831702.3296441771206, tol=PTOL)
|
| 796 |
+
v = fp.e1((-30.0 - 30.0j))
|
| 797 |
+
assert ae(v, (154596484273.69322527 + 204179357837.41389696j), tol=ATOL)
|
| 798 |
+
assert ae(v.real, 154596484273.69322527, tol=PTOL)
|
| 799 |
+
assert ae(v.imag, 204179357837.41389696, tol=PTOL)
|
| 800 |
+
v = fp.e1((-40.0 - 40.0j))
|
| 801 |
+
assert ae(v, (-287512180321448.45408 - 4203502407932314.974j), tol=ATOL)
|
| 802 |
+
assert ae(v.real, -287512180321448.45408, tol=PTOL)
|
| 803 |
+
assert ae(v.imag, -4203502407932314.974, tol=PTOL)
|
| 804 |
+
v = fp.e1((-50.0 - 50.0j))
|
| 805 |
+
assert ae(v, (-36128528616649268826.0 + 64648801861338741963.0j), tol=ATOL)
|
| 806 |
+
assert ae(v.real, -36128528616649268826.0, tol=PTOL)
|
| 807 |
+
assert ae(v.imag, 64648801861338741963.0, tol=PTOL)
|
| 808 |
+
v = fp.e1((-80.0 - 80.0j))
|
| 809 |
+
assert ae(v, (3.8674816337930010217e+32 + 3.0540709639658071041e+32j), tol=ATOL)
|
| 810 |
+
assert ae(v.real, 3.8674816337930010217e+32, tol=PTOL)
|
| 811 |
+
assert ae(v.imag, 3.0540709639658071041e+32, tol=PTOL)
|
| 812 |
+
v = fp.e1((-1.1641532182693481445e-10 - 4.6566128730773925781e-10j))
|
| 813 |
+
assert ae(v, (20.880034621432138988 + 1.8157749894560994861j), tol=ATOL)
|
| 814 |
+
assert ae(v.real, 20.880034621432138988, tol=PTOL)
|
| 815 |
+
assert ae(v.imag, 1.8157749894560994861, tol=PTOL)
|
| 816 |
+
v = fp.e1((-0.25 - 1.0j))
|
| 817 |
+
assert ae(v, (-0.59066621214766308594 + 0.74474454765205036972j), tol=ATOL)
|
| 818 |
+
assert ae(v.real, -0.59066621214766308594, tol=PTOL)
|
| 819 |
+
assert ae(v.imag, 0.74474454765205036972, tol=PTOL)
|
| 820 |
+
v = fp.e1((-1.0 - 4.0j))
|
| 821 |
+
assert ae(v, (0.49739047283060471093 - 0.41543605404038863174j), tol=ATOL)
|
| 822 |
+
assert ae(v.real, 0.49739047283060471093, tol=PTOL)
|
| 823 |
+
assert ae(v.imag, -0.41543605404038863174, tol=PTOL)
|
| 824 |
+
v = fp.e1((-2.0 - 8.0j))
|
| 825 |
+
assert ae(v, (-0.8705211147733730969 - 0.24099328498605539667j), tol=ATOL)
|
| 826 |
+
assert ae(v.real, -0.8705211147733730969, tol=PTOL)
|
| 827 |
+
assert ae(v.imag, -0.24099328498605539667, tol=PTOL)
|
| 828 |
+
v = fp.e1((-5.0 - 20.0j))
|
| 829 |
+
assert ae(v, (-7.0789514293925893007 + 1.6102177171960790536j), tol=ATOL)
|
| 830 |
+
assert ae(v.real, -7.0789514293925893007, tol=PTOL)
|
| 831 |
+
assert ae(v.imag, 1.6102177171960790536, tol=PTOL)
|
| 832 |
+
v = fp.e1((-20.0 - 80.0j))
|
| 833 |
+
assert ae(v, (5855431.4907298084434 + 720920.93315409165707j), tol=ATOL)
|
| 834 |
+
assert ae(v.real, 5855431.4907298084434, tol=PTOL)
|
| 835 |
+
assert ae(v.imag, 720920.93315409165707, tol=PTOL)
|
| 836 |
+
v = fp.e1((-30.0 - 120.0j))
|
| 837 |
+
assert ae(v, (-65402491644.703470747 + 56697658399.657460294j), tol=ATOL)
|
| 838 |
+
assert ae(v.real, -65402491644.703470747, tol=PTOL)
|
| 839 |
+
assert ae(v.imag, 56697658399.657460294, tol=PTOL)
|
| 840 |
+
v = fp.e1((-40.0 - 160.0j))
|
| 841 |
+
assert ae(v, (25504929379604.776769 - 1429035198630573.2463j), tol=ATOL)
|
| 842 |
+
assert ae(v.real, 25504929379604.776769, tol=PTOL)
|
| 843 |
+
assert ae(v.imag, -1429035198630573.2463, tol=PTOL)
|
| 844 |
+
v = fp.e1((-50.0 - 200.0j))
|
| 845 |
+
assert ae(v, (18437746526988116954.0 + 17146362239046152345.0j), tol=ATOL)
|
| 846 |
+
assert ae(v.real, 18437746526988116954.0, tol=PTOL)
|
| 847 |
+
assert ae(v.imag, 17146362239046152345.0, tol=PTOL)
|
| 848 |
+
v = fp.e1((-80.0 - 320.0j))
|
| 849 |
+
assert ae(v, (3.3464697299634526706e+31 + 1.6473152633843023919e+32j), tol=ATOL)
|
| 850 |
+
assert ae(v.real, 3.3464697299634526706e+31, tol=PTOL)
|
| 851 |
+
assert ae(v.imag, 1.6473152633843023919e+32, tol=PTOL)
|
| 852 |
+
v = fp.e1((0.0 - 1.1641532182693481445e-10j))
|
| 853 |
+
assert ae(v, (22.29664129357666235 + 1.5707963266784812974j), tol=ATOL)
|
| 854 |
+
assert ae(v.real, 22.29664129357666235, tol=PTOL)
|
| 855 |
+
assert ae(v.imag, 1.5707963266784812974, tol=PTOL)
|
| 856 |
+
v = fp.e1((0.0 - 0.25j))
|
| 857 |
+
assert ae(v, (0.82466306258094565309 + 1.3216627564751394551j), tol=ATOL)
|
| 858 |
+
assert ae(v.real, 0.82466306258094565309, tol=PTOL)
|
| 859 |
+
assert ae(v.imag, 1.3216627564751394551, tol=PTOL)
|
| 860 |
+
v = fp.e1((0.0 - 1.0j))
|
| 861 |
+
assert ae(v, (-0.33740392290096813466 + 0.62471325642771360429j), tol=ATOL)
|
| 862 |
+
assert ae(v.real, -0.33740392290096813466, tol=PTOL)
|
| 863 |
+
assert ae(v.imag, 0.62471325642771360429, tol=PTOL)
|
| 864 |
+
v = fp.e1((0.0 - 2.0j))
|
| 865 |
+
assert ae(v, (-0.4229808287748649957 - 0.034616650007798229345j), tol=ATOL)
|
| 866 |
+
assert ae(v.real, -0.4229808287748649957, tol=PTOL)
|
| 867 |
+
assert ae(v.imag, -0.034616650007798229345, tol=PTOL)
|
| 868 |
+
v = fp.e1((0.0 - 5.0j))
|
| 869 |
+
assert ae(v, (0.19002974965664387862 + 0.020865081850222481957j), tol=ATOL)
|
| 870 |
+
assert ae(v.real, 0.19002974965664387862, tol=PTOL)
|
| 871 |
+
assert ae(v.imag, 0.020865081850222481957, tol=PTOL)
|
| 872 |
+
v = fp.e1((0.0 - 20.0j))
|
| 873 |
+
assert ae(v, (-0.04441982084535331654 + 0.022554625751456779068j), tol=ATOL)
|
| 874 |
+
assert ae(v.real, -0.04441982084535331654, tol=PTOL)
|
| 875 |
+
assert ae(v.imag, 0.022554625751456779068, tol=PTOL)
|
| 876 |
+
v = fp.e1((0.0 - 30.0j))
|
| 877 |
+
assert ae(v, (0.033032417282071143779 + 0.0040397867645455082476j), tol=ATOL)
|
| 878 |
+
assert ae(v.real, 0.033032417282071143779, tol=PTOL)
|
| 879 |
+
assert ae(v.imag, 0.0040397867645455082476, tol=PTOL)
|
| 880 |
+
v = fp.e1((0.0 - 40.0j))
|
| 881 |
+
assert ae(v, (-0.019020007896208766962 - 0.016188792559887887544j), tol=ATOL)
|
| 882 |
+
assert ae(v.real, -0.019020007896208766962, tol=PTOL)
|
| 883 |
+
assert ae(v.imag, -0.016188792559887887544, tol=PTOL)
|
| 884 |
+
v = fp.e1((0.0 - 50.0j))
|
| 885 |
+
assert ae(v, (0.0056283863241163054402 + 0.019179254308960724503j), tol=ATOL)
|
| 886 |
+
assert ae(v.real, 0.0056283863241163054402, tol=PTOL)
|
| 887 |
+
assert ae(v.imag, 0.019179254308960724503, tol=PTOL)
|
| 888 |
+
v = fp.e1((0.0 - 80.0j))
|
| 889 |
+
assert ae(v, (0.012402501155070958192 - 0.0015345601175906961199j), tol=ATOL)
|
| 890 |
+
assert ae(v.real, 0.012402501155070958192, tol=PTOL)
|
| 891 |
+
assert ae(v.imag, -0.0015345601175906961199, tol=PTOL)
|
| 892 |
+
v = fp.e1((1.1641532182693481445e-10 - 4.6566128730773925781e-10j))
|
| 893 |
+
assert ae(v, (20.880034621664969632 + 1.3258176632023711778j), tol=ATOL)
|
| 894 |
+
assert ae(v.real, 20.880034621664969632, tol=PTOL)
|
| 895 |
+
assert ae(v.imag, 1.3258176632023711778, tol=PTOL)
|
| 896 |
+
v = fp.e1((0.25 - 1.0j))
|
| 897 |
+
assert ae(v, (-0.16868306393667788761 + 0.4858011885947426971j), tol=ATOL)
|
| 898 |
+
assert ae(v.real, -0.16868306393667788761, tol=PTOL)
|
| 899 |
+
assert ae(v.imag, 0.4858011885947426971, tol=PTOL)
|
| 900 |
+
v = fp.e1((1.0 - 4.0j))
|
| 901 |
+
assert ae(v, (0.03373591813926547318 - 0.073523452241083821877j), tol=ATOL)
|
| 902 |
+
assert ae(v.real, 0.03373591813926547318, tol=PTOL)
|
| 903 |
+
assert ae(v.imag, -0.073523452241083821877, tol=PTOL)
|
| 904 |
+
v = fp.e1((2.0 - 8.0j))
|
| 905 |
+
assert ae(v, (-0.015392833434733785143 + 0.0031747121557605415914j), tol=ATOL)
|
| 906 |
+
assert ae(v.real, -0.015392833434733785143, tol=PTOL)
|
| 907 |
+
assert ae(v.imag, 0.0031747121557605415914, tol=PTOL)
|
| 908 |
+
v = fp.e1((5.0 - 20.0j))
|
| 909 |
+
assert ae(v, (-0.00024419662286542966525 + 0.00021008322966152755674j), tol=ATOL)
|
| 910 |
+
assert ae(v.real, -0.00024419662286542966525, tol=PTOL)
|
| 911 |
+
assert ae(v.imag, 0.00021008322966152755674, tol=PTOL)
|
| 912 |
+
v = fp.e1((20.0 - 80.0j))
|
| 913 |
+
assert ae(v, (2.3255552781051330088e-11 - 8.9463918891349438007e-12j), tol=ATOL)
|
| 914 |
+
assert ae(v.real, 2.3255552781051330088e-11, tol=PTOL)
|
| 915 |
+
assert ae(v.imag, -8.9463918891349438007e-12, tol=PTOL)
|
| 916 |
+
v = fp.e1((30.0 - 120.0j))
|
| 917 |
+
assert ae(v, (-2.7068919097124652332e-16 + 7.0477762411705130239e-16j), tol=ATOL)
|
| 918 |
+
assert ae(v.real, -2.7068919097124652332e-16, tol=PTOL)
|
| 919 |
+
assert ae(v.imag, 7.0477762411705130239e-16, tol=PTOL)
|
| 920 |
+
v = fp.e1((40.0 - 160.0j))
|
| 921 |
+
assert ae(v, (-1.1695597827678024687e-20 - 2.2907401455645736661e-20j), tol=ATOL)
|
| 922 |
+
assert ae(v.real, -1.1695597827678024687e-20, tol=PTOL)
|
| 923 |
+
assert ae(v.imag, -2.2907401455645736661e-20, tol=PTOL)
|
| 924 |
+
v = fp.e1((50.0 - 200.0j))
|
| 925 |
+
assert ae(v, (9.0323746914410162531e-25 + 2.3950601790033530935e-25j), tol=ATOL)
|
| 926 |
+
assert ae(v.real, 9.0323746914410162531e-25, tol=PTOL)
|
| 927 |
+
assert ae(v.imag, 2.3950601790033530935e-25, tol=PTOL)
|
| 928 |
+
v = fp.e1((80.0 - 320.0j))
|
| 929 |
+
assert ae(v, (3.4819106748728063576e-38 + 4.215653005615772724e-38j), tol=ATOL)
|
| 930 |
+
assert ae(v.real, 3.4819106748728063576e-38, tol=PTOL)
|
| 931 |
+
assert ae(v.imag, 4.215653005615772724e-38, tol=PTOL)
|
| 932 |
+
v = fp.e1((1.1641532182693481445e-10 - 1.1641532182693481445e-10j))
|
| 933 |
+
assert ae(v, (21.950067703413105017 + 0.7853981632810329878j), tol=ATOL)
|
| 934 |
+
assert ae(v.real, 21.950067703413105017, tol=PTOL)
|
| 935 |
+
assert ae(v.imag, 0.7853981632810329878, tol=PTOL)
|
| 936 |
+
v = fp.e1((0.25 - 0.25j))
|
| 937 |
+
assert ae(v, (0.71092525792923287894 + 0.56491812441304194711j), tol=ATOL)
|
| 938 |
+
assert ae(v.real, 0.71092525792923287894, tol=PTOL)
|
| 939 |
+
assert ae(v.imag, 0.56491812441304194711, tol=PTOL)
|
| 940 |
+
v = fp.e1((1.0 - 1.0j))
|
| 941 |
+
assert ae(v, (0.00028162445198141832551 + 0.17932453503935894015j), tol=ATOL)
|
| 942 |
+
assert ae(v.real, 0.00028162445198141832551, tol=PTOL)
|
| 943 |
+
assert ae(v.imag, 0.17932453503935894015, tol=PTOL)
|
| 944 |
+
v = fp.e1((2.0 - 2.0j))
|
| 945 |
+
assert ae(v, (-0.033767089606562004246 + 0.018599414169750541925j), tol=ATOL)
|
| 946 |
+
assert ae(v.real, -0.033767089606562004246, tol=PTOL)
|
| 947 |
+
assert ae(v.imag, 0.018599414169750541925, tol=PTOL)
|
| 948 |
+
v = fp.e1((5.0 - 5.0j))
|
| 949 |
+
assert ae(v, (0.0007266506660356393891 - 0.00047102780163522245054j), tol=ATOL)
|
| 950 |
+
assert ae(v.real, 0.0007266506660356393891, tol=PTOL)
|
| 951 |
+
assert ae(v.imag, -0.00047102780163522245054, tol=PTOL)
|
| 952 |
+
v = fp.e1((20.0 - 20.0j))
|
| 953 |
+
assert ae(v, (-2.3824537449367396579e-11 + 6.6969873156525615158e-11j), tol=ATOL)
|
| 954 |
+
assert ae(v.real, -2.3824537449367396579e-11, tol=PTOL)
|
| 955 |
+
assert ae(v.imag, 6.6969873156525615158e-11, tol=PTOL)
|
| 956 |
+
v = fp.e1((30.0 - 30.0j))
|
| 957 |
+
assert ae(v, (1.7316045841744061617e-15 - 1.3065678019487308689e-15j), tol=ATOL)
|
| 958 |
+
assert ae(v.real, 1.7316045841744061617e-15, tol=PTOL)
|
| 959 |
+
assert ae(v.imag, -1.3065678019487308689e-15, tol=PTOL)
|
| 960 |
+
v = fp.e1((40.0 - 40.0j))
|
| 961 |
+
assert ae(v, (-7.4001043002899232182e-20 + 4.991847855336816304e-21j), tol=ATOL)
|
| 962 |
+
assert ae(v.real, -7.4001043002899232182e-20, tol=PTOL)
|
| 963 |
+
assert ae(v.imag, 4.991847855336816304e-21, tol=PTOL)
|
| 964 |
+
v = fp.e1((50.0 - 50.0j))
|
| 965 |
+
assert ae(v, (2.3566128324644641219e-24 + 1.3188326726201614778e-24j), tol=ATOL)
|
| 966 |
+
assert ae(v.real, 2.3566128324644641219e-24, tol=PTOL)
|
| 967 |
+
assert ae(v.imag, 1.3188326726201614778e-24, tol=PTOL)
|
| 968 |
+
v = fp.e1((80.0 - 80.0j))
|
| 969 |
+
assert ae(v, (9.8279750572186526673e-38 - 1.243952841288868831e-37j), tol=ATOL)
|
| 970 |
+
assert ae(v.real, 9.8279750572186526673e-38, tol=PTOL)
|
| 971 |
+
assert ae(v.imag, -1.243952841288868831e-37, tol=PTOL)
|
| 972 |
+
v = fp.e1((4.6566128730773925781e-10 - 1.1641532182693481445e-10j))
|
| 973 |
+
assert ae(v, (20.880034622014215597 + 0.24497866301044883237j), tol=ATOL)
|
| 974 |
+
assert ae(v.real, 20.880034622014215597, tol=PTOL)
|
| 975 |
+
assert ae(v.imag, 0.24497866301044883237, tol=PTOL)
|
| 976 |
+
v = fp.e1((1.0 - 0.25j))
|
| 977 |
+
assert ae(v, (0.19731063945004229095 + 0.087366045774299963672j), tol=ATOL)
|
| 978 |
+
assert ae(v.real, 0.19731063945004229095, tol=PTOL)
|
| 979 |
+
assert ae(v.imag, 0.087366045774299963672, tol=PTOL)
|
| 980 |
+
v = fp.e1((4.0 - 1.0j))
|
| 981 |
+
assert ae(v, (0.0013106173980145506944 + 0.0034542480199350626699j), tol=ATOL)
|
| 982 |
+
assert ae(v.real, 0.0013106173980145506944, tol=PTOL)
|
| 983 |
+
assert ae(v.imag, 0.0034542480199350626699, tol=PTOL)
|
| 984 |
+
v = fp.e1((8.0 - 2.0j))
|
| 985 |
+
assert ae(v, (-0.000022278049065270225945 + 0.000029191940456521555288j), tol=ATOL)
|
| 986 |
+
assert ae(v.real, -0.000022278049065270225945, tol=PTOL)
|
| 987 |
+
assert ae(v.imag, 0.000029191940456521555288, tol=PTOL)
|
| 988 |
+
v = fp.e1((20.0 - 5.0j))
|
| 989 |
+
assert ae(v, (4.7711374515765346894e-11 - 8.2902652405126947359e-11j), tol=ATOL)
|
| 990 |
+
assert ae(v.real, 4.7711374515765346894e-11, tol=PTOL)
|
| 991 |
+
assert ae(v.imag, -8.2902652405126947359e-11, tol=PTOL)
|
| 992 |
+
v = fp.e1((80.0 - 20.0j))
|
| 993 |
+
assert ae(v, (3.8353473865788235787e-38 + 2.129247592349605139e-37j), tol=ATOL)
|
| 994 |
+
assert ae(v.real, 3.8353473865788235787e-38, tol=PTOL)
|
| 995 |
+
assert ae(v.imag, 2.129247592349605139e-37, tol=PTOL)
|
| 996 |
+
v = fp.e1((120.0 - 30.0j))
|
| 997 |
+
assert ae(v, (2.3836002337480334716e-55 - 5.6704043587126198306e-55j), tol=ATOL)
|
| 998 |
+
assert ae(v.real, 2.3836002337480334716e-55, tol=PTOL)
|
| 999 |
+
assert ae(v.imag, -5.6704043587126198306e-55, tol=PTOL)
|
| 1000 |
+
v = fp.e1((160.0 - 40.0j))
|
| 1001 |
+
assert ae(v, (-1.6238022898654510661e-72 + 1.104172355572287367e-72j), tol=ATOL)
|
| 1002 |
+
assert ae(v.real, -1.6238022898654510661e-72, tol=PTOL)
|
| 1003 |
+
assert ae(v.imag, 1.104172355572287367e-72, tol=PTOL)
|
| 1004 |
+
v = fp.e1((200.0 - 50.0j))
|
| 1005 |
+
assert ae(v, (6.6800061461666228487e-90 - 1.4473816083541016115e-91j), tol=ATOL)
|
| 1006 |
+
assert ae(v.real, 6.6800061461666228487e-90, tol=PTOL)
|
| 1007 |
+
assert ae(v.imag, -1.4473816083541016115e-91, tol=PTOL)
|
| 1008 |
+
v = fp.e1((320.0 - 80.0j))
|
| 1009 |
+
assert ae(v, (4.2737871527778786157e-143 - 3.1789935525785660314e-142j), tol=ATOL)
|
| 1010 |
+
assert ae(v.real, 4.2737871527778786157e-143, tol=PTOL)
|
| 1011 |
+
assert ae(v.imag, -3.1789935525785660314e-142, tol=PTOL)
|
| 1012 |
+
v = fp.ei(1.1641532182693481445e-10)
|
| 1013 |
+
assert ae(v, -22.296641293460247028, tol=ATOL)
|
| 1014 |
+
assert type(v) is float
|
| 1015 |
+
v = fp.ei(0.25)
|
| 1016 |
+
assert ae(v, -0.54254326466191372953, tol=ATOL)
|
| 1017 |
+
assert type(v) is float
|
| 1018 |
+
v = fp.ei(1.0)
|
| 1019 |
+
assert ae(v, 1.8951178163559367555, tol=ATOL)
|
| 1020 |
+
assert type(v) is float
|
| 1021 |
+
v = fp.ei(2.0)
|
| 1022 |
+
assert ae(v, 4.9542343560018901634, tol=ATOL)
|
| 1023 |
+
assert type(v) is float
|
| 1024 |
+
v = fp.ei(5.0)
|
| 1025 |
+
assert ae(v, 40.185275355803177455, tol=ATOL)
|
| 1026 |
+
assert type(v) is float
|
| 1027 |
+
v = fp.ei(20.0)
|
| 1028 |
+
assert ae(v, 25615652.66405658882, tol=ATOL)
|
| 1029 |
+
assert type(v) is float
|
| 1030 |
+
v = fp.ei(30.0)
|
| 1031 |
+
assert ae(v, 368973209407.27419706, tol=ATOL)
|
| 1032 |
+
assert type(v) is float
|
| 1033 |
+
v = fp.ei(40.0)
|
| 1034 |
+
assert ae(v, 6039718263611241.5784, tol=ATOL)
|
| 1035 |
+
assert type(v) is float
|
| 1036 |
+
v = fp.ei(50.0)
|
| 1037 |
+
assert ae(v, 1.0585636897131690963e+20, tol=ATOL)
|
| 1038 |
+
assert type(v) is float
|
| 1039 |
+
v = fp.ei(80.0)
|
| 1040 |
+
assert ae(v, 7.0146000049047999696e+32, tol=ATOL)
|
| 1041 |
+
assert type(v) is float
|
| 1042 |
+
v = fp.ei((1.1641532182693481445e-10 + 0.0j))
|
| 1043 |
+
assert ae(v, (-22.296641293460247028 + 0.0j), tol=ATOL)
|
| 1044 |
+
assert ae(v.real, -22.296641293460247028, tol=PTOL)
|
| 1045 |
+
assert v.imag == 0
|
| 1046 |
+
v = fp.ei((0.25 + 0.0j))
|
| 1047 |
+
assert ae(v, (-0.54254326466191372953 + 0.0j), tol=ATOL)
|
| 1048 |
+
assert ae(v.real, -0.54254326466191372953, tol=PTOL)
|
| 1049 |
+
assert v.imag == 0
|
| 1050 |
+
v = fp.ei((1.0 + 0.0j))
|
| 1051 |
+
assert ae(v, (1.8951178163559367555 + 0.0j), tol=ATOL)
|
| 1052 |
+
assert ae(v.real, 1.8951178163559367555, tol=PTOL)
|
| 1053 |
+
assert v.imag == 0
|
| 1054 |
+
v = fp.ei((2.0 + 0.0j))
|
| 1055 |
+
assert ae(v, (4.9542343560018901634 + 0.0j), tol=ATOL)
|
| 1056 |
+
assert ae(v.real, 4.9542343560018901634, tol=PTOL)
|
| 1057 |
+
assert v.imag == 0
|
| 1058 |
+
v = fp.ei((5.0 + 0.0j))
|
| 1059 |
+
assert ae(v, (40.185275355803177455 + 0.0j), tol=ATOL)
|
| 1060 |
+
assert ae(v.real, 40.185275355803177455, tol=PTOL)
|
| 1061 |
+
assert v.imag == 0
|
| 1062 |
+
v = fp.ei((20.0 + 0.0j))
|
| 1063 |
+
assert ae(v, (25615652.66405658882 + 0.0j), tol=ATOL)
|
| 1064 |
+
assert ae(v.real, 25615652.66405658882, tol=PTOL)
|
| 1065 |
+
assert v.imag == 0
|
| 1066 |
+
v = fp.ei((30.0 + 0.0j))
|
| 1067 |
+
assert ae(v, (368973209407.27419706 + 0.0j), tol=ATOL)
|
| 1068 |
+
assert ae(v.real, 368973209407.27419706, tol=PTOL)
|
| 1069 |
+
assert v.imag == 0
|
| 1070 |
+
v = fp.ei((40.0 + 0.0j))
|
| 1071 |
+
assert ae(v, (6039718263611241.5784 + 0.0j), tol=ATOL)
|
| 1072 |
+
assert ae(v.real, 6039718263611241.5784, tol=PTOL)
|
| 1073 |
+
assert v.imag == 0
|
| 1074 |
+
v = fp.ei((50.0 + 0.0j))
|
| 1075 |
+
assert ae(v, (1.0585636897131690963e+20 + 0.0j), tol=ATOL)
|
| 1076 |
+
assert ae(v.real, 1.0585636897131690963e+20, tol=PTOL)
|
| 1077 |
+
assert v.imag == 0
|
| 1078 |
+
v = fp.ei((80.0 + 0.0j))
|
| 1079 |
+
assert ae(v, (7.0146000049047999696e+32 + 0.0j), tol=ATOL)
|
| 1080 |
+
assert ae(v.real, 7.0146000049047999696e+32, tol=PTOL)
|
| 1081 |
+
assert v.imag == 0
|
| 1082 |
+
v = fp.ei((4.6566128730773925781e-10 + 1.1641532182693481445e-10j))
|
| 1083 |
+
assert ae(v, (-20.880034621082893023 + 0.24497866324327947603j), tol=ATOL)
|
| 1084 |
+
assert ae(v.real, -20.880034621082893023, tol=PTOL)
|
| 1085 |
+
assert ae(v.imag, 0.24497866324327947603, tol=PTOL)
|
| 1086 |
+
v = fp.ei((1.0 + 0.25j))
|
| 1087 |
+
assert ae(v, (1.8942716983721074932 + 0.67268237088273915854j), tol=ATOL)
|
| 1088 |
+
assert ae(v.real, 1.8942716983721074932, tol=PTOL)
|
| 1089 |
+
assert ae(v.imag, 0.67268237088273915854, tol=PTOL)
|
| 1090 |
+
v = fp.ei((4.0 + 1.0j))
|
| 1091 |
+
assert ae(v, (14.806699492675420438 + 12.280015176673582616j), tol=ATOL)
|
| 1092 |
+
assert ae(v.real, 14.806699492675420438, tol=PTOL)
|
| 1093 |
+
assert ae(v.imag, 12.280015176673582616, tol=PTOL)
|
| 1094 |
+
v = fp.ei((8.0 + 2.0j))
|
| 1095 |
+
assert ae(v, (-54.633252667426386294 + 416.34477429173650012j), tol=ATOL)
|
| 1096 |
+
assert ae(v.real, -54.633252667426386294, tol=PTOL)
|
| 1097 |
+
assert ae(v.imag, 416.34477429173650012, tol=PTOL)
|
| 1098 |
+
v = fp.ei((20.0 + 5.0j))
|
| 1099 |
+
assert ae(v, (711836.97165402624643 - 24745247.798103247366j), tol=ATOL)
|
| 1100 |
+
assert ae(v.real, 711836.97165402624643, tol=PTOL)
|
| 1101 |
+
assert ae(v.imag, -24745247.798103247366, tol=PTOL)
|
| 1102 |
+
v = fp.ei((80.0 + 20.0j))
|
| 1103 |
+
assert ae(v, (4.2139911108612653091e+32 + 5.3367124741918251637e+32j), tol=ATOL)
|
| 1104 |
+
assert ae(v.real, 4.2139911108612653091e+32, tol=PTOL)
|
| 1105 |
+
assert ae(v.imag, 5.3367124741918251637e+32, tol=PTOL)
|
| 1106 |
+
v = fp.ei((120.0 + 30.0j))
|
| 1107 |
+
assert ae(v, (-9.7760616203707508892e+48 - 1.058257682317195792e+50j), tol=ATOL)
|
| 1108 |
+
assert ae(v.real, -9.7760616203707508892e+48, tol=PTOL)
|
| 1109 |
+
assert ae(v.imag, -1.058257682317195792e+50, tol=PTOL)
|
| 1110 |
+
v = fp.ei((160.0 + 40.0j))
|
| 1111 |
+
assert ae(v, (-8.7065541466623638861e+66 + 1.6577106725141739889e+67j), tol=ATOL)
|
| 1112 |
+
assert ae(v.real, -8.7065541466623638861e+66, tol=PTOL)
|
| 1113 |
+
assert ae(v.imag, 1.6577106725141739889e+67, tol=PTOL)
|
| 1114 |
+
v = fp.ei((200.0 + 50.0j))
|
| 1115 |
+
assert ae(v, (3.070744996327018106e+84 - 1.7243244846769415903e+84j), tol=ATOL)
|
| 1116 |
+
assert ae(v.real, 3.070744996327018106e+84, tol=PTOL)
|
| 1117 |
+
assert ae(v.imag, -1.7243244846769415903e+84, tol=PTOL)
|
| 1118 |
+
v = fp.ei((320.0 + 80.0j))
|
| 1119 |
+
assert ae(v, (-9.9960598637998647276e+135 - 2.6855081527595608863e+136j), tol=ATOL)
|
| 1120 |
+
assert ae(v.real, -9.9960598637998647276e+135, tol=PTOL)
|
| 1121 |
+
assert ae(v.imag, -2.6855081527595608863e+136, tol=PTOL)
|
| 1122 |
+
v = fp.ei((1.1641532182693481445e-10 + 1.1641532182693481445e-10j))
|
| 1123 |
+
assert ae(v, (-21.950067703180274374 + 0.78539816351386363145j), tol=ATOL)
|
| 1124 |
+
assert ae(v.real, -21.950067703180274374, tol=PTOL)
|
| 1125 |
+
assert ae(v.imag, 0.78539816351386363145, tol=PTOL)
|
| 1126 |
+
v = fp.ei((0.25 + 0.25j))
|
| 1127 |
+
assert ae(v, (-0.21441047326710323254 + 1.0683772981589995996j), tol=ATOL)
|
| 1128 |
+
assert ae(v.real, -0.21441047326710323254, tol=PTOL)
|
| 1129 |
+
assert ae(v.imag, 1.0683772981589995996, tol=PTOL)
|
| 1130 |
+
v = fp.ei((1.0 + 1.0j))
|
| 1131 |
+
assert ae(v, (1.7646259855638540684 + 2.3877698515105224193j), tol=ATOL)
|
| 1132 |
+
assert ae(v.real, 1.7646259855638540684, tol=PTOL)
|
| 1133 |
+
assert ae(v.imag, 2.3877698515105224193, tol=PTOL)
|
| 1134 |
+
v = fp.ei((2.0 + 2.0j))
|
| 1135 |
+
assert ae(v, (1.8920781621855474089 + 5.3169624378326579621j), tol=ATOL)
|
| 1136 |
+
assert ae(v.real, 1.8920781621855474089, tol=PTOL)
|
| 1137 |
+
assert ae(v.imag, 5.3169624378326579621, tol=PTOL)
|
| 1138 |
+
v = fp.ei((5.0 + 5.0j))
|
| 1139 |
+
assert ae(v, (-13.470936071475245856 - 15.322492395731230968j), tol=ATOL)
|
| 1140 |
+
assert ae(v.real, -13.470936071475245856, tol=PTOL)
|
| 1141 |
+
assert ae(v.imag, -15.322492395731230968, tol=PTOL)
|
| 1142 |
+
v = fp.ei((20.0 + 20.0j))
|
| 1143 |
+
assert ae(v, (16589317.398788971896 + 5831705.4712368307104j), tol=ATOL)
|
| 1144 |
+
assert ae(v.real, 16589317.398788971896, tol=PTOL)
|
| 1145 |
+
assert ae(v.imag, 5831705.4712368307104, tol=PTOL)
|
| 1146 |
+
v = fp.ei((30.0 + 30.0j))
|
| 1147 |
+
assert ae(v, (-154596484273.69322527 - 204179357834.2723043j), tol=ATOL)
|
| 1148 |
+
assert ae(v.real, -154596484273.69322527, tol=PTOL)
|
| 1149 |
+
assert ae(v.imag, -204179357834.2723043, tol=PTOL)
|
| 1150 |
+
v = fp.ei((40.0 + 40.0j))
|
| 1151 |
+
assert ae(v, (287512180321448.45408 + 4203502407932318.1156j), tol=ATOL)
|
| 1152 |
+
assert ae(v.real, 287512180321448.45408, tol=PTOL)
|
| 1153 |
+
assert ae(v.imag, 4203502407932318.1156, tol=PTOL)
|
| 1154 |
+
v = fp.ei((50.0 + 50.0j))
|
| 1155 |
+
assert ae(v, (36128528616649268826.0 - 64648801861338741960.0j), tol=ATOL)
|
| 1156 |
+
assert ae(v.real, 36128528616649268826.0, tol=PTOL)
|
| 1157 |
+
assert ae(v.imag, -64648801861338741960.0, tol=PTOL)
|
| 1158 |
+
v = fp.ei((80.0 + 80.0j))
|
| 1159 |
+
assert ae(v, (-3.8674816337930010217e+32 - 3.0540709639658071041e+32j), tol=ATOL)
|
| 1160 |
+
assert ae(v.real, -3.8674816337930010217e+32, tol=PTOL)
|
| 1161 |
+
assert ae(v.imag, -3.0540709639658071041e+32, tol=PTOL)
|
| 1162 |
+
v = fp.ei((1.1641532182693481445e-10 + 4.6566128730773925781e-10j))
|
| 1163 |
+
assert ae(v, (-20.880034621432138988 + 1.3258176641336937524j), tol=ATOL)
|
| 1164 |
+
assert ae(v.real, -20.880034621432138988, tol=PTOL)
|
| 1165 |
+
assert ae(v.imag, 1.3258176641336937524, tol=PTOL)
|
| 1166 |
+
v = fp.ei((0.25 + 1.0j))
|
| 1167 |
+
assert ae(v, (0.59066621214766308594 + 2.3968481059377428687j), tol=ATOL)
|
| 1168 |
+
assert ae(v.real, 0.59066621214766308594, tol=PTOL)
|
| 1169 |
+
assert ae(v.imag, 2.3968481059377428687, tol=PTOL)
|
| 1170 |
+
v = fp.ei((1.0 + 4.0j))
|
| 1171 |
+
assert ae(v, (-0.49739047283060471093 + 3.5570287076301818702j), tol=ATOL)
|
| 1172 |
+
assert ae(v.real, -0.49739047283060471093, tol=PTOL)
|
| 1173 |
+
assert ae(v.imag, 3.5570287076301818702, tol=PTOL)
|
| 1174 |
+
v = fp.ei((2.0 + 8.0j))
|
| 1175 |
+
assert ae(v, (0.8705211147733730969 + 3.3825859385758486351j), tol=ATOL)
|
| 1176 |
+
assert ae(v.real, 0.8705211147733730969, tol=PTOL)
|
| 1177 |
+
assert ae(v.imag, 3.3825859385758486351, tol=PTOL)
|
| 1178 |
+
v = fp.ei((5.0 + 20.0j))
|
| 1179 |
+
assert ae(v, (7.0789514293925893007 + 1.5313749363937141849j), tol=ATOL)
|
| 1180 |
+
assert ae(v.real, 7.0789514293925893007, tol=PTOL)
|
| 1181 |
+
assert ae(v.imag, 1.5313749363937141849, tol=PTOL)
|
| 1182 |
+
v = fp.ei((20.0 + 80.0j))
|
| 1183 |
+
assert ae(v, (-5855431.4907298084434 - 720917.79156143806727j), tol=ATOL)
|
| 1184 |
+
assert ae(v.real, -5855431.4907298084434, tol=PTOL)
|
| 1185 |
+
assert ae(v.imag, -720917.79156143806727, tol=PTOL)
|
| 1186 |
+
v = fp.ei((30.0 + 120.0j))
|
| 1187 |
+
assert ae(v, (65402491644.703470747 - 56697658396.51586764j), tol=ATOL)
|
| 1188 |
+
assert ae(v.real, 65402491644.703470747, tol=PTOL)
|
| 1189 |
+
assert ae(v.imag, -56697658396.51586764, tol=PTOL)
|
| 1190 |
+
v = fp.ei((40.0 + 160.0j))
|
| 1191 |
+
assert ae(v, (-25504929379604.776769 + 1429035198630576.3879j), tol=ATOL)
|
| 1192 |
+
assert ae(v.real, -25504929379604.776769, tol=PTOL)
|
| 1193 |
+
assert ae(v.imag, 1429035198630576.3879, tol=PTOL)
|
| 1194 |
+
v = fp.ei((50.0 + 200.0j))
|
| 1195 |
+
assert ae(v, (-18437746526988116954.0 - 17146362239046152342.0j), tol=ATOL)
|
| 1196 |
+
assert ae(v.real, -18437746526988116954.0, tol=PTOL)
|
| 1197 |
+
assert ae(v.imag, -17146362239046152342.0, tol=PTOL)
|
| 1198 |
+
v = fp.ei((80.0 + 320.0j))
|
| 1199 |
+
assert ae(v, (-3.3464697299634526706e+31 - 1.6473152633843023919e+32j), tol=ATOL)
|
| 1200 |
+
assert ae(v.real, -3.3464697299634526706e+31, tol=PTOL)
|
| 1201 |
+
assert ae(v.imag, -1.6473152633843023919e+32, tol=PTOL)
|
| 1202 |
+
v = fp.ei((0.0 + 1.1641532182693481445e-10j))
|
| 1203 |
+
assert ae(v, (-22.29664129357666235 + 1.5707963269113119411j), tol=ATOL)
|
| 1204 |
+
assert ae(v.real, -22.29664129357666235, tol=PTOL)
|
| 1205 |
+
assert ae(v.imag, 1.5707963269113119411, tol=PTOL)
|
| 1206 |
+
v = fp.ei((0.0 + 0.25j))
|
| 1207 |
+
assert ae(v, (-0.82466306258094565309 + 1.8199298971146537833j), tol=ATOL)
|
| 1208 |
+
assert ae(v.real, -0.82466306258094565309, tol=PTOL)
|
| 1209 |
+
assert ae(v.imag, 1.8199298971146537833, tol=PTOL)
|
| 1210 |
+
v = fp.ei((0.0 + 1.0j))
|
| 1211 |
+
assert ae(v, (0.33740392290096813466 + 2.5168793971620796342j), tol=ATOL)
|
| 1212 |
+
assert ae(v.real, 0.33740392290096813466, tol=PTOL)
|
| 1213 |
+
assert ae(v.imag, 2.5168793971620796342, tol=PTOL)
|
| 1214 |
+
v = fp.ei((0.0 + 2.0j))
|
| 1215 |
+
assert ae(v, (0.4229808287748649957 + 3.1762093035975914678j), tol=ATOL)
|
| 1216 |
+
assert ae(v.real, 0.4229808287748649957, tol=PTOL)
|
| 1217 |
+
assert ae(v.imag, 3.1762093035975914678, tol=PTOL)
|
| 1218 |
+
v = fp.ei((0.0 + 5.0j))
|
| 1219 |
+
assert ae(v, (-0.19002974965664387862 + 3.1207275717395707565j), tol=ATOL)
|
| 1220 |
+
assert ae(v.real, -0.19002974965664387862, tol=PTOL)
|
| 1221 |
+
assert ae(v.imag, 3.1207275717395707565, tol=PTOL)
|
| 1222 |
+
v = fp.ei((0.0 + 20.0j))
|
| 1223 |
+
assert ae(v, (0.04441982084535331654 + 3.1190380278383364594j), tol=ATOL)
|
| 1224 |
+
assert ae(v.real, 0.04441982084535331654, tol=PTOL)
|
| 1225 |
+
assert ae(v.imag, 3.1190380278383364594, tol=PTOL)
|
| 1226 |
+
v = fp.ei((0.0 + 30.0j))
|
| 1227 |
+
assert ae(v, (-0.033032417282071143779 + 3.1375528668252477302j), tol=ATOL)
|
| 1228 |
+
assert ae(v.real, -0.033032417282071143779, tol=PTOL)
|
| 1229 |
+
assert ae(v.imag, 3.1375528668252477302, tol=PTOL)
|
| 1230 |
+
v = fp.ei((0.0 + 40.0j))
|
| 1231 |
+
assert ae(v, (0.019020007896208766962 + 3.157781446149681126j), tol=ATOL)
|
| 1232 |
+
assert ae(v.real, 0.019020007896208766962, tol=PTOL)
|
| 1233 |
+
assert ae(v.imag, 3.157781446149681126, tol=PTOL)
|
| 1234 |
+
v = fp.ei((0.0 + 50.0j))
|
| 1235 |
+
assert ae(v, (-0.0056283863241163054402 + 3.122413399280832514j), tol=ATOL)
|
| 1236 |
+
assert ae(v.real, -0.0056283863241163054402, tol=PTOL)
|
| 1237 |
+
assert ae(v.imag, 3.122413399280832514, tol=PTOL)
|
| 1238 |
+
v = fp.ei((0.0 + 80.0j))
|
| 1239 |
+
assert ae(v, (-0.012402501155070958192 + 3.1431272137073839346j), tol=ATOL)
|
| 1240 |
+
assert ae(v.real, -0.012402501155070958192, tol=PTOL)
|
| 1241 |
+
assert ae(v.imag, 3.1431272137073839346, tol=PTOL)
|
| 1242 |
+
v = fp.ei((-1.1641532182693481445e-10 + 4.6566128730773925781e-10j))
|
| 1243 |
+
assert ae(v, (-20.880034621664969632 + 1.8157749903874220607j), tol=ATOL)
|
| 1244 |
+
assert ae(v.real, -20.880034621664969632, tol=PTOL)
|
| 1245 |
+
assert ae(v.imag, 1.8157749903874220607, tol=PTOL)
|
| 1246 |
+
v = fp.ei((-0.25 + 1.0j))
|
| 1247 |
+
assert ae(v, (0.16868306393667788761 + 2.6557914649950505414j), tol=ATOL)
|
| 1248 |
+
assert ae(v.real, 0.16868306393667788761, tol=PTOL)
|
| 1249 |
+
assert ae(v.imag, 2.6557914649950505414, tol=PTOL)
|
| 1250 |
+
v = fp.ei((-1.0 + 4.0j))
|
| 1251 |
+
assert ae(v, (-0.03373591813926547318 + 3.2151161058308770603j), tol=ATOL)
|
| 1252 |
+
assert ae(v.real, -0.03373591813926547318, tol=PTOL)
|
| 1253 |
+
assert ae(v.imag, 3.2151161058308770603, tol=PTOL)
|
| 1254 |
+
v = fp.ei((-2.0 + 8.0j))
|
| 1255 |
+
assert ae(v, (0.015392833434733785143 + 3.1384179414340326969j), tol=ATOL)
|
| 1256 |
+
assert ae(v.real, 0.015392833434733785143, tol=PTOL)
|
| 1257 |
+
assert ae(v.imag, 3.1384179414340326969, tol=PTOL)
|
| 1258 |
+
v = fp.ei((-5.0 + 20.0j))
|
| 1259 |
+
assert ae(v, (0.00024419662286542966525 + 3.1413825703601317109j), tol=ATOL)
|
| 1260 |
+
assert ae(v.real, 0.00024419662286542966525, tol=PTOL)
|
| 1261 |
+
assert ae(v.imag, 3.1413825703601317109, tol=PTOL)
|
| 1262 |
+
v = fp.ei((-20.0 + 80.0j))
|
| 1263 |
+
assert ae(v, (-2.3255552781051330088e-11 + 3.1415926535987396304j), tol=ATOL)
|
| 1264 |
+
assert ae(v.real, -2.3255552781051330088e-11, tol=PTOL)
|
| 1265 |
+
assert ae(v.imag, 3.1415926535987396304, tol=PTOL)
|
| 1266 |
+
v = fp.ei((-30.0 + 120.0j))
|
| 1267 |
+
assert ae(v, (2.7068919097124652332e-16 + 3.1415926535897925337j), tol=ATOL)
|
| 1268 |
+
assert ae(v.real, 2.7068919097124652332e-16, tol=PTOL)
|
| 1269 |
+
assert ae(v.imag, 3.1415926535897925337, tol=PTOL)
|
| 1270 |
+
v = fp.ei((-40.0 + 160.0j))
|
| 1271 |
+
assert ae(v, (1.1695597827678024687e-20 + 3.1415926535897932385j), tol=ATOL)
|
| 1272 |
+
assert ae(v.real, 1.1695597827678024687e-20, tol=PTOL)
|
| 1273 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1274 |
+
v = fp.ei((-50.0 + 200.0j))
|
| 1275 |
+
assert ae(v, (-9.0323746914410162531e-25 + 3.1415926535897932385j), tol=ATOL)
|
| 1276 |
+
assert ae(v.real, -9.0323746914410162531e-25, tol=PTOL)
|
| 1277 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1278 |
+
v = fp.ei((-80.0 + 320.0j))
|
| 1279 |
+
assert ae(v, (-3.4819106748728063576e-38 + 3.1415926535897932385j), tol=ATOL)
|
| 1280 |
+
assert ae(v.real, -3.4819106748728063576e-38, tol=PTOL)
|
| 1281 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1282 |
+
v = fp.ei((-4.6566128730773925781e-10 + 1.1641532182693481445e-10j))
|
| 1283 |
+
assert ae(v, (-20.880034622014215597 + 2.8966139905793444061j), tol=ATOL)
|
| 1284 |
+
assert ae(v.real, -20.880034622014215597, tol=PTOL)
|
| 1285 |
+
assert ae(v.imag, 2.8966139905793444061, tol=PTOL)
|
| 1286 |
+
v = fp.ei((-1.0 + 0.25j))
|
| 1287 |
+
assert ae(v, (-0.19731063945004229095 + 3.0542266078154932748j), tol=ATOL)
|
| 1288 |
+
assert ae(v.real, -0.19731063945004229095, tol=PTOL)
|
| 1289 |
+
assert ae(v.imag, 3.0542266078154932748, tol=PTOL)
|
| 1290 |
+
v = fp.ei((-4.0 + 1.0j))
|
| 1291 |
+
assert ae(v, (-0.0013106173980145506944 + 3.1381384055698581758j), tol=ATOL)
|
| 1292 |
+
assert ae(v.real, -0.0013106173980145506944, tol=PTOL)
|
| 1293 |
+
assert ae(v.imag, 3.1381384055698581758, tol=PTOL)
|
| 1294 |
+
v = fp.ei((-8.0 + 2.0j))
|
| 1295 |
+
assert ae(v, (0.000022278049065270225945 + 3.1415634616493367169j), tol=ATOL)
|
| 1296 |
+
assert ae(v.real, 0.000022278049065270225945, tol=PTOL)
|
| 1297 |
+
assert ae(v.imag, 3.1415634616493367169, tol=PTOL)
|
| 1298 |
+
v = fp.ei((-20.0 + 5.0j))
|
| 1299 |
+
assert ae(v, (-4.7711374515765346894e-11 + 3.1415926536726958909j), tol=ATOL)
|
| 1300 |
+
assert ae(v.real, -4.7711374515765346894e-11, tol=PTOL)
|
| 1301 |
+
assert ae(v.imag, 3.1415926536726958909, tol=PTOL)
|
| 1302 |
+
v = fp.ei((-80.0 + 20.0j))
|
| 1303 |
+
assert ae(v, (-3.8353473865788235787e-38 + 3.1415926535897932385j), tol=ATOL)
|
| 1304 |
+
assert ae(v.real, -3.8353473865788235787e-38, tol=PTOL)
|
| 1305 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1306 |
+
v = fp.ei((-120.0 + 30.0j))
|
| 1307 |
+
assert ae(v, (-2.3836002337480334716e-55 + 3.1415926535897932385j), tol=ATOL)
|
| 1308 |
+
assert ae(v.real, -2.3836002337480334716e-55, tol=PTOL)
|
| 1309 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1310 |
+
v = fp.ei((-160.0 + 40.0j))
|
| 1311 |
+
assert ae(v, (1.6238022898654510661e-72 + 3.1415926535897932385j), tol=ATOL)
|
| 1312 |
+
assert ae(v.real, 1.6238022898654510661e-72, tol=PTOL)
|
| 1313 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1314 |
+
v = fp.ei((-200.0 + 50.0j))
|
| 1315 |
+
assert ae(v, (-6.6800061461666228487e-90 + 3.1415926535897932385j), tol=ATOL)
|
| 1316 |
+
assert ae(v.real, -6.6800061461666228487e-90, tol=PTOL)
|
| 1317 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1318 |
+
v = fp.ei((-320.0 + 80.0j))
|
| 1319 |
+
assert ae(v, (-4.2737871527778786157e-143 + 3.1415926535897932385j), tol=ATOL)
|
| 1320 |
+
assert ae(v.real, -4.2737871527778786157e-143, tol=PTOL)
|
| 1321 |
+
assert ae(v.imag, 3.1415926535897932385, tol=PTOL)
|
| 1322 |
+
v = fp.ei(-1.1641532182693481445e-10)
|
| 1323 |
+
assert ae(v, -22.296641293693077672, tol=ATOL)
|
| 1324 |
+
assert type(v) is float
|
| 1325 |
+
v = fp.ei(-0.25)
|
| 1326 |
+
assert ae(v, -1.0442826344437381945, tol=ATOL)
|
| 1327 |
+
assert type(v) is float
|
| 1328 |
+
v = fp.ei(-1.0)
|
| 1329 |
+
assert ae(v, -0.21938393439552027368, tol=ATOL)
|
| 1330 |
+
assert type(v) is float
|
| 1331 |
+
v = fp.ei(-2.0)
|
| 1332 |
+
assert ae(v, -0.048900510708061119567, tol=ATOL)
|
| 1333 |
+
assert type(v) is float
|
| 1334 |
+
v = fp.ei(-5.0)
|
| 1335 |
+
assert ae(v, -0.0011482955912753257973, tol=ATOL)
|
| 1336 |
+
assert type(v) is float
|
| 1337 |
+
v = fp.ei(-20.0)
|
| 1338 |
+
assert ae(v, -9.8355252906498816904e-11, tol=ATOL)
|
| 1339 |
+
assert type(v) is float
|
| 1340 |
+
v = fp.ei(-30.0)
|
| 1341 |
+
assert ae(v, -3.0215520106888125448e-15, tol=ATOL)
|
| 1342 |
+
assert type(v) is float
|
| 1343 |
+
v = fp.ei(-40.0)
|
| 1344 |
+
assert ae(v, -1.0367732614516569722e-19, tol=ATOL)
|
| 1345 |
+
assert type(v) is float
|
| 1346 |
+
v = fp.ei(-50.0)
|
| 1347 |
+
assert ae(v, -3.7832640295504590187e-24, tol=ATOL)
|
| 1348 |
+
assert type(v) is float
|
| 1349 |
+
v = fp.ei(-80.0)
|
| 1350 |
+
assert ae(v, -2.2285432586884729112e-37, tol=ATOL)
|
| 1351 |
+
assert type(v) is float
|
| 1352 |
+
v = fp.ei((-1.1641532182693481445e-10 + 0.0j))
|
| 1353 |
+
assert ae(v, (-22.296641293693077672 + 0.0j), tol=ATOL)
|
| 1354 |
+
assert ae(v.real, -22.296641293693077672, tol=PTOL)
|
| 1355 |
+
assert v.imag == 0
|
| 1356 |
+
v = fp.ei((-0.25 + 0.0j))
|
| 1357 |
+
assert ae(v, (-1.0442826344437381945 + 0.0j), tol=ATOL)
|
| 1358 |
+
assert ae(v.real, -1.0442826344437381945, tol=PTOL)
|
| 1359 |
+
assert v.imag == 0
|
| 1360 |
+
v = fp.ei((-1.0 + 0.0j))
|
| 1361 |
+
assert ae(v, (-0.21938393439552027368 + 0.0j), tol=ATOL)
|
| 1362 |
+
assert ae(v.real, -0.21938393439552027368, tol=PTOL)
|
| 1363 |
+
assert v.imag == 0
|
| 1364 |
+
v = fp.ei((-2.0 + 0.0j))
|
| 1365 |
+
assert ae(v, (-0.048900510708061119567 + 0.0j), tol=ATOL)
|
| 1366 |
+
assert ae(v.real, -0.048900510708061119567, tol=PTOL)
|
| 1367 |
+
assert v.imag == 0
|
| 1368 |
+
v = fp.ei((-5.0 + 0.0j))
|
| 1369 |
+
assert ae(v, (-0.0011482955912753257973 + 0.0j), tol=ATOL)
|
| 1370 |
+
assert ae(v.real, -0.0011482955912753257973, tol=PTOL)
|
| 1371 |
+
assert v.imag == 0
|
| 1372 |
+
v = fp.ei((-20.0 + 0.0j))
|
| 1373 |
+
assert ae(v, (-9.8355252906498816904e-11 + 0.0j), tol=ATOL)
|
| 1374 |
+
assert ae(v.real, -9.8355252906498816904e-11, tol=PTOL)
|
| 1375 |
+
assert v.imag == 0
|
| 1376 |
+
v = fp.ei((-30.0 + 0.0j))
|
| 1377 |
+
assert ae(v, (-3.0215520106888125448e-15 + 0.0j), tol=ATOL)
|
| 1378 |
+
assert ae(v.real, -3.0215520106888125448e-15, tol=PTOL)
|
| 1379 |
+
assert v.imag == 0
|
| 1380 |
+
v = fp.ei((-40.0 + 0.0j))
|
| 1381 |
+
assert ae(v, (-1.0367732614516569722e-19 + 0.0j), tol=ATOL)
|
| 1382 |
+
assert ae(v.real, -1.0367732614516569722e-19, tol=PTOL)
|
| 1383 |
+
assert v.imag == 0
|
| 1384 |
+
v = fp.ei((-50.0 + 0.0j))
|
| 1385 |
+
assert ae(v, (-3.7832640295504590187e-24 + 0.0j), tol=ATOL)
|
| 1386 |
+
assert ae(v.real, -3.7832640295504590187e-24, tol=PTOL)
|
| 1387 |
+
assert v.imag == 0
|
| 1388 |
+
v = fp.ei((-80.0 + 0.0j))
|
| 1389 |
+
assert ae(v, (-2.2285432586884729112e-37 + 0.0j), tol=ATOL)
|
| 1390 |
+
assert ae(v.real, -2.2285432586884729112e-37, tol=PTOL)
|
| 1391 |
+
assert v.imag == 0
|
| 1392 |
+
v = fp.ei((-4.6566128730773925781e-10 - 1.1641532182693481445e-10j))
|
| 1393 |
+
assert ae(v, (-20.880034622014215597 - 2.8966139905793444061j), tol=ATOL)
|
| 1394 |
+
assert ae(v.real, -20.880034622014215597, tol=PTOL)
|
| 1395 |
+
assert ae(v.imag, -2.8966139905793444061, tol=PTOL)
|
| 1396 |
+
v = fp.ei((-1.0 - 0.25j))
|
| 1397 |
+
assert ae(v, (-0.19731063945004229095 - 3.0542266078154932748j), tol=ATOL)
|
| 1398 |
+
assert ae(v.real, -0.19731063945004229095, tol=PTOL)
|
| 1399 |
+
assert ae(v.imag, -3.0542266078154932748, tol=PTOL)
|
| 1400 |
+
v = fp.ei((-4.0 - 1.0j))
|
| 1401 |
+
assert ae(v, (-0.0013106173980145506944 - 3.1381384055698581758j), tol=ATOL)
|
| 1402 |
+
assert ae(v.real, -0.0013106173980145506944, tol=PTOL)
|
| 1403 |
+
assert ae(v.imag, -3.1381384055698581758, tol=PTOL)
|
| 1404 |
+
v = fp.ei((-8.0 - 2.0j))
|
| 1405 |
+
assert ae(v, (0.000022278049065270225945 - 3.1415634616493367169j), tol=ATOL)
|
| 1406 |
+
assert ae(v.real, 0.000022278049065270225945, tol=PTOL)
|
| 1407 |
+
assert ae(v.imag, -3.1415634616493367169, tol=PTOL)
|
| 1408 |
+
v = fp.ei((-20.0 - 5.0j))
|
| 1409 |
+
assert ae(v, (-4.7711374515765346894e-11 - 3.1415926536726958909j), tol=ATOL)
|
| 1410 |
+
assert ae(v.real, -4.7711374515765346894e-11, tol=PTOL)
|
| 1411 |
+
assert ae(v.imag, -3.1415926536726958909, tol=PTOL)
|
| 1412 |
+
v = fp.ei((-80.0 - 20.0j))
|
| 1413 |
+
assert ae(v, (-3.8353473865788235787e-38 - 3.1415926535897932385j), tol=ATOL)
|
| 1414 |
+
assert ae(v.real, -3.8353473865788235787e-38, tol=PTOL)
|
| 1415 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1416 |
+
v = fp.ei((-120.0 - 30.0j))
|
| 1417 |
+
assert ae(v, (-2.3836002337480334716e-55 - 3.1415926535897932385j), tol=ATOL)
|
| 1418 |
+
assert ae(v.real, -2.3836002337480334716e-55, tol=PTOL)
|
| 1419 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1420 |
+
v = fp.ei((-160.0 - 40.0j))
|
| 1421 |
+
assert ae(v, (1.6238022898654510661e-72 - 3.1415926535897932385j), tol=ATOL)
|
| 1422 |
+
assert ae(v.real, 1.6238022898654510661e-72, tol=PTOL)
|
| 1423 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1424 |
+
v = fp.ei((-200.0 - 50.0j))
|
| 1425 |
+
assert ae(v, (-6.6800061461666228487e-90 - 3.1415926535897932385j), tol=ATOL)
|
| 1426 |
+
assert ae(v.real, -6.6800061461666228487e-90, tol=PTOL)
|
| 1427 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1428 |
+
v = fp.ei((-320.0 - 80.0j))
|
| 1429 |
+
assert ae(v, (-4.2737871527778786157e-143 - 3.1415926535897932385j), tol=ATOL)
|
| 1430 |
+
assert ae(v.real, -4.2737871527778786157e-143, tol=PTOL)
|
| 1431 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1432 |
+
v = fp.ei((-1.1641532182693481445e-10 - 1.1641532182693481445e-10j))
|
| 1433 |
+
assert ae(v, (-21.950067703413105017 - 2.3561944903087602507j), tol=ATOL)
|
| 1434 |
+
assert ae(v.real, -21.950067703413105017, tol=PTOL)
|
| 1435 |
+
assert ae(v.imag, -2.3561944903087602507, tol=PTOL)
|
| 1436 |
+
v = fp.ei((-0.25 - 0.25j))
|
| 1437 |
+
assert ae(v, (-0.71092525792923287894 - 2.5766745291767512913j), tol=ATOL)
|
| 1438 |
+
assert ae(v.real, -0.71092525792923287894, tol=PTOL)
|
| 1439 |
+
assert ae(v.imag, -2.5766745291767512913, tol=PTOL)
|
| 1440 |
+
v = fp.ei((-1.0 - 1.0j))
|
| 1441 |
+
assert ae(v, (-0.00028162445198141832551 - 2.9622681185504342983j), tol=ATOL)
|
| 1442 |
+
assert ae(v.real, -0.00028162445198141832551, tol=PTOL)
|
| 1443 |
+
assert ae(v.imag, -2.9622681185504342983, tol=PTOL)
|
| 1444 |
+
v = fp.ei((-2.0 - 2.0j))
|
| 1445 |
+
assert ae(v, (0.033767089606562004246 - 3.1229932394200426965j), tol=ATOL)
|
| 1446 |
+
assert ae(v.real, 0.033767089606562004246, tol=PTOL)
|
| 1447 |
+
assert ae(v.imag, -3.1229932394200426965, tol=PTOL)
|
| 1448 |
+
v = fp.ei((-5.0 - 5.0j))
|
| 1449 |
+
assert ae(v, (-0.0007266506660356393891 - 3.1420636813914284609j), tol=ATOL)
|
| 1450 |
+
assert ae(v.real, -0.0007266506660356393891, tol=PTOL)
|
| 1451 |
+
assert ae(v.imag, -3.1420636813914284609, tol=PTOL)
|
| 1452 |
+
v = fp.ei((-20.0 - 20.0j))
|
| 1453 |
+
assert ae(v, (2.3824537449367396579e-11 - 3.1415926535228233653j), tol=ATOL)
|
| 1454 |
+
assert ae(v.real, 2.3824537449367396579e-11, tol=PTOL)
|
| 1455 |
+
assert ae(v.imag, -3.1415926535228233653, tol=PTOL)
|
| 1456 |
+
v = fp.ei((-30.0 - 30.0j))
|
| 1457 |
+
assert ae(v, (-1.7316045841744061617e-15 - 3.141592653589794545j), tol=ATOL)
|
| 1458 |
+
assert ae(v.real, -1.7316045841744061617e-15, tol=PTOL)
|
| 1459 |
+
assert ae(v.imag, -3.141592653589794545, tol=PTOL)
|
| 1460 |
+
v = fp.ei((-40.0 - 40.0j))
|
| 1461 |
+
assert ae(v, (7.4001043002899232182e-20 - 3.1415926535897932385j), tol=ATOL)
|
| 1462 |
+
assert ae(v.real, 7.4001043002899232182e-20, tol=PTOL)
|
| 1463 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1464 |
+
v = fp.ei((-50.0 - 50.0j))
|
| 1465 |
+
assert ae(v, (-2.3566128324644641219e-24 - 3.1415926535897932385j), tol=ATOL)
|
| 1466 |
+
assert ae(v.real, -2.3566128324644641219e-24, tol=PTOL)
|
| 1467 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1468 |
+
v = fp.ei((-80.0 - 80.0j))
|
| 1469 |
+
assert ae(v, (-9.8279750572186526673e-38 - 3.1415926535897932385j), tol=ATOL)
|
| 1470 |
+
assert ae(v.real, -9.8279750572186526673e-38, tol=PTOL)
|
| 1471 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1472 |
+
v = fp.ei((-1.1641532182693481445e-10 - 4.6566128730773925781e-10j))
|
| 1473 |
+
assert ae(v, (-20.880034621664969632 - 1.8157749903874220607j), tol=ATOL)
|
| 1474 |
+
assert ae(v.real, -20.880034621664969632, tol=PTOL)
|
| 1475 |
+
assert ae(v.imag, -1.8157749903874220607, tol=PTOL)
|
| 1476 |
+
v = fp.ei((-0.25 - 1.0j))
|
| 1477 |
+
assert ae(v, (0.16868306393667788761 - 2.6557914649950505414j), tol=ATOL)
|
| 1478 |
+
assert ae(v.real, 0.16868306393667788761, tol=PTOL)
|
| 1479 |
+
assert ae(v.imag, -2.6557914649950505414, tol=PTOL)
|
| 1480 |
+
v = fp.ei((-1.0 - 4.0j))
|
| 1481 |
+
assert ae(v, (-0.03373591813926547318 - 3.2151161058308770603j), tol=ATOL)
|
| 1482 |
+
assert ae(v.real, -0.03373591813926547318, tol=PTOL)
|
| 1483 |
+
assert ae(v.imag, -3.2151161058308770603, tol=PTOL)
|
| 1484 |
+
v = fp.ei((-2.0 - 8.0j))
|
| 1485 |
+
assert ae(v, (0.015392833434733785143 - 3.1384179414340326969j), tol=ATOL)
|
| 1486 |
+
assert ae(v.real, 0.015392833434733785143, tol=PTOL)
|
| 1487 |
+
assert ae(v.imag, -3.1384179414340326969, tol=PTOL)
|
| 1488 |
+
v = fp.ei((-5.0 - 20.0j))
|
| 1489 |
+
assert ae(v, (0.00024419662286542966525 - 3.1413825703601317109j), tol=ATOL)
|
| 1490 |
+
assert ae(v.real, 0.00024419662286542966525, tol=PTOL)
|
| 1491 |
+
assert ae(v.imag, -3.1413825703601317109, tol=PTOL)
|
| 1492 |
+
v = fp.ei((-20.0 - 80.0j))
|
| 1493 |
+
assert ae(v, (-2.3255552781051330088e-11 - 3.1415926535987396304j), tol=ATOL)
|
| 1494 |
+
assert ae(v.real, -2.3255552781051330088e-11, tol=PTOL)
|
| 1495 |
+
assert ae(v.imag, -3.1415926535987396304, tol=PTOL)
|
| 1496 |
+
v = fp.ei((-30.0 - 120.0j))
|
| 1497 |
+
assert ae(v, (2.7068919097124652332e-16 - 3.1415926535897925337j), tol=ATOL)
|
| 1498 |
+
assert ae(v.real, 2.7068919097124652332e-16, tol=PTOL)
|
| 1499 |
+
assert ae(v.imag, -3.1415926535897925337, tol=PTOL)
|
| 1500 |
+
v = fp.ei((-40.0 - 160.0j))
|
| 1501 |
+
assert ae(v, (1.1695597827678024687e-20 - 3.1415926535897932385j), tol=ATOL)
|
| 1502 |
+
assert ae(v.real, 1.1695597827678024687e-20, tol=PTOL)
|
| 1503 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1504 |
+
v = fp.ei((-50.0 - 200.0j))
|
| 1505 |
+
assert ae(v, (-9.0323746914410162531e-25 - 3.1415926535897932385j), tol=ATOL)
|
| 1506 |
+
assert ae(v.real, -9.0323746914410162531e-25, tol=PTOL)
|
| 1507 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1508 |
+
v = fp.ei((-80.0 - 320.0j))
|
| 1509 |
+
assert ae(v, (-3.4819106748728063576e-38 - 3.1415926535897932385j), tol=ATOL)
|
| 1510 |
+
assert ae(v.real, -3.4819106748728063576e-38, tol=PTOL)
|
| 1511 |
+
assert ae(v.imag, -3.1415926535897932385, tol=PTOL)
|
| 1512 |
+
v = fp.ei((0.0 - 1.1641532182693481445e-10j))
|
| 1513 |
+
assert ae(v, (-22.29664129357666235 - 1.5707963269113119411j), tol=ATOL)
|
| 1514 |
+
assert ae(v.real, -22.29664129357666235, tol=PTOL)
|
| 1515 |
+
assert ae(v.imag, -1.5707963269113119411, tol=PTOL)
|
| 1516 |
+
v = fp.ei((0.0 - 0.25j))
|
| 1517 |
+
assert ae(v, (-0.82466306258094565309 - 1.8199298971146537833j), tol=ATOL)
|
| 1518 |
+
assert ae(v.real, -0.82466306258094565309, tol=PTOL)
|
| 1519 |
+
assert ae(v.imag, -1.8199298971146537833, tol=PTOL)
|
| 1520 |
+
v = fp.ei((0.0 - 1.0j))
|
| 1521 |
+
assert ae(v, (0.33740392290096813466 - 2.5168793971620796342j), tol=ATOL)
|
| 1522 |
+
assert ae(v.real, 0.33740392290096813466, tol=PTOL)
|
| 1523 |
+
assert ae(v.imag, -2.5168793971620796342, tol=PTOL)
|
| 1524 |
+
v = fp.ei((0.0 - 2.0j))
|
| 1525 |
+
assert ae(v, (0.4229808287748649957 - 3.1762093035975914678j), tol=ATOL)
|
| 1526 |
+
assert ae(v.real, 0.4229808287748649957, tol=PTOL)
|
| 1527 |
+
assert ae(v.imag, -3.1762093035975914678, tol=PTOL)
|
| 1528 |
+
v = fp.ei((0.0 - 5.0j))
|
| 1529 |
+
assert ae(v, (-0.19002974965664387862 - 3.1207275717395707565j), tol=ATOL)
|
| 1530 |
+
assert ae(v.real, -0.19002974965664387862, tol=PTOL)
|
| 1531 |
+
assert ae(v.imag, -3.1207275717395707565, tol=PTOL)
|
| 1532 |
+
v = fp.ei((0.0 - 20.0j))
|
| 1533 |
+
assert ae(v, (0.04441982084535331654 - 3.1190380278383364594j), tol=ATOL)
|
| 1534 |
+
assert ae(v.real, 0.04441982084535331654, tol=PTOL)
|
| 1535 |
+
assert ae(v.imag, -3.1190380278383364594, tol=PTOL)
|
| 1536 |
+
v = fp.ei((0.0 - 30.0j))
|
| 1537 |
+
assert ae(v, (-0.033032417282071143779 - 3.1375528668252477302j), tol=ATOL)
|
| 1538 |
+
assert ae(v.real, -0.033032417282071143779, tol=PTOL)
|
| 1539 |
+
assert ae(v.imag, -3.1375528668252477302, tol=PTOL)
|
| 1540 |
+
v = fp.ei((0.0 - 40.0j))
|
| 1541 |
+
assert ae(v, (0.019020007896208766962 - 3.157781446149681126j), tol=ATOL)
|
| 1542 |
+
assert ae(v.real, 0.019020007896208766962, tol=PTOL)
|
| 1543 |
+
assert ae(v.imag, -3.157781446149681126, tol=PTOL)
|
| 1544 |
+
v = fp.ei((0.0 - 50.0j))
|
| 1545 |
+
assert ae(v, (-0.0056283863241163054402 - 3.122413399280832514j), tol=ATOL)
|
| 1546 |
+
assert ae(v.real, -0.0056283863241163054402, tol=PTOL)
|
| 1547 |
+
assert ae(v.imag, -3.122413399280832514, tol=PTOL)
|
| 1548 |
+
v = fp.ei((0.0 - 80.0j))
|
| 1549 |
+
assert ae(v, (-0.012402501155070958192 - 3.1431272137073839346j), tol=ATOL)
|
| 1550 |
+
assert ae(v.real, -0.012402501155070958192, tol=PTOL)
|
| 1551 |
+
assert ae(v.imag, -3.1431272137073839346, tol=PTOL)
|
| 1552 |
+
v = fp.ei((1.1641532182693481445e-10 - 4.6566128730773925781e-10j))
|
| 1553 |
+
assert ae(v, (-20.880034621432138988 - 1.3258176641336937524j), tol=ATOL)
|
| 1554 |
+
assert ae(v.real, -20.880034621432138988, tol=PTOL)
|
| 1555 |
+
assert ae(v.imag, -1.3258176641336937524, tol=PTOL)
|
| 1556 |
+
v = fp.ei((0.25 - 1.0j))
|
| 1557 |
+
assert ae(v, (0.59066621214766308594 - 2.3968481059377428687j), tol=ATOL)
|
| 1558 |
+
assert ae(v.real, 0.59066621214766308594, tol=PTOL)
|
| 1559 |
+
assert ae(v.imag, -2.3968481059377428687, tol=PTOL)
|
| 1560 |
+
v = fp.ei((1.0 - 4.0j))
|
| 1561 |
+
assert ae(v, (-0.49739047283060471093 - 3.5570287076301818702j), tol=ATOL)
|
| 1562 |
+
assert ae(v.real, -0.49739047283060471093, tol=PTOL)
|
| 1563 |
+
assert ae(v.imag, -3.5570287076301818702, tol=PTOL)
|
| 1564 |
+
v = fp.ei((2.0 - 8.0j))
|
| 1565 |
+
assert ae(v, (0.8705211147733730969 - 3.3825859385758486351j), tol=ATOL)
|
| 1566 |
+
assert ae(v.real, 0.8705211147733730969, tol=PTOL)
|
| 1567 |
+
assert ae(v.imag, -3.3825859385758486351, tol=PTOL)
|
| 1568 |
+
v = fp.ei((5.0 - 20.0j))
|
| 1569 |
+
assert ae(v, (7.0789514293925893007 - 1.5313749363937141849j), tol=ATOL)
|
| 1570 |
+
assert ae(v.real, 7.0789514293925893007, tol=PTOL)
|
| 1571 |
+
assert ae(v.imag, -1.5313749363937141849, tol=PTOL)
|
| 1572 |
+
v = fp.ei((20.0 - 80.0j))
|
| 1573 |
+
assert ae(v, (-5855431.4907298084434 + 720917.79156143806727j), tol=ATOL)
|
| 1574 |
+
assert ae(v.real, -5855431.4907298084434, tol=PTOL)
|
| 1575 |
+
assert ae(v.imag, 720917.79156143806727, tol=PTOL)
|
| 1576 |
+
v = fp.ei((30.0 - 120.0j))
|
| 1577 |
+
assert ae(v, (65402491644.703470747 + 56697658396.51586764j), tol=ATOL)
|
| 1578 |
+
assert ae(v.real, 65402491644.703470747, tol=PTOL)
|
| 1579 |
+
assert ae(v.imag, 56697658396.51586764, tol=PTOL)
|
| 1580 |
+
v = fp.ei((40.0 - 160.0j))
|
| 1581 |
+
assert ae(v, (-25504929379604.776769 - 1429035198630576.3879j), tol=ATOL)
|
| 1582 |
+
assert ae(v.real, -25504929379604.776769, tol=PTOL)
|
| 1583 |
+
assert ae(v.imag, -1429035198630576.3879, tol=PTOL)
|
| 1584 |
+
v = fp.ei((50.0 - 200.0j))
|
| 1585 |
+
assert ae(v, (-18437746526988116954.0 + 17146362239046152342.0j), tol=ATOL)
|
| 1586 |
+
assert ae(v.real, -18437746526988116954.0, tol=PTOL)
|
| 1587 |
+
assert ae(v.imag, 17146362239046152342.0, tol=PTOL)
|
| 1588 |
+
v = fp.ei((80.0 - 320.0j))
|
| 1589 |
+
assert ae(v, (-3.3464697299634526706e+31 + 1.6473152633843023919e+32j), tol=ATOL)
|
| 1590 |
+
assert ae(v.real, -3.3464697299634526706e+31, tol=PTOL)
|
| 1591 |
+
assert ae(v.imag, 1.6473152633843023919e+32, tol=PTOL)
|
| 1592 |
+
v = fp.ei((1.1641532182693481445e-10 - 1.1641532182693481445e-10j))
|
| 1593 |
+
assert ae(v, (-21.950067703180274374 - 0.78539816351386363145j), tol=ATOL)
|
| 1594 |
+
assert ae(v.real, -21.950067703180274374, tol=PTOL)
|
| 1595 |
+
assert ae(v.imag, -0.78539816351386363145, tol=PTOL)
|
| 1596 |
+
v = fp.ei((0.25 - 0.25j))
|
| 1597 |
+
assert ae(v, (-0.21441047326710323254 - 1.0683772981589995996j), tol=ATOL)
|
| 1598 |
+
assert ae(v.real, -0.21441047326710323254, tol=PTOL)
|
| 1599 |
+
assert ae(v.imag, -1.0683772981589995996, tol=PTOL)
|
| 1600 |
+
v = fp.ei((1.0 - 1.0j))
|
| 1601 |
+
assert ae(v, (1.7646259855638540684 - 2.3877698515105224193j), tol=ATOL)
|
| 1602 |
+
assert ae(v.real, 1.7646259855638540684, tol=PTOL)
|
| 1603 |
+
assert ae(v.imag, -2.3877698515105224193, tol=PTOL)
|
| 1604 |
+
v = fp.ei((2.0 - 2.0j))
|
| 1605 |
+
assert ae(v, (1.8920781621855474089 - 5.3169624378326579621j), tol=ATOL)
|
| 1606 |
+
assert ae(v.real, 1.8920781621855474089, tol=PTOL)
|
| 1607 |
+
assert ae(v.imag, -5.3169624378326579621, tol=PTOL)
|
| 1608 |
+
v = fp.ei((5.0 - 5.0j))
|
| 1609 |
+
assert ae(v, (-13.470936071475245856 + 15.322492395731230968j), tol=ATOL)
|
| 1610 |
+
assert ae(v.real, -13.470936071475245856, tol=PTOL)
|
| 1611 |
+
assert ae(v.imag, 15.322492395731230968, tol=PTOL)
|
| 1612 |
+
v = fp.ei((20.0 - 20.0j))
|
| 1613 |
+
assert ae(v, (16589317.398788971896 - 5831705.4712368307104j), tol=ATOL)
|
| 1614 |
+
assert ae(v.real, 16589317.398788971896, tol=PTOL)
|
| 1615 |
+
assert ae(v.imag, -5831705.4712368307104, tol=PTOL)
|
| 1616 |
+
v = fp.ei((30.0 - 30.0j))
|
| 1617 |
+
assert ae(v, (-154596484273.69322527 + 204179357834.2723043j), tol=ATOL)
|
| 1618 |
+
assert ae(v.real, -154596484273.69322527, tol=PTOL)
|
| 1619 |
+
assert ae(v.imag, 204179357834.2723043, tol=PTOL)
|
| 1620 |
+
v = fp.ei((40.0 - 40.0j))
|
| 1621 |
+
assert ae(v, (287512180321448.45408 - 4203502407932318.1156j), tol=ATOL)
|
| 1622 |
+
assert ae(v.real, 287512180321448.45408, tol=PTOL)
|
| 1623 |
+
assert ae(v.imag, -4203502407932318.1156, tol=PTOL)
|
| 1624 |
+
v = fp.ei((50.0 - 50.0j))
|
| 1625 |
+
assert ae(v, (36128528616649268826.0 + 64648801861338741960.0j), tol=ATOL)
|
| 1626 |
+
assert ae(v.real, 36128528616649268826.0, tol=PTOL)
|
| 1627 |
+
assert ae(v.imag, 64648801861338741960.0, tol=PTOL)
|
| 1628 |
+
v = fp.ei((80.0 - 80.0j))
|
| 1629 |
+
assert ae(v, (-3.8674816337930010217e+32 + 3.0540709639658071041e+32j), tol=ATOL)
|
| 1630 |
+
assert ae(v.real, -3.8674816337930010217e+32, tol=PTOL)
|
| 1631 |
+
assert ae(v.imag, 3.0540709639658071041e+32, tol=PTOL)
|
| 1632 |
+
v = fp.ei((4.6566128730773925781e-10 - 1.1641532182693481445e-10j))
|
| 1633 |
+
assert ae(v, (-20.880034621082893023 - 0.24497866324327947603j), tol=ATOL)
|
| 1634 |
+
assert ae(v.real, -20.880034621082893023, tol=PTOL)
|
| 1635 |
+
assert ae(v.imag, -0.24497866324327947603, tol=PTOL)
|
| 1636 |
+
v = fp.ei((1.0 - 0.25j))
|
| 1637 |
+
assert ae(v, (1.8942716983721074932 - 0.67268237088273915854j), tol=ATOL)
|
| 1638 |
+
assert ae(v.real, 1.8942716983721074932, tol=PTOL)
|
| 1639 |
+
assert ae(v.imag, -0.67268237088273915854, tol=PTOL)
|
| 1640 |
+
v = fp.ei((4.0 - 1.0j))
|
| 1641 |
+
assert ae(v, (14.806699492675420438 - 12.280015176673582616j), tol=ATOL)
|
| 1642 |
+
assert ae(v.real, 14.806699492675420438, tol=PTOL)
|
| 1643 |
+
assert ae(v.imag, -12.280015176673582616, tol=PTOL)
|
| 1644 |
+
v = fp.ei((8.0 - 2.0j))
|
| 1645 |
+
assert ae(v, (-54.633252667426386294 - 416.34477429173650012j), tol=ATOL)
|
| 1646 |
+
assert ae(v.real, -54.633252667426386294, tol=PTOL)
|
| 1647 |
+
assert ae(v.imag, -416.34477429173650012, tol=PTOL)
|
| 1648 |
+
v = fp.ei((20.0 - 5.0j))
|
| 1649 |
+
assert ae(v, (711836.97165402624643 + 24745247.798103247366j), tol=ATOL)
|
| 1650 |
+
assert ae(v.real, 711836.97165402624643, tol=PTOL)
|
| 1651 |
+
assert ae(v.imag, 24745247.798103247366, tol=PTOL)
|
| 1652 |
+
v = fp.ei((80.0 - 20.0j))
|
| 1653 |
+
assert ae(v, (4.2139911108612653091e+32 - 5.3367124741918251637e+32j), tol=ATOL)
|
| 1654 |
+
assert ae(v.real, 4.2139911108612653091e+32, tol=PTOL)
|
| 1655 |
+
assert ae(v.imag, -5.3367124741918251637e+32, tol=PTOL)
|
| 1656 |
+
v = fp.ei((120.0 - 30.0j))
|
| 1657 |
+
assert ae(v, (-9.7760616203707508892e+48 + 1.058257682317195792e+50j), tol=ATOL)
|
| 1658 |
+
assert ae(v.real, -9.7760616203707508892e+48, tol=PTOL)
|
| 1659 |
+
assert ae(v.imag, 1.058257682317195792e+50, tol=PTOL)
|
| 1660 |
+
v = fp.ei((160.0 - 40.0j))
|
| 1661 |
+
assert ae(v, (-8.7065541466623638861e+66 - 1.6577106725141739889e+67j), tol=ATOL)
|
| 1662 |
+
assert ae(v.real, -8.7065541466623638861e+66, tol=PTOL)
|
| 1663 |
+
assert ae(v.imag, -1.6577106725141739889e+67, tol=PTOL)
|
| 1664 |
+
v = fp.ei((200.0 - 50.0j))
|
| 1665 |
+
assert ae(v, (3.070744996327018106e+84 + 1.7243244846769415903e+84j), tol=ATOL)
|
| 1666 |
+
assert ae(v.real, 3.070744996327018106e+84, tol=PTOL)
|
| 1667 |
+
assert ae(v.imag, 1.7243244846769415903e+84, tol=PTOL)
|
| 1668 |
+
v = fp.ei((320.0 - 80.0j))
|
| 1669 |
+
assert ae(v, (-9.9960598637998647276e+135 + 2.6855081527595608863e+136j), tol=ATOL)
|
| 1670 |
+
assert ae(v.real, -9.9960598637998647276e+135, tol=PTOL)
|
| 1671 |
+
assert ae(v.imag, 2.6855081527595608863e+136, tol=PTOL)
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/mpmath/tests/test_functions.py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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from mpmath.libmp import *
|
| 2 |
+
from mpmath import *
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
import math
|
| 6 |
+
import cmath
|
| 7 |
+
|
| 8 |
+
def mpc_ae(a, b, eps=eps):
|
| 9 |
+
res = True
|
| 10 |
+
res = res and a.real.ae(b.real, eps)
|
| 11 |
+
res = res and a.imag.ae(b.imag, eps)
|
| 12 |
+
return res
|
| 13 |
+
|
| 14 |
+
#----------------------------------------------------------------------------
|
| 15 |
+
# Constants and functions
|
| 16 |
+
#
|
| 17 |
+
|
| 18 |
+
tpi = "3.1415926535897932384626433832795028841971693993751058209749445923078\
|
| 19 |
+
1640628620899862803482534211706798"
|
| 20 |
+
te = "2.71828182845904523536028747135266249775724709369995957496696762772407\
|
| 21 |
+
663035354759457138217852516642743"
|
| 22 |
+
tdegree = "0.017453292519943295769236907684886127134428718885417254560971914\
|
| 23 |
+
4017100911460344944368224156963450948221"
|
| 24 |
+
teuler = "0.5772156649015328606065120900824024310421593359399235988057672348\
|
| 25 |
+
84867726777664670936947063291746749516"
|
| 26 |
+
tln2 = "0.693147180559945309417232121458176568075500134360255254120680009493\
|
| 27 |
+
393621969694715605863326996418687542"
|
| 28 |
+
tln10 = "2.30258509299404568401799145468436420760110148862877297603332790096\
|
| 29 |
+
757260967735248023599720508959829834"
|
| 30 |
+
tcatalan = "0.91596559417721901505460351493238411077414937428167213426649811\
|
| 31 |
+
9621763019776254769479356512926115106249"
|
| 32 |
+
tkhinchin = "2.6854520010653064453097148354817956938203822939944629530511523\
|
| 33 |
+
4555721885953715200280114117493184769800"
|
| 34 |
+
tglaisher = "1.2824271291006226368753425688697917277676889273250011920637400\
|
| 35 |
+
2174040630885882646112973649195820237439420646"
|
| 36 |
+
tapery = "1.2020569031595942853997381615114499907649862923404988817922715553\
|
| 37 |
+
4183820578631309018645587360933525815"
|
| 38 |
+
tphi = "1.618033988749894848204586834365638117720309179805762862135448622705\
|
| 39 |
+
26046281890244970720720418939113748475"
|
| 40 |
+
tmertens = "0.26149721284764278375542683860869585905156664826119920619206421\
|
| 41 |
+
3924924510897368209714142631434246651052"
|
| 42 |
+
ttwinprime = "0.660161815846869573927812110014555778432623360284733413319448\
|
| 43 |
+
423335405642304495277143760031413839867912"
|
| 44 |
+
|
| 45 |
+
def test_constants():
|
| 46 |
+
for prec in [3, 7, 10, 15, 20, 37, 80, 100, 29]:
|
| 47 |
+
mp.dps = prec
|
| 48 |
+
assert pi == mpf(tpi)
|
| 49 |
+
assert e == mpf(te)
|
| 50 |
+
assert degree == mpf(tdegree)
|
| 51 |
+
assert euler == mpf(teuler)
|
| 52 |
+
assert ln2 == mpf(tln2)
|
| 53 |
+
assert ln10 == mpf(tln10)
|
| 54 |
+
assert catalan == mpf(tcatalan)
|
| 55 |
+
assert khinchin == mpf(tkhinchin)
|
| 56 |
+
assert glaisher == mpf(tglaisher)
|
| 57 |
+
assert phi == mpf(tphi)
|
| 58 |
+
if prec < 50:
|
| 59 |
+
assert mertens == mpf(tmertens)
|
| 60 |
+
assert twinprime == mpf(ttwinprime)
|
| 61 |
+
mp.dps = 15
|
| 62 |
+
assert pi >= -1
|
| 63 |
+
assert pi > 2
|
| 64 |
+
assert pi > 3
|
| 65 |
+
assert pi < 4
|
| 66 |
+
|
| 67 |
+
def test_exact_sqrts():
|
| 68 |
+
for i in range(20000):
|
| 69 |
+
assert sqrt(mpf(i*i)) == i
|
| 70 |
+
random.seed(1)
|
| 71 |
+
for prec in [100, 300, 1000, 10000]:
|
| 72 |
+
mp.dps = prec
|
| 73 |
+
for i in range(20):
|
| 74 |
+
A = random.randint(10**(prec//2-2), 10**(prec//2-1))
|
| 75 |
+
assert sqrt(mpf(A*A)) == A
|
| 76 |
+
mp.dps = 15
|
| 77 |
+
for i in range(100):
|
| 78 |
+
for a in [1, 8, 25, 112307]:
|
| 79 |
+
assert sqrt(mpf((a*a, 2*i))) == mpf((a, i))
|
| 80 |
+
assert sqrt(mpf((a*a, -2*i))) == mpf((a, -i))
|
| 81 |
+
|
| 82 |
+
def test_sqrt_rounding():
|
| 83 |
+
for i in [2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]:
|
| 84 |
+
i = from_int(i)
|
| 85 |
+
for dps in [7, 15, 83, 106, 2000]:
|
| 86 |
+
mp.dps = dps
|
| 87 |
+
a = mpf_pow_int(mpf_sqrt(i, mp.prec, round_down), 2, mp.prec, round_down)
|
| 88 |
+
b = mpf_pow_int(mpf_sqrt(i, mp.prec, round_up), 2, mp.prec, round_up)
|
| 89 |
+
assert mpf_lt(a, i)
|
| 90 |
+
assert mpf_gt(b, i)
|
| 91 |
+
random.seed(1234)
|
| 92 |
+
prec = 100
|
| 93 |
+
for rnd in [round_down, round_nearest, round_ceiling]:
|
| 94 |
+
for i in range(100):
|
| 95 |
+
a = mpf_rand(prec)
|
| 96 |
+
b = mpf_mul(a, a)
|
| 97 |
+
assert mpf_sqrt(b, prec, rnd) == a
|
| 98 |
+
# Test some extreme cases
|
| 99 |
+
mp.dps = 100
|
| 100 |
+
a = mpf(9) + 1e-90
|
| 101 |
+
b = mpf(9) - 1e-90
|
| 102 |
+
mp.dps = 15
|
| 103 |
+
assert sqrt(a, rounding='d') == 3
|
| 104 |
+
assert sqrt(a, rounding='n') == 3
|
| 105 |
+
assert sqrt(a, rounding='u') > 3
|
| 106 |
+
assert sqrt(b, rounding='d') < 3
|
| 107 |
+
assert sqrt(b, rounding='n') == 3
|
| 108 |
+
assert sqrt(b, rounding='u') == 3
|
| 109 |
+
# A worst case, from the MPFR test suite
|
| 110 |
+
assert sqrt(mpf('7.0503726185518891')) == mpf('2.655253776675949')
|
| 111 |
+
|
| 112 |
+
def test_float_sqrt():
|
| 113 |
+
mp.dps = 15
|
| 114 |
+
# These should round identically
|
| 115 |
+
for x in [0, 1e-7, 0.1, 0.5, 1, 2, 3, 4, 5, 0.333, 76.19]:
|
| 116 |
+
assert sqrt(mpf(x)) == float(x)**0.5
|
| 117 |
+
assert sqrt(-1) == 1j
|
| 118 |
+
assert sqrt(-2).ae(cmath.sqrt(-2))
|
| 119 |
+
assert sqrt(-3).ae(cmath.sqrt(-3))
|
| 120 |
+
assert sqrt(-100).ae(cmath.sqrt(-100))
|
| 121 |
+
assert sqrt(1j).ae(cmath.sqrt(1j))
|
| 122 |
+
assert sqrt(-1j).ae(cmath.sqrt(-1j))
|
| 123 |
+
assert sqrt(math.pi + math.e*1j).ae(cmath.sqrt(math.pi + math.e*1j))
|
| 124 |
+
assert sqrt(math.pi - math.e*1j).ae(cmath.sqrt(math.pi - math.e*1j))
|
| 125 |
+
|
| 126 |
+
def test_hypot():
|
| 127 |
+
assert hypot(0, 0) == 0
|
| 128 |
+
assert hypot(0, 0.33) == mpf(0.33)
|
| 129 |
+
assert hypot(0.33, 0) == mpf(0.33)
|
| 130 |
+
assert hypot(-0.33, 0) == mpf(0.33)
|
| 131 |
+
assert hypot(3, 4) == mpf(5)
|
| 132 |
+
|
| 133 |
+
def test_exact_cbrt():
|
| 134 |
+
for i in range(0, 20000, 200):
|
| 135 |
+
assert cbrt(mpf(i*i*i)) == i
|
| 136 |
+
random.seed(1)
|
| 137 |
+
for prec in [100, 300, 1000, 10000]:
|
| 138 |
+
mp.dps = prec
|
| 139 |
+
A = random.randint(10**(prec//2-2), 10**(prec//2-1))
|
| 140 |
+
assert cbrt(mpf(A*A*A)) == A
|
| 141 |
+
mp.dps = 15
|
| 142 |
+
|
| 143 |
+
def test_exp():
|
| 144 |
+
assert exp(0) == 1
|
| 145 |
+
assert exp(10000).ae(mpf('8.8068182256629215873e4342'))
|
| 146 |
+
assert exp(-10000).ae(mpf('1.1354838653147360985e-4343'))
|
| 147 |
+
a = exp(mpf((1, 8198646019315405, -53, 53)))
|
| 148 |
+
assert(a.bc == bitcount(a.man))
|
| 149 |
+
mp.prec = 67
|
| 150 |
+
a = exp(mpf((1, 1781864658064754565, -60, 61)))
|
| 151 |
+
assert(a.bc == bitcount(a.man))
|
| 152 |
+
mp.prec = 53
|
| 153 |
+
assert exp(ln2 * 10).ae(1024)
|
| 154 |
+
assert exp(2+2j).ae(cmath.exp(2+2j))
|
| 155 |
+
|
| 156 |
+
def test_issue_73():
|
| 157 |
+
mp.dps = 512
|
| 158 |
+
a = exp(-1)
|
| 159 |
+
b = exp(1)
|
| 160 |
+
mp.dps = 15
|
| 161 |
+
assert (+a).ae(0.36787944117144233)
|
| 162 |
+
assert (+b).ae(2.7182818284590451)
|
| 163 |
+
|
| 164 |
+
def test_log():
|
| 165 |
+
mp.dps = 15
|
| 166 |
+
assert log(1) == 0
|
| 167 |
+
for x in [0.5, 1.5, 2.0, 3.0, 100, 10**50, 1e-50]:
|
| 168 |
+
assert log(x).ae(math.log(x))
|
| 169 |
+
assert log(x, x) == 1
|
| 170 |
+
assert log(1024, 2) == 10
|
| 171 |
+
assert log(10**1234, 10) == 1234
|
| 172 |
+
assert log(2+2j).ae(cmath.log(2+2j))
|
| 173 |
+
# Accuracy near 1
|
| 174 |
+
assert (log(0.6+0.8j).real*10**17).ae(2.2204460492503131)
|
| 175 |
+
assert (log(0.6-0.8j).real*10**17).ae(2.2204460492503131)
|
| 176 |
+
assert (log(0.8-0.6j).real*10**17).ae(2.2204460492503131)
|
| 177 |
+
assert (log(1+1e-8j).real*10**16).ae(0.5)
|
| 178 |
+
assert (log(1-1e-8j).real*10**16).ae(0.5)
|
| 179 |
+
assert (log(-1+1e-8j).real*10**16).ae(0.5)
|
| 180 |
+
assert (log(-1-1e-8j).real*10**16).ae(0.5)
|
| 181 |
+
assert (log(1j+1e-8).real*10**16).ae(0.5)
|
| 182 |
+
assert (log(1j-1e-8).real*10**16).ae(0.5)
|
| 183 |
+
assert (log(-1j+1e-8).real*10**16).ae(0.5)
|
| 184 |
+
assert (log(-1j-1e-8).real*10**16).ae(0.5)
|
| 185 |
+
assert (log(1+1e-40j).real*10**80).ae(0.5)
|
| 186 |
+
assert (log(1j+1e-40).real*10**80).ae(0.5)
|
| 187 |
+
# Huge
|
| 188 |
+
assert log(ldexp(1.234,10**20)).ae(log(2)*1e20)
|
| 189 |
+
assert log(ldexp(1.234,10**200)).ae(log(2)*1e200)
|
| 190 |
+
# Some special values
|
| 191 |
+
assert log(mpc(0,0)) == mpc(-inf,0)
|
| 192 |
+
assert isnan(log(mpc(nan,0)).real)
|
| 193 |
+
assert isnan(log(mpc(nan,0)).imag)
|
| 194 |
+
assert isnan(log(mpc(0,nan)).real)
|
| 195 |
+
assert isnan(log(mpc(0,nan)).imag)
|
| 196 |
+
assert isnan(log(mpc(nan,1)).real)
|
| 197 |
+
assert isnan(log(mpc(nan,1)).imag)
|
| 198 |
+
assert isnan(log(mpc(1,nan)).real)
|
| 199 |
+
assert isnan(log(mpc(1,nan)).imag)
|
| 200 |
+
|
| 201 |
+
def test_trig_hyperb_basic():
|
| 202 |
+
for x in (list(range(100)) + list(range(-100,0))):
|
| 203 |
+
t = x / 4.1
|
| 204 |
+
assert cos(mpf(t)).ae(math.cos(t))
|
| 205 |
+
assert sin(mpf(t)).ae(math.sin(t))
|
| 206 |
+
assert tan(mpf(t)).ae(math.tan(t))
|
| 207 |
+
assert cosh(mpf(t)).ae(math.cosh(t))
|
| 208 |
+
assert sinh(mpf(t)).ae(math.sinh(t))
|
| 209 |
+
assert tanh(mpf(t)).ae(math.tanh(t))
|
| 210 |
+
assert sin(1+1j).ae(cmath.sin(1+1j))
|
| 211 |
+
assert sin(-4-3.6j).ae(cmath.sin(-4-3.6j))
|
| 212 |
+
assert cos(1+1j).ae(cmath.cos(1+1j))
|
| 213 |
+
assert cos(-4-3.6j).ae(cmath.cos(-4-3.6j))
|
| 214 |
+
|
| 215 |
+
def test_degrees():
|
| 216 |
+
assert cos(0*degree) == 1
|
| 217 |
+
assert cos(90*degree).ae(0)
|
| 218 |
+
assert cos(180*degree).ae(-1)
|
| 219 |
+
assert cos(270*degree).ae(0)
|
| 220 |
+
assert cos(360*degree).ae(1)
|
| 221 |
+
assert sin(0*degree) == 0
|
| 222 |
+
assert sin(90*degree).ae(1)
|
| 223 |
+
assert sin(180*degree).ae(0)
|
| 224 |
+
assert sin(270*degree).ae(-1)
|
| 225 |
+
assert sin(360*degree).ae(0)
|
| 226 |
+
|
| 227 |
+
def random_complexes(N):
|
| 228 |
+
random.seed(1)
|
| 229 |
+
a = []
|
| 230 |
+
for i in range(N):
|
| 231 |
+
x1 = random.uniform(-10, 10)
|
| 232 |
+
y1 = random.uniform(-10, 10)
|
| 233 |
+
x2 = random.uniform(-10, 10)
|
| 234 |
+
y2 = random.uniform(-10, 10)
|
| 235 |
+
z1 = complex(x1, y1)
|
| 236 |
+
z2 = complex(x2, y2)
|
| 237 |
+
a.append((z1, z2))
|
| 238 |
+
return a
|
| 239 |
+
|
| 240 |
+
def test_complex_powers():
|
| 241 |
+
for dps in [15, 30, 100]:
|
| 242 |
+
# Check accuracy for complex square root
|
| 243 |
+
mp.dps = dps
|
| 244 |
+
a = mpc(1j)**0.5
|
| 245 |
+
assert a.real == a.imag == mpf(2)**0.5 / 2
|
| 246 |
+
mp.dps = 15
|
| 247 |
+
random.seed(1)
|
| 248 |
+
for (z1, z2) in random_complexes(100):
|
| 249 |
+
assert (mpc(z1)**mpc(z2)).ae(z1**z2, 1e-12)
|
| 250 |
+
assert (e**(-pi*1j)).ae(-1)
|
| 251 |
+
mp.dps = 50
|
| 252 |
+
assert (e**(-pi*1j)).ae(-1)
|
| 253 |
+
mp.dps = 15
|
| 254 |
+
|
| 255 |
+
def test_complex_sqrt_accuracy():
|
| 256 |
+
def test_mpc_sqrt(lst):
|
| 257 |
+
for a, b in lst:
|
| 258 |
+
z = mpc(a + j*b)
|
| 259 |
+
assert mpc_ae(sqrt(z*z), z)
|
| 260 |
+
z = mpc(-a + j*b)
|
| 261 |
+
assert mpc_ae(sqrt(z*z), -z)
|
| 262 |
+
z = mpc(a - j*b)
|
| 263 |
+
assert mpc_ae(sqrt(z*z), z)
|
| 264 |
+
z = mpc(-a - j*b)
|
| 265 |
+
assert mpc_ae(sqrt(z*z), -z)
|
| 266 |
+
random.seed(2)
|
| 267 |
+
N = 10
|
| 268 |
+
mp.dps = 30
|
| 269 |
+
dps = mp.dps
|
| 270 |
+
test_mpc_sqrt([(random.uniform(0, 10),random.uniform(0, 10)) for i in range(N)])
|
| 271 |
+
test_mpc_sqrt([(i + 0.1, (i + 0.2)*10**i) for i in range(N)])
|
| 272 |
+
mp.dps = 15
|
| 273 |
+
|
| 274 |
+
def test_atan():
|
| 275 |
+
mp.dps = 15
|
| 276 |
+
assert atan(-2.3).ae(math.atan(-2.3))
|
| 277 |
+
assert atan(1e-50) == 1e-50
|
| 278 |
+
assert atan(1e50).ae(pi/2)
|
| 279 |
+
assert atan(-1e-50) == -1e-50
|
| 280 |
+
assert atan(-1e50).ae(-pi/2)
|
| 281 |
+
assert atan(10**1000).ae(pi/2)
|
| 282 |
+
for dps in [25, 70, 100, 300, 1000]:
|
| 283 |
+
mp.dps = dps
|
| 284 |
+
assert (4*atan(1)).ae(pi)
|
| 285 |
+
mp.dps = 15
|
| 286 |
+
pi2 = pi/2
|
| 287 |
+
assert atan(mpc(inf,-1)).ae(pi2)
|
| 288 |
+
assert atan(mpc(inf,0)).ae(pi2)
|
| 289 |
+
assert atan(mpc(inf,1)).ae(pi2)
|
| 290 |
+
assert atan(mpc(1,inf)).ae(pi2)
|
| 291 |
+
assert atan(mpc(0,inf)).ae(pi2)
|
| 292 |
+
assert atan(mpc(-1,inf)).ae(-pi2)
|
| 293 |
+
assert atan(mpc(-inf,1)).ae(-pi2)
|
| 294 |
+
assert atan(mpc(-inf,0)).ae(-pi2)
|
| 295 |
+
assert atan(mpc(-inf,-1)).ae(-pi2)
|
| 296 |
+
assert atan(mpc(-1,-inf)).ae(-pi2)
|
| 297 |
+
assert atan(mpc(0,-inf)).ae(-pi2)
|
| 298 |
+
assert atan(mpc(1,-inf)).ae(pi2)
|
| 299 |
+
|
| 300 |
+
def test_atan2():
|
| 301 |
+
mp.dps = 15
|
| 302 |
+
assert atan2(1,1).ae(pi/4)
|
| 303 |
+
assert atan2(1,-1).ae(3*pi/4)
|
| 304 |
+
assert atan2(-1,-1).ae(-3*pi/4)
|
| 305 |
+
assert atan2(-1,1).ae(-pi/4)
|
| 306 |
+
assert atan2(-1,0).ae(-pi/2)
|
| 307 |
+
assert atan2(1,0).ae(pi/2)
|
| 308 |
+
assert atan2(0,0) == 0
|
| 309 |
+
assert atan2(inf,0).ae(pi/2)
|
| 310 |
+
assert atan2(-inf,0).ae(-pi/2)
|
| 311 |
+
assert isnan(atan2(inf,inf))
|
| 312 |
+
assert isnan(atan2(-inf,inf))
|
| 313 |
+
assert isnan(atan2(inf,-inf))
|
| 314 |
+
assert isnan(atan2(3,nan))
|
| 315 |
+
assert isnan(atan2(nan,3))
|
| 316 |
+
assert isnan(atan2(0,nan))
|
| 317 |
+
assert isnan(atan2(nan,0))
|
| 318 |
+
assert atan2(0,inf) == 0
|
| 319 |
+
assert atan2(0,-inf).ae(pi)
|
| 320 |
+
assert atan2(10,inf) == 0
|
| 321 |
+
assert atan2(-10,inf) == 0
|
| 322 |
+
assert atan2(-10,-inf).ae(-pi)
|
| 323 |
+
assert atan2(10,-inf).ae(pi)
|
| 324 |
+
assert atan2(inf,10).ae(pi/2)
|
| 325 |
+
assert atan2(inf,-10).ae(pi/2)
|
| 326 |
+
assert atan2(-inf,10).ae(-pi/2)
|
| 327 |
+
assert atan2(-inf,-10).ae(-pi/2)
|
| 328 |
+
|
| 329 |
+
def test_areal_inverses():
|
| 330 |
+
assert asin(mpf(0)) == 0
|
| 331 |
+
assert asinh(mpf(0)) == 0
|
| 332 |
+
assert acosh(mpf(1)) == 0
|
| 333 |
+
assert isinstance(asin(mpf(0.5)), mpf)
|
| 334 |
+
assert isinstance(asin(mpf(2.0)), mpc)
|
| 335 |
+
assert isinstance(acos(mpf(0.5)), mpf)
|
| 336 |
+
assert isinstance(acos(mpf(2.0)), mpc)
|
| 337 |
+
assert isinstance(atanh(mpf(0.1)), mpf)
|
| 338 |
+
assert isinstance(atanh(mpf(1.1)), mpc)
|
| 339 |
+
|
| 340 |
+
random.seed(1)
|
| 341 |
+
for i in range(50):
|
| 342 |
+
x = random.uniform(0, 1)
|
| 343 |
+
assert asin(mpf(x)).ae(math.asin(x))
|
| 344 |
+
assert acos(mpf(x)).ae(math.acos(x))
|
| 345 |
+
|
| 346 |
+
x = random.uniform(-10, 10)
|
| 347 |
+
assert asinh(mpf(x)).ae(cmath.asinh(x).real)
|
| 348 |
+
assert isinstance(asinh(mpf(x)), mpf)
|
| 349 |
+
x = random.uniform(1, 10)
|
| 350 |
+
assert acosh(mpf(x)).ae(cmath.acosh(x).real)
|
| 351 |
+
assert isinstance(acosh(mpf(x)), mpf)
|
| 352 |
+
x = random.uniform(-10, 0.999)
|
| 353 |
+
assert isinstance(acosh(mpf(x)), mpc)
|
| 354 |
+
|
| 355 |
+
x = random.uniform(-1, 1)
|
| 356 |
+
assert atanh(mpf(x)).ae(cmath.atanh(x).real)
|
| 357 |
+
assert isinstance(atanh(mpf(x)), mpf)
|
| 358 |
+
|
| 359 |
+
dps = mp.dps
|
| 360 |
+
mp.dps = 300
|
| 361 |
+
assert isinstance(asin(0.5), mpf)
|
| 362 |
+
mp.dps = 1000
|
| 363 |
+
assert asin(1).ae(pi/2)
|
| 364 |
+
assert asin(-1).ae(-pi/2)
|
| 365 |
+
mp.dps = dps
|
| 366 |
+
|
| 367 |
+
def test_invhyperb_inaccuracy():
|
| 368 |
+
mp.dps = 15
|
| 369 |
+
assert (asinh(1e-5)*10**5).ae(0.99999999998333333)
|
| 370 |
+
assert (asinh(1e-10)*10**10).ae(1)
|
| 371 |
+
assert (asinh(1e-50)*10**50).ae(1)
|
| 372 |
+
assert (asinh(-1e-5)*10**5).ae(-0.99999999998333333)
|
| 373 |
+
assert (asinh(-1e-10)*10**10).ae(-1)
|
| 374 |
+
assert (asinh(-1e-50)*10**50).ae(-1)
|
| 375 |
+
assert asinh(10**20).ae(46.744849040440862)
|
| 376 |
+
assert asinh(-10**20).ae(-46.744849040440862)
|
| 377 |
+
assert (tanh(1e-10)*10**10).ae(1)
|
| 378 |
+
assert (tanh(-1e-10)*10**10).ae(-1)
|
| 379 |
+
assert (atanh(1e-10)*10**10).ae(1)
|
| 380 |
+
assert (atanh(-1e-10)*10**10).ae(-1)
|
| 381 |
+
|
| 382 |
+
def test_complex_functions():
|
| 383 |
+
for x in (list(range(10)) + list(range(-10,0))):
|
| 384 |
+
for y in (list(range(10)) + list(range(-10,0))):
|
| 385 |
+
z = complex(x, y)/4.3 + 0.01j
|
| 386 |
+
assert exp(mpc(z)).ae(cmath.exp(z))
|
| 387 |
+
assert log(mpc(z)).ae(cmath.log(z))
|
| 388 |
+
assert cos(mpc(z)).ae(cmath.cos(z))
|
| 389 |
+
assert sin(mpc(z)).ae(cmath.sin(z))
|
| 390 |
+
assert tan(mpc(z)).ae(cmath.tan(z))
|
| 391 |
+
assert sinh(mpc(z)).ae(cmath.sinh(z))
|
| 392 |
+
assert cosh(mpc(z)).ae(cmath.cosh(z))
|
| 393 |
+
assert tanh(mpc(z)).ae(cmath.tanh(z))
|
| 394 |
+
|
| 395 |
+
def test_complex_inverse_functions():
|
| 396 |
+
mp.dps = 15
|
| 397 |
+
iv.dps = 15
|
| 398 |
+
for (z1, z2) in random_complexes(30):
|
| 399 |
+
# apparently cmath uses a different branch, so we
|
| 400 |
+
# can't use it for comparison
|
| 401 |
+
assert sinh(asinh(z1)).ae(z1)
|
| 402 |
+
#
|
| 403 |
+
assert acosh(z1).ae(cmath.acosh(z1))
|
| 404 |
+
assert atanh(z1).ae(cmath.atanh(z1))
|
| 405 |
+
assert atan(z1).ae(cmath.atan(z1))
|
| 406 |
+
# the reason we set a big eps here is that the cmath
|
| 407 |
+
# functions are inaccurate
|
| 408 |
+
assert asin(z1).ae(cmath.asin(z1), rel_eps=1e-12)
|
| 409 |
+
assert acos(z1).ae(cmath.acos(z1), rel_eps=1e-12)
|
| 410 |
+
one = mpf(1)
|
| 411 |
+
for i in range(-9, 10, 3):
|
| 412 |
+
for k in range(-9, 10, 3):
|
| 413 |
+
a = 0.9*j*10**k + 0.8*one*10**i
|
| 414 |
+
b = cos(acos(a))
|
| 415 |
+
assert b.ae(a)
|
| 416 |
+
b = sin(asin(a))
|
| 417 |
+
assert b.ae(a)
|
| 418 |
+
one = mpf(1)
|
| 419 |
+
err = 2*10**-15
|
| 420 |
+
for i in range(-9, 9, 3):
|
| 421 |
+
for k in range(-9, 9, 3):
|
| 422 |
+
a = -0.9*10**k + j*0.8*one*10**i
|
| 423 |
+
b = cosh(acosh(a))
|
| 424 |
+
assert b.ae(a, err)
|
| 425 |
+
b = sinh(asinh(a))
|
| 426 |
+
assert b.ae(a, err)
|
| 427 |
+
|
| 428 |
+
def test_reciprocal_functions():
|
| 429 |
+
assert sec(3).ae(-1.01010866590799375)
|
| 430 |
+
assert csc(3).ae(7.08616739573718592)
|
| 431 |
+
assert cot(3).ae(-7.01525255143453347)
|
| 432 |
+
assert sech(3).ae(0.0993279274194332078)
|
| 433 |
+
assert csch(3).ae(0.0998215696688227329)
|
| 434 |
+
assert coth(3).ae(1.00496982331368917)
|
| 435 |
+
assert asec(3).ae(1.23095941734077468)
|
| 436 |
+
assert acsc(3).ae(0.339836909454121937)
|
| 437 |
+
assert acot(3).ae(0.321750554396642193)
|
| 438 |
+
assert asech(0.5).ae(1.31695789692481671)
|
| 439 |
+
assert acsch(3).ae(0.327450150237258443)
|
| 440 |
+
assert acoth(3).ae(0.346573590279972655)
|
| 441 |
+
assert acot(0).ae(1.5707963267948966192)
|
| 442 |
+
assert acoth(0).ae(1.5707963267948966192j)
|
| 443 |
+
|
| 444 |
+
def test_ldexp():
|
| 445 |
+
mp.dps = 15
|
| 446 |
+
assert ldexp(mpf(2.5), 0) == 2.5
|
| 447 |
+
assert ldexp(mpf(2.5), -1) == 1.25
|
| 448 |
+
assert ldexp(mpf(2.5), 2) == 10
|
| 449 |
+
assert ldexp(mpf('inf'), 3) == mpf('inf')
|
| 450 |
+
|
| 451 |
+
def test_frexp():
|
| 452 |
+
mp.dps = 15
|
| 453 |
+
assert frexp(0) == (0.0, 0)
|
| 454 |
+
assert frexp(9) == (0.5625, 4)
|
| 455 |
+
assert frexp(1) == (0.5, 1)
|
| 456 |
+
assert frexp(0.2) == (0.8, -2)
|
| 457 |
+
assert frexp(1000) == (0.9765625, 10)
|
| 458 |
+
|
| 459 |
+
def test_aliases():
|
| 460 |
+
assert ln(7) == log(7)
|
| 461 |
+
assert log10(3.75) == log(3.75,10)
|
| 462 |
+
assert degrees(5.6) == 5.6 / degree
|
| 463 |
+
assert radians(5.6) == 5.6 * degree
|
| 464 |
+
assert power(-1,0.5) == j
|
| 465 |
+
assert fmod(25,7) == 4.0 and isinstance(fmod(25,7), mpf)
|
| 466 |
+
|
| 467 |
+
def test_arg_sign():
|
| 468 |
+
assert arg(3) == 0
|
| 469 |
+
assert arg(-3).ae(pi)
|
| 470 |
+
assert arg(j).ae(pi/2)
|
| 471 |
+
assert arg(-j).ae(-pi/2)
|
| 472 |
+
assert arg(0) == 0
|
| 473 |
+
assert isnan(atan2(3,nan))
|
| 474 |
+
assert isnan(atan2(nan,3))
|
| 475 |
+
assert isnan(atan2(0,nan))
|
| 476 |
+
assert isnan(atan2(nan,0))
|
| 477 |
+
assert isnan(atan2(nan,nan))
|
| 478 |
+
assert arg(inf) == 0
|
| 479 |
+
assert arg(-inf).ae(pi)
|
| 480 |
+
assert isnan(arg(nan))
|
| 481 |
+
#assert arg(inf*j).ae(pi/2)
|
| 482 |
+
assert sign(0) == 0
|
| 483 |
+
assert sign(3) == 1
|
| 484 |
+
assert sign(-3) == -1
|
| 485 |
+
assert sign(inf) == 1
|
| 486 |
+
assert sign(-inf) == -1
|
| 487 |
+
assert isnan(sign(nan))
|
| 488 |
+
assert sign(j) == j
|
| 489 |
+
assert sign(-3*j) == -j
|
| 490 |
+
assert sign(1+j).ae((1+j)/sqrt(2))
|
| 491 |
+
|
| 492 |
+
def test_misc_bugs():
|
| 493 |
+
# test that this doesn't raise an exception
|
| 494 |
+
mp.dps = 1000
|
| 495 |
+
log(1302)
|
| 496 |
+
mp.dps = 15
|
| 497 |
+
|
| 498 |
+
def test_arange():
|
| 499 |
+
assert arange(10) == [mpf('0.0'), mpf('1.0'), mpf('2.0'), mpf('3.0'),
|
| 500 |
+
mpf('4.0'), mpf('5.0'), mpf('6.0'), mpf('7.0'),
|
| 501 |
+
mpf('8.0'), mpf('9.0')]
|
| 502 |
+
assert arange(-5, 5) == [mpf('-5.0'), mpf('-4.0'), mpf('-3.0'),
|
| 503 |
+
mpf('-2.0'), mpf('-1.0'), mpf('0.0'),
|
| 504 |
+
mpf('1.0'), mpf('2.0'), mpf('3.0'), mpf('4.0')]
|
| 505 |
+
assert arange(0, 1, 0.1) == [mpf('0.0'), mpf('0.10000000000000001'),
|
| 506 |
+
mpf('0.20000000000000001'),
|
| 507 |
+
mpf('0.30000000000000004'),
|
| 508 |
+
mpf('0.40000000000000002'),
|
| 509 |
+
mpf('0.5'), mpf('0.60000000000000009'),
|
| 510 |
+
mpf('0.70000000000000007'),
|
| 511 |
+
mpf('0.80000000000000004'),
|
| 512 |
+
mpf('0.90000000000000002')]
|
| 513 |
+
assert arange(17, -9, -3) == [mpf('17.0'), mpf('14.0'), mpf('11.0'),
|
| 514 |
+
mpf('8.0'), mpf('5.0'), mpf('2.0'),
|
| 515 |
+
mpf('-1.0'), mpf('-4.0'), mpf('-7.0')]
|
| 516 |
+
assert arange(0.2, 0.1, -0.1) == [mpf('0.20000000000000001')]
|
| 517 |
+
assert arange(0) == []
|
| 518 |
+
assert arange(1000, -1) == []
|
| 519 |
+
assert arange(-1.23, 3.21, -0.0000001) == []
|
| 520 |
+
|
| 521 |
+
def test_linspace():
|
| 522 |
+
assert linspace(2, 9, 7) == [mpf('2.0'), mpf('3.166666666666667'),
|
| 523 |
+
mpf('4.3333333333333339'), mpf('5.5'), mpf('6.666666666666667'),
|
| 524 |
+
mpf('7.8333333333333339'), mpf('9.0')]
|
| 525 |
+
assert linspace(2, 9, 7, endpoint=0) == [mpf('2.0'), mpf('3.0'), mpf('4.0'),
|
| 526 |
+
mpf('5.0'), mpf('6.0'), mpf('7.0'), mpf('8.0')]
|
| 527 |
+
assert linspace(2, 7, 1) == [mpf(2)]
|
| 528 |
+
|
| 529 |
+
def test_float_cbrt():
|
| 530 |
+
mp.dps = 30
|
| 531 |
+
for a in arange(0,10,0.1):
|
| 532 |
+
assert cbrt(a*a*a).ae(a, eps)
|
| 533 |
+
assert cbrt(-1).ae(0.5 + j*sqrt(3)/2)
|
| 534 |
+
one_third = mpf(1)/3
|
| 535 |
+
for a in arange(0,10,2.7) + [0.1 + 10**5]:
|
| 536 |
+
a = mpc(a + 1.1j)
|
| 537 |
+
r1 = cbrt(a)
|
| 538 |
+
mp.dps += 10
|
| 539 |
+
r2 = pow(a, one_third)
|
| 540 |
+
mp.dps -= 10
|
| 541 |
+
assert r1.ae(r2, eps)
|
| 542 |
+
mp.dps = 100
|
| 543 |
+
for n in range(100, 301, 100):
|
| 544 |
+
w = 10**n + j*10**-3
|
| 545 |
+
z = w*w*w
|
| 546 |
+
r = cbrt(z)
|
| 547 |
+
assert mpc_ae(r, w, eps)
|
| 548 |
+
mp.dps = 15
|
| 549 |
+
|
| 550 |
+
def test_root():
|
| 551 |
+
mp.dps = 30
|
| 552 |
+
random.seed(1)
|
| 553 |
+
a = random.randint(0, 10000)
|
| 554 |
+
p = a*a*a
|
| 555 |
+
r = nthroot(mpf(p), 3)
|
| 556 |
+
assert r == a
|
| 557 |
+
for n in range(4, 10):
|
| 558 |
+
p = p*a
|
| 559 |
+
assert nthroot(mpf(p), n) == a
|
| 560 |
+
mp.dps = 40
|
| 561 |
+
for n in range(10, 5000, 100):
|
| 562 |
+
for a in [random.random()*10000, random.random()*10**100]:
|
| 563 |
+
r = nthroot(a, n)
|
| 564 |
+
r1 = pow(a, mpf(1)/n)
|
| 565 |
+
assert r.ae(r1)
|
| 566 |
+
r = nthroot(a, -n)
|
| 567 |
+
r1 = pow(a, -mpf(1)/n)
|
| 568 |
+
assert r.ae(r1)
|
| 569 |
+
# XXX: this is broken right now
|
| 570 |
+
# tests for nthroot rounding
|
| 571 |
+
for rnd in ['nearest', 'up', 'down']:
|
| 572 |
+
mp.rounding = rnd
|
| 573 |
+
for n in [-5, -3, 3, 5]:
|
| 574 |
+
prec = 50
|
| 575 |
+
for i in range(10):
|
| 576 |
+
mp.prec = prec
|
| 577 |
+
a = rand()
|
| 578 |
+
mp.prec = 2*prec
|
| 579 |
+
b = a**n
|
| 580 |
+
mp.prec = prec
|
| 581 |
+
r = nthroot(b, n)
|
| 582 |
+
assert r == a
|
| 583 |
+
mp.dps = 30
|
| 584 |
+
for n in range(3, 21):
|
| 585 |
+
a = (random.random() + j*random.random())
|
| 586 |
+
assert nthroot(a, n).ae(pow(a, mpf(1)/n))
|
| 587 |
+
assert mpc_ae(nthroot(a, n), pow(a, mpf(1)/n))
|
| 588 |
+
a = (random.random()*10**100 + j*random.random())
|
| 589 |
+
r = nthroot(a, n)
|
| 590 |
+
mp.dps += 4
|
| 591 |
+
r1 = pow(a, mpf(1)/n)
|
| 592 |
+
mp.dps -= 4
|
| 593 |
+
assert r.ae(r1)
|
| 594 |
+
assert mpc_ae(r, r1, eps)
|
| 595 |
+
r = nthroot(a, -n)
|
| 596 |
+
mp.dps += 4
|
| 597 |
+
r1 = pow(a, -mpf(1)/n)
|
| 598 |
+
mp.dps -= 4
|
| 599 |
+
assert r.ae(r1)
|
| 600 |
+
assert mpc_ae(r, r1, eps)
|
| 601 |
+
mp.dps = 15
|
| 602 |
+
assert nthroot(4, 1) == 4
|
| 603 |
+
assert nthroot(4, 0) == 1
|
| 604 |
+
assert nthroot(4, -1) == 0.25
|
| 605 |
+
assert nthroot(inf, 1) == inf
|
| 606 |
+
assert nthroot(inf, 2) == inf
|
| 607 |
+
assert nthroot(inf, 3) == inf
|
| 608 |
+
assert nthroot(inf, -1) == 0
|
| 609 |
+
assert nthroot(inf, -2) == 0
|
| 610 |
+
assert nthroot(inf, -3) == 0
|
| 611 |
+
assert nthroot(j, 1) == j
|
| 612 |
+
assert nthroot(j, 0) == 1
|
| 613 |
+
assert nthroot(j, -1) == -j
|
| 614 |
+
assert isnan(nthroot(nan, 1))
|
| 615 |
+
assert isnan(nthroot(nan, 0))
|
| 616 |
+
assert isnan(nthroot(nan, -1))
|
| 617 |
+
assert isnan(nthroot(inf, 0))
|
| 618 |
+
assert root(2,3) == nthroot(2,3)
|
| 619 |
+
assert root(16,4,0) == 2
|
| 620 |
+
assert root(16,4,1) == 2j
|
| 621 |
+
assert root(16,4,2) == -2
|
| 622 |
+
assert root(16,4,3) == -2j
|
| 623 |
+
assert root(16,4,4) == 2
|
| 624 |
+
assert root(-125,3,1) == -5
|
| 625 |
+
|
| 626 |
+
def test_issue_136():
|
| 627 |
+
for dps in [20, 80]:
|
| 628 |
+
mp.dps = dps
|
| 629 |
+
r = nthroot(mpf('-1e-20'), 4)
|
| 630 |
+
assert r.ae(mpf(10)**(-5) * (1 + j) * mpf(2)**(-0.5))
|
| 631 |
+
mp.dps = 80
|
| 632 |
+
assert nthroot('-1e-3', 4).ae(mpf(10)**(-3./4) * (1 + j)/sqrt(2))
|
| 633 |
+
assert nthroot('-1e-6', 4).ae((1 + j)/(10 * sqrt(20)))
|
| 634 |
+
# Check that this doesn't take eternity to compute
|
| 635 |
+
mp.dps = 20
|
| 636 |
+
assert nthroot('-1e100000000', 4).ae((1+j)*mpf('1e25000000')/sqrt(2))
|
| 637 |
+
mp.dps = 15
|
| 638 |
+
|
| 639 |
+
def test_mpcfun_real_imag():
|
| 640 |
+
mp.dps = 15
|
| 641 |
+
x = mpf(0.3)
|
| 642 |
+
y = mpf(0.4)
|
| 643 |
+
assert exp(mpc(x,0)) == exp(x)
|
| 644 |
+
assert exp(mpc(0,y)) == mpc(cos(y),sin(y))
|
| 645 |
+
assert cos(mpc(x,0)) == cos(x)
|
| 646 |
+
assert sin(mpc(x,0)) == sin(x)
|
| 647 |
+
assert cos(mpc(0,y)) == cosh(y)
|
| 648 |
+
assert sin(mpc(0,y)) == mpc(0,sinh(y))
|
| 649 |
+
assert cospi(mpc(x,0)) == cospi(x)
|
| 650 |
+
assert sinpi(mpc(x,0)) == sinpi(x)
|
| 651 |
+
assert cospi(mpc(0,y)).ae(cosh(pi*y))
|
| 652 |
+
assert sinpi(mpc(0,y)).ae(mpc(0,sinh(pi*y)))
|
| 653 |
+
c, s = cospi_sinpi(mpc(x,0))
|
| 654 |
+
assert c == cospi(x)
|
| 655 |
+
assert s == sinpi(x)
|
| 656 |
+
c, s = cospi_sinpi(mpc(0,y))
|
| 657 |
+
assert c.ae(cosh(pi*y))
|
| 658 |
+
assert s.ae(mpc(0,sinh(pi*y)))
|
| 659 |
+
c, s = cos_sin(mpc(x,0))
|
| 660 |
+
assert c == cos(x)
|
| 661 |
+
assert s == sin(x)
|
| 662 |
+
c, s = cos_sin(mpc(0,y))
|
| 663 |
+
assert c == cosh(y)
|
| 664 |
+
assert s == mpc(0,sinh(y))
|
| 665 |
+
|
| 666 |
+
def test_perturbation_rounding():
|
| 667 |
+
mp.dps = 100
|
| 668 |
+
a = pi/10**50
|
| 669 |
+
b = -pi/10**50
|
| 670 |
+
c = 1 + a
|
| 671 |
+
d = 1 + b
|
| 672 |
+
mp.dps = 15
|
| 673 |
+
assert exp(a) == 1
|
| 674 |
+
assert exp(a, rounding='c') > 1
|
| 675 |
+
assert exp(b, rounding='c') == 1
|
| 676 |
+
assert exp(a, rounding='f') == 1
|
| 677 |
+
assert exp(b, rounding='f') < 1
|
| 678 |
+
assert cos(a) == 1
|
| 679 |
+
assert cos(a, rounding='c') == 1
|
| 680 |
+
assert cos(b, rounding='c') == 1
|
| 681 |
+
assert cos(a, rounding='f') < 1
|
| 682 |
+
assert cos(b, rounding='f') < 1
|
| 683 |
+
for f in [sin, atan, asinh, tanh]:
|
| 684 |
+
assert f(a) == +a
|
| 685 |
+
assert f(a, rounding='c') > a
|
| 686 |
+
assert f(a, rounding='f') < a
|
| 687 |
+
assert f(b) == +b
|
| 688 |
+
assert f(b, rounding='c') > b
|
| 689 |
+
assert f(b, rounding='f') < b
|
| 690 |
+
for f in [asin, tan, sinh, atanh]:
|
| 691 |
+
assert f(a) == +a
|
| 692 |
+
assert f(b) == +b
|
| 693 |
+
assert f(a, rounding='c') > a
|
| 694 |
+
assert f(b, rounding='c') > b
|
| 695 |
+
assert f(a, rounding='f') < a
|
| 696 |
+
assert f(b, rounding='f') < b
|
| 697 |
+
assert ln(c) == +a
|
| 698 |
+
assert ln(d) == +b
|
| 699 |
+
assert ln(c, rounding='c') > a
|
| 700 |
+
assert ln(c, rounding='f') < a
|
| 701 |
+
assert ln(d, rounding='c') > b
|
| 702 |
+
assert ln(d, rounding='f') < b
|
| 703 |
+
assert cosh(a) == 1
|
| 704 |
+
assert cosh(b) == 1
|
| 705 |
+
assert cosh(a, rounding='c') > 1
|
| 706 |
+
assert cosh(b, rounding='c') > 1
|
| 707 |
+
assert cosh(a, rounding='f') == 1
|
| 708 |
+
assert cosh(b, rounding='f') == 1
|
| 709 |
+
|
| 710 |
+
def test_integer_parts():
|
| 711 |
+
assert floor(3.2) == 3
|
| 712 |
+
assert ceil(3.2) == 4
|
| 713 |
+
assert floor(3.2+5j) == 3+5j
|
| 714 |
+
assert ceil(3.2+5j) == 4+5j
|
| 715 |
+
|
| 716 |
+
def test_complex_parts():
|
| 717 |
+
assert fabs('3') == 3
|
| 718 |
+
assert fabs(3+4j) == 5
|
| 719 |
+
assert re(3) == 3
|
| 720 |
+
assert re(1+4j) == 1
|
| 721 |
+
assert im(3) == 0
|
| 722 |
+
assert im(1+4j) == 4
|
| 723 |
+
assert conj(3) == 3
|
| 724 |
+
assert conj(3+4j) == 3-4j
|
| 725 |
+
assert mpf(3).conjugate() == 3
|
| 726 |
+
|
| 727 |
+
def test_cospi_sinpi():
|
| 728 |
+
assert sinpi(0) == 0
|
| 729 |
+
assert sinpi(0.5) == 1
|
| 730 |
+
assert sinpi(1) == 0
|
| 731 |
+
assert sinpi(1.5) == -1
|
| 732 |
+
assert sinpi(2) == 0
|
| 733 |
+
assert sinpi(2.5) == 1
|
| 734 |
+
assert sinpi(-0.5) == -1
|
| 735 |
+
assert cospi(0) == 1
|
| 736 |
+
assert cospi(0.5) == 0
|
| 737 |
+
assert cospi(1) == -1
|
| 738 |
+
assert cospi(1.5) == 0
|
| 739 |
+
assert cospi(2) == 1
|
| 740 |
+
assert cospi(2.5) == 0
|
| 741 |
+
assert cospi(-0.5) == 0
|
| 742 |
+
assert cospi(100000000000.25).ae(sqrt(2)/2)
|
| 743 |
+
a = cospi(2+3j)
|
| 744 |
+
assert a.real.ae(cos((2+3j)*pi).real)
|
| 745 |
+
assert a.imag == 0
|
| 746 |
+
b = sinpi(2+3j)
|
| 747 |
+
assert b.imag.ae(sin((2+3j)*pi).imag)
|
| 748 |
+
assert b.real == 0
|
| 749 |
+
mp.dps = 35
|
| 750 |
+
x1 = mpf(10000) - mpf('1e-15')
|
| 751 |
+
x2 = mpf(10000) + mpf('1e-15')
|
| 752 |
+
x3 = mpf(10000.5) - mpf('1e-15')
|
| 753 |
+
x4 = mpf(10000.5) + mpf('1e-15')
|
| 754 |
+
x5 = mpf(10001) - mpf('1e-15')
|
| 755 |
+
x6 = mpf(10001) + mpf('1e-15')
|
| 756 |
+
x7 = mpf(10001.5) - mpf('1e-15')
|
| 757 |
+
x8 = mpf(10001.5) + mpf('1e-15')
|
| 758 |
+
mp.dps = 15
|
| 759 |
+
M = 10**15
|
| 760 |
+
assert (sinpi(x1)*M).ae(-pi)
|
| 761 |
+
assert (sinpi(x2)*M).ae(pi)
|
| 762 |
+
assert (cospi(x3)*M).ae(pi)
|
| 763 |
+
assert (cospi(x4)*M).ae(-pi)
|
| 764 |
+
assert (sinpi(x5)*M).ae(pi)
|
| 765 |
+
assert (sinpi(x6)*M).ae(-pi)
|
| 766 |
+
assert (cospi(x7)*M).ae(-pi)
|
| 767 |
+
assert (cospi(x8)*M).ae(pi)
|
| 768 |
+
assert 0.999 < cospi(x1, rounding='d') < 1
|
| 769 |
+
assert 0.999 < cospi(x2, rounding='d') < 1
|
| 770 |
+
assert 0.999 < sinpi(x3, rounding='d') < 1
|
| 771 |
+
assert 0.999 < sinpi(x4, rounding='d') < 1
|
| 772 |
+
assert -1 < cospi(x5, rounding='d') < -0.999
|
| 773 |
+
assert -1 < cospi(x6, rounding='d') < -0.999
|
| 774 |
+
assert -1 < sinpi(x7, rounding='d') < -0.999
|
| 775 |
+
assert -1 < sinpi(x8, rounding='d') < -0.999
|
| 776 |
+
assert (sinpi(1e-15)*M).ae(pi)
|
| 777 |
+
assert (sinpi(-1e-15)*M).ae(-pi)
|
| 778 |
+
assert cospi(1e-15) == 1
|
| 779 |
+
assert cospi(1e-15, rounding='d') < 1
|
| 780 |
+
|
| 781 |
+
def test_expj():
|
| 782 |
+
assert expj(0) == 1
|
| 783 |
+
assert expj(1).ae(exp(j))
|
| 784 |
+
assert expj(j).ae(exp(-1))
|
| 785 |
+
assert expj(1+j).ae(exp(j*(1+j)))
|
| 786 |
+
assert expjpi(0) == 1
|
| 787 |
+
assert expjpi(1).ae(exp(j*pi))
|
| 788 |
+
assert expjpi(j).ae(exp(-pi))
|
| 789 |
+
assert expjpi(1+j).ae(exp(j*pi*(1+j)))
|
| 790 |
+
assert expjpi(-10**15 * j).ae('2.22579818340535731e+1364376353841841')
|
| 791 |
+
|
| 792 |
+
def test_sinc():
|
| 793 |
+
assert sinc(0) == sincpi(0) == 1
|
| 794 |
+
assert sinc(inf) == sincpi(inf) == 0
|
| 795 |
+
assert sinc(-inf) == sincpi(-inf) == 0
|
| 796 |
+
assert sinc(2).ae(0.45464871341284084770)
|
| 797 |
+
assert sinc(2+3j).ae(0.4463290318402435457-2.7539470277436474940j)
|
| 798 |
+
assert sincpi(2) == 0
|
| 799 |
+
assert sincpi(1.5).ae(-0.212206590789193781)
|
| 800 |
+
|
| 801 |
+
def test_fibonacci():
|
| 802 |
+
mp.dps = 15
|
| 803 |
+
assert [fibonacci(n) for n in range(-5, 10)] == \
|
| 804 |
+
[5, -3, 2, -1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
|
| 805 |
+
assert fib(2.5).ae(1.4893065462657091)
|
| 806 |
+
assert fib(3+4j).ae(-5248.51130728372 - 14195.962288353j)
|
| 807 |
+
assert fib(1000).ae(4.3466557686937455e+208)
|
| 808 |
+
assert str(fib(10**100)) == '6.24499112864607e+2089876402499787337692720892375554168224592399182109535392875613974104853496745963277658556235103534'
|
| 809 |
+
mp.dps = 2100
|
| 810 |
+
a = fib(10000)
|
| 811 |
+
assert a % 10**10 == 9947366875
|
| 812 |
+
mp.dps = 15
|
| 813 |
+
assert fibonacci(inf) == inf
|
| 814 |
+
assert fib(3+0j) == 2
|
| 815 |
+
|
| 816 |
+
def test_call_with_dps():
|
| 817 |
+
mp.dps = 15
|
| 818 |
+
assert abs(exp(1, dps=30)-e(dps=35)) < 1e-29
|
| 819 |
+
|
| 820 |
+
def test_tanh():
|
| 821 |
+
mp.dps = 15
|
| 822 |
+
assert tanh(0) == 0
|
| 823 |
+
assert tanh(inf) == 1
|
| 824 |
+
assert tanh(-inf) == -1
|
| 825 |
+
assert isnan(tanh(nan))
|
| 826 |
+
assert tanh(mpc('inf', '0')) == 1
|
| 827 |
+
|
| 828 |
+
def test_atanh():
|
| 829 |
+
mp.dps = 15
|
| 830 |
+
assert atanh(0) == 0
|
| 831 |
+
assert atanh(0.5).ae(0.54930614433405484570)
|
| 832 |
+
assert atanh(-0.5).ae(-0.54930614433405484570)
|
| 833 |
+
assert atanh(1) == inf
|
| 834 |
+
assert atanh(-1) == -inf
|
| 835 |
+
assert isnan(atanh(nan))
|
| 836 |
+
assert isinstance(atanh(1), mpf)
|
| 837 |
+
assert isinstance(atanh(-1), mpf)
|
| 838 |
+
# Limits at infinity
|
| 839 |
+
jpi2 = j*pi/2
|
| 840 |
+
assert atanh(inf).ae(-jpi2)
|
| 841 |
+
assert atanh(-inf).ae(jpi2)
|
| 842 |
+
assert atanh(mpc(inf,-1)).ae(-jpi2)
|
| 843 |
+
assert atanh(mpc(inf,0)).ae(-jpi2)
|
| 844 |
+
assert atanh(mpc(inf,1)).ae(jpi2)
|
| 845 |
+
assert atanh(mpc(1,inf)).ae(jpi2)
|
| 846 |
+
assert atanh(mpc(0,inf)).ae(jpi2)
|
| 847 |
+
assert atanh(mpc(-1,inf)).ae(jpi2)
|
| 848 |
+
assert atanh(mpc(-inf,1)).ae(jpi2)
|
| 849 |
+
assert atanh(mpc(-inf,0)).ae(jpi2)
|
| 850 |
+
assert atanh(mpc(-inf,-1)).ae(-jpi2)
|
| 851 |
+
assert atanh(mpc(-1,-inf)).ae(-jpi2)
|
| 852 |
+
assert atanh(mpc(0,-inf)).ae(-jpi2)
|
| 853 |
+
assert atanh(mpc(1,-inf)).ae(-jpi2)
|
| 854 |
+
|
| 855 |
+
def test_expm1():
|
| 856 |
+
mp.dps = 15
|
| 857 |
+
assert expm1(0) == 0
|
| 858 |
+
assert expm1(3).ae(exp(3)-1)
|
| 859 |
+
assert expm1(inf) == inf
|
| 860 |
+
assert expm1(1e-50).ae(1e-50)
|
| 861 |
+
assert (expm1(1e-10)*1e10).ae(1.00000000005)
|
| 862 |
+
|
| 863 |
+
def test_log1p():
|
| 864 |
+
mp.dps = 15
|
| 865 |
+
assert log1p(0) == 0
|
| 866 |
+
assert log1p(3).ae(log(1+3))
|
| 867 |
+
assert log1p(inf) == inf
|
| 868 |
+
assert log1p(1e-50).ae(1e-50)
|
| 869 |
+
assert (log1p(1e-10)*1e10).ae(0.99999999995)
|
| 870 |
+
|
| 871 |
+
def test_powm1():
|
| 872 |
+
mp.dps = 15
|
| 873 |
+
assert powm1(2,3) == 7
|
| 874 |
+
assert powm1(-1,2) == 0
|
| 875 |
+
assert powm1(-1,0) == 0
|
| 876 |
+
assert powm1(-2,0) == 0
|
| 877 |
+
assert powm1(3+4j,0) == 0
|
| 878 |
+
assert powm1(0,1) == -1
|
| 879 |
+
assert powm1(0,0) == 0
|
| 880 |
+
assert powm1(1,0) == 0
|
| 881 |
+
assert powm1(1,2) == 0
|
| 882 |
+
assert powm1(1,3+4j) == 0
|
| 883 |
+
assert powm1(1,5) == 0
|
| 884 |
+
assert powm1(j,4) == 0
|
| 885 |
+
assert powm1(-j,4) == 0
|
| 886 |
+
assert (powm1(2,1e-100)*1e100).ae(ln2)
|
| 887 |
+
assert powm1(2,'1e-100000000000') != 0
|
| 888 |
+
assert (powm1(fadd(1,1e-100,exact=True), 5)*1e100).ae(5)
|
| 889 |
+
|
| 890 |
+
def test_unitroots():
|
| 891 |
+
assert unitroots(1) == [1]
|
| 892 |
+
assert unitroots(2) == [1, -1]
|
| 893 |
+
a, b, c = unitroots(3)
|
| 894 |
+
assert a == 1
|
| 895 |
+
assert b.ae(-0.5 + 0.86602540378443864676j)
|
| 896 |
+
assert c.ae(-0.5 - 0.86602540378443864676j)
|
| 897 |
+
assert unitroots(1, primitive=True) == [1]
|
| 898 |
+
assert unitroots(2, primitive=True) == [-1]
|
| 899 |
+
assert unitroots(3, primitive=True) == unitroots(3)[1:]
|
| 900 |
+
assert unitroots(4, primitive=True) == [j, -j]
|
| 901 |
+
assert len(unitroots(17, primitive=True)) == 16
|
| 902 |
+
assert len(unitroots(16, primitive=True)) == 8
|
| 903 |
+
|
| 904 |
+
def test_cyclotomic():
|
| 905 |
+
mp.dps = 15
|
| 906 |
+
assert [cyclotomic(n,1) for n in range(31)] == [1,0,2,3,2,5,1,7,2,3,1,11,1,13,1,1,2,17,1,19,1,1,1,23,1,5,1,3,1,29,1]
|
| 907 |
+
assert [cyclotomic(n,-1) for n in range(31)] == [1,-2,0,1,2,1,3,1,2,1,5,1,1,1,7,1,2,1,3,1,1,1,11,1,1,1,13,1,1,1,1]
|
| 908 |
+
assert [cyclotomic(n,j) for n in range(21)] == [1,-1+j,1+j,j,0,1,-j,j,2,-j,1,j,3,1,-j,1,2,1,j,j,5]
|
| 909 |
+
assert [cyclotomic(n,-j) for n in range(21)] == [1,-1-j,1-j,-j,0,1,j,-j,2,j,1,-j,3,1,j,1,2,1,-j,-j,5]
|
| 910 |
+
assert cyclotomic(1624,j) == 1
|
| 911 |
+
assert cyclotomic(33600,j) == 1
|
| 912 |
+
u = sqrt(j, prec=500)
|
| 913 |
+
assert cyclotomic(8, u).ae(0)
|
| 914 |
+
assert cyclotomic(30, u).ae(5.8284271247461900976)
|
| 915 |
+
assert cyclotomic(2040, u).ae(1)
|
| 916 |
+
assert cyclotomic(0,2.5) == 1
|
| 917 |
+
assert cyclotomic(1,2.5) == 2.5-1
|
| 918 |
+
assert cyclotomic(2,2.5) == 2.5+1
|
| 919 |
+
assert cyclotomic(3,2.5) == 2.5**2 + 2.5 + 1
|
| 920 |
+
assert cyclotomic(7,2.5) == 406.234375
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/__init__.py
ADDED
|
File without changes
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudaGL.h
ADDED
|
@@ -0,0 +1,605 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef CUDAGL_H
|
| 51 |
+
#define CUDAGL_H
|
| 52 |
+
|
| 53 |
+
#include <cuda.h>
|
| 54 |
+
#include <GL/gl.h>
|
| 55 |
+
|
| 56 |
+
#if defined(__CUDA_API_VERSION_INTERNAL) || defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
|
| 57 |
+
#define __CUDA_DEPRECATED
|
| 58 |
+
#elif defined(_MSC_VER)
|
| 59 |
+
#define __CUDA_DEPRECATED __declspec(deprecated)
|
| 60 |
+
#elif defined(__GNUC__)
|
| 61 |
+
#define __CUDA_DEPRECATED __attribute__((deprecated))
|
| 62 |
+
#else
|
| 63 |
+
#define __CUDA_DEPRECATED
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
#ifdef CUDA_FORCE_API_VERSION
|
| 67 |
+
#error "CUDA_FORCE_API_VERSION is no longer supported."
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
#if defined(__CUDA_API_VERSION_INTERNAL) || defined(CUDA_API_PER_THREAD_DEFAULT_STREAM)
|
| 71 |
+
#define __CUDA_API_PER_THREAD_DEFAULT_STREAM
|
| 72 |
+
#define __CUDA_API_PTDS(api) api ## _ptds
|
| 73 |
+
#define __CUDA_API_PTSZ(api) api ## _ptsz
|
| 74 |
+
#else
|
| 75 |
+
#define __CUDA_API_PTDS(api) api
|
| 76 |
+
#define __CUDA_API_PTSZ(api) api
|
| 77 |
+
#endif
|
| 78 |
+
|
| 79 |
+
#define cuGLCtxCreate cuGLCtxCreate_v2
|
| 80 |
+
#define cuGLMapBufferObject __CUDA_API_PTDS(cuGLMapBufferObject_v2)
|
| 81 |
+
#define cuGLMapBufferObjectAsync __CUDA_API_PTSZ(cuGLMapBufferObjectAsync_v2)
|
| 82 |
+
#define cuGLGetDevices cuGLGetDevices_v2
|
| 83 |
+
|
| 84 |
+
#ifdef __cplusplus
|
| 85 |
+
extern "C" {
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* \file cudaGL.h
|
| 90 |
+
* \brief Header file for the OpenGL interoperability functions of the
|
| 91 |
+
* low-level CUDA driver application programming interface.
|
| 92 |
+
*/
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* \defgroup CUDA_GL OpenGL Interoperability
|
| 96 |
+
* \ingroup CUDA_DRIVER
|
| 97 |
+
*
|
| 98 |
+
* ___MANBRIEF___ OpenGL interoperability functions of the low-level CUDA
|
| 99 |
+
* driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 100 |
+
*
|
| 101 |
+
* This section describes the OpenGL interoperability functions of the
|
| 102 |
+
* low-level CUDA driver application programming interface. Note that mapping
|
| 103 |
+
* of OpenGL resources is performed with the graphics API agnostic, resource
|
| 104 |
+
* mapping interface described in \ref CUDA_GRAPHICS "Graphics Interoperability".
|
| 105 |
+
*
|
| 106 |
+
* @{
|
| 107 |
+
*/
|
| 108 |
+
|
| 109 |
+
#if defined(_WIN32)
|
| 110 |
+
#if !defined(WGL_NV_gpu_affinity)
|
| 111 |
+
typedef void* HGPUNV;
|
| 112 |
+
#endif
|
| 113 |
+
#endif /* _WIN32 */
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* \brief Registers an OpenGL buffer object
|
| 117 |
+
*
|
| 118 |
+
* Registers the buffer object specified by \p buffer for access by
|
| 119 |
+
* CUDA. A handle to the registered object is returned as \p
|
| 120 |
+
* pCudaResource. The register flags \p Flags specify the intended usage,
|
| 121 |
+
* as follows:
|
| 122 |
+
*
|
| 123 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this
|
| 124 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 125 |
+
* read from and written to by CUDA. This is the default value.
|
| 126 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA
|
| 127 |
+
* will not write to this resource.
|
| 128 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that
|
| 129 |
+
* CUDA will not read from this resource and will write over the
|
| 130 |
+
* entire contents of the resource, so none of the data previously
|
| 131 |
+
* stored in the resource will be preserved.
|
| 132 |
+
*
|
| 133 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 134 |
+
* \param buffer - name of buffer object to be registered
|
| 135 |
+
* \param Flags - Register flags
|
| 136 |
+
*
|
| 137 |
+
* \return
|
| 138 |
+
* ::CUDA_SUCCESS,
|
| 139 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 140 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 141 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 142 |
+
* \notefnerr
|
| 143 |
+
*
|
| 144 |
+
* \sa
|
| 145 |
+
* ::cuGraphicsUnregisterResource,
|
| 146 |
+
* ::cuGraphicsMapResources,
|
| 147 |
+
* ::cuGraphicsResourceGetMappedPointer,
|
| 148 |
+
* ::cudaGraphicsGLRegisterBuffer
|
| 149 |
+
*/
|
| 150 |
+
CUresult CUDAAPI cuGraphicsGLRegisterBuffer(CUgraphicsResource *pCudaResource, GLuint buffer, unsigned int Flags);
|
| 151 |
+
|
| 152 |
+
/**
|
| 153 |
+
* \brief Register an OpenGL texture or renderbuffer object
|
| 154 |
+
*
|
| 155 |
+
* Registers the texture or renderbuffer object specified by \p image for access by CUDA.
|
| 156 |
+
* A handle to the registered object is returned as \p pCudaResource.
|
| 157 |
+
*
|
| 158 |
+
* \p target must match the type of the object, and must be one of ::GL_TEXTURE_2D,
|
| 159 |
+
* ::GL_TEXTURE_RECTANGLE, ::GL_TEXTURE_CUBE_MAP, ::GL_TEXTURE_3D, ::GL_TEXTURE_2D_ARRAY,
|
| 160 |
+
* or ::GL_RENDERBUFFER.
|
| 161 |
+
*
|
| 162 |
+
* The register flags \p Flags specify the intended usage, as follows:
|
| 163 |
+
*
|
| 164 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_NONE: Specifies no hints about how this
|
| 165 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 166 |
+
* read from and written to by CUDA. This is the default value.
|
| 167 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY: Specifies that CUDA
|
| 168 |
+
* will not write to this resource.
|
| 169 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD: Specifies that
|
| 170 |
+
* CUDA will not read from this resource and will write over the
|
| 171 |
+
* entire contents of the resource, so none of the data previously
|
| 172 |
+
* stored in the resource will be preserved.
|
| 173 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST: Specifies that CUDA will
|
| 174 |
+
* bind this resource to a surface reference.
|
| 175 |
+
* - ::CU_GRAPHICS_REGISTER_FLAGS_TEXTURE_GATHER: Specifies that CUDA will perform
|
| 176 |
+
* texture gather operations on this resource.
|
| 177 |
+
*
|
| 178 |
+
* The following image formats are supported. For brevity's sake, the list is abbreviated.
|
| 179 |
+
* For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats
|
| 180 |
+
* {GL_R8, GL_R16, GL_RG8, GL_RG16} :
|
| 181 |
+
* - GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY
|
| 182 |
+
* - {GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
|
| 183 |
+
* - {GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X
|
| 184 |
+
* {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
|
| 185 |
+
*
|
| 186 |
+
* The following image classes are currently disallowed:
|
| 187 |
+
* - Textures with borders
|
| 188 |
+
* - Multisampled renderbuffers
|
| 189 |
+
*
|
| 190 |
+
* \param pCudaResource - Pointer to the returned object handle
|
| 191 |
+
* \param image - name of texture or renderbuffer object to be registered
|
| 192 |
+
* \param target - Identifies the type of object specified by \p image
|
| 193 |
+
* \param Flags - Register flags
|
| 194 |
+
*
|
| 195 |
+
* \return
|
| 196 |
+
* ::CUDA_SUCCESS,
|
| 197 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 198 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 199 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 200 |
+
* \notefnerr
|
| 201 |
+
*
|
| 202 |
+
* \sa
|
| 203 |
+
* ::cuGraphicsUnregisterResource,
|
| 204 |
+
* ::cuGraphicsMapResources,
|
| 205 |
+
* ::cuGraphicsSubResourceGetMappedArray,
|
| 206 |
+
* ::cudaGraphicsGLRegisterImage
|
| 207 |
+
*/
|
| 208 |
+
CUresult CUDAAPI cuGraphicsGLRegisterImage(CUgraphicsResource *pCudaResource, GLuint image, GLenum target, unsigned int Flags);
|
| 209 |
+
|
| 210 |
+
#ifdef _WIN32
|
| 211 |
+
/**
|
| 212 |
+
* \brief Gets the CUDA device associated with hGpu
|
| 213 |
+
*
|
| 214 |
+
* Returns in \p *pDevice the CUDA device associated with a \p hGpu, if
|
| 215 |
+
* applicable.
|
| 216 |
+
*
|
| 217 |
+
* \param pDevice - Device associated with hGpu
|
| 218 |
+
* \param hGpu - Handle to a GPU, as queried via ::WGL_NV_gpu_affinity()
|
| 219 |
+
*
|
| 220 |
+
* \return
|
| 221 |
+
* ::CUDA_SUCCESS,
|
| 222 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 223 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 224 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 225 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 226 |
+
* \notefnerr
|
| 227 |
+
*
|
| 228 |
+
* \sa ::cuGLMapBufferObject,
|
| 229 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 230 |
+
* ::cuGLUnregisterBufferObject, ::cuGLUnmapBufferObjectAsync,
|
| 231 |
+
* ::cuGLSetBufferObjectMapFlags,
|
| 232 |
+
* ::cudaWGLGetDevice
|
| 233 |
+
*/
|
| 234 |
+
CUresult CUDAAPI cuWGLGetDevice(CUdevice *pDevice, HGPUNV hGpu);
|
| 235 |
+
#endif /* _WIN32 */
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* CUDA devices corresponding to an OpenGL device
|
| 239 |
+
*/
|
| 240 |
+
typedef enum CUGLDeviceList_enum {
|
| 241 |
+
CU_GL_DEVICE_LIST_ALL = 0x01, /**< The CUDA devices for all GPUs used by the current OpenGL context */
|
| 242 |
+
CU_GL_DEVICE_LIST_CURRENT_FRAME = 0x02, /**< The CUDA devices for the GPUs used by the current OpenGL context in its currently rendering frame */
|
| 243 |
+
CU_GL_DEVICE_LIST_NEXT_FRAME = 0x03, /**< The CUDA devices for the GPUs to be used by the current OpenGL context in the next frame */
|
| 244 |
+
} CUGLDeviceList;
|
| 245 |
+
|
| 246 |
+
/**
|
| 247 |
+
* \brief Gets the CUDA devices associated with the current OpenGL context
|
| 248 |
+
*
|
| 249 |
+
* Returns in \p *pCudaDeviceCount the number of CUDA-compatible devices
|
| 250 |
+
* corresponding to the current OpenGL context. Also returns in \p *pCudaDevices
|
| 251 |
+
* at most cudaDeviceCount of the CUDA-compatible devices corresponding to
|
| 252 |
+
* the current OpenGL context. If any of the GPUs being used by the current OpenGL
|
| 253 |
+
* context are not CUDA capable then the call will return CUDA_ERROR_NO_DEVICE.
|
| 254 |
+
*
|
| 255 |
+
* The \p deviceList argument may be any of the following:
|
| 256 |
+
* - ::CU_GL_DEVICE_LIST_ALL: Query all devices used by the current OpenGL context.
|
| 257 |
+
* - ::CU_GL_DEVICE_LIST_CURRENT_FRAME: Query the devices used by the current OpenGL context to
|
| 258 |
+
* render the current frame (in SLI).
|
| 259 |
+
* - ::CU_GL_DEVICE_LIST_NEXT_FRAME: Query the devices used by the current OpenGL context to
|
| 260 |
+
* render the next frame (in SLI). Note that this is a prediction, it can't be guaranteed that
|
| 261 |
+
* this is correct in all cases.
|
| 262 |
+
*
|
| 263 |
+
* \param pCudaDeviceCount - Returned number of CUDA devices.
|
| 264 |
+
* \param pCudaDevices - Returned CUDA devices.
|
| 265 |
+
* \param cudaDeviceCount - The size of the output device array pCudaDevices.
|
| 266 |
+
* \param deviceList - The set of devices to return.
|
| 267 |
+
*
|
| 268 |
+
* \return
|
| 269 |
+
* ::CUDA_SUCCESS,
|
| 270 |
+
* ::CUDA_ERROR_NO_DEVICE,
|
| 271 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 272 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 273 |
+
* ::CUDA_ERROR_INVALID_GRAPHICS_CONTEXT
|
| 274 |
+
*
|
| 275 |
+
* \notefnerr
|
| 276 |
+
*
|
| 277 |
+
* \sa
|
| 278 |
+
* ::cuWGLGetDevice,
|
| 279 |
+
* ::cudaGLGetDevices
|
| 280 |
+
*/
|
| 281 |
+
CUresult CUDAAPI cuGLGetDevices(unsigned int *pCudaDeviceCount, CUdevice *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* \defgroup CUDA_GL_DEPRECATED OpenGL Interoperability [DEPRECATED]
|
| 285 |
+
*
|
| 286 |
+
* ___MANBRIEF___ deprecated OpenGL interoperability functions of the low-level
|
| 287 |
+
* CUDA driver API (___CURRENT_FILE___) ___ENDMANBRIEF___
|
| 288 |
+
*
|
| 289 |
+
* This section describes deprecated OpenGL interoperability functionality.
|
| 290 |
+
*
|
| 291 |
+
* @{
|
| 292 |
+
*/
|
| 293 |
+
|
| 294 |
+
/** Flags to map or unmap a resource */
|
| 295 |
+
typedef enum CUGLmap_flags_enum {
|
| 296 |
+
CU_GL_MAP_RESOURCE_FLAGS_NONE = 0x00,
|
| 297 |
+
CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY = 0x01,
|
| 298 |
+
CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02,
|
| 299 |
+
} CUGLmap_flags;
|
| 300 |
+
|
| 301 |
+
/**
|
| 302 |
+
* \brief Create a CUDA context for interoperability with OpenGL
|
| 303 |
+
*
|
| 304 |
+
* \deprecated This function is deprecated as of Cuda 5.0.
|
| 305 |
+
*
|
| 306 |
+
* This function is deprecated and should no longer be used. It is
|
| 307 |
+
* no longer necessary to associate a CUDA context with an OpenGL
|
| 308 |
+
* context in order to achieve maximum interoperability performance.
|
| 309 |
+
*
|
| 310 |
+
* \param pCtx - Returned CUDA context
|
| 311 |
+
* \param Flags - Options for CUDA context creation
|
| 312 |
+
* \param device - Device on which to create the context
|
| 313 |
+
*
|
| 314 |
+
* \return
|
| 315 |
+
* ::CUDA_SUCCESS,
|
| 316 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 317 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 318 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 319 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 320 |
+
* ::CUDA_ERROR_OUT_OF_MEMORY
|
| 321 |
+
* \notefnerr
|
| 322 |
+
*
|
| 323 |
+
* \sa ::cuCtxCreate, ::cuGLInit, ::cuGLMapBufferObject,
|
| 324 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 325 |
+
* ::cuGLUnregisterBufferObject, ::cuGLMapBufferObjectAsync,
|
| 326 |
+
* ::cuGLUnmapBufferObjectAsync, ::cuGLSetBufferObjectMapFlags,
|
| 327 |
+
* ::cuWGLGetDevice
|
| 328 |
+
*/
|
| 329 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLCtxCreate(CUcontext *pCtx, unsigned int Flags, CUdevice device );
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* \brief Initializes OpenGL interoperability
|
| 333 |
+
*
|
| 334 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 335 |
+
*
|
| 336 |
+
* Initializes OpenGL interoperability. This function is deprecated
|
| 337 |
+
* and calling it is no longer required. It may fail if the needed
|
| 338 |
+
* OpenGL driver facilities are not available.
|
| 339 |
+
*
|
| 340 |
+
* \return
|
| 341 |
+
* ::CUDA_SUCCESS,
|
| 342 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 343 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 344 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 345 |
+
* ::CUDA_ERROR_UNKNOWN
|
| 346 |
+
* \notefnerr
|
| 347 |
+
*
|
| 348 |
+
* \sa ::cuGLMapBufferObject,
|
| 349 |
+
* ::cuGLRegisterBufferObject, ::cuGLUnmapBufferObject,
|
| 350 |
+
* ::cuGLUnregisterBufferObject, ::cuGLMapBufferObjectAsync,
|
| 351 |
+
* ::cuGLUnmapBufferObjectAsync, ::cuGLSetBufferObjectMapFlags,
|
| 352 |
+
* ::cuWGLGetDevice
|
| 353 |
+
*/
|
| 354 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLInit(void);
|
| 355 |
+
|
| 356 |
+
/**
|
| 357 |
+
* \brief Registers an OpenGL buffer object
|
| 358 |
+
*
|
| 359 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 360 |
+
*
|
| 361 |
+
* Registers the buffer object specified by \p buffer for access by
|
| 362 |
+
* CUDA. This function must be called before CUDA can map the buffer
|
| 363 |
+
* object. There must be a valid OpenGL context bound to the current
|
| 364 |
+
* thread when this function is called, and the buffer name is
|
| 365 |
+
* resolved by that context.
|
| 366 |
+
*
|
| 367 |
+
* \param buffer - The name of the buffer object to register.
|
| 368 |
+
*
|
| 369 |
+
* \return
|
| 370 |
+
* ::CUDA_SUCCESS,
|
| 371 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 372 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 373 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 374 |
+
* ::CUDA_ERROR_ALREADY_MAPPED
|
| 375 |
+
* \notefnerr
|
| 376 |
+
*
|
| 377 |
+
* \sa ::cuGraphicsGLRegisterBuffer
|
| 378 |
+
*/
|
| 379 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLRegisterBufferObject(GLuint buffer);
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* \brief Maps an OpenGL buffer object
|
| 383 |
+
*
|
| 384 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 385 |
+
*
|
| 386 |
+
* Maps the buffer object specified by \p buffer into the address space of the
|
| 387 |
+
* current CUDA context and returns in \p *dptr and \p *size the base pointer
|
| 388 |
+
* and size of the resulting mapping.
|
| 389 |
+
*
|
| 390 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 391 |
+
* when this function is called. This must be the same context, or a
|
| 392 |
+
* member of the same shareGroup, as the context that was bound when
|
| 393 |
+
* the buffer was registered.
|
| 394 |
+
*
|
| 395 |
+
* All streams in the current CUDA context are synchronized with the
|
| 396 |
+
* current GL context.
|
| 397 |
+
*
|
| 398 |
+
* \param dptr - Returned mapped base pointer
|
| 399 |
+
* \param size - Returned size of mapping
|
| 400 |
+
* \param buffer - The name of the buffer object to map
|
| 401 |
+
*
|
| 402 |
+
* \return
|
| 403 |
+
* ::CUDA_SUCCESS,
|
| 404 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 405 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 406 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 407 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 408 |
+
* ::CUDA_ERROR_MAP_FAILED
|
| 409 |
+
* \notefnerr
|
| 410 |
+
*
|
| 411 |
+
* \sa ::cuGraphicsMapResources
|
| 412 |
+
*/
|
| 413 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLMapBufferObject(CUdeviceptr *dptr, size_t *size, GLuint buffer);
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* \brief Unmaps an OpenGL buffer object
|
| 417 |
+
*
|
| 418 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 419 |
+
*
|
| 420 |
+
* Unmaps the buffer object specified by \p buffer for access by CUDA.
|
| 421 |
+
*
|
| 422 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 423 |
+
* when this function is called. This must be the same context, or a
|
| 424 |
+
* member of the same shareGroup, as the context that was bound when
|
| 425 |
+
* the buffer was registered.
|
| 426 |
+
*
|
| 427 |
+
* All streams in the current CUDA context are synchronized with the
|
| 428 |
+
* current GL context.
|
| 429 |
+
*
|
| 430 |
+
* \param buffer - Buffer object to unmap
|
| 431 |
+
*
|
| 432 |
+
* \return
|
| 433 |
+
* ::CUDA_SUCCESS,
|
| 434 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 435 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 436 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 437 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 438 |
+
* \notefnerr
|
| 439 |
+
*
|
| 440 |
+
* \sa ::cuGraphicsUnmapResources
|
| 441 |
+
*/
|
| 442 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnmapBufferObject(GLuint buffer);
|
| 443 |
+
|
| 444 |
+
/**
|
| 445 |
+
* \brief Unregister an OpenGL buffer object
|
| 446 |
+
*
|
| 447 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 448 |
+
*
|
| 449 |
+
* Unregisters the buffer object specified by \p buffer. This
|
| 450 |
+
* releases any resources associated with the registered buffer.
|
| 451 |
+
* After this call, the buffer may no longer be mapped for access by
|
| 452 |
+
* CUDA.
|
| 453 |
+
*
|
| 454 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 455 |
+
* when this function is called. This must be the same context, or a
|
| 456 |
+
* member of the same shareGroup, as the context that was bound when
|
| 457 |
+
* the buffer was registered.
|
| 458 |
+
*
|
| 459 |
+
* \param buffer - Name of the buffer object to unregister
|
| 460 |
+
*
|
| 461 |
+
* \return
|
| 462 |
+
* ::CUDA_SUCCESS,
|
| 463 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 464 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 465 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 466 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 467 |
+
* \notefnerr
|
| 468 |
+
*
|
| 469 |
+
* \sa ::cuGraphicsUnregisterResource
|
| 470 |
+
*/
|
| 471 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnregisterBufferObject(GLuint buffer);
|
| 472 |
+
|
| 473 |
+
/**
|
| 474 |
+
* \brief Set the map flags for an OpenGL buffer object
|
| 475 |
+
*
|
| 476 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 477 |
+
*
|
| 478 |
+
* Sets the map flags for the buffer object specified by \p buffer.
|
| 479 |
+
*
|
| 480 |
+
* Changes to \p Flags will take effect the next time \p buffer is mapped.
|
| 481 |
+
* The \p Flags argument may be any of the following:
|
| 482 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_NONE: Specifies no hints about how this
|
| 483 |
+
* resource will be used. It is therefore assumed that this resource will be
|
| 484 |
+
* read from and written to by CUDA kernels. This is the default value.
|
| 485 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_READ_ONLY: Specifies that CUDA kernels which
|
| 486 |
+
* access this resource will not write to this resource.
|
| 487 |
+
* - ::CU_GL_MAP_RESOURCE_FLAGS_WRITE_DISCARD: Specifies that CUDA kernels
|
| 488 |
+
* which access this resource will not read from this resource and will
|
| 489 |
+
* write over the entire contents of the resource, so none of the data
|
| 490 |
+
* previously stored in the resource will be preserved.
|
| 491 |
+
*
|
| 492 |
+
* If \p buffer has not been registered for use with CUDA, then
|
| 493 |
+
* ::CUDA_ERROR_INVALID_HANDLE is returned. If \p buffer is presently
|
| 494 |
+
* mapped for access by CUDA, then ::CUDA_ERROR_ALREADY_MAPPED is returned.
|
| 495 |
+
*
|
| 496 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 497 |
+
* when this function is called. This must be the same context, or a
|
| 498 |
+
* member of the same shareGroup, as the context that was bound when
|
| 499 |
+
* the buffer was registered.
|
| 500 |
+
*
|
| 501 |
+
* \param buffer - Buffer object to unmap
|
| 502 |
+
* \param Flags - Map flags
|
| 503 |
+
*
|
| 504 |
+
* \return
|
| 505 |
+
* ::CUDA_SUCCESS,
|
| 506 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 507 |
+
* ::CUDA_ERROR_INVALID_HANDLE,
|
| 508 |
+
* ::CUDA_ERROR_ALREADY_MAPPED,
|
| 509 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 510 |
+
* \notefnerr
|
| 511 |
+
*
|
| 512 |
+
* \sa ::cuGraphicsResourceSetMapFlags
|
| 513 |
+
*/
|
| 514 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLSetBufferObjectMapFlags(GLuint buffer, unsigned int Flags);
|
| 515 |
+
|
| 516 |
+
/**
|
| 517 |
+
* \brief Maps an OpenGL buffer object
|
| 518 |
+
*
|
| 519 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 520 |
+
*
|
| 521 |
+
* Maps the buffer object specified by \p buffer into the address space of the
|
| 522 |
+
* current CUDA context and returns in \p *dptr and \p *size the base pointer
|
| 523 |
+
* and size of the resulting mapping.
|
| 524 |
+
*
|
| 525 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 526 |
+
* when this function is called. This must be the same context, or a
|
| 527 |
+
* member of the same shareGroup, as the context that was bound when
|
| 528 |
+
* the buffer was registered.
|
| 529 |
+
*
|
| 530 |
+
* Stream \p hStream in the current CUDA context is synchronized with
|
| 531 |
+
* the current GL context.
|
| 532 |
+
*
|
| 533 |
+
* \param dptr - Returned mapped base pointer
|
| 534 |
+
* \param size - Returned size of mapping
|
| 535 |
+
* \param buffer - The name of the buffer object to map
|
| 536 |
+
* \param hStream - Stream to synchronize
|
| 537 |
+
*
|
| 538 |
+
* \return
|
| 539 |
+
* ::CUDA_SUCCESS,
|
| 540 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 541 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 542 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 543 |
+
* ::CUDA_ERROR_INVALID_VALUE,
|
| 544 |
+
* ::CUDA_ERROR_MAP_FAILED
|
| 545 |
+
* \notefnerr
|
| 546 |
+
*
|
| 547 |
+
* \sa ::cuGraphicsMapResources
|
| 548 |
+
*/
|
| 549 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLMapBufferObjectAsync(CUdeviceptr *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 550 |
+
|
| 551 |
+
/**
|
| 552 |
+
* \brief Unmaps an OpenGL buffer object
|
| 553 |
+
*
|
| 554 |
+
* \deprecated This function is deprecated as of Cuda 3.0.
|
| 555 |
+
*
|
| 556 |
+
* Unmaps the buffer object specified by \p buffer for access by CUDA.
|
| 557 |
+
*
|
| 558 |
+
* There must be a valid OpenGL context bound to the current thread
|
| 559 |
+
* when this function is called. This must be the same context, or a
|
| 560 |
+
* member of the same shareGroup, as the context that was bound when
|
| 561 |
+
* the buffer was registered.
|
| 562 |
+
*
|
| 563 |
+
* Stream \p hStream in the current CUDA context is synchronized with
|
| 564 |
+
* the current GL context.
|
| 565 |
+
*
|
| 566 |
+
* \param buffer - Name of the buffer object to unmap
|
| 567 |
+
* \param hStream - Stream to synchronize
|
| 568 |
+
*
|
| 569 |
+
* \return
|
| 570 |
+
* ::CUDA_SUCCESS,
|
| 571 |
+
* ::CUDA_ERROR_DEINITIALIZED,
|
| 572 |
+
* ::CUDA_ERROR_NOT_INITIALIZED,
|
| 573 |
+
* ::CUDA_ERROR_INVALID_CONTEXT,
|
| 574 |
+
* ::CUDA_ERROR_INVALID_VALUE
|
| 575 |
+
* \notefnerr
|
| 576 |
+
*
|
| 577 |
+
* \sa ::cuGraphicsUnmapResources
|
| 578 |
+
*/
|
| 579 |
+
__CUDA_DEPRECATED CUresult CUDAAPI cuGLUnmapBufferObjectAsync(GLuint buffer, CUstream hStream);
|
| 580 |
+
|
| 581 |
+
/** @} */ /* END CUDA_GL_DEPRECATED */
|
| 582 |
+
/** @} */ /* END CUDA_GL */
|
| 583 |
+
|
| 584 |
+
|
| 585 |
+
#if defined(__CUDA_API_VERSION_INTERNAL)
|
| 586 |
+
#undef cuGLCtxCreate
|
| 587 |
+
#undef cuGLMapBufferObject
|
| 588 |
+
#undef cuGLMapBufferObjectAsync
|
| 589 |
+
#undef cuGLGetDevices
|
| 590 |
+
|
| 591 |
+
CUresult CUDAAPI cuGLGetDevices(unsigned int *pCudaDeviceCount, CUdevice *pCudaDevices, unsigned int cudaDeviceCount, CUGLDeviceList deviceList);
|
| 592 |
+
CUresult CUDAAPI cuGLMapBufferObject_v2(CUdeviceptr *dptr, size_t *size, GLuint buffer);
|
| 593 |
+
CUresult CUDAAPI cuGLMapBufferObjectAsync_v2(CUdeviceptr *dptr, size_t *size, GLuint buffer, CUstream hStream);
|
| 594 |
+
CUresult CUDAAPI cuGLCtxCreate(CUcontext *pCtx, unsigned int Flags, CUdevice device );
|
| 595 |
+
CUresult CUDAAPI cuGLMapBufferObject(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer);
|
| 596 |
+
CUresult CUDAAPI cuGLMapBufferObjectAsync(CUdeviceptr_v1 *dptr, unsigned int *size, GLuint buffer, CUstream hStream);
|
| 597 |
+
#endif /* __CUDA_API_VERSION_INTERNAL */
|
| 598 |
+
|
| 599 |
+
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2021 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_DEVICE_RUNTIME_API_H__)
|
| 51 |
+
#define __CUDA_DEVICE_RUNTIME_API_H__
|
| 52 |
+
|
| 53 |
+
/*******************************************************************************
|
| 54 |
+
* *
|
| 55 |
+
* *
|
| 56 |
+
* *
|
| 57 |
+
*******************************************************************************/
|
| 58 |
+
|
| 59 |
+
#if !defined(__CUDACC_RTC__)
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__)
|
| 62 |
+
|
| 63 |
+
#if defined(__cplusplus)
|
| 64 |
+
extern "C" {
|
| 65 |
+
#endif
|
| 66 |
+
|
| 67 |
+
struct cudaFuncAttributes;
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
inline __device__ cudaError_t CUDARTAPI cudaMalloc(void **p, size_t s)
|
| 71 |
+
{
|
| 72 |
+
return cudaErrorUnknown;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
inline __device__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *p, const void *c)
|
| 76 |
+
{
|
| 77 |
+
return cudaErrorUnknown;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
inline __device__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device)
|
| 81 |
+
{
|
| 82 |
+
return cudaErrorUnknown;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
inline __device__ cudaError_t CUDARTAPI cudaGetDevice(int *device)
|
| 86 |
+
{
|
| 87 |
+
return cudaErrorUnknown;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize)
|
| 91 |
+
{
|
| 92 |
+
return cudaErrorUnknown;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
inline __device__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags)
|
| 96 |
+
{
|
| 97 |
+
return cudaErrorUnknown;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
#if defined(__cplusplus)
|
| 102 |
+
}
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
#endif /* !defined(__CUDACC_INTERNAL_NO_STUBS__) && !defined(__CUDACC_RDC__) && !defined(__CUDACC_EWP__) && defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 350) && !defined(__CUDADEVRT_INTERNAL__) */
|
| 106 |
+
|
| 107 |
+
#endif /* !defined(__CUDACC_RTC__) */
|
| 108 |
+
|
| 109 |
+
#if defined(__DOXYGEN_ONLY__) || defined(CUDA_ENABLE_DEPRECATED)
|
| 110 |
+
# define __DEPRECATED__(msg)
|
| 111 |
+
#elif defined(_WIN32)
|
| 112 |
+
# define __DEPRECATED__(msg) __declspec(deprecated(msg))
|
| 113 |
+
#elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
|
| 114 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated))
|
| 115 |
+
#else
|
| 116 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
|
| 117 |
+
#endif
|
| 118 |
+
|
| 119 |
+
#if defined(__CUDA_ARCH__) && !defined(__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING)
|
| 120 |
+
# define __CDPRT_DEPRECATED(func_name) __DEPRECATED__("Use of "#func_name" from device code is deprecated. Moreover, such use will cause this module to fail to load on sm_90+ devices. If calls to "#func_name" from device code cannot be removed for older devices at this time, you may guard them with __CUDA_ARCH__ macros to remove them only for sm_90+ devices, making sure to generate code for compute_90 for the macros to take effect. Note that this mitigation will no longer work when support for "#func_name" from device code is eventually dropped for all devices. Disable this warning with -D__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING.")
|
| 121 |
+
#else
|
| 122 |
+
# define __CDPRT_DEPRECATED(func_name)
|
| 123 |
+
#endif
|
| 124 |
+
|
| 125 |
+
#if defined(__cplusplus) && defined(__CUDACC__) /* Visible to nvcc front-end only */
|
| 126 |
+
#if !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350) // Visible to SM>=3.5 and "__host__ __device__" only
|
| 127 |
+
|
| 128 |
+
#include "driver_types.h"
|
| 129 |
+
#include "crt/host_defines.h"
|
| 130 |
+
|
| 131 |
+
extern "C"
|
| 132 |
+
{
|
| 133 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetAttribute(int *value, enum cudaDeviceAttr attr, int device);
|
| 134 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetLimit(size_t *pValue, enum cudaLimit limit);
|
| 135 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetCacheConfig(enum cudaFuncCache *pCacheConfig);
|
| 136 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaDeviceGetSharedMemConfig(enum cudaSharedMemConfig *pConfig);
|
| 137 |
+
#if (__CUDA_ARCH__ < 900)
|
| 138 |
+
// cudaDeviceSynchronize is removed on sm_90+
|
| 139 |
+
extern __device__ __cudart_builtin__ __CDPRT_DEPRECATED(cudaDeviceSynchronize) cudaError_t CUDARTAPI cudaDeviceSynchronize(void);
|
| 140 |
+
#endif
|
| 141 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI __cudaDeviceSynchronizeDeprecationAvoidance(void);
|
| 142 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetLastError(void);
|
| 143 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaPeekAtLastError(void);
|
| 144 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorString(cudaError_t error);
|
| 145 |
+
extern __device__ __cudart_builtin__ const char* CUDARTAPI cudaGetErrorName(cudaError_t error);
|
| 146 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDeviceCount(int *count);
|
| 147 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaGetDevice(int *device);
|
| 148 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamCreateWithFlags(cudaStream_t *pStream, unsigned int flags);
|
| 149 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamDestroy(cudaStream_t stream);
|
| 150 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 151 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaStreamWaitEvent_ptsz(cudaStream_t stream, cudaEvent_t event, unsigned int flags);
|
| 152 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventCreateWithFlags(cudaEvent_t *event, unsigned int flags);
|
| 153 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream);
|
| 154 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecord_ptsz(cudaEvent_t event, cudaStream_t stream);
|
| 155 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 156 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventRecordWithFlags_ptsz(cudaEvent_t event, cudaStream_t stream, unsigned int flags);
|
| 157 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event);
|
| 158 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFuncGetAttributes(struct cudaFuncAttributes *attr, const void *func);
|
| 159 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaFree(void *devPtr);
|
| 160 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMalloc(void **devPtr, size_t size);
|
| 161 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 162 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpyAsync_ptsz(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 163 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 164 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy2DAsync_ptsz(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, enum cudaMemcpyKind kind, cudaStream_t stream);
|
| 165 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 166 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemcpy3DAsync_ptsz(const struct cudaMemcpy3DParms *p, cudaStream_t stream);
|
| 167 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 168 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemsetAsync_ptsz(void *devPtr, int value, size_t count, cudaStream_t stream);
|
| 169 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 170 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset2DAsync_ptsz(void *devPtr, size_t pitch, int value, size_t width, size_t height, cudaStream_t stream);
|
| 171 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 172 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaMemset3DAsync_ptsz(struct cudaPitchedPtr pitchedDevPtr, int value, struct cudaExtent extent, cudaStream_t stream);
|
| 173 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaRuntimeGetVersion(int *runtimeVersion);
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* \ingroup CUDART_EXECUTION
|
| 177 |
+
* \brief Obtains a parameter buffer
|
| 178 |
+
*
|
| 179 |
+
* Obtains a parameter buffer which can be filled with parameters for a kernel launch.
|
| 180 |
+
* Parameters passed to ::cudaLaunchDevice must be allocated via this function.
|
| 181 |
+
*
|
| 182 |
+
* This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
|
| 183 |
+
* CUDA user code should use <<< >>> to launch kernels.
|
| 184 |
+
*
|
| 185 |
+
* \param alignment - Specifies alignment requirement of the parameter buffer
|
| 186 |
+
* \param size - Specifies size requirement in bytes
|
| 187 |
+
*
|
| 188 |
+
* \return
|
| 189 |
+
* Returns pointer to the allocated parameterBuffer
|
| 190 |
+
* \notefnerr
|
| 191 |
+
*
|
| 192 |
+
* \sa cudaLaunchDevice
|
| 193 |
+
*/
|
| 194 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBuffer(size_t alignment, size_t size);
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* \ingroup CUDART_EXECUTION
|
| 198 |
+
* \brief Launches a specified kernel
|
| 199 |
+
*
|
| 200 |
+
* Launches a specified kernel with the specified parameter buffer. A parameter buffer can be obtained
|
| 201 |
+
* by calling ::cudaGetParameterBuffer().
|
| 202 |
+
*
|
| 203 |
+
* This is a low level API and can only be accessed from Parallel Thread Execution (PTX).
|
| 204 |
+
* CUDA user code should use <<< >>> to launch the kernels.
|
| 205 |
+
*
|
| 206 |
+
* \param func - Pointer to the kernel to be launched
|
| 207 |
+
* \param parameterBuffer - Holds the parameters to the launched kernel. parameterBuffer can be NULL. (Optional)
|
| 208 |
+
* \param gridDimension - Specifies grid dimensions
|
| 209 |
+
* \param blockDimension - Specifies block dimensions
|
| 210 |
+
* \param sharedMemSize - Specifies size of shared memory
|
| 211 |
+
* \param stream - Specifies the stream to be used
|
| 212 |
+
*
|
| 213 |
+
* \return
|
| 214 |
+
* ::cudaSuccess, ::cudaErrorInvalidDevice, ::cudaErrorLaunchMaxDepthExceeded, ::cudaErrorInvalidConfiguration,
|
| 215 |
+
* ::cudaErrorStartupFailure, ::cudaErrorLaunchPendingCountExceeded, ::cudaErrorLaunchOutOfResources
|
| 216 |
+
* \notefnerr
|
| 217 |
+
* \n Please refer to Execution Configuration and Parameter Buffer Layout from the CUDA Programming
|
| 218 |
+
* Guide for the detailed descriptions of launch configuration and parameter layout respectively.
|
| 219 |
+
*
|
| 220 |
+
* \sa cudaGetParameterBuffer
|
| 221 |
+
*/
|
| 222 |
+
extern __device__ __cudart_builtin__ void * CUDARTAPI cudaGetParameterBufferV2(void *func, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize);
|
| 223 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice_ptsz(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 224 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2_ptsz(void *parameterBuffer, cudaStream_t stream);
|
| 225 |
+
|
| 226 |
+
#if defined(CUDA_API_PER_THREAD_DEFAULT_STREAM) && defined(__CUDA_ARCH__)
|
| 227 |
+
// When compiling for the device and per thread default stream is enabled, add
|
| 228 |
+
// a static inline redirect to the per thread stream entry points.
|
| 229 |
+
|
| 230 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
|
| 231 |
+
cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream)
|
| 232 |
+
{
|
| 233 |
+
return cudaLaunchDevice_ptsz(func, parameterBuffer, gridDimension, blockDimension, sharedMemSize, stream);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
static __inline__ __device__ __cudart_builtin__ cudaError_t CUDARTAPI
|
| 237 |
+
cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream)
|
| 238 |
+
{
|
| 239 |
+
return cudaLaunchDeviceV2_ptsz(parameterBuffer, stream);
|
| 240 |
+
}
|
| 241 |
+
#else
|
| 242 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDevice(void *func, void *parameterBuffer, dim3 gridDimension, dim3 blockDimension, unsigned int sharedMemSize, cudaStream_t stream);
|
| 243 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaLaunchDeviceV2(void *parameterBuffer, cudaStream_t stream);
|
| 244 |
+
#endif
|
| 245 |
+
|
| 246 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize);
|
| 247 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, const void *func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
|
| 248 |
+
|
| 249 |
+
extern __device__ __cudart_builtin__ unsigned long long CUDARTAPI cudaCGGetIntrinsicHandle(enum cudaCGScope scope);
|
| 250 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronize(unsigned long long handle, unsigned int flags);
|
| 251 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGSynchronizeGrid(unsigned long long handle, unsigned int flags);
|
| 252 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetSize(unsigned int *numThreads, unsigned int *numGrids, unsigned long long handle);
|
| 253 |
+
extern __device__ __cudart_builtin__ cudaError_t CUDARTAPI cudaCGGetRank(unsigned int *threadRank, unsigned int *gridRank, unsigned long long handle);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaMalloc(T **devPtr, size_t size);
|
| 257 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaFuncGetAttributes(struct cudaFuncAttributes *attr, T *entry);
|
| 258 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessor(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize);
|
| 259 |
+
template <typename T> static __inline__ __device__ __cudart_builtin__ cudaError_t cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags(int *numBlocks, T func, int blockSize, size_t dynamicSmemSize, unsigned int flags);
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
#endif // !defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350)
|
| 263 |
+
#endif /* defined(__cplusplus) && defined(__CUDACC__) */
|
| 264 |
+
|
| 265 |
+
#undef __DEPRECATED__
|
| 266 |
+
#undef __CDPRT_DEPRECATED
|
| 267 |
+
|
| 268 |
+
#endif /* !__CUDA_DEVICE_RUNTIME_API_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cuda_surface_types.h
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__CUDA_SURFACE_TYPES_H__)
|
| 51 |
+
#define __CUDA_SURFACE_TYPES_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 54 |
+
|
| 55 |
+
/*******************************************************************************
|
| 56 |
+
* *
|
| 57 |
+
* *
|
| 58 |
+
* *
|
| 59 |
+
*******************************************************************************/
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDACC_RTC__)
|
| 62 |
+
#define EXCLUDE_FROM_RTC
|
| 63 |
+
#include "channel_descriptor.h"
|
| 64 |
+
#undef EXCLUDE_FROM_RTC
|
| 65 |
+
#endif /* !__CUDACC_RTC__ */
|
| 66 |
+
#include "cuda_runtime_api.h"
|
| 67 |
+
|
| 68 |
+
/*******************************************************************************
|
| 69 |
+
* *
|
| 70 |
+
* *
|
| 71 |
+
* *
|
| 72 |
+
*******************************************************************************/
|
| 73 |
+
|
| 74 |
+
template<class T, int dim = 1>
|
| 75 |
+
struct __device_builtin_surface_type__ surface : public surfaceReference
|
| 76 |
+
{
|
| 77 |
+
#if !defined(__CUDACC_RTC__)
|
| 78 |
+
__host__ surface(void)
|
| 79 |
+
{
|
| 80 |
+
channelDesc = cudaCreateChannelDesc<T>();
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
__host__ surface(struct cudaChannelFormatDesc desc)
|
| 84 |
+
{
|
| 85 |
+
channelDesc = desc;
|
| 86 |
+
}
|
| 87 |
+
#endif /* !__CUDACC_RTC__ */
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
template<int dim>
|
| 91 |
+
struct __device_builtin_surface_type__ surface<void, dim> : public surfaceReference
|
| 92 |
+
{
|
| 93 |
+
#if !defined(__CUDACC_RTC__)
|
| 94 |
+
__host__ surface(void)
|
| 95 |
+
{
|
| 96 |
+
channelDesc = cudaCreateChannelDesc<void>();
|
| 97 |
+
}
|
| 98 |
+
#endif /* !__CUDACC_RTC__ */
|
| 99 |
+
};
|
| 100 |
+
|
| 101 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 102 |
+
|
| 103 |
+
#endif /* !__CUDA_SURFACE_TYPES_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/cudart_platform.h
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2016 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#ifndef __CUDART_PLATFORM_H__
|
| 51 |
+
#define __CUDART_PLATFORM_H__
|
| 52 |
+
|
| 53 |
+
#if ((defined(__linux__) || defined(__QNX__)) && (defined(__arm__) || defined(__aarch64__) || defined(__x86_64__)))
|
| 54 |
+
#define isEglSupported 1
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
#endif
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/device_atomic_functions.h
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__DEVICE_ATOMIC_FUNCTIONS_H__)
|
| 51 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC_RTC__)
|
| 54 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ __device__
|
| 55 |
+
#else /* __CUDACC_RTC__ */
|
| 56 |
+
#define __DEVICE_ATOMIC_FUNCTIONS_DECL__ static __inline__ __device__
|
| 57 |
+
#endif /* __CUDACC_RTC__ */
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 60 |
+
|
| 61 |
+
/*******************************************************************************
|
| 62 |
+
* *
|
| 63 |
+
* *
|
| 64 |
+
* *
|
| 65 |
+
*******************************************************************************/
|
| 66 |
+
|
| 67 |
+
#include "cuda_runtime_api.h"
|
| 68 |
+
|
| 69 |
+
#ifndef __CUDA_ARCH__
|
| 70 |
+
#define __DEF_IF_HOST { }
|
| 71 |
+
#else /* !__CUDA_ARCH__ */
|
| 72 |
+
#define __DEF_IF_HOST ;
|
| 73 |
+
#endif /* __CUDA_ARCH__ */
|
| 74 |
+
|
| 75 |
+
#ifdef __CUDA_ARCH__
|
| 76 |
+
extern "C"
|
| 77 |
+
{
|
| 78 |
+
extern __device__ __device_builtin__ int __iAtomicAdd(int *address, int val);
|
| 79 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicAdd(unsigned int *address, unsigned int val);
|
| 80 |
+
extern __device__ __device_builtin__ int __iAtomicExch(int *address, int val);
|
| 81 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicExch(unsigned int *address, unsigned int val);
|
| 82 |
+
extern __device__ __device_builtin__ float __fAtomicExch(float *address, float val);
|
| 83 |
+
extern __device__ __device_builtin__ int __iAtomicMin(int *address, int val);
|
| 84 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicMin(unsigned int *address, unsigned int val);
|
| 85 |
+
extern __device__ __device_builtin__ int __iAtomicMax(int *address, int val);
|
| 86 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicMax(unsigned int *address, unsigned int val);
|
| 87 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicInc(unsigned int *address, unsigned int val);
|
| 88 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicDec(unsigned int *address, unsigned int val);
|
| 89 |
+
extern __device__ __device_builtin__ int __iAtomicAnd(int *address, int val);
|
| 90 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicAnd(unsigned int *address, unsigned int val);
|
| 91 |
+
extern __device__ __device_builtin__ int __iAtomicOr(int *address, int val);
|
| 92 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicOr(unsigned int *address, unsigned int val);
|
| 93 |
+
extern __device__ __device_builtin__ int __iAtomicXor(int *address, int val);
|
| 94 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicXor(unsigned int *address, unsigned int val);
|
| 95 |
+
extern __device__ __device_builtin__ int __iAtomicCAS(int *address, int compare, int val);
|
| 96 |
+
extern __device__ __device_builtin__ unsigned int __uAtomicCAS(unsigned int *address, unsigned int compare, unsigned int val);
|
| 97 |
+
}
|
| 98 |
+
#endif /* __CUDA_ARCH__ */
|
| 99 |
+
|
| 100 |
+
/*******************************************************************************
|
| 101 |
+
* *
|
| 102 |
+
* *
|
| 103 |
+
* *
|
| 104 |
+
*******************************************************************************/
|
| 105 |
+
|
| 106 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAdd(int *address, int val) __DEF_IF_HOST
|
| 107 |
+
|
| 108 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAdd(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 109 |
+
|
| 110 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicSub(int *address, int val) __DEF_IF_HOST
|
| 111 |
+
|
| 112 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicSub(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 113 |
+
|
| 114 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicExch(int *address, int val) __DEF_IF_HOST
|
| 115 |
+
|
| 116 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicExch(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 117 |
+
|
| 118 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ float atomicExch(float *address, float val) __DEF_IF_HOST
|
| 119 |
+
|
| 120 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMin(int *address, int val) __DEF_IF_HOST
|
| 121 |
+
|
| 122 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMin(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 123 |
+
|
| 124 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicMax(int *address, int val) __DEF_IF_HOST
|
| 125 |
+
|
| 126 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicMax(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 127 |
+
|
| 128 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicInc(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 129 |
+
|
| 130 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicDec(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 131 |
+
|
| 132 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicAnd(int *address, int val) __DEF_IF_HOST
|
| 133 |
+
|
| 134 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicAnd(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 135 |
+
|
| 136 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicOr(int *address, int val) __DEF_IF_HOST
|
| 137 |
+
|
| 138 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicOr(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 139 |
+
|
| 140 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicXor(int *address, int val) __DEF_IF_HOST
|
| 141 |
+
|
| 142 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicXor(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 143 |
+
|
| 144 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ int atomicCAS(int *address, int compare, int val) __DEF_IF_HOST
|
| 145 |
+
|
| 146 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned int atomicCAS(unsigned int *address, unsigned int compare, unsigned int val) __DEF_IF_HOST
|
| 147 |
+
|
| 148 |
+
/*******************************************************************************
|
| 149 |
+
* *
|
| 150 |
+
* *
|
| 151 |
+
* *
|
| 152 |
+
*******************************************************************************/
|
| 153 |
+
|
| 154 |
+
#include "cuda_runtime_api.h"
|
| 155 |
+
|
| 156 |
+
#if defined(_WIN32)
|
| 157 |
+
# define __DEPRECATED__(msg) __declspec(deprecated(msg))
|
| 158 |
+
#elif (defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5 && !defined(__clang__))))
|
| 159 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated))
|
| 160 |
+
#else
|
| 161 |
+
# define __DEPRECATED__(msg) __attribute__((deprecated(msg)))
|
| 162 |
+
#endif
|
| 163 |
+
|
| 164 |
+
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
|
| 165 |
+
#define __WSB_DEPRECATION_MESSAGE(x) #x"() is not valid on compute_70 and above, and should be replaced with "#x"_sync()."\
|
| 166 |
+
"To continue using "#x"(), specify virtual architecture compute_60 when targeting sm_70 and above, for example, using the pair of compiler options: -arch=compute_60 -code=sm_70."
|
| 167 |
+
#else
|
| 168 |
+
#define __WSB_DEPRECATION_MESSAGE(x) #x"() is deprecated in favor of "#x"_sync() and may be removed in a future release (Use -Wno-deprecated-declarations to suppress this warning)."
|
| 169 |
+
#endif
|
| 170 |
+
|
| 171 |
+
extern "C"
|
| 172 |
+
{
|
| 173 |
+
#ifdef __CUDA_ARCH__
|
| 174 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicAdd(unsigned long long int *address, unsigned long long int val);
|
| 175 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicExch(unsigned long long int *address, unsigned long long int val);
|
| 176 |
+
extern __device__ __device_builtin__ unsigned long long int __ullAtomicCAS(unsigned long long int *address, unsigned long long int compare, unsigned long long int val);
|
| 177 |
+
#endif /* __CUDA_ARCH__ */
|
| 178 |
+
extern __device__ __device_builtin__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__any)) int __any(int cond);
|
| 179 |
+
extern __device__ __device_builtin__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__all)) int __all(int cond);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
/*******************************************************************************
|
| 184 |
+
* *
|
| 185 |
+
* *
|
| 186 |
+
* *
|
| 187 |
+
*******************************************************************************/
|
| 188 |
+
|
| 189 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicAdd(unsigned long long int *address, unsigned long long int val) __DEF_IF_HOST
|
| 190 |
+
|
| 191 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicExch(unsigned long long int *address, unsigned long long int val) __DEF_IF_HOST
|
| 192 |
+
|
| 193 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ unsigned long long int atomicCAS(unsigned long long int *address, unsigned long long int compare, unsigned long long int val) __DEF_IF_HOST
|
| 194 |
+
|
| 195 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__any)) bool any(bool cond) __DEF_IF_HOST
|
| 196 |
+
|
| 197 |
+
__DEVICE_ATOMIC_FUNCTIONS_DECL__ __DEPRECATED__(__WSB_DEPRECATION_MESSAGE(__all)) bool all(bool cond) __DEF_IF_HOST
|
| 198 |
+
|
| 199 |
+
#undef __DEPRECATED__
|
| 200 |
+
#undef __WSB_DEPRECATION_MESSAGE
|
| 201 |
+
|
| 202 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 203 |
+
|
| 204 |
+
#undef __DEF_IF_HOST
|
| 205 |
+
#undef __DEVICE_ATOMIC_FUNCTIONS_DECL__
|
| 206 |
+
|
| 207 |
+
#if !defined(__CUDACC_RTC__) && defined(__CUDA_ARCH__)
|
| 208 |
+
#include "device_atomic_functions.hpp"
|
| 209 |
+
#endif /* !__CUDACC_RTC__ && defined(__CUDA_ARCH__) */
|
| 210 |
+
|
| 211 |
+
#endif /* !__DEVICE_ATOMIC_FUNCTIONS_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_atomic_functions.h
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 35.235 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.35.235 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__SM_32_ATOMIC_FUNCTIONS_H__)
|
| 51 |
+
#define __SM_32_ATOMIC_FUNCTIONS_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC_RTC__)
|
| 54 |
+
#define __SM_32_ATOMIC_FUNCTIONS_DECL__ __device__
|
| 55 |
+
#else /* !__CUDACC_RTC__ */
|
| 56 |
+
#define __SM_32_ATOMIC_FUNCTIONS_DECL__ static __inline__ __device__
|
| 57 |
+
#endif /* __CUDACC_RTC__ */
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
|
| 62 |
+
|
| 63 |
+
/*******************************************************************************
|
| 64 |
+
* *
|
| 65 |
+
* *
|
| 66 |
+
* *
|
| 67 |
+
*******************************************************************************/
|
| 68 |
+
|
| 69 |
+
#include "cuda_runtime_api.h"
|
| 70 |
+
|
| 71 |
+
#ifndef __CUDA_ARCH__
|
| 72 |
+
#define __DEF_IF_HOST { }
|
| 73 |
+
#else /* !__CUDA_ARCH__ */
|
| 74 |
+
#define __DEF_IF_HOST ;
|
| 75 |
+
#endif /* __CUDA_ARCH__ */
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
#ifdef __CUDA_ARCH__
|
| 79 |
+
extern "C"
|
| 80 |
+
{
|
| 81 |
+
extern __device__ __device_builtin__ long long __illAtomicMin(long long *address, long long val);
|
| 82 |
+
extern __device__ __device_builtin__ long long __illAtomicMax(long long *address, long long val);
|
| 83 |
+
extern __device__ __device_builtin__ long long __llAtomicAnd(long long *address, long long val);
|
| 84 |
+
extern __device__ __device_builtin__ long long __llAtomicOr(long long *address, long long val);
|
| 85 |
+
extern __device__ __device_builtin__ long long __llAtomicXor(long long *address, long long val);
|
| 86 |
+
extern __device__ __device_builtin__ unsigned long long __ullAtomicMin(unsigned long long *address, unsigned long long val);
|
| 87 |
+
extern __device__ __device_builtin__ unsigned long long __ullAtomicMax(unsigned long long *address, unsigned long long val);
|
| 88 |
+
extern __device__ __device_builtin__ unsigned long long __ullAtomicAnd(unsigned long long *address, unsigned long long val);
|
| 89 |
+
extern __device__ __device_builtin__ unsigned long long __ullAtomicOr (unsigned long long *address, unsigned long long val);
|
| 90 |
+
extern __device__ __device_builtin__ unsigned long long __ullAtomicXor(unsigned long long *address, unsigned long long val);
|
| 91 |
+
}
|
| 92 |
+
#endif /* __CUDA_ARCH__ */
|
| 93 |
+
|
| 94 |
+
/*******************************************************************************
|
| 95 |
+
* *
|
| 96 |
+
* *
|
| 97 |
+
* *
|
| 98 |
+
*******************************************************************************/
|
| 99 |
+
|
| 100 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ long long atomicMin(long long *address, long long val) __DEF_IF_HOST
|
| 101 |
+
|
| 102 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ long long atomicMax(long long *address, long long val) __DEF_IF_HOST
|
| 103 |
+
|
| 104 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ long long atomicAnd(long long *address, long long val) __DEF_IF_HOST
|
| 105 |
+
|
| 106 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ long long atomicOr(long long *address, long long val) __DEF_IF_HOST
|
| 107 |
+
|
| 108 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ long long atomicXor(long long *address, long long val) __DEF_IF_HOST
|
| 109 |
+
|
| 110 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ unsigned long long atomicMin(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 111 |
+
|
| 112 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ unsigned long long atomicMax(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 113 |
+
|
| 114 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ unsigned long long atomicAnd(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 115 |
+
|
| 116 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ unsigned long long atomicOr(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 117 |
+
|
| 118 |
+
__SM_32_ATOMIC_FUNCTIONS_DECL__ unsigned long long atomicXor(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 119 |
+
|
| 120 |
+
#endif /* !__CUDA_ARCH__ || __CUDA_ARCH__ >= 320 */
|
| 121 |
+
|
| 122 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 123 |
+
|
| 124 |
+
#undef __DEF_IF_HOST
|
| 125 |
+
#undef __SM_32_ATOMIC_FUNCTIONS_DECL__
|
| 126 |
+
|
| 127 |
+
#if !defined(__CUDACC_RTC__) && defined(__CUDA_ARCH__)
|
| 128 |
+
#include "sm_32_atomic_functions.hpp"
|
| 129 |
+
#endif /* !__CUDACC_RTC__ && defined(__CUDA_ARCH__) */
|
| 130 |
+
|
| 131 |
+
#endif /* !__SM_32_ATOMIC_FUNCTIONS_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_intrinsics.h
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2020 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__SM_32_INTRINSICS_H__)
|
| 51 |
+
#define __SM_32_INTRINSICS_H__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC_RTC__)
|
| 54 |
+
#define __SM_32_INTRINSICS_DECL__ __device__
|
| 55 |
+
#else /* !__CUDACC_RTC__ */
|
| 56 |
+
#define __SM_32_INTRINSICS_DECL__ static __device__ __inline__
|
| 57 |
+
#endif /* __CUDACC_RTC__ */
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
|
| 62 |
+
|
| 63 |
+
/*******************************************************************************
|
| 64 |
+
* *
|
| 65 |
+
* *
|
| 66 |
+
* *
|
| 67 |
+
*******************************************************************************/
|
| 68 |
+
|
| 69 |
+
#include "cuda_runtime_api.h"
|
| 70 |
+
|
| 71 |
+
#ifndef __CUDA_ARCH__
|
| 72 |
+
#define __DEF_IF_HOST { }
|
| 73 |
+
#else /* !__CUDA_ARCH__ */
|
| 74 |
+
#define __DEF_IF_HOST ;
|
| 75 |
+
#endif /* __CUDA_ARCH__ */
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
/*******************************************************************************
|
| 79 |
+
* *
|
| 80 |
+
* Below are declarations of SM-3.5 intrinsics which are included as *
|
| 81 |
+
* source (instead of being built in to the compiler) *
|
| 82 |
+
* *
|
| 83 |
+
*******************************************************************************/
|
| 84 |
+
/******************************************************************************
|
| 85 |
+
* __ldg *
|
| 86 |
+
******************************************************************************/
|
| 87 |
+
__SM_32_INTRINSICS_DECL__ long __ldg(const long *ptr) __DEF_IF_HOST
|
| 88 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldg(const unsigned long *ptr) __DEF_IF_HOST
|
| 89 |
+
|
| 90 |
+
__SM_32_INTRINSICS_DECL__ char __ldg(const char *ptr) __DEF_IF_HOST
|
| 91 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldg(const signed char *ptr) __DEF_IF_HOST
|
| 92 |
+
__SM_32_INTRINSICS_DECL__ short __ldg(const short *ptr) __DEF_IF_HOST
|
| 93 |
+
__SM_32_INTRINSICS_DECL__ int __ldg(const int *ptr) __DEF_IF_HOST
|
| 94 |
+
__SM_32_INTRINSICS_DECL__ long long __ldg(const long long *ptr) __DEF_IF_HOST
|
| 95 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldg(const char2 *ptr) __DEF_IF_HOST
|
| 96 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldg(const char4 *ptr) __DEF_IF_HOST
|
| 97 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldg(const short2 *ptr) __DEF_IF_HOST
|
| 98 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldg(const short4 *ptr) __DEF_IF_HOST
|
| 99 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldg(const int2 *ptr) __DEF_IF_HOST
|
| 100 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldg(const int4 *ptr) __DEF_IF_HOST
|
| 101 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldg(const longlong2 *ptr) __DEF_IF_HOST
|
| 102 |
+
|
| 103 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldg(const unsigned char *ptr) __DEF_IF_HOST
|
| 104 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldg(const unsigned short *ptr) __DEF_IF_HOST
|
| 105 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldg(const unsigned int *ptr) __DEF_IF_HOST
|
| 106 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldg(const unsigned long long *ptr) __DEF_IF_HOST
|
| 107 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldg(const uchar2 *ptr) __DEF_IF_HOST
|
| 108 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldg(const uchar4 *ptr) __DEF_IF_HOST
|
| 109 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldg(const ushort2 *ptr) __DEF_IF_HOST
|
| 110 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldg(const ushort4 *ptr) __DEF_IF_HOST
|
| 111 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldg(const uint2 *ptr) __DEF_IF_HOST
|
| 112 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldg(const uint4 *ptr) __DEF_IF_HOST
|
| 113 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldg(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 114 |
+
|
| 115 |
+
__SM_32_INTRINSICS_DECL__ float __ldg(const float *ptr) __DEF_IF_HOST
|
| 116 |
+
__SM_32_INTRINSICS_DECL__ double __ldg(const double *ptr) __DEF_IF_HOST
|
| 117 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldg(const float2 *ptr) __DEF_IF_HOST
|
| 118 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldg(const float4 *ptr) __DEF_IF_HOST
|
| 119 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldg(const double2 *ptr) __DEF_IF_HOST
|
| 120 |
+
/******************************************************************************
|
| 121 |
+
* __ldcg *
|
| 122 |
+
******************************************************************************/
|
| 123 |
+
__SM_32_INTRINSICS_DECL__ long __ldcg(const long *ptr) __DEF_IF_HOST
|
| 124 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcg(const unsigned long *ptr) __DEF_IF_HOST
|
| 125 |
+
|
| 126 |
+
__SM_32_INTRINSICS_DECL__ char __ldcg(const char *ptr) __DEF_IF_HOST
|
| 127 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcg(const signed char *ptr) __DEF_IF_HOST
|
| 128 |
+
__SM_32_INTRINSICS_DECL__ short __ldcg(const short *ptr) __DEF_IF_HOST
|
| 129 |
+
__SM_32_INTRINSICS_DECL__ int __ldcg(const int *ptr) __DEF_IF_HOST
|
| 130 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcg(const long long *ptr) __DEF_IF_HOST
|
| 131 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcg(const char2 *ptr) __DEF_IF_HOST
|
| 132 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcg(const char4 *ptr) __DEF_IF_HOST
|
| 133 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcg(const short2 *ptr) __DEF_IF_HOST
|
| 134 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcg(const short4 *ptr) __DEF_IF_HOST
|
| 135 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcg(const int2 *ptr) __DEF_IF_HOST
|
| 136 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcg(const int4 *ptr) __DEF_IF_HOST
|
| 137 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcg(const longlong2 *ptr) __DEF_IF_HOST
|
| 138 |
+
|
| 139 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcg(const unsigned char *ptr) __DEF_IF_HOST
|
| 140 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcg(const unsigned short *ptr) __DEF_IF_HOST
|
| 141 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcg(const unsigned int *ptr) __DEF_IF_HOST
|
| 142 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcg(const unsigned long long *ptr) __DEF_IF_HOST
|
| 143 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcg(const uchar2 *ptr) __DEF_IF_HOST
|
| 144 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcg(const uchar4 *ptr) __DEF_IF_HOST
|
| 145 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcg(const ushort2 *ptr) __DEF_IF_HOST
|
| 146 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcg(const ushort4 *ptr) __DEF_IF_HOST
|
| 147 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcg(const uint2 *ptr) __DEF_IF_HOST
|
| 148 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcg(const uint4 *ptr) __DEF_IF_HOST
|
| 149 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcg(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 150 |
+
|
| 151 |
+
__SM_32_INTRINSICS_DECL__ float __ldcg(const float *ptr) __DEF_IF_HOST
|
| 152 |
+
__SM_32_INTRINSICS_DECL__ double __ldcg(const double *ptr) __DEF_IF_HOST
|
| 153 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcg(const float2 *ptr) __DEF_IF_HOST
|
| 154 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcg(const float4 *ptr) __DEF_IF_HOST
|
| 155 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcg(const double2 *ptr) __DEF_IF_HOST
|
| 156 |
+
/******************************************************************************
|
| 157 |
+
* __ldca *
|
| 158 |
+
******************************************************************************/
|
| 159 |
+
__SM_32_INTRINSICS_DECL__ long __ldca(const long *ptr) __DEF_IF_HOST
|
| 160 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldca(const unsigned long *ptr) __DEF_IF_HOST
|
| 161 |
+
|
| 162 |
+
__SM_32_INTRINSICS_DECL__ char __ldca(const char *ptr) __DEF_IF_HOST
|
| 163 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldca(const signed char *ptr) __DEF_IF_HOST
|
| 164 |
+
__SM_32_INTRINSICS_DECL__ short __ldca(const short *ptr) __DEF_IF_HOST
|
| 165 |
+
__SM_32_INTRINSICS_DECL__ int __ldca(const int *ptr) __DEF_IF_HOST
|
| 166 |
+
__SM_32_INTRINSICS_DECL__ long long __ldca(const long long *ptr) __DEF_IF_HOST
|
| 167 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldca(const char2 *ptr) __DEF_IF_HOST
|
| 168 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldca(const char4 *ptr) __DEF_IF_HOST
|
| 169 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldca(const short2 *ptr) __DEF_IF_HOST
|
| 170 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldca(const short4 *ptr) __DEF_IF_HOST
|
| 171 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldca(const int2 *ptr) __DEF_IF_HOST
|
| 172 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldca(const int4 *ptr) __DEF_IF_HOST
|
| 173 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldca(const longlong2 *ptr) __DEF_IF_HOST
|
| 174 |
+
|
| 175 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldca(const unsigned char *ptr) __DEF_IF_HOST
|
| 176 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldca(const unsigned short *ptr) __DEF_IF_HOST
|
| 177 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldca(const unsigned int *ptr) __DEF_IF_HOST
|
| 178 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldca(const unsigned long long *ptr) __DEF_IF_HOST
|
| 179 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldca(const uchar2 *ptr) __DEF_IF_HOST
|
| 180 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldca(const uchar4 *ptr) __DEF_IF_HOST
|
| 181 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldca(const ushort2 *ptr) __DEF_IF_HOST
|
| 182 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldca(const ushort4 *ptr) __DEF_IF_HOST
|
| 183 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldca(const uint2 *ptr) __DEF_IF_HOST
|
| 184 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldca(const uint4 *ptr) __DEF_IF_HOST
|
| 185 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldca(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 186 |
+
|
| 187 |
+
__SM_32_INTRINSICS_DECL__ float __ldca(const float *ptr) __DEF_IF_HOST
|
| 188 |
+
__SM_32_INTRINSICS_DECL__ double __ldca(const double *ptr) __DEF_IF_HOST
|
| 189 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldca(const float2 *ptr) __DEF_IF_HOST
|
| 190 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldca(const float4 *ptr) __DEF_IF_HOST
|
| 191 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldca(const double2 *ptr) __DEF_IF_HOST
|
| 192 |
+
/******************************************************************************
|
| 193 |
+
* __ldcs *
|
| 194 |
+
******************************************************************************/
|
| 195 |
+
__SM_32_INTRINSICS_DECL__ long __ldcs(const long *ptr) __DEF_IF_HOST
|
| 196 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcs(const unsigned long *ptr) __DEF_IF_HOST
|
| 197 |
+
|
| 198 |
+
__SM_32_INTRINSICS_DECL__ char __ldcs(const char *ptr) __DEF_IF_HOST
|
| 199 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcs(const signed char *ptr) __DEF_IF_HOST
|
| 200 |
+
__SM_32_INTRINSICS_DECL__ short __ldcs(const short *ptr) __DEF_IF_HOST
|
| 201 |
+
__SM_32_INTRINSICS_DECL__ int __ldcs(const int *ptr) __DEF_IF_HOST
|
| 202 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcs(const long long *ptr) __DEF_IF_HOST
|
| 203 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcs(const char2 *ptr) __DEF_IF_HOST
|
| 204 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcs(const char4 *ptr) __DEF_IF_HOST
|
| 205 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcs(const short2 *ptr) __DEF_IF_HOST
|
| 206 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcs(const short4 *ptr) __DEF_IF_HOST
|
| 207 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcs(const int2 *ptr) __DEF_IF_HOST
|
| 208 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcs(const int4 *ptr) __DEF_IF_HOST
|
| 209 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcs(const longlong2 *ptr) __DEF_IF_HOST
|
| 210 |
+
|
| 211 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcs(const unsigned char *ptr) __DEF_IF_HOST
|
| 212 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcs(const unsigned short *ptr) __DEF_IF_HOST
|
| 213 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcs(const unsigned int *ptr) __DEF_IF_HOST
|
| 214 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcs(const unsigned long long *ptr) __DEF_IF_HOST
|
| 215 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcs(const uchar2 *ptr) __DEF_IF_HOST
|
| 216 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcs(const uchar4 *ptr) __DEF_IF_HOST
|
| 217 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcs(const ushort2 *ptr) __DEF_IF_HOST
|
| 218 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcs(const ushort4 *ptr) __DEF_IF_HOST
|
| 219 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcs(const uint2 *ptr) __DEF_IF_HOST
|
| 220 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcs(const uint4 *ptr) __DEF_IF_HOST
|
| 221 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcs(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 222 |
+
|
| 223 |
+
__SM_32_INTRINSICS_DECL__ float __ldcs(const float *ptr) __DEF_IF_HOST
|
| 224 |
+
__SM_32_INTRINSICS_DECL__ double __ldcs(const double *ptr) __DEF_IF_HOST
|
| 225 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcs(const float2 *ptr) __DEF_IF_HOST
|
| 226 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcs(const float4 *ptr) __DEF_IF_HOST
|
| 227 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcs(const double2 *ptr) __DEF_IF_HOST
|
| 228 |
+
/******************************************************************************
|
| 229 |
+
* __ldlu *
|
| 230 |
+
******************************************************************************/
|
| 231 |
+
__SM_32_INTRINSICS_DECL__ long __ldlu(const long *ptr) __DEF_IF_HOST
|
| 232 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldlu(const unsigned long *ptr) __DEF_IF_HOST
|
| 233 |
+
|
| 234 |
+
__SM_32_INTRINSICS_DECL__ char __ldlu(const char *ptr) __DEF_IF_HOST
|
| 235 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldlu(const signed char *ptr) __DEF_IF_HOST
|
| 236 |
+
__SM_32_INTRINSICS_DECL__ short __ldlu(const short *ptr) __DEF_IF_HOST
|
| 237 |
+
__SM_32_INTRINSICS_DECL__ int __ldlu(const int *ptr) __DEF_IF_HOST
|
| 238 |
+
__SM_32_INTRINSICS_DECL__ long long __ldlu(const long long *ptr) __DEF_IF_HOST
|
| 239 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldlu(const char2 *ptr) __DEF_IF_HOST
|
| 240 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldlu(const char4 *ptr) __DEF_IF_HOST
|
| 241 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldlu(const short2 *ptr) __DEF_IF_HOST
|
| 242 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldlu(const short4 *ptr) __DEF_IF_HOST
|
| 243 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldlu(const int2 *ptr) __DEF_IF_HOST
|
| 244 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldlu(const int4 *ptr) __DEF_IF_HOST
|
| 245 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldlu(const longlong2 *ptr) __DEF_IF_HOST
|
| 246 |
+
|
| 247 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldlu(const unsigned char *ptr) __DEF_IF_HOST
|
| 248 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldlu(const unsigned short *ptr) __DEF_IF_HOST
|
| 249 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldlu(const unsigned int *ptr) __DEF_IF_HOST
|
| 250 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldlu(const unsigned long long *ptr) __DEF_IF_HOST
|
| 251 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldlu(const uchar2 *ptr) __DEF_IF_HOST
|
| 252 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldlu(const uchar4 *ptr) __DEF_IF_HOST
|
| 253 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldlu(const ushort2 *ptr) __DEF_IF_HOST
|
| 254 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldlu(const ushort4 *ptr) __DEF_IF_HOST
|
| 255 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldlu(const uint2 *ptr) __DEF_IF_HOST
|
| 256 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldlu(const uint4 *ptr) __DEF_IF_HOST
|
| 257 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldlu(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 258 |
+
|
| 259 |
+
__SM_32_INTRINSICS_DECL__ float __ldlu(const float *ptr) __DEF_IF_HOST
|
| 260 |
+
__SM_32_INTRINSICS_DECL__ double __ldlu(const double *ptr) __DEF_IF_HOST
|
| 261 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldlu(const float2 *ptr) __DEF_IF_HOST
|
| 262 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldlu(const float4 *ptr) __DEF_IF_HOST
|
| 263 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldlu(const double2 *ptr) __DEF_IF_HOST
|
| 264 |
+
/******************************************************************************
|
| 265 |
+
* __ldcv *
|
| 266 |
+
******************************************************************************/
|
| 267 |
+
__SM_32_INTRINSICS_DECL__ long __ldcv(const long *ptr) __DEF_IF_HOST
|
| 268 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcv(const unsigned long *ptr) __DEF_IF_HOST
|
| 269 |
+
|
| 270 |
+
__SM_32_INTRINSICS_DECL__ char __ldcv(const char *ptr) __DEF_IF_HOST
|
| 271 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcv(const signed char *ptr) __DEF_IF_HOST
|
| 272 |
+
__SM_32_INTRINSICS_DECL__ short __ldcv(const short *ptr) __DEF_IF_HOST
|
| 273 |
+
__SM_32_INTRINSICS_DECL__ int __ldcv(const int *ptr) __DEF_IF_HOST
|
| 274 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcv(const long long *ptr) __DEF_IF_HOST
|
| 275 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcv(const char2 *ptr) __DEF_IF_HOST
|
| 276 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcv(const char4 *ptr) __DEF_IF_HOST
|
| 277 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcv(const short2 *ptr) __DEF_IF_HOST
|
| 278 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcv(const short4 *ptr) __DEF_IF_HOST
|
| 279 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcv(const int2 *ptr) __DEF_IF_HOST
|
| 280 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcv(const int4 *ptr) __DEF_IF_HOST
|
| 281 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcv(const longlong2 *ptr) __DEF_IF_HOST
|
| 282 |
+
|
| 283 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcv(const unsigned char *ptr) __DEF_IF_HOST
|
| 284 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcv(const unsigned short *ptr) __DEF_IF_HOST
|
| 285 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcv(const unsigned int *ptr) __DEF_IF_HOST
|
| 286 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcv(const unsigned long long *ptr) __DEF_IF_HOST
|
| 287 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcv(const uchar2 *ptr) __DEF_IF_HOST
|
| 288 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcv(const uchar4 *ptr) __DEF_IF_HOST
|
| 289 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcv(const ushort2 *ptr) __DEF_IF_HOST
|
| 290 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcv(const ushort4 *ptr) __DEF_IF_HOST
|
| 291 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcv(const uint2 *ptr) __DEF_IF_HOST
|
| 292 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcv(const uint4 *ptr) __DEF_IF_HOST
|
| 293 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcv(const ulonglong2 *ptr) __DEF_IF_HOST
|
| 294 |
+
|
| 295 |
+
__SM_32_INTRINSICS_DECL__ float __ldcv(const float *ptr) __DEF_IF_HOST
|
| 296 |
+
__SM_32_INTRINSICS_DECL__ double __ldcv(const double *ptr) __DEF_IF_HOST
|
| 297 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcv(const float2 *ptr) __DEF_IF_HOST
|
| 298 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcv(const float4 *ptr) __DEF_IF_HOST
|
| 299 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcv(const double2 *ptr) __DEF_IF_HOST
|
| 300 |
+
/******************************************************************************
|
| 301 |
+
* __stwb *
|
| 302 |
+
******************************************************************************/
|
| 303 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(long *ptr, long value) __DEF_IF_HOST
|
| 304 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned long *ptr, unsigned long value) __DEF_IF_HOST
|
| 305 |
+
|
| 306 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char *ptr, char value) __DEF_IF_HOST
|
| 307 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(signed char *ptr, signed char value) __DEF_IF_HOST
|
| 308 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short *ptr, short value) __DEF_IF_HOST
|
| 309 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int *ptr, int value) __DEF_IF_HOST
|
| 310 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(long long *ptr, long long value) __DEF_IF_HOST
|
| 311 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char2 *ptr, char2 value) __DEF_IF_HOST
|
| 312 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char4 *ptr, char4 value) __DEF_IF_HOST
|
| 313 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short2 *ptr, short2 value) __DEF_IF_HOST
|
| 314 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short4 *ptr, short4 value) __DEF_IF_HOST
|
| 315 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int2 *ptr, int2 value) __DEF_IF_HOST
|
| 316 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int4 *ptr, int4 value) __DEF_IF_HOST
|
| 317 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(longlong2 *ptr, longlong2 value) __DEF_IF_HOST
|
| 318 |
+
|
| 319 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned char *ptr, unsigned char value) __DEF_IF_HOST
|
| 320 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned short *ptr, unsigned short value) __DEF_IF_HOST
|
| 321 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned int *ptr, unsigned int value) __DEF_IF_HOST
|
| 322 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned long long *ptr, unsigned long long value) __DEF_IF_HOST
|
| 323 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uchar2 *ptr, uchar2 value) __DEF_IF_HOST
|
| 324 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uchar4 *ptr, uchar4 value) __DEF_IF_HOST
|
| 325 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ushort2 *ptr, ushort2 value) __DEF_IF_HOST
|
| 326 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ushort4 *ptr, ushort4 value) __DEF_IF_HOST
|
| 327 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uint2 *ptr, uint2 value) __DEF_IF_HOST
|
| 328 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uint4 *ptr, uint4 value) __DEF_IF_HOST
|
| 329 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ulonglong2 *ptr, ulonglong2 value) __DEF_IF_HOST
|
| 330 |
+
|
| 331 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float *ptr, float value) __DEF_IF_HOST
|
| 332 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(double *ptr, double value) __DEF_IF_HOST
|
| 333 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float2 *ptr, float2 value) __DEF_IF_HOST
|
| 334 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float4 *ptr, float4 value) __DEF_IF_HOST
|
| 335 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(double2 *ptr, double2 value) __DEF_IF_HOST
|
| 336 |
+
/******************************************************************************
|
| 337 |
+
* __stcg *
|
| 338 |
+
******************************************************************************/
|
| 339 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(long *ptr, long value) __DEF_IF_HOST
|
| 340 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned long *ptr, unsigned long value) __DEF_IF_HOST
|
| 341 |
+
|
| 342 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char *ptr, char value) __DEF_IF_HOST
|
| 343 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(signed char *ptr, signed char value) __DEF_IF_HOST
|
| 344 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short *ptr, short value) __DEF_IF_HOST
|
| 345 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int *ptr, int value) __DEF_IF_HOST
|
| 346 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(long long *ptr, long long value) __DEF_IF_HOST
|
| 347 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char2 *ptr, char2 value) __DEF_IF_HOST
|
| 348 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char4 *ptr, char4 value) __DEF_IF_HOST
|
| 349 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short2 *ptr, short2 value) __DEF_IF_HOST
|
| 350 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short4 *ptr, short4 value) __DEF_IF_HOST
|
| 351 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int2 *ptr, int2 value) __DEF_IF_HOST
|
| 352 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int4 *ptr, int4 value) __DEF_IF_HOST
|
| 353 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(longlong2 *ptr, longlong2 value) __DEF_IF_HOST
|
| 354 |
+
|
| 355 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned char *ptr, unsigned char value) __DEF_IF_HOST
|
| 356 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned short *ptr, unsigned short value) __DEF_IF_HOST
|
| 357 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned int *ptr, unsigned int value) __DEF_IF_HOST
|
| 358 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned long long *ptr, unsigned long long value) __DEF_IF_HOST
|
| 359 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uchar2 *ptr, uchar2 value) __DEF_IF_HOST
|
| 360 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uchar4 *ptr, uchar4 value) __DEF_IF_HOST
|
| 361 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ushort2 *ptr, ushort2 value) __DEF_IF_HOST
|
| 362 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ushort4 *ptr, ushort4 value) __DEF_IF_HOST
|
| 363 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uint2 *ptr, uint2 value) __DEF_IF_HOST
|
| 364 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uint4 *ptr, uint4 value) __DEF_IF_HOST
|
| 365 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ulonglong2 *ptr, ulonglong2 value) __DEF_IF_HOST
|
| 366 |
+
|
| 367 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float *ptr, float value) __DEF_IF_HOST
|
| 368 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(double *ptr, double value) __DEF_IF_HOST
|
| 369 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float2 *ptr, float2 value) __DEF_IF_HOST
|
| 370 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float4 *ptr, float4 value) __DEF_IF_HOST
|
| 371 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(double2 *ptr, double2 value) __DEF_IF_HOST
|
| 372 |
+
/******************************************************************************
|
| 373 |
+
* __stcs *
|
| 374 |
+
******************************************************************************/
|
| 375 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(long *ptr, long value) __DEF_IF_HOST
|
| 376 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned long *ptr, unsigned long value) __DEF_IF_HOST
|
| 377 |
+
|
| 378 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char *ptr, char value) __DEF_IF_HOST
|
| 379 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(signed char *ptr, signed char value) __DEF_IF_HOST
|
| 380 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short *ptr, short value) __DEF_IF_HOST
|
| 381 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int *ptr, int value) __DEF_IF_HOST
|
| 382 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(long long *ptr, long long value) __DEF_IF_HOST
|
| 383 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char2 *ptr, char2 value) __DEF_IF_HOST
|
| 384 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char4 *ptr, char4 value) __DEF_IF_HOST
|
| 385 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short2 *ptr, short2 value) __DEF_IF_HOST
|
| 386 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short4 *ptr, short4 value) __DEF_IF_HOST
|
| 387 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int2 *ptr, int2 value) __DEF_IF_HOST
|
| 388 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int4 *ptr, int4 value) __DEF_IF_HOST
|
| 389 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(longlong2 *ptr, longlong2 value) __DEF_IF_HOST
|
| 390 |
+
|
| 391 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned char *ptr, unsigned char value) __DEF_IF_HOST
|
| 392 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned short *ptr, unsigned short value) __DEF_IF_HOST
|
| 393 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned int *ptr, unsigned int value) __DEF_IF_HOST
|
| 394 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned long long *ptr, unsigned long long value) __DEF_IF_HOST
|
| 395 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uchar2 *ptr, uchar2 value) __DEF_IF_HOST
|
| 396 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uchar4 *ptr, uchar4 value) __DEF_IF_HOST
|
| 397 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ushort2 *ptr, ushort2 value) __DEF_IF_HOST
|
| 398 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ushort4 *ptr, ushort4 value) __DEF_IF_HOST
|
| 399 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uint2 *ptr, uint2 value) __DEF_IF_HOST
|
| 400 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uint4 *ptr, uint4 value) __DEF_IF_HOST
|
| 401 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ulonglong2 *ptr, ulonglong2 value) __DEF_IF_HOST
|
| 402 |
+
|
| 403 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float *ptr, float value) __DEF_IF_HOST
|
| 404 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(double *ptr, double value) __DEF_IF_HOST
|
| 405 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float2 *ptr, float2 value) __DEF_IF_HOST
|
| 406 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float4 *ptr, float4 value) __DEF_IF_HOST
|
| 407 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(double2 *ptr, double2 value) __DEF_IF_HOST
|
| 408 |
+
/******************************************************************************
|
| 409 |
+
* __stwt *
|
| 410 |
+
******************************************************************************/
|
| 411 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(long *ptr, long value) __DEF_IF_HOST
|
| 412 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned long *ptr, unsigned long value) __DEF_IF_HOST
|
| 413 |
+
|
| 414 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char *ptr, char value) __DEF_IF_HOST
|
| 415 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(signed char *ptr, signed char value) __DEF_IF_HOST
|
| 416 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short *ptr, short value) __DEF_IF_HOST
|
| 417 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int *ptr, int value) __DEF_IF_HOST
|
| 418 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(long long *ptr, long long value) __DEF_IF_HOST
|
| 419 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char2 *ptr, char2 value) __DEF_IF_HOST
|
| 420 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char4 *ptr, char4 value) __DEF_IF_HOST
|
| 421 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short2 *ptr, short2 value) __DEF_IF_HOST
|
| 422 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short4 *ptr, short4 value) __DEF_IF_HOST
|
| 423 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int2 *ptr, int2 value) __DEF_IF_HOST
|
| 424 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int4 *ptr, int4 value) __DEF_IF_HOST
|
| 425 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(longlong2 *ptr, longlong2 value) __DEF_IF_HOST
|
| 426 |
+
|
| 427 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned char *ptr, unsigned char value) __DEF_IF_HOST
|
| 428 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned short *ptr, unsigned short value) __DEF_IF_HOST
|
| 429 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned int *ptr, unsigned int value) __DEF_IF_HOST
|
| 430 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned long long *ptr, unsigned long long value) __DEF_IF_HOST
|
| 431 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uchar2 *ptr, uchar2 value) __DEF_IF_HOST
|
| 432 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uchar4 *ptr, uchar4 value) __DEF_IF_HOST
|
| 433 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ushort2 *ptr, ushort2 value) __DEF_IF_HOST
|
| 434 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ushort4 *ptr, ushort4 value) __DEF_IF_HOST
|
| 435 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uint2 *ptr, uint2 value) __DEF_IF_HOST
|
| 436 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uint4 *ptr, uint4 value) __DEF_IF_HOST
|
| 437 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ulonglong2 *ptr, ulonglong2 value) __DEF_IF_HOST
|
| 438 |
+
|
| 439 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float *ptr, float value) __DEF_IF_HOST
|
| 440 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(double *ptr, double value) __DEF_IF_HOST
|
| 441 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float2 *ptr, float2 value) __DEF_IF_HOST
|
| 442 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float4 *ptr, float4 value) __DEF_IF_HOST
|
| 443 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(double2 *ptr, double2 value) __DEF_IF_HOST
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
// SHF is the "funnel shift" operation - an accelerated left/right shift with carry
|
| 447 |
+
// operating on 64-bit quantities, which are concatenations of two 32-bit registers.
|
| 448 |
+
|
| 449 |
+
/**
|
| 450 |
+
* \ingroup CUDA_MATH_INTRINSIC_INT
|
| 451 |
+
* \brief Concatenate \p hi : \p lo, shift left by \p shift & 31 bits, return the most significant 32 bits.
|
| 452 |
+
*
|
| 453 |
+
* Shift the 64-bit value formed by concatenating argument \p lo and \p hi left by the amount specified by the argument \p shift.
|
| 454 |
+
* Argument \p lo holds bits 31:0 and argument \p hi holds bits 63:32 of the 64-bit source value.
|
| 455 |
+
* The source is shifted left by the wrapped value of \p shift (\p shift & 31).
|
| 456 |
+
* The most significant 32-bits of the result are returned.
|
| 457 |
+
*
|
| 458 |
+
* \return Returns the most significant 32 bits of the shifted 64-bit value.
|
| 459 |
+
*/
|
| 460 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_l(unsigned int lo, unsigned int hi, unsigned int shift) __DEF_IF_HOST
|
| 461 |
+
/**
|
| 462 |
+
* \ingroup CUDA_MATH_INTRINSIC_INT
|
| 463 |
+
* \brief Concatenate \p hi : \p lo, shift left by min(\p shift, 32) bits, return the most significant 32 bits.
|
| 464 |
+
*
|
| 465 |
+
* Shift the 64-bit value formed by concatenating argument \p lo and \p hi left by the amount specified by the argument \p shift.
|
| 466 |
+
* Argument \p lo holds bits 31:0 and argument \p hi holds bits 63:32 of the 64-bit source value.
|
| 467 |
+
* The source is shifted left by the clamped value of \p shift (min(\p shift, 32)).
|
| 468 |
+
* The most significant 32-bits of the result are returned.
|
| 469 |
+
*
|
| 470 |
+
* \return Returns the most significant 32 bits of the shifted 64-bit value.
|
| 471 |
+
*/
|
| 472 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_lc(unsigned int lo, unsigned int hi, unsigned int shift) __DEF_IF_HOST
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* \ingroup CUDA_MATH_INTRINSIC_INT
|
| 476 |
+
* \brief Concatenate \p hi : \p lo, shift right by \p shift & 31 bits, return the least significant 32 bits.
|
| 477 |
+
*
|
| 478 |
+
* Shift the 64-bit value formed by concatenating argument \p lo and \p hi right by the amount specified by the argument \p shift.
|
| 479 |
+
* Argument \p lo holds bits 31:0 and argument \p hi holds bits 63:32 of the 64-bit source value.
|
| 480 |
+
* The source is shifted right by the wrapped value of \p shift (\p shift & 31).
|
| 481 |
+
* The least significant 32-bits of the result are returned.
|
| 482 |
+
*
|
| 483 |
+
* \return Returns the least significant 32 bits of the shifted 64-bit value.
|
| 484 |
+
*/
|
| 485 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_r(unsigned int lo, unsigned int hi, unsigned int shift) __DEF_IF_HOST
|
| 486 |
+
/**
|
| 487 |
+
* \ingroup CUDA_MATH_INTRINSIC_INT
|
| 488 |
+
* \brief Concatenate \p hi : \p lo, shift right by min(\p shift, 32) bits, return the least significant 32 bits.
|
| 489 |
+
*
|
| 490 |
+
* Shift the 64-bit value formed by concatenating argument \p lo and \p hi right by the amount specified by the argument \p shift.
|
| 491 |
+
* Argument \p lo holds bits 31:0 and argument \p hi holds bits 63:32 of the 64-bit source value.
|
| 492 |
+
* The source is shifted right by the clamped value of \p shift (min(\p shift, 32)).
|
| 493 |
+
* The least significant 32-bits of the result are returned.
|
| 494 |
+
*
|
| 495 |
+
* \return Returns the least significant 32 bits of the shifted 64-bit value.
|
| 496 |
+
*/
|
| 497 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_rc(unsigned int lo, unsigned int hi, unsigned int shift) __DEF_IF_HOST
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
#endif /* !__CUDA_ARCH__ || __CUDA_ARCH__ >= 320 */
|
| 501 |
+
|
| 502 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 503 |
+
|
| 504 |
+
#undef __SM_32_INTRINSICS_DECL__
|
| 505 |
+
|
| 506 |
+
#if !defined(__CUDACC_RTC__) && defined(__CUDA_ARCH__)
|
| 507 |
+
#include "sm_32_intrinsics.hpp"
|
| 508 |
+
#endif /* !__CUDACC_RTC__ && defined(__CUDA_ARCH__) */
|
| 509 |
+
|
| 510 |
+
#endif /* !__SM_32_INTRINSICS_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/cuda_runtime/include/sm_32_intrinsics.hpp
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__SM_32_INTRINSICS_HPP__)
|
| 51 |
+
#define __SM_32_INTRINSICS_HPP__
|
| 52 |
+
|
| 53 |
+
#if defined(__CUDACC_RTC__)
|
| 54 |
+
#define __SM_32_INTRINSICS_DECL__ __device__
|
| 55 |
+
#else /* !__CUDACC_RTC__ */
|
| 56 |
+
#define __SM_32_INTRINSICS_DECL__ static __device__ __inline__
|
| 57 |
+
#endif /* __CUDACC_RTC__ */
|
| 58 |
+
|
| 59 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 60 |
+
|
| 61 |
+
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 320
|
| 62 |
+
|
| 63 |
+
/*******************************************************************************
|
| 64 |
+
* *
|
| 65 |
+
* *
|
| 66 |
+
* *
|
| 67 |
+
*******************************************************************************/
|
| 68 |
+
|
| 69 |
+
#include "cuda_runtime_api.h"
|
| 70 |
+
|
| 71 |
+
// In here are intrinsics which are built in to the compiler. These may be
|
| 72 |
+
// referenced by intrinsic implementations from this file.
|
| 73 |
+
extern "C"
|
| 74 |
+
{
|
| 75 |
+
// There are no intrinsics built in to the compiler for SM-3.5,
|
| 76 |
+
// all intrinsics are now implemented as inline PTX below.
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/*******************************************************************************
|
| 80 |
+
* *
|
| 81 |
+
* Below are implementations of SM-3.5 intrinsics which are included as *
|
| 82 |
+
* source (instead of being built in to the compiler) *
|
| 83 |
+
* *
|
| 84 |
+
*******************************************************************************/
|
| 85 |
+
|
| 86 |
+
// LDG is a "load from global via texture path" command which can exhibit higher
|
| 87 |
+
// bandwidth on GK110 than a regular LD.
|
| 88 |
+
// Define a different pointer storage size for 64 and 32 bit
|
| 89 |
+
#if (defined(_MSC_VER) && defined(_WIN64)) || defined(__LP64__) || defined(__CUDACC_RTC__)
|
| 90 |
+
#define __LDG_PTR "l"
|
| 91 |
+
#else
|
| 92 |
+
#define __LDG_PTR "r"
|
| 93 |
+
#endif
|
| 94 |
+
|
| 95 |
+
/******************************************************************************
|
| 96 |
+
* __ldg *
|
| 97 |
+
******************************************************************************/
|
| 98 |
+
|
| 99 |
+
// Size of long is architecture and OS specific.
|
| 100 |
+
#if defined(__LP64__) // 64 bits
|
| 101 |
+
__SM_32_INTRINSICS_DECL__ long __ldg(const long *ptr) { unsigned long ret; asm volatile ("ld.global.nc.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 102 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldg(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.nc.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 103 |
+
#else // 32 bits
|
| 104 |
+
__SM_32_INTRINSICS_DECL__ long __ldg(const long *ptr) { unsigned long ret; asm volatile ("ld.global.nc.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 105 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldg(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.nc.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 106 |
+
#endif
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
__SM_32_INTRINSICS_DECL__ char __ldg(const char *ptr) { unsigned int ret; asm volatile ("ld.global.nc.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (char)ret; }
|
| 110 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldg(const signed char *ptr) { unsigned int ret; asm volatile ("ld.global.nc.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (signed char)ret; }
|
| 111 |
+
__SM_32_INTRINSICS_DECL__ short __ldg(const short *ptr) { unsigned short ret; asm volatile ("ld.global.nc.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return (short)ret; }
|
| 112 |
+
__SM_32_INTRINSICS_DECL__ int __ldg(const int *ptr) { unsigned int ret; asm volatile ("ld.global.nc.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (int)ret; }
|
| 113 |
+
__SM_32_INTRINSICS_DECL__ long long __ldg(const long long *ptr) { unsigned long long ret; asm volatile ("ld.global.nc.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long long)ret; }
|
| 114 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldg(const char2 *ptr) { char2 ret; int2 tmp; asm volatile ("ld.global.nc.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 115 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldg(const char4 *ptr) { char4 ret; int4 tmp; asm volatile ("ld.global.nc.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 116 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldg(const short2 *ptr) { short2 ret; asm volatile ("ld.global.nc.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 117 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldg(const short4 *ptr) { short4 ret; asm volatile ("ld.global.nc.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 118 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldg(const int2 *ptr) { int2 ret; asm volatile ("ld.global.nc.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 119 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldg(const int4 *ptr) { int4 ret; asm volatile ("ld.global.nc.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 120 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldg(const longlong2 *ptr) { longlong2 ret; asm volatile ("ld.global.nc.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 121 |
+
|
| 122 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldg(const unsigned char *ptr) { unsigned int ret; asm volatile ("ld.global.nc.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (unsigned char)ret; }
|
| 123 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldg(const unsigned short *ptr) { unsigned short ret; asm volatile ("ld.global.nc.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 124 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldg(const unsigned int *ptr) { unsigned int ret; asm volatile ("ld.global.nc.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 125 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldg(const unsigned long long *ptr) { unsigned long long ret; asm volatile ("ld.global.nc.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 126 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldg(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm volatile ("ld.global.nc.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 127 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldg(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm volatile ("ld.global.nc.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 128 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldg(const ushort2 *ptr) { ushort2 ret; asm volatile ("ld.global.nc.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 129 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldg(const ushort4 *ptr) { ushort4 ret; asm volatile ("ld.global.nc.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 130 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldg(const uint2 *ptr) { uint2 ret; asm volatile ("ld.global.nc.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 131 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldg(const uint4 *ptr) { uint4 ret; asm volatile ("ld.global.nc.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 132 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldg(const ulonglong2 *ptr) { ulonglong2 ret; asm volatile ("ld.global.nc.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 133 |
+
|
| 134 |
+
__SM_32_INTRINSICS_DECL__ float __ldg(const float *ptr) { float ret; asm volatile ("ld.global.nc.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 135 |
+
__SM_32_INTRINSICS_DECL__ double __ldg(const double *ptr) { double ret; asm volatile ("ld.global.nc.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 136 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldg(const float2 *ptr) { float2 ret; asm volatile ("ld.global.nc.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 137 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldg(const float4 *ptr) { float4 ret; asm volatile ("ld.global.nc.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 138 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldg(const double2 *ptr) { double2 ret; asm volatile ("ld.global.nc.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
/******************************************************************************
|
| 142 |
+
* __ldcg *
|
| 143 |
+
******************************************************************************/
|
| 144 |
+
|
| 145 |
+
// Size of long is architecture and OS specific.
|
| 146 |
+
#if defined(__LP64__) // 64 bits
|
| 147 |
+
__SM_32_INTRINSICS_DECL__ long __ldcg(const long *ptr) { unsigned long ret; asm volatile ("ld.global.cg.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 148 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcg(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.cg.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 149 |
+
#else // 32 bits
|
| 150 |
+
__SM_32_INTRINSICS_DECL__ long __ldcg(const long *ptr) { unsigned long ret; asm volatile ("ld.global.cg.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 151 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcg(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.cg.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 152 |
+
#endif
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
__SM_32_INTRINSICS_DECL__ char __ldcg(const char *ptr) { unsigned int ret; asm volatile ("ld.global.cg.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (char)ret; }
|
| 156 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcg(const signed char *ptr) { unsigned int ret; asm volatile ("ld.global.cg.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (signed char)ret; }
|
| 157 |
+
__SM_32_INTRINSICS_DECL__ short __ldcg(const short *ptr) { unsigned short ret; asm volatile ("ld.global.cg.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return (short)ret; }
|
| 158 |
+
__SM_32_INTRINSICS_DECL__ int __ldcg(const int *ptr) { unsigned int ret; asm volatile ("ld.global.cg.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (int)ret; }
|
| 159 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcg(const long long *ptr) { unsigned long long ret; asm volatile ("ld.global.cg.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long long)ret; }
|
| 160 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcg(const char2 *ptr) { char2 ret; int2 tmp; asm volatile ("ld.global.cg.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 161 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcg(const char4 *ptr) { char4 ret; int4 tmp; asm volatile ("ld.global.cg.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 162 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcg(const short2 *ptr) { short2 ret; asm volatile ("ld.global.cg.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 163 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcg(const short4 *ptr) { short4 ret; asm volatile ("ld.global.cg.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 164 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcg(const int2 *ptr) { int2 ret; asm volatile ("ld.global.cg.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 165 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcg(const int4 *ptr) { int4 ret; asm volatile ("ld.global.cg.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 166 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcg(const longlong2 *ptr) { longlong2 ret; asm volatile ("ld.global.cg.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 167 |
+
|
| 168 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcg(const unsigned char *ptr) { unsigned int ret; asm volatile ("ld.global.cg.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (unsigned char)ret; }
|
| 169 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcg(const unsigned short *ptr) { unsigned short ret; asm volatile ("ld.global.cg.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 170 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcg(const unsigned int *ptr) { unsigned int ret; asm volatile ("ld.global.cg.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 171 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcg(const unsigned long long *ptr) { unsigned long long ret; asm volatile ("ld.global.cg.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 172 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcg(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm volatile ("ld.global.cg.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 173 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcg(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm volatile ("ld.global.cg.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 174 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcg(const ushort2 *ptr) { ushort2 ret; asm volatile ("ld.global.cg.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 175 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcg(const ushort4 *ptr) { ushort4 ret; asm volatile ("ld.global.cg.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 176 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcg(const uint2 *ptr) { uint2 ret; asm volatile ("ld.global.cg.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 177 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcg(const uint4 *ptr) { uint4 ret; asm volatile ("ld.global.cg.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 178 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcg(const ulonglong2 *ptr) { ulonglong2 ret; asm volatile ("ld.global.cg.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 179 |
+
|
| 180 |
+
__SM_32_INTRINSICS_DECL__ float __ldcg(const float *ptr) { float ret; asm volatile ("ld.global.cg.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 181 |
+
__SM_32_INTRINSICS_DECL__ double __ldcg(const double *ptr) { double ret; asm volatile ("ld.global.cg.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 182 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcg(const float2 *ptr) { float2 ret; asm volatile ("ld.global.cg.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 183 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcg(const float4 *ptr) { float4 ret; asm volatile ("ld.global.cg.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 184 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcg(const double2 *ptr) { double2 ret; asm volatile ("ld.global.cg.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 185 |
+
|
| 186 |
+
/******************************************************************************
|
| 187 |
+
* __ldca *
|
| 188 |
+
******************************************************************************/
|
| 189 |
+
|
| 190 |
+
// Size of long is architecture and OS specific.
|
| 191 |
+
#if defined(__LP64__) // 64 bits
|
| 192 |
+
__SM_32_INTRINSICS_DECL__ long __ldca(const long *ptr) { unsigned long ret; asm volatile ("ld.global.ca.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 193 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldca(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.ca.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 194 |
+
#else // 32 bits
|
| 195 |
+
__SM_32_INTRINSICS_DECL__ long __ldca(const long *ptr) { unsigned long ret; asm volatile ("ld.global.ca.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 196 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldca(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.ca.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 197 |
+
#endif
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
__SM_32_INTRINSICS_DECL__ char __ldca(const char *ptr) { unsigned int ret; asm volatile ("ld.global.ca.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (char)ret; }
|
| 201 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldca(const signed char *ptr) { unsigned int ret; asm volatile ("ld.global.ca.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (signed char)ret; }
|
| 202 |
+
__SM_32_INTRINSICS_DECL__ short __ldca(const short *ptr) { unsigned short ret; asm volatile ("ld.global.ca.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return (short)ret; }
|
| 203 |
+
__SM_32_INTRINSICS_DECL__ int __ldca(const int *ptr) { unsigned int ret; asm volatile ("ld.global.ca.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (int)ret; }
|
| 204 |
+
__SM_32_INTRINSICS_DECL__ long long __ldca(const long long *ptr) { unsigned long long ret; asm volatile ("ld.global.ca.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long long)ret; }
|
| 205 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldca(const char2 *ptr) { char2 ret; int2 tmp; asm volatile ("ld.global.ca.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 206 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldca(const char4 *ptr) { char4 ret; int4 tmp; asm volatile ("ld.global.ca.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 207 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldca(const short2 *ptr) { short2 ret; asm volatile ("ld.global.ca.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 208 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldca(const short4 *ptr) { short4 ret; asm volatile ("ld.global.ca.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 209 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldca(const int2 *ptr) { int2 ret; asm volatile ("ld.global.ca.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 210 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldca(const int4 *ptr) { int4 ret; asm volatile ("ld.global.ca.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 211 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldca(const longlong2 *ptr) { longlong2 ret; asm volatile ("ld.global.ca.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 212 |
+
|
| 213 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldca(const unsigned char *ptr) { unsigned int ret; asm volatile ("ld.global.ca.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (unsigned char)ret; }
|
| 214 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldca(const unsigned short *ptr) { unsigned short ret; asm volatile ("ld.global.ca.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 215 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldca(const unsigned int *ptr) { unsigned int ret; asm volatile ("ld.global.ca.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 216 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldca(const unsigned long long *ptr) { unsigned long long ret; asm volatile ("ld.global.ca.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 217 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldca(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm volatile ("ld.global.ca.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 218 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldca(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm volatile ("ld.global.ca.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 219 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldca(const ushort2 *ptr) { ushort2 ret; asm volatile ("ld.global.ca.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 220 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldca(const ushort4 *ptr) { ushort4 ret; asm volatile ("ld.global.ca.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 221 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldca(const uint2 *ptr) { uint2 ret; asm volatile ("ld.global.ca.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 222 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldca(const uint4 *ptr) { uint4 ret; asm volatile ("ld.global.ca.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 223 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldca(const ulonglong2 *ptr) { ulonglong2 ret; asm volatile ("ld.global.ca.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 224 |
+
|
| 225 |
+
__SM_32_INTRINSICS_DECL__ float __ldca(const float *ptr) { float ret; asm volatile ("ld.global.ca.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 226 |
+
__SM_32_INTRINSICS_DECL__ double __ldca(const double *ptr) { double ret; asm volatile ("ld.global.ca.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 227 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldca(const float2 *ptr) { float2 ret; asm volatile ("ld.global.ca.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 228 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldca(const float4 *ptr) { float4 ret; asm volatile ("ld.global.ca.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 229 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldca(const double2 *ptr) { double2 ret; asm volatile ("ld.global.ca.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 230 |
+
|
| 231 |
+
/******************************************************************************
|
| 232 |
+
* __ldcs *
|
| 233 |
+
******************************************************************************/
|
| 234 |
+
|
| 235 |
+
// Size of long is architecture and OS specific.
|
| 236 |
+
#if defined(__LP64__) // 64 bits
|
| 237 |
+
__SM_32_INTRINSICS_DECL__ long __ldcs(const long *ptr) { unsigned long ret; asm volatile ("ld.global.cs.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 238 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcs(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.cs.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 239 |
+
#else // 32 bits
|
| 240 |
+
__SM_32_INTRINSICS_DECL__ long __ldcs(const long *ptr) { unsigned long ret; asm volatile ("ld.global.cs.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (long)ret; }
|
| 241 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcs(const unsigned long *ptr) { unsigned long ret; asm volatile ("ld.global.cs.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 242 |
+
#endif
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
__SM_32_INTRINSICS_DECL__ char __ldcs(const char *ptr) { unsigned int ret; asm volatile ("ld.global.cs.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (char)ret; }
|
| 246 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcs(const signed char *ptr) { unsigned int ret; asm volatile ("ld.global.cs.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (signed char)ret; }
|
| 247 |
+
__SM_32_INTRINSICS_DECL__ short __ldcs(const short *ptr) { unsigned short ret; asm volatile ("ld.global.cs.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return (short)ret; }
|
| 248 |
+
__SM_32_INTRINSICS_DECL__ int __ldcs(const int *ptr) { unsigned int ret; asm volatile ("ld.global.cs.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (int)ret; }
|
| 249 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcs(const long long *ptr) { unsigned long long ret; asm volatile ("ld.global.cs.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return (long long)ret; }
|
| 250 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcs(const char2 *ptr) { char2 ret; int2 tmp; asm volatile ("ld.global.cs.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 251 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcs(const char4 *ptr) { char4 ret; int4 tmp; asm volatile ("ld.global.cs.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 252 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcs(const short2 *ptr) { short2 ret; asm volatile ("ld.global.cs.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 253 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcs(const short4 *ptr) { short4 ret; asm volatile ("ld.global.cs.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 254 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcs(const int2 *ptr) { int2 ret; asm volatile ("ld.global.cs.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 255 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcs(const int4 *ptr) { int4 ret; asm volatile ("ld.global.cs.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 256 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcs(const longlong2 *ptr) { longlong2 ret; asm volatile ("ld.global.cs.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 257 |
+
|
| 258 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcs(const unsigned char *ptr) { unsigned int ret; asm volatile ("ld.global.cs.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return (unsigned char)ret; }
|
| 259 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcs(const unsigned short *ptr) { unsigned short ret; asm volatile ("ld.global.cs.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 260 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcs(const unsigned int *ptr) { unsigned int ret; asm volatile ("ld.global.cs.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 261 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcs(const unsigned long long *ptr) { unsigned long long ret; asm volatile ("ld.global.cs.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 262 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcs(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm volatile ("ld.global.cs.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 263 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcs(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm volatile ("ld.global.cs.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr)); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 264 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcs(const ushort2 *ptr) { ushort2 ret; asm volatile ("ld.global.cs.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 265 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcs(const ushort4 *ptr) { ushort4 ret; asm volatile ("ld.global.cs.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 266 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcs(const uint2 *ptr) { uint2 ret; asm volatile ("ld.global.cs.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 267 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcs(const uint4 *ptr) { uint4 ret; asm volatile ("ld.global.cs.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 268 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcs(const ulonglong2 *ptr) { ulonglong2 ret; asm volatile ("ld.global.cs.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 269 |
+
|
| 270 |
+
__SM_32_INTRINSICS_DECL__ float __ldcs(const float *ptr) { float ret; asm volatile ("ld.global.cs.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 271 |
+
__SM_32_INTRINSICS_DECL__ double __ldcs(const double *ptr) { double ret; asm volatile ("ld.global.cs.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr)); return ret; }
|
| 272 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcs(const float2 *ptr) { float2 ret; asm volatile ("ld.global.cs.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 273 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcs(const float4 *ptr) { float4 ret; asm volatile ("ld.global.cs.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr)); return ret; }
|
| 274 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcs(const double2 *ptr) { double2 ret; asm volatile ("ld.global.cs.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr)); return ret; }
|
| 275 |
+
|
| 276 |
+
/******************************************************************************
|
| 277 |
+
* __ldlu *
|
| 278 |
+
******************************************************************************/
|
| 279 |
+
|
| 280 |
+
// Size of long is architecture and OS specific.
|
| 281 |
+
#if defined(__LP64__) // 64 bits
|
| 282 |
+
__SM_32_INTRINSICS_DECL__ long __ldlu(const long *ptr) { unsigned long ret; asm ("ld.global.lu.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return (long)ret; }
|
| 283 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldlu(const unsigned long *ptr) { unsigned long ret; asm ("ld.global.lu.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 284 |
+
#else // 32 bits
|
| 285 |
+
__SM_32_INTRINSICS_DECL__ long __ldlu(const long *ptr) { unsigned long ret; asm ("ld.global.lu.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (long)ret; }
|
| 286 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldlu(const unsigned long *ptr) { unsigned long ret; asm ("ld.global.lu.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 287 |
+
#endif
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
__SM_32_INTRINSICS_DECL__ char __ldlu(const char *ptr) { unsigned int ret; asm ("ld.global.lu.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (char)ret; }
|
| 291 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldlu(const signed char *ptr) { unsigned int ret; asm ("ld.global.lu.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (signed char)ret; }
|
| 292 |
+
__SM_32_INTRINSICS_DECL__ short __ldlu(const short *ptr) { unsigned short ret; asm ("ld.global.lu.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr) : "memory"); return (short)ret; }
|
| 293 |
+
__SM_32_INTRINSICS_DECL__ int __ldlu(const int *ptr) { unsigned int ret; asm ("ld.global.lu.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (int)ret; }
|
| 294 |
+
__SM_32_INTRINSICS_DECL__ long long __ldlu(const long long *ptr) { unsigned long long ret; asm ("ld.global.lu.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return (long long)ret; }
|
| 295 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldlu(const char2 *ptr) { char2 ret; int2 tmp; asm ("ld.global.lu.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr) : "memory"); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 296 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldlu(const char4 *ptr) { char4 ret; int4 tmp; asm ("ld.global.lu.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr) : "memory"); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 297 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldlu(const short2 *ptr) { short2 ret; asm ("ld.global.lu.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 298 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldlu(const short4 *ptr) { short4 ret; asm ("ld.global.lu.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 299 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldlu(const int2 *ptr) { int2 ret; asm ("ld.global.lu.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 300 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldlu(const int4 *ptr) { int4 ret; asm ("ld.global.lu.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 301 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldlu(const longlong2 *ptr) { longlong2 ret; asm ("ld.global.lu.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 302 |
+
|
| 303 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldlu(const unsigned char *ptr) { unsigned int ret; asm ("ld.global.lu.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (unsigned char)ret; }
|
| 304 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldlu(const unsigned short *ptr) { unsigned short ret; asm ("ld.global.lu.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 305 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldlu(const unsigned int *ptr) { unsigned int ret; asm ("ld.global.lu.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 306 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldlu(const unsigned long long *ptr) { unsigned long long ret; asm ("ld.global.lu.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 307 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldlu(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm ("ld.global.lu.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr) : "memory"); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 308 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldlu(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm ("ld.global.lu.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr) : "memory"); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 309 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldlu(const ushort2 *ptr) { ushort2 ret; asm ("ld.global.lu.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 310 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldlu(const ushort4 *ptr) { ushort4 ret; asm ("ld.global.lu.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 311 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldlu(const uint2 *ptr) { uint2 ret; asm ("ld.global.lu.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 312 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldlu(const uint4 *ptr) { uint4 ret; asm ("ld.global.lu.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 313 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldlu(const ulonglong2 *ptr) { ulonglong2 ret; asm ("ld.global.lu.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 314 |
+
|
| 315 |
+
__SM_32_INTRINSICS_DECL__ float __ldlu(const float *ptr) { float ret; asm ("ld.global.lu.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 316 |
+
__SM_32_INTRINSICS_DECL__ double __ldlu(const double *ptr) { double ret; asm ("ld.global.lu.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 317 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldlu(const float2 *ptr) { float2 ret; asm ("ld.global.lu.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 318 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldlu(const float4 *ptr) { float4 ret; asm ("ld.global.lu.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 319 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldlu(const double2 *ptr) { double2 ret; asm ("ld.global.lu.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 320 |
+
|
| 321 |
+
/******************************************************************************
|
| 322 |
+
* __ldcv *
|
| 323 |
+
******************************************************************************/
|
| 324 |
+
|
| 325 |
+
// Size of long is architecture and OS specific.
|
| 326 |
+
#if defined(__LP64__) // 64 bits
|
| 327 |
+
__SM_32_INTRINSICS_DECL__ long __ldcv(const long *ptr) { unsigned long ret; asm ("ld.global.cv.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return (long)ret; }
|
| 328 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcv(const unsigned long *ptr) { unsigned long ret; asm ("ld.global.cv.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 329 |
+
#else // 32 bits
|
| 330 |
+
__SM_32_INTRINSICS_DECL__ long __ldcv(const long *ptr) { unsigned long ret; asm ("ld.global.cv.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (long)ret; }
|
| 331 |
+
__SM_32_INTRINSICS_DECL__ unsigned long __ldcv(const unsigned long *ptr) { unsigned long ret; asm ("ld.global.cv.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 332 |
+
#endif
|
| 333 |
+
|
| 334 |
+
|
| 335 |
+
__SM_32_INTRINSICS_DECL__ char __ldcv(const char *ptr) { unsigned int ret; asm ("ld.global.cv.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (char)ret; }
|
| 336 |
+
__SM_32_INTRINSICS_DECL__ signed char __ldcv(const signed char *ptr) { unsigned int ret; asm ("ld.global.cv.s8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (signed char)ret; }
|
| 337 |
+
__SM_32_INTRINSICS_DECL__ short __ldcv(const short *ptr) { unsigned short ret; asm ("ld.global.cv.s16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr) : "memory"); return (short)ret; }
|
| 338 |
+
__SM_32_INTRINSICS_DECL__ int __ldcv(const int *ptr) { unsigned int ret; asm ("ld.global.cv.s32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (int)ret; }
|
| 339 |
+
__SM_32_INTRINSICS_DECL__ long long __ldcv(const long long *ptr) { unsigned long long ret; asm ("ld.global.cv.s64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return (long long)ret; }
|
| 340 |
+
__SM_32_INTRINSICS_DECL__ char2 __ldcv(const char2 *ptr) { char2 ret; int2 tmp; asm ("ld.global.cv.v2.s8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr) : "memory"); ret.x = (char)tmp.x; ret.y = (char)tmp.y; return ret; }
|
| 341 |
+
__SM_32_INTRINSICS_DECL__ char4 __ldcv(const char4 *ptr) { char4 ret; int4 tmp; asm ("ld.global.cv.v4.s8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr) : "memory"); ret.x = (char)tmp.x; ret.y = (char)tmp.y; ret.z = (char)tmp.z; ret.w = (char)tmp.w; return ret; }
|
| 342 |
+
__SM_32_INTRINSICS_DECL__ short2 __ldcv(const short2 *ptr) { short2 ret; asm ("ld.global.cv.v2.s16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 343 |
+
__SM_32_INTRINSICS_DECL__ short4 __ldcv(const short4 *ptr) { short4 ret; asm ("ld.global.cv.v4.s16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 344 |
+
__SM_32_INTRINSICS_DECL__ int2 __ldcv(const int2 *ptr) { int2 ret; asm ("ld.global.cv.v2.s32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 345 |
+
__SM_32_INTRINSICS_DECL__ int4 __ldcv(const int4 *ptr) { int4 ret; asm ("ld.global.cv.v4.s32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 346 |
+
__SM_32_INTRINSICS_DECL__ longlong2 __ldcv(const longlong2 *ptr) { longlong2 ret; asm ("ld.global.cv.v2.s64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 347 |
+
|
| 348 |
+
__SM_32_INTRINSICS_DECL__ unsigned char __ldcv(const unsigned char *ptr) { unsigned int ret; asm ("ld.global.cv.u8 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return (unsigned char)ret; }
|
| 349 |
+
__SM_32_INTRINSICS_DECL__ unsigned short __ldcv(const unsigned short *ptr) { unsigned short ret; asm ("ld.global.cv.u16 %0, [%1];" : "=h"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 350 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __ldcv(const unsigned int *ptr) { unsigned int ret; asm ("ld.global.cv.u32 %0, [%1];" : "=r"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 351 |
+
__SM_32_INTRINSICS_DECL__ unsigned long long __ldcv(const unsigned long long *ptr) { unsigned long long ret; asm ("ld.global.cv.u64 %0, [%1];" : "=l"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 352 |
+
__SM_32_INTRINSICS_DECL__ uchar2 __ldcv(const uchar2 *ptr) { uchar2 ret; uint2 tmp; asm ("ld.global.cv.v2.u8 {%0,%1}, [%2];" : "=r"(tmp.x), "=r"(tmp.y) : __LDG_PTR (ptr) : "memory"); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; return ret; }
|
| 353 |
+
__SM_32_INTRINSICS_DECL__ uchar4 __ldcv(const uchar4 *ptr) { uchar4 ret; uint4 tmp; asm ("ld.global.cv.v4.u8 {%0,%1,%2,%3}, [%4];" : "=r"(tmp.x), "=r"(tmp.y), "=r"(tmp.z), "=r"(tmp.w) : __LDG_PTR (ptr) : "memory"); ret.x = (unsigned char)tmp.x; ret.y = (unsigned char)tmp.y; ret.z = (unsigned char)tmp.z; ret.w = (unsigned char)tmp.w; return ret; }
|
| 354 |
+
__SM_32_INTRINSICS_DECL__ ushort2 __ldcv(const ushort2 *ptr) { ushort2 ret; asm ("ld.global.cv.v2.u16 {%0,%1}, [%2];" : "=h"(ret.x), "=h"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 355 |
+
__SM_32_INTRINSICS_DECL__ ushort4 __ldcv(const ushort4 *ptr) { ushort4 ret; asm ("ld.global.cv.v4.u16 {%0,%1,%2,%3}, [%4];" : "=h"(ret.x), "=h"(ret.y), "=h"(ret.z), "=h"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 356 |
+
__SM_32_INTRINSICS_DECL__ uint2 __ldcv(const uint2 *ptr) { uint2 ret; asm ("ld.global.cv.v2.u32 {%0,%1}, [%2];" : "=r"(ret.x), "=r"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 357 |
+
__SM_32_INTRINSICS_DECL__ uint4 __ldcv(const uint4 *ptr) { uint4 ret; asm ("ld.global.cv.v4.u32 {%0,%1,%2,%3}, [%4];" : "=r"(ret.x), "=r"(ret.y), "=r"(ret.z), "=r"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 358 |
+
__SM_32_INTRINSICS_DECL__ ulonglong2 __ldcv(const ulonglong2 *ptr) { ulonglong2 ret; asm ("ld.global.cv.v2.u64 {%0,%1}, [%2];" : "=l"(ret.x), "=l"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 359 |
+
|
| 360 |
+
__SM_32_INTRINSICS_DECL__ float __ldcv(const float *ptr) { float ret; asm ("ld.global.cv.f32 %0, [%1];" : "=f"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 361 |
+
__SM_32_INTRINSICS_DECL__ double __ldcv(const double *ptr) { double ret; asm ("ld.global.cv.f64 %0, [%1];" : "=d"(ret) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 362 |
+
__SM_32_INTRINSICS_DECL__ float2 __ldcv(const float2 *ptr) { float2 ret; asm ("ld.global.cv.v2.f32 {%0,%1}, [%2];" : "=f"(ret.x), "=f"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 363 |
+
__SM_32_INTRINSICS_DECL__ float4 __ldcv(const float4 *ptr) { float4 ret; asm ("ld.global.cv.v4.f32 {%0,%1,%2,%3}, [%4];" : "=f"(ret.x), "=f"(ret.y), "=f"(ret.z), "=f"(ret.w) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 364 |
+
__SM_32_INTRINSICS_DECL__ double2 __ldcv(const double2 *ptr) { double2 ret; asm ("ld.global.cv.v2.f64 {%0,%1}, [%2];" : "=d"(ret.x), "=d"(ret.y) : __LDG_PTR (ptr) : "memory"); return ret; }
|
| 365 |
+
|
| 366 |
+
/******************************************************************************
|
| 367 |
+
* __stwb *
|
| 368 |
+
******************************************************************************/
|
| 369 |
+
|
| 370 |
+
// Size of long is architecture and OS specific.
|
| 371 |
+
#if defined(__LP64__) // 64 bits
|
| 372 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(long *ptr, long value) { asm ("st.global.wb.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 373 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned long *ptr, unsigned long value) { asm ("st.global.wb.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 374 |
+
#else // 32 bits
|
| 375 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(long *ptr, long value) { asm ("st.global.wb.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 376 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned long *ptr, unsigned long value) { asm ("st.global.wb.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 377 |
+
#endif
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char *ptr, char value) { asm ("st.global.wb.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 381 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(signed char *ptr, signed char value) { asm ("st.global.wb.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 382 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short *ptr, short value) { asm ("st.global.wb.s16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 383 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int *ptr, int value) { asm ("st.global.wb.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 384 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(long long *ptr, long long value) { asm ("st.global.wb.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 385 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char2 *ptr, char2 value) { const int x = value.x, y = value.y; asm ("st.global.wb.v2.s8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 386 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(char4 *ptr, char4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.wb.v4.s8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 387 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short2 *ptr, short2 value) { asm ("st.global.wb.v2.s16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 388 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(short4 *ptr, short4 value) { asm ("st.global.wb.v4.s16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 389 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int2 *ptr, int2 value) { asm ("st.global.wb.v2.s32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 390 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(int4 *ptr, int4 value) { asm ("st.global.wb.v4.s32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 391 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(longlong2 *ptr, longlong2 value) { asm ("st.global.wb.v2.s64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 392 |
+
|
| 393 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned char *ptr, unsigned char value) { asm ("st.global.wb.u8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 394 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned short *ptr, unsigned short value) { asm ("st.global.wb.u16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 395 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned int *ptr, unsigned int value) { asm ("st.global.wb.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 396 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(unsigned long long *ptr, unsigned long long value) { asm ("st.global.wb.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 397 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uchar2 *ptr, uchar2 value) { const int x = value.x, y = value.y; asm ("st.global.wb.v2.u8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 398 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uchar4 *ptr, uchar4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.wb.v4.u8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 399 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ushort2 *ptr, ushort2 value) { asm ("st.global.wb.v2.u16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 400 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ushort4 *ptr, ushort4 value) { asm ("st.global.wb.v4.u16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 401 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uint2 *ptr, uint2 value) { asm ("st.global.wb.v2.u32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 402 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(uint4 *ptr, uint4 value) { asm ("st.global.wb.v4.u32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 403 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(ulonglong2 *ptr, ulonglong2 value) { asm ("st.global.wb.v2.u64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 404 |
+
|
| 405 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float *ptr, float value) { asm ("st.global.wb.f32 [%0], %1;" :: __LDG_PTR (ptr), "f"(value) : "memory"); }
|
| 406 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(double *ptr, double value) { asm ("st.global.wb.f64 [%0], %1;" :: __LDG_PTR (ptr), "d"(value) : "memory"); }
|
| 407 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float2 *ptr, float2 value) { asm ("st.global.wb.v2.f32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y) : "memory"); }
|
| 408 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(float4 *ptr, float4 value) { asm ("st.global.wb.v4.f32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y), "f"(value.z), "f"(value.w) : "memory"); }
|
| 409 |
+
__SM_32_INTRINSICS_DECL__ void __stwb(double2 *ptr, double2 value) { asm ("st.global.wb.v2.f64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "d"(value.x), "d"(value.y) : "memory"); }
|
| 410 |
+
|
| 411 |
+
/******************************************************************************
|
| 412 |
+
* __stcg *
|
| 413 |
+
******************************************************************************/
|
| 414 |
+
|
| 415 |
+
// Size of long is architecture and OS specific.
|
| 416 |
+
#if defined(__LP64__) // 64 bits
|
| 417 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(long *ptr, long value) { asm ("st.global.cg.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 418 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned long *ptr, unsigned long value) { asm ("st.global.cg.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 419 |
+
#else // 32 bits
|
| 420 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(long *ptr, long value) { asm ("st.global.cg.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 421 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned long *ptr, unsigned long value) { asm ("st.global.cg.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 422 |
+
#endif
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char *ptr, char value) { asm ("st.global.cg.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 426 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(signed char *ptr, signed char value) { asm ("st.global.cg.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 427 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short *ptr, short value) { asm ("st.global.cg.s16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 428 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int *ptr, int value) { asm ("st.global.cg.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 429 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(long long *ptr, long long value) { asm ("st.global.cg.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 430 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char2 *ptr, char2 value) { const int x = value.x, y = value.y; asm ("st.global.cg.v2.s8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 431 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(char4 *ptr, char4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.cg.v4.s8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 432 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short2 *ptr, short2 value) { asm ("st.global.cg.v2.s16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 433 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(short4 *ptr, short4 value) { asm ("st.global.cg.v4.s16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 434 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int2 *ptr, int2 value) { asm ("st.global.cg.v2.s32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 435 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(int4 *ptr, int4 value) { asm ("st.global.cg.v4.s32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 436 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(longlong2 *ptr, longlong2 value) { asm ("st.global.cg.v2.s64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 437 |
+
|
| 438 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned char *ptr, unsigned char value) { asm ("st.global.cg.u8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 439 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned short *ptr, unsigned short value) { asm ("st.global.cg.u16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 440 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned int *ptr, unsigned int value) { asm ("st.global.cg.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 441 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(unsigned long long *ptr, unsigned long long value) { asm ("st.global.cg.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 442 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uchar2 *ptr, uchar2 value) { const int x = value.x, y = value.y; asm ("st.global.cg.v2.u8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 443 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uchar4 *ptr, uchar4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.cg.v4.u8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 444 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ushort2 *ptr, ushort2 value) { asm ("st.global.cg.v2.u16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 445 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ushort4 *ptr, ushort4 value) { asm ("st.global.cg.v4.u16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 446 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uint2 *ptr, uint2 value) { asm ("st.global.cg.v2.u32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 447 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(uint4 *ptr, uint4 value) { asm ("st.global.cg.v4.u32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 448 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(ulonglong2 *ptr, ulonglong2 value) { asm ("st.global.cg.v2.u64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 449 |
+
|
| 450 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float *ptr, float value) { asm ("st.global.cg.f32 [%0], %1;" :: __LDG_PTR (ptr), "f"(value) : "memory"); }
|
| 451 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(double *ptr, double value) { asm ("st.global.cg.f64 [%0], %1;" :: __LDG_PTR (ptr), "d"(value) : "memory"); }
|
| 452 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float2 *ptr, float2 value) { asm ("st.global.cg.v2.f32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y) : "memory"); }
|
| 453 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(float4 *ptr, float4 value) { asm ("st.global.cg.v4.f32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y), "f"(value.z), "f"(value.w) : "memory"); }
|
| 454 |
+
__SM_32_INTRINSICS_DECL__ void __stcg(double2 *ptr, double2 value) { asm ("st.global.cg.v2.f64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "d"(value.x), "d"(value.y) : "memory"); }
|
| 455 |
+
|
| 456 |
+
/******************************************************************************
|
| 457 |
+
* __stcs *
|
| 458 |
+
******************************************************************************/
|
| 459 |
+
|
| 460 |
+
// Size of long is architecture and OS specific.
|
| 461 |
+
#if defined(__LP64__) // 64 bits
|
| 462 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(long *ptr, long value) { asm ("st.global.cs.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 463 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned long *ptr, unsigned long value) { asm ("st.global.cs.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 464 |
+
#else // 32 bits
|
| 465 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(long *ptr, long value) { asm ("st.global.cs.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 466 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned long *ptr, unsigned long value) { asm ("st.global.cs.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 467 |
+
#endif
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char *ptr, char value) { asm ("st.global.cs.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 471 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(signed char *ptr, signed char value) { asm ("st.global.cs.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 472 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short *ptr, short value) { asm ("st.global.cs.s16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 473 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int *ptr, int value) { asm ("st.global.cs.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 474 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(long long *ptr, long long value) { asm ("st.global.cs.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 475 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char2 *ptr, char2 value) { const int x = value.x, y = value.y; asm ("st.global.cs.v2.s8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 476 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(char4 *ptr, char4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.cs.v4.s8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 477 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short2 *ptr, short2 value) { asm ("st.global.cs.v2.s16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 478 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(short4 *ptr, short4 value) { asm ("st.global.cs.v4.s16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 479 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int2 *ptr, int2 value) { asm ("st.global.cs.v2.s32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 480 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(int4 *ptr, int4 value) { asm ("st.global.cs.v4.s32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 481 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(longlong2 *ptr, longlong2 value) { asm ("st.global.cs.v2.s64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 482 |
+
|
| 483 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned char *ptr, unsigned char value) { asm ("st.global.cs.u8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 484 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned short *ptr, unsigned short value) { asm ("st.global.cs.u16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 485 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned int *ptr, unsigned int value) { asm ("st.global.cs.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 486 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(unsigned long long *ptr, unsigned long long value) { asm ("st.global.cs.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 487 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uchar2 *ptr, uchar2 value) { const int x = value.x, y = value.y; asm ("st.global.cs.v2.u8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 488 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uchar4 *ptr, uchar4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.cs.v4.u8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 489 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ushort2 *ptr, ushort2 value) { asm ("st.global.cs.v2.u16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 490 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ushort4 *ptr, ushort4 value) { asm ("st.global.cs.v4.u16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 491 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uint2 *ptr, uint2 value) { asm ("st.global.cs.v2.u32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 492 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(uint4 *ptr, uint4 value) { asm ("st.global.cs.v4.u32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 493 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(ulonglong2 *ptr, ulonglong2 value) { asm ("st.global.cs.v2.u64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 494 |
+
|
| 495 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float *ptr, float value) { asm ("st.global.cs.f32 [%0], %1;" :: __LDG_PTR (ptr), "f"(value) : "memory"); }
|
| 496 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(double *ptr, double value) { asm ("st.global.cs.f64 [%0], %1;" :: __LDG_PTR (ptr), "d"(value) : "memory"); }
|
| 497 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float2 *ptr, float2 value) { asm ("st.global.cs.v2.f32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y) : "memory"); }
|
| 498 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(float4 *ptr, float4 value) { asm ("st.global.cs.v4.f32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y), "f"(value.z), "f"(value.w) : "memory"); }
|
| 499 |
+
__SM_32_INTRINSICS_DECL__ void __stcs(double2 *ptr, double2 value) { asm ("st.global.cs.v2.f64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "d"(value.x), "d"(value.y) : "memory"); }
|
| 500 |
+
|
| 501 |
+
/******************************************************************************
|
| 502 |
+
* __stwt *
|
| 503 |
+
******************************************************************************/
|
| 504 |
+
|
| 505 |
+
// Size of long is architecture and OS specific.
|
| 506 |
+
#if defined(__LP64__) // 64 bits
|
| 507 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(long *ptr, long value) { asm ("st.global.wt.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 508 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned long *ptr, unsigned long value) { asm ("st.global.wt.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 509 |
+
#else // 32 bits
|
| 510 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(long *ptr, long value) { asm ("st.global.wt.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 511 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned long *ptr, unsigned long value) { asm ("st.global.wt.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 512 |
+
#endif
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char *ptr, char value) { asm ("st.global.wt.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 516 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(signed char *ptr, signed char value) { asm ("st.global.wt.s8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 517 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short *ptr, short value) { asm ("st.global.wt.s16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 518 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int *ptr, int value) { asm ("st.global.wt.s32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 519 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(long long *ptr, long long value) { asm ("st.global.wt.s64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 520 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char2 *ptr, char2 value) { const int x = value.x, y = value.y; asm ("st.global.wt.v2.s8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 521 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(char4 *ptr, char4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.wt.v4.s8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 522 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short2 *ptr, short2 value) { asm ("st.global.wt.v2.s16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 523 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(short4 *ptr, short4 value) { asm ("st.global.wt.v4.s16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 524 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int2 *ptr, int2 value) { asm ("st.global.wt.v2.s32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 525 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(int4 *ptr, int4 value) { asm ("st.global.wt.v4.s32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 526 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(longlong2 *ptr, longlong2 value) { asm ("st.global.wt.v2.s64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 527 |
+
|
| 528 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned char *ptr, unsigned char value) { asm ("st.global.wt.u8 [%0], %1;" :: __LDG_PTR (ptr), "r"((int)value) : "memory"); }
|
| 529 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned short *ptr, unsigned short value) { asm ("st.global.wt.u16 [%0], %1;" :: __LDG_PTR (ptr), "h"(value) : "memory"); }
|
| 530 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned int *ptr, unsigned int value) { asm ("st.global.wt.u32 [%0], %1;" :: __LDG_PTR (ptr), "r"(value) : "memory"); }
|
| 531 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(unsigned long long *ptr, unsigned long long value) { asm ("st.global.wt.u64 [%0], %1;" :: __LDG_PTR (ptr), "l"(value) : "memory"); }
|
| 532 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uchar2 *ptr, uchar2 value) { const int x = value.x, y = value.y; asm ("st.global.wt.v2.u8 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(x), "r"(y) : "memory"); }
|
| 533 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uchar4 *ptr, uchar4 value) { const int x = value.x, y = value.y, z = value.z, w = value.w; asm ("st.global.wt.v4.u8 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(x), "r"(y), "r"(z), "r"(w) : "memory"); }
|
| 534 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ushort2 *ptr, ushort2 value) { asm ("st.global.wt.v2.u16 [%0], {%1,%2};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y) : "memory"); }
|
| 535 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ushort4 *ptr, ushort4 value) { asm ("st.global.wt.v4.u16 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "h"(value.x), "h"(value.y), "h"(value.z), "h"(value.w) : "memory"); }
|
| 536 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uint2 *ptr, uint2 value) { asm ("st.global.wt.v2.u32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y) : "memory"); }
|
| 537 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(uint4 *ptr, uint4 value) { asm ("st.global.wt.v4.u32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "r"(value.x), "r"(value.y), "r"(value.z), "r"(value.w) : "memory"); }
|
| 538 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(ulonglong2 *ptr, ulonglong2 value) { asm ("st.global.wt.v2.u64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "l"(value.x), "l"(value.y) : "memory"); }
|
| 539 |
+
|
| 540 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float *ptr, float value) { asm ("st.global.wt.f32 [%0], %1;" :: __LDG_PTR (ptr), "f"(value) : "memory"); }
|
| 541 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(double *ptr, double value) { asm ("st.global.wt.f64 [%0], %1;" :: __LDG_PTR (ptr), "d"(value) : "memory"); }
|
| 542 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float2 *ptr, float2 value) { asm ("st.global.wt.v2.f32 [%0], {%1,%2};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y) : "memory"); }
|
| 543 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(float4 *ptr, float4 value) { asm ("st.global.wt.v4.f32 [%0], {%1,%2,%3,%4};" :: __LDG_PTR (ptr), "f"(value.x), "f"(value.y), "f"(value.z), "f"(value.w) : "memory"); }
|
| 544 |
+
__SM_32_INTRINSICS_DECL__ void __stwt(double2 *ptr, double2 value) { asm ("st.global.wt.v2.f64 [%0], {%1,%2};" :: __LDG_PTR (ptr), "d"(value.x), "d"(value.y) : "memory"); }
|
| 545 |
+
|
| 546 |
+
#undef __LDG_PTR
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
// SHF is the "funnel shift" operation - an accelerated left/right shift with carry
|
| 550 |
+
// operating on 64-bit quantities, which are concatenations of two 32-bit registers.
|
| 551 |
+
|
| 552 |
+
// This shifts [b:a] left by "shift" bits, returning the most significant bits of the result.
|
| 553 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_l(unsigned int lo, unsigned int hi, unsigned int shift)
|
| 554 |
+
{
|
| 555 |
+
unsigned int ret;
|
| 556 |
+
asm volatile ("shf.l.wrap.b32 %0, %1, %2, %3;" : "=r"(ret) : "r"(lo), "r"(hi), "r"(shift));
|
| 557 |
+
return ret;
|
| 558 |
+
}
|
| 559 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_lc(unsigned int lo, unsigned int hi, unsigned int shift)
|
| 560 |
+
{
|
| 561 |
+
unsigned int ret;
|
| 562 |
+
asm volatile ("shf.l.clamp.b32 %0, %1, %2, %3;" : "=r"(ret) : "r"(lo), "r"(hi), "r"(shift));
|
| 563 |
+
return ret;
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
// This shifts [b:a] right by "shift" bits, returning the least significant bits of the result.
|
| 567 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_r(unsigned int lo, unsigned int hi, unsigned int shift)
|
| 568 |
+
{
|
| 569 |
+
unsigned int ret;
|
| 570 |
+
asm volatile ("shf.r.wrap.b32 %0, %1, %2, %3;" : "=r"(ret) : "r"(lo), "r"(hi), "r"(shift));
|
| 571 |
+
return ret;
|
| 572 |
+
}
|
| 573 |
+
__SM_32_INTRINSICS_DECL__ unsigned int __funnelshift_rc(unsigned int lo, unsigned int hi, unsigned int shift)
|
| 574 |
+
{
|
| 575 |
+
unsigned int ret;
|
| 576 |
+
asm volatile ("shf.r.clamp.b32 %0, %1, %2, %3;" : "=r"(ret) : "r"(lo), "r"(hi), "r"(shift));
|
| 577 |
+
return ret;
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
#endif /* !__CUDA_ARCH__ || __CUDA_ARCH__ >= 320 */
|
| 582 |
+
|
| 583 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 584 |
+
|
| 585 |
+
#undef __SM_32_INTRINSICS_DECL__
|
| 586 |
+
|
| 587 |
+
#end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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1993-2014 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO LICENSEE:
|
| 5 |
+
*
|
| 6 |
+
* This source code and/or documentation ("Licensed Deliverables") are
|
| 7 |
+
* subject to NVIDIA intellectual property rights under U.S. and
|
| 8 |
+
* international Copyright laws.
|
| 9 |
+
*
|
| 10 |
+
* These Licensed Deliverables contained herein is PROPRIETARY and
|
| 11 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and
|
| 12 |
+
* conditions of a form of NVIDIA software license agreement by and
|
| 13 |
+
* between NVIDIA and Licensee ("License Agreement") or electronically
|
| 14 |
+
* accepted by Licensee. Notwithstanding any terms or conditions to
|
| 15 |
+
* the contrary in the License Agreement, reproduction or disclosure
|
| 16 |
+
* of the Licensed Deliverables to any third party without the express
|
| 17 |
+
* written consent of NVIDIA is prohibited.
|
| 18 |
+
*
|
| 19 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 20 |
+
* LICENSE AGREEMENT, NVIDIA MAKES NO REPRESENTATION ABOUT THE
|
| 21 |
+
* SUITABILITY OF THESE LICENSED DELIVERABLES FOR ANY PURPOSE. IT IS
|
| 22 |
+
* PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
|
| 23 |
+
* NVIDIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THESE LICENSED
|
| 24 |
+
* DELIVERABLES, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,
|
| 25 |
+
* NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 26 |
+
* NOTWITHSTANDING ANY TERMS OR CONDITIONS TO THE CONTRARY IN THE
|
| 27 |
+
* LICENSE AGREEMENT, IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY
|
| 28 |
+
* SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY
|
| 29 |
+
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 30 |
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
| 31 |
+
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 32 |
+
* OF THESE LICENSED DELIVERABLES.
|
| 33 |
+
*
|
| 34 |
+
* U.S. Government End Users. These Licensed Deliverables are a
|
| 35 |
+
* "commercial item" as that term is defined at 48 C.F.R. 2.101 (OCT
|
| 36 |
+
* 1995), consisting of "commercial computer software" and "commercial
|
| 37 |
+
* computer software documentation" as such terms are used in 48
|
| 38 |
+
* C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Government
|
| 39 |
+
* only as a commercial end item. Consistent with 48 C.F.R.12.212 and
|
| 40 |
+
* 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), all
|
| 41 |
+
* U.S. Government End Users acquire the Licensed Deliverables with
|
| 42 |
+
* only those rights set forth herein.
|
| 43 |
+
*
|
| 44 |
+
* Any use of the Licensed Deliverables in individual and commercial
|
| 45 |
+
* software must include, in the user documentation and internal
|
| 46 |
+
* comments to the code, the above Disclaimer and U.S. Government End
|
| 47 |
+
* Users Notice.
|
| 48 |
+
*/
|
| 49 |
+
|
| 50 |
+
#if !defined(__SM_60_ATOMIC_FUNCTIONS_H__)
|
| 51 |
+
#define __SM_60_ATOMIC_FUNCTIONS_H__
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
#if defined(__CUDACC_RTC__)
|
| 55 |
+
#define __SM_60_ATOMIC_FUNCTIONS_DECL__ __device__
|
| 56 |
+
#else /* __CUDACC_RTC__ */
|
| 57 |
+
#define __SM_60_ATOMIC_FUNCTIONS_DECL__ static __inline__ __device__
|
| 58 |
+
#endif /* __CUDACC_RTC__ */
|
| 59 |
+
|
| 60 |
+
#if defined(__cplusplus) && defined(__CUDACC__)
|
| 61 |
+
|
| 62 |
+
#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
|
| 63 |
+
|
| 64 |
+
/*******************************************************************************
|
| 65 |
+
* *
|
| 66 |
+
* *
|
| 67 |
+
* *
|
| 68 |
+
*******************************************************************************/
|
| 69 |
+
|
| 70 |
+
#include "cuda_runtime_api.h"
|
| 71 |
+
|
| 72 |
+
#ifndef __CUDA_ARCH__
|
| 73 |
+
#define __DEF_IF_HOST { }
|
| 74 |
+
#else /* !__CUDA_ARCH__ */
|
| 75 |
+
#define __DEF_IF_HOST ;
|
| 76 |
+
#endif /* __CUDA_ARCH__ */
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
#ifdef __CUDA_ARCH__
|
| 81 |
+
extern "C"
|
| 82 |
+
{
|
| 83 |
+
extern __device__ __device_builtin__ double __dAtomicAdd(double *address, double val);
|
| 84 |
+
|
| 85 |
+
extern __device__ __device_builtin__
|
| 86 |
+
int __iAtomicAdd_block(int *address, int val);
|
| 87 |
+
|
| 88 |
+
extern __device__ __device_builtin__
|
| 89 |
+
int __iAtomicAdd_system(int *address, int val);
|
| 90 |
+
|
| 91 |
+
extern __device__ __device_builtin__
|
| 92 |
+
unsigned int __uAtomicAdd_block(unsigned int *address, unsigned int val);
|
| 93 |
+
|
| 94 |
+
extern __device__ __device_builtin__
|
| 95 |
+
unsigned int __uAtomicAdd_system(unsigned int *address, unsigned int val);
|
| 96 |
+
|
| 97 |
+
extern __device__ __device_builtin__
|
| 98 |
+
unsigned long long __ullAtomicAdd_block(unsigned long long *address, unsigned long long val);
|
| 99 |
+
|
| 100 |
+
extern __device__ __device_builtin__
|
| 101 |
+
unsigned long long __ullAtomicAdd_system(unsigned long long *address, unsigned long long val);
|
| 102 |
+
|
| 103 |
+
extern __device__ __device_builtin__
|
| 104 |
+
float __fAtomicAdd_block(float *address, float val);
|
| 105 |
+
|
| 106 |
+
extern __device__ __device_builtin__
|
| 107 |
+
float __fAtomicAdd_system(float *address, float val);
|
| 108 |
+
|
| 109 |
+
extern __device__ __device_builtin__
|
| 110 |
+
double __dAtomicAdd_block(double *address, double val);
|
| 111 |
+
|
| 112 |
+
extern __device__ __device_builtin__
|
| 113 |
+
double __dAtomicAdd_system(double *address, double val);
|
| 114 |
+
|
| 115 |
+
extern __device__ __device_builtin__
|
| 116 |
+
int __iAtomicExch_block(int *address, int val);
|
| 117 |
+
|
| 118 |
+
extern __device__ __device_builtin__
|
| 119 |
+
int __iAtomicExch_system(int *address, int val);
|
| 120 |
+
|
| 121 |
+
extern __device__ __device_builtin__
|
| 122 |
+
unsigned int __uAtomicExch_block(unsigned int *address, unsigned int val);
|
| 123 |
+
|
| 124 |
+
extern __device__ __device_builtin__
|
| 125 |
+
unsigned int __uAtomicExch_system(unsigned int *address, unsigned int val);
|
| 126 |
+
|
| 127 |
+
extern __device__ __device_builtin__
|
| 128 |
+
unsigned long long __ullAtomicExch_block(unsigned long long *address, unsigned long long val);
|
| 129 |
+
|
| 130 |
+
extern __device__ __device_builtin__
|
| 131 |
+
unsigned long long __ullAtomicExch_system(unsigned long long *address, unsigned long long val);
|
| 132 |
+
|
| 133 |
+
extern __device__ __device_builtin__
|
| 134 |
+
float __fAtomicExch_block(float *address, float val);
|
| 135 |
+
|
| 136 |
+
extern __device__ __device_builtin__
|
| 137 |
+
float __fAtomicExch_system(float *address, float val);
|
| 138 |
+
|
| 139 |
+
extern __device__ __device_builtin__
|
| 140 |
+
int __iAtomicMin_block(int *address, int val);
|
| 141 |
+
|
| 142 |
+
extern __device__ __device_builtin__
|
| 143 |
+
int __iAtomicMin_system(int *address, int val);
|
| 144 |
+
|
| 145 |
+
extern __device__ __device_builtin__
|
| 146 |
+
long long __illAtomicMin_block(long long *address, long long val);
|
| 147 |
+
|
| 148 |
+
extern __device__ __device_builtin__
|
| 149 |
+
long long __illAtomicMin_system(long long *address, long long val);
|
| 150 |
+
|
| 151 |
+
extern __device__ __device_builtin__
|
| 152 |
+
unsigned int __uAtomicMin_block(unsigned int *address, unsigned int val);
|
| 153 |
+
|
| 154 |
+
extern __device__ __device_builtin__
|
| 155 |
+
unsigned int __uAtomicMin_system(unsigned int *address, unsigned int val);
|
| 156 |
+
|
| 157 |
+
extern __device__ __device_builtin__
|
| 158 |
+
unsigned long long __ullAtomicMin_block(unsigned long long *address, unsigned long long val);
|
| 159 |
+
|
| 160 |
+
extern __device__ __device_builtin__
|
| 161 |
+
unsigned long long __ullAtomicMin_system(unsigned long long *address, unsigned long long val);
|
| 162 |
+
|
| 163 |
+
extern __device__ __device_builtin__
|
| 164 |
+
int __iAtomicMax_block(int *address, int val);
|
| 165 |
+
|
| 166 |
+
extern __device__ __device_builtin__
|
| 167 |
+
int __iAtomicMax_system(int *address, int val);
|
| 168 |
+
|
| 169 |
+
extern __device__ __device_builtin__
|
| 170 |
+
long long __illAtomicMax_block(long long *address, long long val);
|
| 171 |
+
|
| 172 |
+
extern __device__ __device_builtin__
|
| 173 |
+
long long __illAtomicMax_system(long long *address, long long val);
|
| 174 |
+
|
| 175 |
+
extern __device__ __device_builtin__
|
| 176 |
+
unsigned int __uAtomicMax_block(unsigned int *address, unsigned int val);
|
| 177 |
+
|
| 178 |
+
extern __device__ __device_builtin__
|
| 179 |
+
unsigned int __uAtomicMax_system(unsigned int *address, unsigned int val);
|
| 180 |
+
|
| 181 |
+
extern __device__ __device_builtin__
|
| 182 |
+
unsigned long long __ullAtomicMax_block(unsigned long long *address, unsigned long long val);
|
| 183 |
+
|
| 184 |
+
extern __device__ __device_builtin__
|
| 185 |
+
unsigned long long __ullAtomicMax_system(unsigned long long *address, unsigned long long val);
|
| 186 |
+
|
| 187 |
+
extern __device__ __device_builtin__
|
| 188 |
+
unsigned int __uAtomicInc_block(unsigned int *address, unsigned int val);
|
| 189 |
+
|
| 190 |
+
extern __device__ __device_builtin__
|
| 191 |
+
unsigned int __uAtomicInc_system(unsigned int *address, unsigned int val);
|
| 192 |
+
|
| 193 |
+
extern __device__ __device_builtin__
|
| 194 |
+
unsigned int __uAtomicDec_block(unsigned int *address, unsigned int val);
|
| 195 |
+
|
| 196 |
+
extern __device__ __device_builtin__
|
| 197 |
+
unsigned int __uAtomicDec_system(unsigned int *address, unsigned int val);
|
| 198 |
+
|
| 199 |
+
extern __device__ __device_builtin__
|
| 200 |
+
int __iAtomicCAS_block(int *address, int compare, int val);
|
| 201 |
+
|
| 202 |
+
extern __device__ __device_builtin__
|
| 203 |
+
int __iAtomicCAS_system(int *address, int compare, int val);
|
| 204 |
+
|
| 205 |
+
extern __device__ __device_builtin__
|
| 206 |
+
unsigned int __uAtomicCAS_block(unsigned int *address, unsigned int compare,
|
| 207 |
+
unsigned int val);
|
| 208 |
+
|
| 209 |
+
extern __device__ __device_builtin__
|
| 210 |
+
unsigned int __uAtomicCAS_system(unsigned int *address, unsigned int compare,
|
| 211 |
+
unsigned int val);
|
| 212 |
+
|
| 213 |
+
extern __device__ __device_builtin__
|
| 214 |
+
unsigned long long __ullAtomicCAS_block(unsigned long long int *address,
|
| 215 |
+
unsigned long long int compare,
|
| 216 |
+
unsigned long long int val);
|
| 217 |
+
|
| 218 |
+
extern __device__ __device_builtin__
|
| 219 |
+
unsigned long long __ullAtomicCAS_system(unsigned long long int *address,
|
| 220 |
+
unsigned long long int compare,
|
| 221 |
+
unsigned long long int val);
|
| 222 |
+
|
| 223 |
+
extern __device__ __device_builtin__
|
| 224 |
+
int __iAtomicAnd_block(int *address, int val);
|
| 225 |
+
|
| 226 |
+
extern __device__ __device_builtin__
|
| 227 |
+
int __iAtomicAnd_system(int *address, int val);
|
| 228 |
+
|
| 229 |
+
extern __device__ __device_builtin__
|
| 230 |
+
long long __llAtomicAnd_block(long long *address, long long val);
|
| 231 |
+
|
| 232 |
+
extern __device__ __device_builtin__
|
| 233 |
+
long long __llAtomicAnd_system(long long *address, long long val);
|
| 234 |
+
|
| 235 |
+
extern __device__ __device_builtin__
|
| 236 |
+
unsigned int __uAtomicAnd_block(unsigned int *address, unsigned int val);
|
| 237 |
+
|
| 238 |
+
extern __device__ __device_builtin__
|
| 239 |
+
unsigned int __uAtomicAnd_system(unsigned int *address, unsigned int val);
|
| 240 |
+
|
| 241 |
+
extern __device__ __device_builtin__
|
| 242 |
+
unsigned long long __ullAtomicAnd_block(unsigned long long *address, unsigned long long val);
|
| 243 |
+
|
| 244 |
+
extern __device__ __device_builtin__
|
| 245 |
+
unsigned long long __ullAtomicAnd_system(unsigned long long *address, unsigned long long val);
|
| 246 |
+
|
| 247 |
+
extern __device__ __device_builtin__
|
| 248 |
+
int __iAtomicOr_block(int *address, int val);
|
| 249 |
+
|
| 250 |
+
extern __device__ __device_builtin__
|
| 251 |
+
int __iAtomicOr_system(int *address, int val);
|
| 252 |
+
|
| 253 |
+
extern __device__ __device_builtin__
|
| 254 |
+
long long __llAtomicOr_block(long long *address, long long val);
|
| 255 |
+
|
| 256 |
+
extern __device__ __device_builtin__
|
| 257 |
+
long long __llAtomicOr_system(long long *address, long long val);
|
| 258 |
+
|
| 259 |
+
extern __device__ __device_builtin__
|
| 260 |
+
unsigned int __uAtomicOr_block(unsigned int *address, unsigned int val);
|
| 261 |
+
|
| 262 |
+
extern __device__ __device_builtin__
|
| 263 |
+
unsigned int __uAtomicOr_system(unsigned int *address, unsigned int val);
|
| 264 |
+
|
| 265 |
+
extern __device__ __device_builtin__
|
| 266 |
+
unsigned long long __ullAtomicOr_block(unsigned long long *address, unsigned long long val);
|
| 267 |
+
|
| 268 |
+
extern __device__ __device_builtin__
|
| 269 |
+
unsigned long long __ullAtomicOr_system(unsigned long long *address, unsigned long long val);
|
| 270 |
+
|
| 271 |
+
extern __device__ __device_builtin__
|
| 272 |
+
int __iAtomicXor_block(int *address, int val);
|
| 273 |
+
|
| 274 |
+
extern __device__ __device_builtin__
|
| 275 |
+
int __iAtomicXor_system(int *address, int val);
|
| 276 |
+
|
| 277 |
+
extern __device__ __device_builtin__
|
| 278 |
+
long long __llAtomicXor_block(long long *address, long long val);
|
| 279 |
+
|
| 280 |
+
extern __device__ __device_builtin__
|
| 281 |
+
long long __llAtomicXor_system(long long *address, long long val);
|
| 282 |
+
|
| 283 |
+
extern __device__ __device_builtin__
|
| 284 |
+
unsigned int __uAtomicXor_block(unsigned int *address, unsigned int val);
|
| 285 |
+
|
| 286 |
+
extern __device__ __device_builtin__
|
| 287 |
+
unsigned int __uAtomicXor_system(unsigned int *address, unsigned int val);
|
| 288 |
+
|
| 289 |
+
extern __device__ __device_builtin__
|
| 290 |
+
unsigned long long __ullAtomicXor_block(unsigned long long *address, unsigned long long val);
|
| 291 |
+
|
| 292 |
+
extern __device__ __device_builtin__
|
| 293 |
+
unsigned long long __ullAtomicXor_system(unsigned long long *address, unsigned long long val);
|
| 294 |
+
}
|
| 295 |
+
#endif /* __CUDA_ARCH__ */
|
| 296 |
+
|
| 297 |
+
/*******************************************************************************
|
| 298 |
+
* *
|
| 299 |
+
* *
|
| 300 |
+
* *
|
| 301 |
+
*******************************************************************************/
|
| 302 |
+
|
| 303 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__ double atomicAdd(double *address, double val) __DEF_IF_HOST
|
| 304 |
+
|
| 305 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 306 |
+
int atomicAdd_block(int *address, int val) __DEF_IF_HOST
|
| 307 |
+
|
| 308 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 309 |
+
int atomicAdd_system(int *address, int val) __DEF_IF_HOST
|
| 310 |
+
|
| 311 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 312 |
+
unsigned int atomicAdd_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 313 |
+
|
| 314 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 315 |
+
unsigned int atomicAdd_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 316 |
+
|
| 317 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 318 |
+
unsigned long long atomicAdd_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 319 |
+
|
| 320 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 321 |
+
unsigned long long atomicAdd_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 322 |
+
|
| 323 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 324 |
+
float atomicAdd_block(float *address, float val) __DEF_IF_HOST
|
| 325 |
+
|
| 326 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 327 |
+
float atomicAdd_system(float *address, float val) __DEF_IF_HOST
|
| 328 |
+
|
| 329 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 330 |
+
double atomicAdd_block(double *address, double val) __DEF_IF_HOST
|
| 331 |
+
|
| 332 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 333 |
+
double atomicAdd_system(double *address, double val) __DEF_IF_HOST
|
| 334 |
+
|
| 335 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 336 |
+
int atomicSub_block(int *address, int val) __DEF_IF_HOST
|
| 337 |
+
|
| 338 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 339 |
+
int atomicSub_system(int *address, int val) __DEF_IF_HOST
|
| 340 |
+
|
| 341 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 342 |
+
unsigned int atomicSub_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 343 |
+
|
| 344 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 345 |
+
unsigned int atomicSub_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 346 |
+
|
| 347 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 348 |
+
int atomicExch_block(int *address, int val) __DEF_IF_HOST
|
| 349 |
+
|
| 350 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 351 |
+
int atomicExch_system(int *address, int val) __DEF_IF_HOST
|
| 352 |
+
|
| 353 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 354 |
+
unsigned int atomicExch_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 355 |
+
|
| 356 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 357 |
+
unsigned int atomicExch_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 358 |
+
|
| 359 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 360 |
+
unsigned long long atomicExch_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 361 |
+
|
| 362 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 363 |
+
unsigned long long atomicExch_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 364 |
+
|
| 365 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 366 |
+
float atomicExch_block(float *address, float val) __DEF_IF_HOST
|
| 367 |
+
|
| 368 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 369 |
+
float atomicExch_system(float *address, float val) __DEF_IF_HOST
|
| 370 |
+
|
| 371 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 372 |
+
int atomicMin_block(int *address, int val) __DEF_IF_HOST
|
| 373 |
+
|
| 374 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 375 |
+
int atomicMin_system(int *address, int val) __DEF_IF_HOST
|
| 376 |
+
|
| 377 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 378 |
+
long long atomicMin_block(long long *address, long long val) __DEF_IF_HOST
|
| 379 |
+
|
| 380 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 381 |
+
long long atomicMin_system(long long *address, long long val) __DEF_IF_HOST
|
| 382 |
+
|
| 383 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 384 |
+
unsigned int atomicMin_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 385 |
+
|
| 386 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 387 |
+
unsigned int atomicMin_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 388 |
+
|
| 389 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 390 |
+
unsigned long long atomicMin_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 391 |
+
|
| 392 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 393 |
+
unsigned long long atomicMin_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 394 |
+
|
| 395 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 396 |
+
int atomicMax_block(int *address, int val) __DEF_IF_HOST
|
| 397 |
+
|
| 398 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 399 |
+
int atomicMax_system(int *address, int val) __DEF_IF_HOST
|
| 400 |
+
|
| 401 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 402 |
+
long long atomicMax_block(long long *address, long long val) __DEF_IF_HOST
|
| 403 |
+
|
| 404 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 405 |
+
long long atomicMax_system(long long *address, long long val) __DEF_IF_HOST
|
| 406 |
+
|
| 407 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 408 |
+
unsigned int atomicMax_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 409 |
+
|
| 410 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 411 |
+
unsigned int atomicMax_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 412 |
+
|
| 413 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 414 |
+
unsigned long long atomicMax_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 415 |
+
|
| 416 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 417 |
+
unsigned long long atomicMax_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 418 |
+
|
| 419 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 420 |
+
unsigned int atomicInc_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 421 |
+
|
| 422 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 423 |
+
unsigned int atomicInc_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 424 |
+
|
| 425 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 426 |
+
unsigned int atomicDec_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 427 |
+
|
| 428 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 429 |
+
unsigned int atomicDec_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 430 |
+
|
| 431 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 432 |
+
int atomicCAS_block(int *address, int compare, int val) __DEF_IF_HOST
|
| 433 |
+
|
| 434 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 435 |
+
int atomicCAS_system(int *address, int compare, int val) __DEF_IF_HOST
|
| 436 |
+
|
| 437 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 438 |
+
unsigned int atomicCAS_block(unsigned int *address, unsigned int compare,
|
| 439 |
+
unsigned int val) __DEF_IF_HOST
|
| 440 |
+
|
| 441 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 442 |
+
unsigned int atomicCAS_system(unsigned int *address, unsigned int compare,
|
| 443 |
+
unsigned int val) __DEF_IF_HOST
|
| 444 |
+
|
| 445 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 446 |
+
unsigned long long int atomicCAS_block(unsigned long long int *address,
|
| 447 |
+
unsigned long long int compare,
|
| 448 |
+
unsigned long long int val) __DEF_IF_HOST
|
| 449 |
+
|
| 450 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 451 |
+
unsigned long long int atomicCAS_system(unsigned long long int *address,
|
| 452 |
+
unsigned long long int compare,
|
| 453 |
+
unsigned long long int val) __DEF_IF_HOST
|
| 454 |
+
|
| 455 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 456 |
+
int atomicAnd_block(int *address, int val) __DEF_IF_HOST
|
| 457 |
+
|
| 458 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 459 |
+
int atomicAnd_system(int *address, int val) __DEF_IF_HOST
|
| 460 |
+
|
| 461 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 462 |
+
long long atomicAnd_block(long long *address, long long val) __DEF_IF_HOST
|
| 463 |
+
|
| 464 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 465 |
+
long long atomicAnd_system(long long *address, long long val) __DEF_IF_HOST
|
| 466 |
+
|
| 467 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 468 |
+
unsigned int atomicAnd_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 469 |
+
|
| 470 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 471 |
+
unsigned int atomicAnd_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 472 |
+
|
| 473 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 474 |
+
unsigned long long atomicAnd_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 475 |
+
|
| 476 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 477 |
+
unsigned long long atomicAnd_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 478 |
+
|
| 479 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 480 |
+
int atomicOr_block(int *address, int val) __DEF_IF_HOST
|
| 481 |
+
|
| 482 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 483 |
+
int atomicOr_system(int *address, int val) __DEF_IF_HOST
|
| 484 |
+
|
| 485 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 486 |
+
long long atomicOr_block(long long *address, long long val) __DEF_IF_HOST
|
| 487 |
+
|
| 488 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 489 |
+
long long atomicOr_system(long long *address, long long val) __DEF_IF_HOST
|
| 490 |
+
|
| 491 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 492 |
+
unsigned int atomicOr_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 493 |
+
|
| 494 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 495 |
+
unsigned int atomicOr_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 496 |
+
|
| 497 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 498 |
+
unsigned long long atomicOr_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 499 |
+
|
| 500 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 501 |
+
unsigned long long atomicOr_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 502 |
+
|
| 503 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 504 |
+
int atomicXor_block(int *address, int val) __DEF_IF_HOST
|
| 505 |
+
|
| 506 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 507 |
+
int atomicXor_system(int *address, int val) __DEF_IF_HOST
|
| 508 |
+
|
| 509 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 510 |
+
long long atomicXor_block(long long *address, long long val) __DEF_IF_HOST
|
| 511 |
+
|
| 512 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 513 |
+
long long atomicXor_system(long long *address, long long val) __DEF_IF_HOST
|
| 514 |
+
|
| 515 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 516 |
+
unsigned int atomicXor_block(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 517 |
+
|
| 518 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 519 |
+
unsigned int atomicXor_system(unsigned int *address, unsigned int val) __DEF_IF_HOST
|
| 520 |
+
|
| 521 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 522 |
+
unsigned long long atomicXor_block(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 523 |
+
|
| 524 |
+
__SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 525 |
+
unsigned long long atomicXor_system(unsigned long long *address, unsigned long long val) __DEF_IF_HOST
|
| 526 |
+
|
| 527 |
+
#endif /* !__CUDA_ARCH__ || __CUDA_ARCH__ >= 600 */
|
| 528 |
+
|
| 529 |
+
#endif /* __cplusplus && __CUDACC__ */
|
| 530 |
+
|
| 531 |
+
#undef __SM_60_ATOMIC_FUNCTIONS_DECL__
|
| 532 |
+
#undef __DEF_IF_HOST
|
| 533 |
+
|
| 534 |
+
#if !defined(__CUDACC_RTC__) && defined(__CUDA_ARCH__)
|
| 535 |
+
#include "sm_60_atomic_functions.hpp"
|
| 536 |
+
#endif /* !__CUDACC_RTC__ && defined(__CUDA_ARCH__) */
|
| 537 |
+
|
| 538 |
+
#endif /* !__SM_60_ATOMIC_FUNCTIONS_H__ */
|
| 539 |
+
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (220 Bytes). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExt.h
ADDED
|
@@ -0,0 +1,1561 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
/** \file nvToolsExt.h
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
/* ========================================================================= */
|
| 42 |
+
/** \mainpage
|
| 43 |
+
* \tableofcontents
|
| 44 |
+
* \section INTRODUCTION Introduction
|
| 45 |
+
*
|
| 46 |
+
* The NVIDIA Tools Extension library is a set of functions that a
|
| 47 |
+
* developer can use to provide additional information to tools.
|
| 48 |
+
* The additional information is used by the tool to improve
|
| 49 |
+
* analysis and visualization of data.
|
| 50 |
+
*
|
| 51 |
+
* The library introduces close to zero overhead if no tool is
|
| 52 |
+
* attached to the application. The overhead when a tool is
|
| 53 |
+
* attached is specific to the tool.
|
| 54 |
+
*
|
| 55 |
+
* \section INITIALIZATION_SECTION Initialization
|
| 56 |
+
*
|
| 57 |
+
* Typically the tool's library that plugs into NVTX is indirectly
|
| 58 |
+
* loaded via enviromental properties that are platform specific.
|
| 59 |
+
* For some platform or special cases, the user may be required
|
| 60 |
+
* to instead explicity initialize instead though. This can also
|
| 61 |
+
* be helpful to control when the API loads a tool's library instead
|
| 62 |
+
* of what would typically be the first function call to emit info.
|
| 63 |
+
* For these rare case, see \ref INITIALIZATION for additional information.
|
| 64 |
+
*
|
| 65 |
+
* \section MARKERS_AND_RANGES Markers and Ranges
|
| 66 |
+
*
|
| 67 |
+
* Markers and ranges are used to describe events at a specific time (markers)
|
| 68 |
+
* or over a time span (ranges) during the execution of the application
|
| 69 |
+
* respectively.
|
| 70 |
+
*
|
| 71 |
+
* \subsection MARKERS Markers
|
| 72 |
+
*
|
| 73 |
+
* Markers denote specific moments in time.
|
| 74 |
+
*
|
| 75 |
+
*
|
| 76 |
+
* See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
|
| 77 |
+
* how to specify the domain.
|
| 78 |
+
*
|
| 79 |
+
* \subsection THREAD_RANGES Thread Ranges
|
| 80 |
+
*
|
| 81 |
+
* Thread ranges denote nested time ranges. Nesting is maintained per thread
|
| 82 |
+
* per domain and does not require any additional correlation mechanism. The
|
| 83 |
+
* duration of a thread range is defined by the corresponding pair of
|
| 84 |
+
* nvtxRangePush* to nvtxRangePop API calls.
|
| 85 |
+
*
|
| 86 |
+
* See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
|
| 87 |
+
* how to specify the domain.
|
| 88 |
+
*
|
| 89 |
+
* \subsection PROCESS_RANGES Process Ranges
|
| 90 |
+
*
|
| 91 |
+
* Process ranges denote a time span that can expose arbitrary concurrency, as
|
| 92 |
+
* opposed to thread ranges that only support nesting. In addition the range
|
| 93 |
+
* start event can happen on a different thread than the end marker. For the
|
| 94 |
+
* correlation of a start/end pair an unique correlation ID is used that is
|
| 95 |
+
* returned from the start API call and needs to be passed into the end API
|
| 96 |
+
* call.
|
| 97 |
+
*
|
| 98 |
+
* \subsection EVENT_ATTRIBUTES Event Attributes
|
| 99 |
+
*
|
| 100 |
+
* \ref MARKERS_AND_RANGES can be annotated with various attributes to provide
|
| 101 |
+
* additional information for an event or to guide the tool's visualization of
|
| 102 |
+
* the data. Each of the attributes is optional and if left unused the
|
| 103 |
+
* attributes fall back to a default value. The attributes include:
|
| 104 |
+
* - color
|
| 105 |
+
* - category
|
| 106 |
+
*
|
| 107 |
+
* To specify any attribute other than the text message, the \ref
|
| 108 |
+
* EVENT_ATTRIBUTE_STRUCTURE "Event Attribute Structure" must be used.
|
| 109 |
+
*
|
| 110 |
+
* \section DOMAINS Domains
|
| 111 |
+
*
|
| 112 |
+
* Domains enable developers to scope annotations. By default all events and
|
| 113 |
+
* annotations are in the default domain. Additional domains can be registered.
|
| 114 |
+
* This allows developers to scope markers, ranges, and resources names to
|
| 115 |
+
* avoid conflicts.
|
| 116 |
+
*
|
| 117 |
+
* The function ::nvtxDomainCreateA or ::nvtxDomainCreateW is used to create
|
| 118 |
+
* a named domain.
|
| 119 |
+
*
|
| 120 |
+
* Each domain maintains its own
|
| 121 |
+
* - categories
|
| 122 |
+
* - thread range stacks
|
| 123 |
+
* - registered strings
|
| 124 |
+
*
|
| 125 |
+
* The function ::nvtxDomainDestroy marks the end of the domain. Destroying
|
| 126 |
+
* a domain unregisters and destroys all objects associated with it such as
|
| 127 |
+
* registered strings, resource objects, named categories, and started ranges.
|
| 128 |
+
*
|
| 129 |
+
* \section RESOURCE_NAMING Resource Naming
|
| 130 |
+
*
|
| 131 |
+
* This section covers calls that allow to annotate objects with user-provided
|
| 132 |
+
* names in order to allow for a better analysis of complex trace data. All of
|
| 133 |
+
* the functions take the handle or the ID of the object to name and the name.
|
| 134 |
+
* The functions can be called multiple times during the execution of an
|
| 135 |
+
* application, however, in that case it is implementation dependent which
|
| 136 |
+
* name will be reported by the tool.
|
| 137 |
+
*
|
| 138 |
+
* \subsection CATEGORY_NAMING Category Naming
|
| 139 |
+
*
|
| 140 |
+
* Some function in this library support associating an integer category
|
| 141 |
+
* to enable filtering and sorting. The category naming functions allow
|
| 142 |
+
* the application to associate a user friendly name with the integer
|
| 143 |
+
* category. Support for domains have been added in NVTX_VERSION_2 to
|
| 144 |
+
* avoid collisions when domains are developed independantly.
|
| 145 |
+
*
|
| 146 |
+
* \subsection RESOURCE_OBJECTS Resource Objects
|
| 147 |
+
*
|
| 148 |
+
* Resource objects are a generic mechanism for attaching data to an application
|
| 149 |
+
* resource. The identifier field makes the association to a pointer or handle,
|
| 150 |
+
* while the type field helps provide deeper understanding of the identifier as
|
| 151 |
+
* well as enabling differentiation in cases where handles generated by different
|
| 152 |
+
* APIs may collide. The resource object may also have an associated message to
|
| 153 |
+
* associate with the application resource, enabling further annotation of this
|
| 154 |
+
* object and how it is used.
|
| 155 |
+
*
|
| 156 |
+
* The resource object was introduced in NVTX_VERSION_2 to supersede existing naming
|
| 157 |
+
* functions and allow the application resource identified by those functions to be
|
| 158 |
+
* associated to a domain. The other naming functions are still supported for backward
|
| 159 |
+
* compatibility but will be associated only to the default domain.
|
| 160 |
+
*
|
| 161 |
+
* \subsection RESOURCE_NAMING_OS Resource Naming
|
| 162 |
+
*
|
| 163 |
+
* Some operating system resources creation APIs do not support providing a user friendly
|
| 164 |
+
* name, such as some OS thread creation APIs. This API support resource naming though
|
| 165 |
+
* both through resource objects and functions following the pattern
|
| 166 |
+
* nvtxName[RESOURCE_TYPE][A|W](identifier, name). Resource objects introduced in NVTX_VERSION 2
|
| 167 |
+
* supersede the other functions with a a more general method of assigning names to OS resources,
|
| 168 |
+
* along with associating them to domains too. The older nvtxName* functions are only associated
|
| 169 |
+
* with the default domain.
|
| 170 |
+
* \section EXTENSIONS Optional Extensions
|
| 171 |
+
* Optional extensions will either appear within the existing sections the extend or appear
|
| 172 |
+
* in the "Related Pages" when they introduce new concepts.
|
| 173 |
+
*/
|
| 174 |
+
|
| 175 |
+
#ifndef NVTOOLSEXT_H_
|
| 176 |
+
#define NVTOOLSEXT_H_
|
| 177 |
+
|
| 178 |
+
#if defined(_MSC_VER)
|
| 179 |
+
#ifdef NVTX_EXPORTS
|
| 180 |
+
#define NVTX_DECLSPEC
|
| 181 |
+
#else
|
| 182 |
+
#define NVTX_DECLSPEC __declspec(dllimport)
|
| 183 |
+
#endif /* NVTX_EXPORTS */
|
| 184 |
+
#define NVTX_API __stdcall
|
| 185 |
+
#define NVTX_INLINE_STATIC __inline static
|
| 186 |
+
#else /*defined(__GNUC__)*/
|
| 187 |
+
#define NVTX_DECLSPEC
|
| 188 |
+
#define NVTX_API
|
| 189 |
+
#define NVTX_INLINE_STATIC inline static
|
| 190 |
+
#endif /* Platform */
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* The nvToolsExt library depends on stdint.h. If the build tool chain in use
|
| 194 |
+
* does not include stdint.h then define NVTX_STDINT_TYPES_ALREADY_DEFINED
|
| 195 |
+
* and define the following types:
|
| 196 |
+
* <ul>
|
| 197 |
+
* <li>uint8_t
|
| 198 |
+
* <li>int8_t
|
| 199 |
+
* <li>uint16_t
|
| 200 |
+
* <li>int16_t
|
| 201 |
+
* <li>uint32_t
|
| 202 |
+
* <li>int32_t
|
| 203 |
+
* <li>uint64_t
|
| 204 |
+
* <li>int64_t
|
| 205 |
+
* <li>uintptr_t
|
| 206 |
+
* <li>intptr_t
|
| 207 |
+
* </ul>
|
| 208 |
+
#define NVTX_STDINT_TYPES_ALREADY_DEFINED if you are using your own header file.
|
| 209 |
+
*/
|
| 210 |
+
#ifndef NVTX_STDINT_TYPES_ALREADY_DEFINED
|
| 211 |
+
#include <stdint.h>
|
| 212 |
+
#endif
|
| 213 |
+
|
| 214 |
+
#include <stddef.h>
|
| 215 |
+
|
| 216 |
+
#ifdef __cplusplus
|
| 217 |
+
extern "C" {
|
| 218 |
+
#endif /* __cplusplus */
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* Tools Extension API version
|
| 222 |
+
*/
|
| 223 |
+
#define NVTX_VERSION 2
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* Size of the nvtxEventAttributes_t structure.
|
| 227 |
+
*/
|
| 228 |
+
#define NVTX_EVENT_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxEventAttributes_t) ) )
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Size of the nvtxInitializationAttributes_t structure.
|
| 232 |
+
*/
|
| 233 |
+
#define NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxInitializationAttributes_t) ) )
|
| 234 |
+
|
| 235 |
+
#define NVTX_NO_PUSH_POP_TRACKING ((int)-2)
|
| 236 |
+
|
| 237 |
+
typedef uint64_t nvtxRangeId_t;
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
/* \brief String Handle Structure.
|
| 241 |
+
* \anchor STRING_HANDLE_STRUCTURE
|
| 242 |
+
*
|
| 243 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 244 |
+
* a string. The tools will return a pointer through the API for the application
|
| 245 |
+
* to hold on it's behalf to reference the string in the future.
|
| 246 |
+
*
|
| 247 |
+
*/
|
| 248 |
+
typedef struct nvtxStringHandle* nvtxStringHandle_t;
|
| 249 |
+
|
| 250 |
+
/* \brief Domain Handle Structure.
|
| 251 |
+
* \anchor DOMAIN_HANDLE_STRUCTURE
|
| 252 |
+
*
|
| 253 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 254 |
+
* a domain. The tools will return a pointer through the API for the application
|
| 255 |
+
* to hold on its behalf to reference the domain in the future.
|
| 256 |
+
*
|
| 257 |
+
*/
|
| 258 |
+
typedef struct nvtxDomainHandle* nvtxDomainHandle_t;
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
/* ========================================================================= */
|
| 266 |
+
/** \defgroup GENERAL General
|
| 267 |
+
* @{
|
| 268 |
+
*/
|
| 269 |
+
|
| 270 |
+
/** ---------------------------------------------------------------------------
|
| 271 |
+
* Color Types
|
| 272 |
+
* ------------------------------------------------------------------------- */
|
| 273 |
+
typedef enum nvtxColorType_t
|
| 274 |
+
{
|
| 275 |
+
NVTX_COLOR_UNKNOWN = 0, /**< Color attribute is unused. */
|
| 276 |
+
NVTX_COLOR_ARGB = 1 /**< An ARGB color is provided. */
|
| 277 |
+
} nvtxColorType_t;
|
| 278 |
+
|
| 279 |
+
/** ---------------------------------------------------------------------------
|
| 280 |
+
* Message Types
|
| 281 |
+
* ------------------------------------------------------------------------- */
|
| 282 |
+
typedef enum nvtxMessageType_t
|
| 283 |
+
{
|
| 284 |
+
NVTX_MESSAGE_UNKNOWN = 0, /**< Message payload is unused. */
|
| 285 |
+
NVTX_MESSAGE_TYPE_ASCII = 1, /**< A character sequence is used as payload. */
|
| 286 |
+
NVTX_MESSAGE_TYPE_UNICODE = 2, /**< A wide character sequence is used as payload. */
|
| 287 |
+
/* NVTX_VERSION_2 */
|
| 288 |
+
NVTX_MESSAGE_TYPE_REGISTERED = 3 /**< A unique string handle that was registered
|
| 289 |
+
with \ref nvtxDomainRegisterStringA() or
|
| 290 |
+
\ref nvtxDomainRegisterStringW(). */
|
| 291 |
+
} nvtxMessageType_t;
|
| 292 |
+
|
| 293 |
+
typedef union nvtxMessageValue_t
|
| 294 |
+
{
|
| 295 |
+
const char* ascii;
|
| 296 |
+
const wchar_t* unicode;
|
| 297 |
+
/* NVTX_VERSION_2 */
|
| 298 |
+
nvtxStringHandle_t registered;
|
| 299 |
+
} nvtxMessageValue_t;
|
| 300 |
+
|
| 301 |
+
|
| 302 |
+
/** @} */ /*END defgroup*/
|
| 303 |
+
|
| 304 |
+
/* ========================================================================= */
|
| 305 |
+
/** \defgroup INITIALIZATION Initialization
|
| 306 |
+
* @{
|
| 307 |
+
* Typically the tool's library that plugs into NVTX is indirectly
|
| 308 |
+
* loaded via enviromental properties that are platform specific.
|
| 309 |
+
* For some platform or special cases, the user may be required
|
| 310 |
+
* to instead explicity initialize instead though. This can also
|
| 311 |
+
* be helpful to control when the API loads a tool's library instead
|
| 312 |
+
* of what would typically be the first function call to emit info.
|
| 313 |
+
*/
|
| 314 |
+
|
| 315 |
+
/** ---------------------------------------------------------------------------
|
| 316 |
+
* Initialization Modes
|
| 317 |
+
* ------------------------------------------------------------------------- */
|
| 318 |
+
typedef enum nvtxInitializationMode_t
|
| 319 |
+
{
|
| 320 |
+
NVTX_INITIALIZATION_MODE_UNKNOWN = 0, /**< A platform that supports indirect initialization will attempt this style, otherwise expect failure. */
|
| 321 |
+
NVTX_INITIALIZATION_MODE_CALLBACK_V1 = 1, /**< A function pointer conforming to NVTX_VERSION=1 will be used. */
|
| 322 |
+
NVTX_INITIALIZATION_MODE_CALLBACK_V2 = 2, /**< A function pointer conforming to NVTX_VERSION=2 will be used. */
|
| 323 |
+
NVTX_INITIALIZATION_MODE_SIZE
|
| 324 |
+
} nvtxInitializationMode_t;
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
/** \brief Initialization Attribute Structure.
|
| 328 |
+
* \anchor INITIALIZATION_ATTRIBUTE_STRUCTURE
|
| 329 |
+
*
|
| 330 |
+
* This structure is used to describe the attributes used for initialization
|
| 331 |
+
* of the NVTX API.
|
| 332 |
+
*
|
| 333 |
+
* \par Initializing the Attributes
|
| 334 |
+
*
|
| 335 |
+
* The caller should always perform the following three tasks when using
|
| 336 |
+
* attributes:
|
| 337 |
+
* <ul>
|
| 338 |
+
* <li>Zero the structure
|
| 339 |
+
* <li>Set the version field
|
| 340 |
+
* <li>Set the size field
|
| 341 |
+
* </ul>
|
| 342 |
+
*
|
| 343 |
+
* Zeroing the structure sets all the event attributes types and values
|
| 344 |
+
* to the default value.
|
| 345 |
+
*
|
| 346 |
+
* The version and size field are used by the Tools Extension
|
| 347 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 348 |
+
* NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE may be used for the size.
|
| 349 |
+
*
|
| 350 |
+
* It is recommended that the caller use one of the following to methods
|
| 351 |
+
* to initialize the event attributes structure:
|
| 352 |
+
*
|
| 353 |
+
* \par Method 1: Initializing nvtxInitializationAttributes_t for future compatibility
|
| 354 |
+
* \code
|
| 355 |
+
* nvtxInitializationAttributes_t initAttribs = {0};
|
| 356 |
+
* initAttribs.version = NVTX_VERSION;
|
| 357 |
+
* initAttribs.size = NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE;
|
| 358 |
+
* \endcode
|
| 359 |
+
*
|
| 360 |
+
* \par Method 2: Initializing nvtxInitializationAttributes_t for a specific version
|
| 361 |
+
* \code
|
| 362 |
+
* nvtxInitializationAttributes_t initAttribs = {0};
|
| 363 |
+
* initAttribs.version =2;
|
| 364 |
+
* initAttribs.size = (uint16_t)(sizeof(nvtxInitializationAttributes_v2));
|
| 365 |
+
* \endcode
|
| 366 |
+
*
|
| 367 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 368 |
+
* layout of the structure be configured to 0 so that all fields
|
| 369 |
+
* are initialized to the default value.
|
| 370 |
+
*
|
| 371 |
+
* The caller should either use both NVTX_VERSION and
|
| 372 |
+
* NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 373 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 374 |
+
* will likely cause either source level incompatibility or binary
|
| 375 |
+
* incompatibility in the future.
|
| 376 |
+
*
|
| 377 |
+
* \par Settings Attribute Types and Values
|
| 378 |
+
*
|
| 379 |
+
*
|
| 380 |
+
* \par Example:
|
| 381 |
+
* \code
|
| 382 |
+
* // Initialize
|
| 383 |
+
* nvtxInitializationAttributes_t initAttribs = {0};
|
| 384 |
+
* initAttribs.version = NVTX_VERSION;
|
| 385 |
+
* initAttribs.size = NVTX_INITIALIZATION_ATTRIB_STRUCT_SIZE;
|
| 386 |
+
*
|
| 387 |
+
* // Configure the Attributes
|
| 388 |
+
* initAttribs.mode = NVTX_INITIALIZATION_MODE_CALLBACK_V2;
|
| 389 |
+
* initAttribs.fnptr = InitializeInjectionNvtx2;
|
| 390 |
+
* \endcode
|
| 391 |
+
|
| 392 |
+
* \sa
|
| 393 |
+
* ::nvtxInitializationMode_t
|
| 394 |
+
* ::nvtxInitialize
|
| 395 |
+
*/
|
| 396 |
+
typedef struct nvtxInitializationAttributes_v2
|
| 397 |
+
{
|
| 398 |
+
/**
|
| 399 |
+
* \brief Version flag of the structure.
|
| 400 |
+
*
|
| 401 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 402 |
+
* supported in this header file. This can optionally be overridden to
|
| 403 |
+
* another version of the tools extension library.
|
| 404 |
+
*/
|
| 405 |
+
uint16_t version;
|
| 406 |
+
|
| 407 |
+
/**
|
| 408 |
+
* \brief Size of the structure.
|
| 409 |
+
*
|
| 410 |
+
* Needs to be set to the size in bytes of the event attribute
|
| 411 |
+
* structure used to specify the event.
|
| 412 |
+
*/
|
| 413 |
+
uint16_t size;
|
| 414 |
+
|
| 415 |
+
/**
|
| 416 |
+
* \brief Mode of initialization.
|
| 417 |
+
*
|
| 418 |
+
* The mode of initialization dictates the overall behavior and which
|
| 419 |
+
* attributes in this struct will be used.
|
| 420 |
+
*
|
| 421 |
+
* Default Value is NVTX_INITIALIZATION_MODE_UNKNOWN = 0
|
| 422 |
+
* \sa
|
| 423 |
+
* ::nvtxInitializationMode_t
|
| 424 |
+
*/
|
| 425 |
+
uint32_t mode;
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* \brief Function pointer used for initialization if the mode requires
|
| 429 |
+
*
|
| 430 |
+
* The user has retrieved this function pointer from the tool library
|
| 431 |
+
* and would like to use it to initialize. The mode must be set to a
|
| 432 |
+
* NVTX_INITIALIZATION_MODE_CALLBACK_V# for this to be used. The mode
|
| 433 |
+
* will dictate the expectations for this member. The function signature
|
| 434 |
+
* will be cast from void(*)() to the appropriate signature for the mode.
|
| 435 |
+
* the expected behavior of the function will also depend on the mode
|
| 436 |
+
* beyond the simple function signature.
|
| 437 |
+
*
|
| 438 |
+
* Default Value is NVTX_INITIALIZATION_MODE_UNKNOWN which will either
|
| 439 |
+
* initialize based on external properties or fail if not supported on
|
| 440 |
+
* the given platform.
|
| 441 |
+
|
| 442 |
+
* \sa
|
| 443 |
+
* ::nvtxInitializationMode_t
|
| 444 |
+
*/
|
| 445 |
+
void(*fnptr)(void);
|
| 446 |
+
|
| 447 |
+
} nvtxInitializationAttributes_v2;
|
| 448 |
+
|
| 449 |
+
typedef struct nvtxInitializationAttributes_v2 nvtxInitializationAttributes_t;
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
/* ------------------------------------------------------------------------- */
|
| 453 |
+
/** \brief Force initialization (optional on most platforms)
|
| 454 |
+
*
|
| 455 |
+
* Force NVTX library to initialize. On some platform NVTX will implicit initialize
|
| 456 |
+
* upon the first function call into an NVTX API.
|
| 457 |
+
*
|
| 458 |
+
* \return Result codes are simplest to assume NVTX_SUCCESS or !NVTX_SUCCESS
|
| 459 |
+
*
|
| 460 |
+
* \param initAttrib - The initialization attribute structure
|
| 461 |
+
*
|
| 462 |
+
* \sa
|
| 463 |
+
* ::nvtxInitializationAttributes_t
|
| 464 |
+
*
|
| 465 |
+
* \version \NVTX_VERSION_2
|
| 466 |
+
* @{ */
|
| 467 |
+
NVTX_DECLSPEC int NVTX_API nvtxInitialize(const nvtxInitializationAttributes_t* initAttrib);
|
| 468 |
+
/** @} */
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
/** @} */ /*END defgroup*/
|
| 472 |
+
|
| 473 |
+
/* ========================================================================= */
|
| 474 |
+
/** \defgroup EVENT_ATTRIBUTES Event Attributes
|
| 475 |
+
* @{
|
| 476 |
+
*/
|
| 477 |
+
|
| 478 |
+
/** ---------------------------------------------------------------------------
|
| 479 |
+
* Payload Types
|
| 480 |
+
* ------------------------------------------------------------------------- */
|
| 481 |
+
typedef enum nvtxPayloadType_t
|
| 482 |
+
{
|
| 483 |
+
NVTX_PAYLOAD_UNKNOWN = 0, /**< Color payload is unused. */
|
| 484 |
+
NVTX_PAYLOAD_TYPE_UNSIGNED_INT64 = 1, /**< A 64 bit unsigned integer value is used as payload. */
|
| 485 |
+
NVTX_PAYLOAD_TYPE_INT64 = 2, /**< A 64 bit signed integer value is used as payload. */
|
| 486 |
+
NVTX_PAYLOAD_TYPE_DOUBLE = 3, /**< A 64 bit floating point value is used as payload. */
|
| 487 |
+
/* NVTX_VERSION_2 */
|
| 488 |
+
NVTX_PAYLOAD_TYPE_UNSIGNED_INT32 = 4, /**< A 32 bit floating point value is used as payload. */
|
| 489 |
+
NVTX_PAYLOAD_TYPE_INT32 = 5, /**< A 32 bit floating point value is used as payload. */
|
| 490 |
+
NVTX_PAYLOAD_TYPE_FLOAT = 6 /**< A 32 bit floating point value is used as payload. */
|
| 491 |
+
} nvtxPayloadType_t;
|
| 492 |
+
|
| 493 |
+
/** \brief Event Attribute Structure.
|
| 494 |
+
* \anchor EVENT_ATTRIBUTE_STRUCTURE
|
| 495 |
+
*
|
| 496 |
+
* This structure is used to describe the attributes of an event. The layout of
|
| 497 |
+
* the structure is defined by a specific version of the tools extension
|
| 498 |
+
* library and can change between different versions of the Tools Extension
|
| 499 |
+
* library.
|
| 500 |
+
*
|
| 501 |
+
* \par Initializing the Attributes
|
| 502 |
+
*
|
| 503 |
+
* The caller should always perform the following three tasks when using
|
| 504 |
+
* attributes:
|
| 505 |
+
* <ul>
|
| 506 |
+
* <li>Zero the structure
|
| 507 |
+
* <li>Set the version field
|
| 508 |
+
* <li>Set the size field
|
| 509 |
+
* </ul>
|
| 510 |
+
*
|
| 511 |
+
* Zeroing the structure sets all the event attributes types and values
|
| 512 |
+
* to the default value.
|
| 513 |
+
*
|
| 514 |
+
* The version and size field are used by the Tools Extension
|
| 515 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 516 |
+
*
|
| 517 |
+
* It is recommended that the caller use one of the following to methods
|
| 518 |
+
* to initialize the event attributes structure:
|
| 519 |
+
*
|
| 520 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 521 |
+
* \code
|
| 522 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 523 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 524 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 525 |
+
* \endcode
|
| 526 |
+
*
|
| 527 |
+
* \par Method 2: Initializing nvtxEventAttributes for a specific version
|
| 528 |
+
* \code
|
| 529 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 530 |
+
* eventAttrib.version = 1;
|
| 531 |
+
* eventAttrib.size = (uint16_t)(sizeof(nvtxEventAttributes_v1));
|
| 532 |
+
* \endcode
|
| 533 |
+
*
|
| 534 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 535 |
+
* layout of the structure be configured to 0 so that all fields
|
| 536 |
+
* are initialized to the default value.
|
| 537 |
+
*
|
| 538 |
+
* The caller should either use both NVTX_VERSION and
|
| 539 |
+
* NVTX_EVENT_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 540 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 541 |
+
* will likely cause either source level incompatibility or binary
|
| 542 |
+
* incompatibility in the future.
|
| 543 |
+
*
|
| 544 |
+
* \par Settings Attribute Types and Values
|
| 545 |
+
*
|
| 546 |
+
*
|
| 547 |
+
* \par Example:
|
| 548 |
+
* \code
|
| 549 |
+
* // Initialize
|
| 550 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 551 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 552 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 553 |
+
*
|
| 554 |
+
* // Configure the Attributes
|
| 555 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 556 |
+
* eventAttrib.color = 0xFF880000;
|
| 557 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 558 |
+
* eventAttrib.message.ascii = "Example";
|
| 559 |
+
* \endcode
|
| 560 |
+
*
|
| 561 |
+
* In the example the caller does not have to set the value of
|
| 562 |
+
* \ref ::nvtxEventAttributes_v2::category or
|
| 563 |
+
* \ref ::nvtxEventAttributes_v2::payload as these fields were set to
|
| 564 |
+
* the default value by {0}.
|
| 565 |
+
* \sa
|
| 566 |
+
* ::nvtxDomainMarkEx
|
| 567 |
+
* ::nvtxDomainRangeStartEx
|
| 568 |
+
* ::nvtxDomainRangePushEx
|
| 569 |
+
*/
|
| 570 |
+
typedef struct nvtxEventAttributes_v2
|
| 571 |
+
{
|
| 572 |
+
/**
|
| 573 |
+
* \brief Version flag of the structure.
|
| 574 |
+
*
|
| 575 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 576 |
+
* supported in this header file. This can optionally be overridden to
|
| 577 |
+
* another version of the tools extension library.
|
| 578 |
+
*/
|
| 579 |
+
uint16_t version;
|
| 580 |
+
|
| 581 |
+
/**
|
| 582 |
+
* \brief Size of the structure.
|
| 583 |
+
*
|
| 584 |
+
* Needs to be set to the size in bytes of the event attribute
|
| 585 |
+
* structure used to specify the event.
|
| 586 |
+
*/
|
| 587 |
+
uint16_t size;
|
| 588 |
+
|
| 589 |
+
/**
|
| 590 |
+
* \brief ID of the category the event is assigned to.
|
| 591 |
+
*
|
| 592 |
+
* A category is a user-controlled ID that can be used to group
|
| 593 |
+
* events. The tool may use category IDs to improve filtering or
|
| 594 |
+
* enable grouping of events in the same category. The functions
|
| 595 |
+
* \ref ::nvtxNameCategoryA or \ref ::nvtxNameCategoryW can be used
|
| 596 |
+
* to name a category.
|
| 597 |
+
*
|
| 598 |
+
* Default Value is 0
|
| 599 |
+
*/
|
| 600 |
+
uint32_t category;
|
| 601 |
+
|
| 602 |
+
/** \brief Color type specified in this attribute structure.
|
| 603 |
+
*
|
| 604 |
+
* Defines the color format of the attribute structure's \ref COLOR_FIELD
|
| 605 |
+
* "color" field.
|
| 606 |
+
*
|
| 607 |
+
* Default Value is NVTX_COLOR_UNKNOWN
|
| 608 |
+
*/
|
| 609 |
+
int32_t colorType; /* nvtxColorType_t */
|
| 610 |
+
|
| 611 |
+
/** \brief Color assigned to this event. \anchor COLOR_FIELD
|
| 612 |
+
*
|
| 613 |
+
* The color that the tool should use to visualize the event.
|
| 614 |
+
*/
|
| 615 |
+
uint32_t color;
|
| 616 |
+
|
| 617 |
+
/**
|
| 618 |
+
* \brief Payload type specified in this attribute structure.
|
| 619 |
+
*
|
| 620 |
+
* Defines the payload format of the attribute structure's \ref PAYLOAD_FIELD
|
| 621 |
+
* "payload" field.
|
| 622 |
+
*
|
| 623 |
+
* Default Value is NVTX_PAYLOAD_UNKNOWN
|
| 624 |
+
*/
|
| 625 |
+
int32_t payloadType; /* nvtxPayloadType_t */
|
| 626 |
+
|
| 627 |
+
int32_t reserved0;
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* \brief Payload assigned to this event. \anchor PAYLOAD_FIELD
|
| 631 |
+
*
|
| 632 |
+
* A numerical value that can be used to annotate an event. The tool could
|
| 633 |
+
* use the payload data to reconstruct graphs and diagrams.
|
| 634 |
+
*/
|
| 635 |
+
union payload_t
|
| 636 |
+
{
|
| 637 |
+
uint64_t ullValue;
|
| 638 |
+
int64_t llValue;
|
| 639 |
+
double dValue;
|
| 640 |
+
/* NVTX_VERSION_2 */
|
| 641 |
+
uint32_t uiValue;
|
| 642 |
+
int32_t iValue;
|
| 643 |
+
float fValue;
|
| 644 |
+
} payload;
|
| 645 |
+
|
| 646 |
+
/** \brief Message type specified in this attribute structure.
|
| 647 |
+
*
|
| 648 |
+
* Defines the message format of the attribute structure's \ref MESSAGE_FIELD
|
| 649 |
+
* "message" field.
|
| 650 |
+
*
|
| 651 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 652 |
+
*/
|
| 653 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 654 |
+
|
| 655 |
+
/** \brief Message assigned to this attribute structure. \anchor MESSAGE_FIELD
|
| 656 |
+
*
|
| 657 |
+
* The text message that is attached to an event.
|
| 658 |
+
*/
|
| 659 |
+
nvtxMessageValue_t message;
|
| 660 |
+
|
| 661 |
+
} nvtxEventAttributes_v2;
|
| 662 |
+
|
| 663 |
+
typedef struct nvtxEventAttributes_v2 nvtxEventAttributes_t;
|
| 664 |
+
|
| 665 |
+
/** @} */ /*END defgroup*/
|
| 666 |
+
/* ========================================================================= */
|
| 667 |
+
/** \defgroup MARKERS_AND_RANGES Markers and Ranges
|
| 668 |
+
*
|
| 669 |
+
* See \ref MARKERS_AND_RANGES for more details
|
| 670 |
+
*
|
| 671 |
+
* @{
|
| 672 |
+
*/
|
| 673 |
+
|
| 674 |
+
/** \name Marker */
|
| 675 |
+
|
| 676 |
+
/* ------------------------------------------------------------------------- */
|
| 677 |
+
/** \brief Marks an instantaneous event in the application.
|
| 678 |
+
*
|
| 679 |
+
* A marker can contain a text message or specify additional information
|
| 680 |
+
* using the event attributes structure. These attributes include a text
|
| 681 |
+
* message, color, category, and a payload. Each of the attributes is optional
|
| 682 |
+
* and can only be sent out using the \ref nvtxDomainMarkEx function.
|
| 683 |
+
*
|
| 684 |
+
* nvtxDomainMarkEx(NULL, event) is equivalent to calling
|
| 685 |
+
* nvtxMarkEx(event).
|
| 686 |
+
*
|
| 687 |
+
* \param domain - The domain of scoping the category.
|
| 688 |
+
* \param eventAttrib - The event attribute structure defining the marker's
|
| 689 |
+
* attribute types and attribute values.
|
| 690 |
+
*
|
| 691 |
+
* \sa
|
| 692 |
+
* ::nvtxMarkEx
|
| 693 |
+
*
|
| 694 |
+
* \version \NVTX_VERSION_2
|
| 695 |
+
* @{ */
|
| 696 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 697 |
+
/** @} */
|
| 698 |
+
|
| 699 |
+
/* ------------------------------------------------------------------------- */
|
| 700 |
+
/** \brief Marks an instantaneous event in the application.
|
| 701 |
+
*
|
| 702 |
+
* A marker can contain a text message or specify additional information
|
| 703 |
+
* using the event attributes structure. These attributes include a text
|
| 704 |
+
* message, color, category, and a payload. Each of the attributes is optional
|
| 705 |
+
* and can only be sent out using the \ref nvtxMarkEx function.
|
| 706 |
+
* If \ref nvtxMarkA or \ref nvtxMarkW are used to specify the marker
|
| 707 |
+
* or if an attribute is unspecified then a default value will be used.
|
| 708 |
+
*
|
| 709 |
+
* \param eventAttrib - The event attribute structure defining the marker's
|
| 710 |
+
* attribute types and attribute values.
|
| 711 |
+
*
|
| 712 |
+
* \par Example:
|
| 713 |
+
* \code
|
| 714 |
+
* // zero the structure
|
| 715 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 716 |
+
* // set the version and the size information
|
| 717 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 718 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 719 |
+
* // configure the attributes. 0 is the default for all attributes.
|
| 720 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 721 |
+
* eventAttrib.color = 0xFF880000;
|
| 722 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 723 |
+
* eventAttrib.message.ascii = "Example nvtxMarkEx";
|
| 724 |
+
* nvtxMarkEx(&eventAttrib);
|
| 725 |
+
* \endcode
|
| 726 |
+
*
|
| 727 |
+
* \sa
|
| 728 |
+
* ::nvtxDomainMarkEx
|
| 729 |
+
*
|
| 730 |
+
* \version \NVTX_VERSION_1
|
| 731 |
+
* @{ */
|
| 732 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib);
|
| 733 |
+
/** @} */
|
| 734 |
+
|
| 735 |
+
/* ------------------------------------------------------------------------- */
|
| 736 |
+
/** \brief Marks an instantaneous event in the application.
|
| 737 |
+
*
|
| 738 |
+
* A marker created using \ref nvtxMarkA or \ref nvtxMarkW contains only a
|
| 739 |
+
* text message.
|
| 740 |
+
*
|
| 741 |
+
* \param message - The message associated to this marker event.
|
| 742 |
+
*
|
| 743 |
+
* \par Example:
|
| 744 |
+
* \code
|
| 745 |
+
* nvtxMarkA("Example nvtxMarkA");
|
| 746 |
+
* nvtxMarkW(L"Example nvtxMarkW");
|
| 747 |
+
* \endcode
|
| 748 |
+
*
|
| 749 |
+
* \sa
|
| 750 |
+
* ::nvtxDomainMarkEx
|
| 751 |
+
* ::nvtxMarkEx
|
| 752 |
+
*
|
| 753 |
+
* \version \NVTX_VERSION_0
|
| 754 |
+
* @{ */
|
| 755 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message);
|
| 756 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message);
|
| 757 |
+
/** @} */
|
| 758 |
+
|
| 759 |
+
|
| 760 |
+
/** \name Process Ranges */
|
| 761 |
+
|
| 762 |
+
/* ------------------------------------------------------------------------- */
|
| 763 |
+
/** \brief Starts a process range in a domain.
|
| 764 |
+
*
|
| 765 |
+
* \param domain - The domain of scoping the category.
|
| 766 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 767 |
+
* attribute types and attribute values.
|
| 768 |
+
*
|
| 769 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 770 |
+
*
|
| 771 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 772 |
+
*
|
| 773 |
+
* \par Example:
|
| 774 |
+
* \code
|
| 775 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
|
| 776 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 777 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 778 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 779 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 780 |
+
* eventAttrib.message.ascii = "my range";
|
| 781 |
+
* nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
|
| 782 |
+
* // ...
|
| 783 |
+
* nvtxDomainRangeEnd(rangeId);
|
| 784 |
+
* \endcode
|
| 785 |
+
*
|
| 786 |
+
* \sa
|
| 787 |
+
* ::nvtxDomainRangeEnd
|
| 788 |
+
*
|
| 789 |
+
* \version \NVTX_VERSION_2
|
| 790 |
+
* @{ */
|
| 791 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 792 |
+
/** @} */
|
| 793 |
+
|
| 794 |
+
/* ------------------------------------------------------------------------- */
|
| 795 |
+
/** \brief Starts a process range.
|
| 796 |
+
*
|
| 797 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 798 |
+
* attribute types and attribute values.
|
| 799 |
+
*
|
| 800 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 801 |
+
*
|
| 802 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 803 |
+
*
|
| 804 |
+
* \par Example:
|
| 805 |
+
* \code
|
| 806 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 807 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 808 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 809 |
+
* eventAttrib.category = 3;
|
| 810 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 811 |
+
* eventAttrib.color = 0xFF0088FF;
|
| 812 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 813 |
+
* eventAttrib.message.ascii = "Example Range";
|
| 814 |
+
* nvtxRangeId_t rangeId = nvtxRangeStartEx(&eventAttrib);
|
| 815 |
+
* // ...
|
| 816 |
+
* nvtxRangeEnd(rangeId);
|
| 817 |
+
* \endcode
|
| 818 |
+
*
|
| 819 |
+
* \sa
|
| 820 |
+
* ::nvtxRangeEnd
|
| 821 |
+
* ::nvtxDomainRangeStartEx
|
| 822 |
+
*
|
| 823 |
+
* \version \NVTX_VERSION_1
|
| 824 |
+
* @{ */
|
| 825 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib);
|
| 826 |
+
/** @} */
|
| 827 |
+
|
| 828 |
+
/* ------------------------------------------------------------------------- */
|
| 829 |
+
/** \brief Starts a process range.
|
| 830 |
+
*
|
| 831 |
+
* \param message - The event message associated to this range event.
|
| 832 |
+
*
|
| 833 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 834 |
+
*
|
| 835 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 836 |
+
*
|
| 837 |
+
* \par Example:
|
| 838 |
+
* \code
|
| 839 |
+
* nvtxRangeId_t r1 = nvtxRangeStartA("Range 1");
|
| 840 |
+
* nvtxRangeId_t r2 = nvtxRangeStartW(L"Range 2");
|
| 841 |
+
* nvtxRangeEnd(r1);
|
| 842 |
+
* nvtxRangeEnd(r2);
|
| 843 |
+
* \endcode
|
| 844 |
+
*
|
| 845 |
+
* \sa
|
| 846 |
+
* ::nvtxRangeEnd
|
| 847 |
+
* ::nvtxRangeStartEx
|
| 848 |
+
* ::nvtxDomainRangeStartEx
|
| 849 |
+
*
|
| 850 |
+
* \version \NVTX_VERSION_0
|
| 851 |
+
* @{ */
|
| 852 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message);
|
| 853 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message);
|
| 854 |
+
/** @} */
|
| 855 |
+
|
| 856 |
+
/* ------------------------------------------------------------------------- */
|
| 857 |
+
/** \brief Ends a process range.
|
| 858 |
+
*
|
| 859 |
+
* \param domain - The domain
|
| 860 |
+
* \param id - The correlation ID returned from a nvtxRangeStart call.
|
| 861 |
+
*
|
| 862 |
+
* \remarks This function is offered completeness but is an alias for ::nvtxRangeEnd.
|
| 863 |
+
* It does not need a domain param since that is associated iwth the range ID at ::nvtxDomainRangeStartEx
|
| 864 |
+
*
|
| 865 |
+
* \par Example:
|
| 866 |
+
* \code
|
| 867 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
|
| 868 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 869 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 870 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 871 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 872 |
+
* eventAttrib.message.ascii = "my range";
|
| 873 |
+
* nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
|
| 874 |
+
* // ...
|
| 875 |
+
* nvtxDomainRangeEnd(rangeId);
|
| 876 |
+
* \endcode
|
| 877 |
+
*
|
| 878 |
+
* \sa
|
| 879 |
+
* ::nvtxDomainRangeStartEx
|
| 880 |
+
*
|
| 881 |
+
* \version \NVTX_VERSION_2
|
| 882 |
+
* @{ */
|
| 883 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id);
|
| 884 |
+
/** @} */
|
| 885 |
+
|
| 886 |
+
/* ------------------------------------------------------------------------- */
|
| 887 |
+
/** \brief Ends a process range.
|
| 888 |
+
*
|
| 889 |
+
* \param id - The correlation ID returned from an nvtxRangeStart call.
|
| 890 |
+
*
|
| 891 |
+
* \sa
|
| 892 |
+
* ::nvtxDomainRangeStartEx
|
| 893 |
+
* ::nvtxRangeStartEx
|
| 894 |
+
* ::nvtxRangeStartA
|
| 895 |
+
* ::nvtxRangeStartW
|
| 896 |
+
*
|
| 897 |
+
* \version \NVTX_VERSION_0
|
| 898 |
+
* @{ */
|
| 899 |
+
NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id);
|
| 900 |
+
/** @} */
|
| 901 |
+
|
| 902 |
+
/** \name Thread Ranges */
|
| 903 |
+
|
| 904 |
+
/* ------------------------------------------------------------------------- */
|
| 905 |
+
/** \brief Starts a nested thread range.
|
| 906 |
+
*
|
| 907 |
+
* \param domain - The domain of scoping.
|
| 908 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 909 |
+
* attribute types and attribute values.
|
| 910 |
+
*
|
| 911 |
+
* \return The 0 based level of range being started. This value is scoped to the domain.
|
| 912 |
+
* If an error occurs, a negative value is returned.
|
| 913 |
+
*
|
| 914 |
+
* \par Example:
|
| 915 |
+
* \code
|
| 916 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 917 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 918 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 919 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 920 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 921 |
+
* eventAttrib.color = 0xFFFF0000;
|
| 922 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 923 |
+
* eventAttrib.message.ascii = "Level 0";
|
| 924 |
+
* nvtxDomainRangePushEx(domain, &eventAttrib);
|
| 925 |
+
*
|
| 926 |
+
* // Re-use eventAttrib
|
| 927 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
|
| 928 |
+
* eventAttrib.message.unicode = L"Level 1";
|
| 929 |
+
* nvtxDomainRangePushEx(domain, &eventAttrib);
|
| 930 |
+
*
|
| 931 |
+
* nvtxDomainRangePop(domain); //level 1
|
| 932 |
+
* nvtxDomainRangePop(domain); //level 0
|
| 933 |
+
* \endcode
|
| 934 |
+
*
|
| 935 |
+
* \sa
|
| 936 |
+
* ::nvtxDomainRangePop
|
| 937 |
+
*
|
| 938 |
+
* \version \NVTX_VERSION_2
|
| 939 |
+
* @{ */
|
| 940 |
+
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 941 |
+
/** @} */
|
| 942 |
+
|
| 943 |
+
/* ------------------------------------------------------------------------- */
|
| 944 |
+
/** \brief Starts a nested thread range.
|
| 945 |
+
*
|
| 946 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 947 |
+
* attribute types and attribute values.
|
| 948 |
+
*
|
| 949 |
+
* \return The 0 based level of range being started. This level is per domain.
|
| 950 |
+
* If an error occurs a negative value is returned.
|
| 951 |
+
*
|
| 952 |
+
* \par Example:
|
| 953 |
+
* \code
|
| 954 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 955 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 956 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 957 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 958 |
+
* eventAttrib.color = 0xFFFF0000;
|
| 959 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 960 |
+
* eventAttrib.message.ascii = "Level 0";
|
| 961 |
+
* nvtxRangePushEx(&eventAttrib);
|
| 962 |
+
*
|
| 963 |
+
* // Re-use eventAttrib
|
| 964 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
|
| 965 |
+
* eventAttrib.message.unicode = L"Level 1";
|
| 966 |
+
* nvtxRangePushEx(&eventAttrib);
|
| 967 |
+
*
|
| 968 |
+
* nvtxRangePop();
|
| 969 |
+
* nvtxRangePop();
|
| 970 |
+
* \endcode
|
| 971 |
+
*
|
| 972 |
+
* \sa
|
| 973 |
+
* ::nvtxDomainRangePushEx
|
| 974 |
+
* ::nvtxRangePop
|
| 975 |
+
*
|
| 976 |
+
* \version \NVTX_VERSION_1
|
| 977 |
+
* @{ */
|
| 978 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib);
|
| 979 |
+
/** @} */
|
| 980 |
+
|
| 981 |
+
/* ------------------------------------------------------------------------- */
|
| 982 |
+
/** \brief Starts a nested thread range.
|
| 983 |
+
*
|
| 984 |
+
* \param message - The event message associated to this range event.
|
| 985 |
+
*
|
| 986 |
+
* \return The 0 based level of range being started. If an error occurs a
|
| 987 |
+
* negative value is returned.
|
| 988 |
+
*
|
| 989 |
+
* \par Example:
|
| 990 |
+
* \code
|
| 991 |
+
* nvtxRangePushA("Level 0");
|
| 992 |
+
* nvtxRangePushW(L"Level 1");
|
| 993 |
+
* nvtxRangePop();
|
| 994 |
+
* nvtxRangePop();
|
| 995 |
+
* \endcode
|
| 996 |
+
*
|
| 997 |
+
* \sa
|
| 998 |
+
* ::nvtxDomainRangePushEx
|
| 999 |
+
* ::nvtxRangePop
|
| 1000 |
+
*
|
| 1001 |
+
* \version \NVTX_VERSION_0
|
| 1002 |
+
* @{ */
|
| 1003 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message);
|
| 1004 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message);
|
| 1005 |
+
/** @} */
|
| 1006 |
+
|
| 1007 |
+
|
| 1008 |
+
/* ------------------------------------------------------------------------- */
|
| 1009 |
+
/** \brief Ends a nested thread range.
|
| 1010 |
+
*
|
| 1011 |
+
* \return The level of the range being ended. If an error occurs a negative
|
| 1012 |
+
* value is returned on the current thread.
|
| 1013 |
+
*
|
| 1014 |
+
* \par Example:
|
| 1015 |
+
* \code
|
| 1016 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreate("example library");
|
| 1017 |
+
* nvtxDomainRangePushA(domain, "Level 0");
|
| 1018 |
+
* nvtxDomainRangePushW(domain, L"Level 1");
|
| 1019 |
+
* nvtxDomainRangePop(domain);
|
| 1020 |
+
* nvtxDomainRangePop(domain);
|
| 1021 |
+
* \endcode
|
| 1022 |
+
*
|
| 1023 |
+
* \sa
|
| 1024 |
+
* ::nvtxRangePushEx
|
| 1025 |
+
* ::nvtxRangePushA
|
| 1026 |
+
* ::nvtxRangePushW
|
| 1027 |
+
*
|
| 1028 |
+
* \version \NVTX_VERSION_2
|
| 1029 |
+
* @{ */
|
| 1030 |
+
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain);
|
| 1031 |
+
/** @} */
|
| 1032 |
+
|
| 1033 |
+
/* ------------------------------------------------------------------------- */
|
| 1034 |
+
/** \brief Ends a nested thread range.
|
| 1035 |
+
*
|
| 1036 |
+
* \return The level of the range being ended. If an error occurs a negative
|
| 1037 |
+
* value is returned on the current thread.
|
| 1038 |
+
*
|
| 1039 |
+
* \par Example:
|
| 1040 |
+
* \code
|
| 1041 |
+
* nvtxRangePushA("Level 0");
|
| 1042 |
+
* nvtxRangePushW(L"Level 1");
|
| 1043 |
+
* nvtxRangePop();
|
| 1044 |
+
* nvtxRangePop();
|
| 1045 |
+
* \endcode
|
| 1046 |
+
*
|
| 1047 |
+
* \sa
|
| 1048 |
+
* ::nvtxRangePushEx
|
| 1049 |
+
* ::nvtxRangePushA
|
| 1050 |
+
* ::nvtxRangePushW
|
| 1051 |
+
*
|
| 1052 |
+
* \version \NVTX_VERSION_0
|
| 1053 |
+
* @{ */
|
| 1054 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePop(void);
|
| 1055 |
+
/** @} */
|
| 1056 |
+
|
| 1057 |
+
|
| 1058 |
+
/** @} */ /*END defgroup*/
|
| 1059 |
+
/* ========================================================================= */
|
| 1060 |
+
/** \defgroup RESOURCE_NAMING Resource Naming
|
| 1061 |
+
*
|
| 1062 |
+
* See \ref RESOURCE_NAMING for more details
|
| 1063 |
+
*
|
| 1064 |
+
* @{
|
| 1065 |
+
*/
|
| 1066 |
+
|
| 1067 |
+
|
| 1068 |
+
/* ------------------------------------------------------------------------- */
|
| 1069 |
+
/** \name Functions for Generic Resource Naming*/
|
| 1070 |
+
/* ------------------------------------------------------------------------- */
|
| 1071 |
+
|
| 1072 |
+
/* ------------------------------------------------------------------------- */
|
| 1073 |
+
/** \cond SHOW_HIDDEN
|
| 1074 |
+
* \brief Resource typing helpers.
|
| 1075 |
+
*
|
| 1076 |
+
* Classes are used to make it easy to create a series of resource types
|
| 1077 |
+
* per API without collisions
|
| 1078 |
+
*/
|
| 1079 |
+
#define NVTX_RESOURCE_MAKE_TYPE(CLASS, INDEX) ((((uint32_t)(NVTX_RESOURCE_CLASS_ ## CLASS))<<16)|((uint32_t)(INDEX)))
|
| 1080 |
+
#define NVTX_RESOURCE_CLASS_GENERIC 1
|
| 1081 |
+
/** \endcond */
|
| 1082 |
+
|
| 1083 |
+
/* ------------------------------------------------------------------------- */
|
| 1084 |
+
/** \brief Generic resource type for when a resource class is not available.
|
| 1085 |
+
*
|
| 1086 |
+
* \sa
|
| 1087 |
+
* ::nvtxDomainResourceCreate
|
| 1088 |
+
*
|
| 1089 |
+
* \version \NVTX_VERSION_2
|
| 1090 |
+
*/
|
| 1091 |
+
typedef enum nvtxResourceGenericType_t
|
| 1092 |
+
{
|
| 1093 |
+
NVTX_RESOURCE_TYPE_UNKNOWN = 0,
|
| 1094 |
+
NVTX_RESOURCE_TYPE_GENERIC_POINTER = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 1), /**< Generic pointer assumed to have no collisions with other pointers. */
|
| 1095 |
+
NVTX_RESOURCE_TYPE_GENERIC_HANDLE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 2), /**< Generic handle assumed to have no collisions with other handles. */
|
| 1096 |
+
NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 3), /**< OS native thread identifier. */
|
| 1097 |
+
NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 4) /**< POSIX pthread identifier. */
|
| 1098 |
+
} nvtxResourceGenericType_t;
|
| 1099 |
+
|
| 1100 |
+
|
| 1101 |
+
|
| 1102 |
+
/** \brief Resource Attribute Structure.
|
| 1103 |
+
* \anchor RESOURCE_ATTRIBUTE_STRUCTURE
|
| 1104 |
+
*
|
| 1105 |
+
* This structure is used to describe the attributes of a resource. The layout of
|
| 1106 |
+
* the structure is defined by a specific version of the tools extension
|
| 1107 |
+
* library and can change between different versions of the Tools Extension
|
| 1108 |
+
* library.
|
| 1109 |
+
*
|
| 1110 |
+
* \par Initializing the Attributes
|
| 1111 |
+
*
|
| 1112 |
+
* The caller should always perform the following three tasks when using
|
| 1113 |
+
* attributes:
|
| 1114 |
+
* <ul>
|
| 1115 |
+
* <li>Zero the structure
|
| 1116 |
+
* <li>Set the version field
|
| 1117 |
+
* <li>Set the size field
|
| 1118 |
+
* </ul>
|
| 1119 |
+
*
|
| 1120 |
+
* Zeroing the structure sets all the resource attributes types and values
|
| 1121 |
+
* to the default value.
|
| 1122 |
+
*
|
| 1123 |
+
* The version and size field are used by the Tools Extension
|
| 1124 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 1125 |
+
*
|
| 1126 |
+
* It is recommended that the caller use one of the following to methods
|
| 1127 |
+
* to initialize the event attributes structure:
|
| 1128 |
+
*
|
| 1129 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 1130 |
+
* \code
|
| 1131 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1132 |
+
* attribs.version = NVTX_VERSION;
|
| 1133 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1134 |
+
* \endcode
|
| 1135 |
+
*
|
| 1136 |
+
* \par Method 2: Initializing nvtxEventAttributes for a specific version
|
| 1137 |
+
* \code
|
| 1138 |
+
* nvtxResourceAttributes_v0 attribs = {0};
|
| 1139 |
+
* attribs.version = 2;
|
| 1140 |
+
* attribs.size = (uint16_t)(sizeof(nvtxResourceAttributes_v0));
|
| 1141 |
+
* \endcode
|
| 1142 |
+
*
|
| 1143 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 1144 |
+
* layout of the structure be configured to 0 so that all fields
|
| 1145 |
+
* are initialized to the default value.
|
| 1146 |
+
*
|
| 1147 |
+
* The caller should either use both NVTX_VERSION and
|
| 1148 |
+
* NVTX_RESOURCE_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 1149 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 1150 |
+
* will likely cause either source level incompatibility or binary
|
| 1151 |
+
* incompatibility in the future.
|
| 1152 |
+
*
|
| 1153 |
+
* \par Settings Attribute Types and Values
|
| 1154 |
+
*
|
| 1155 |
+
*
|
| 1156 |
+
* \par Example:
|
| 1157 |
+
* \code
|
| 1158 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1159 |
+
*
|
| 1160 |
+
* // Initialize
|
| 1161 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1162 |
+
* attribs.version = NVTX_VERSION;
|
| 1163 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1164 |
+
*
|
| 1165 |
+
* // Configure the Attributes
|
| 1166 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1167 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1168 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1169 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1170 |
+
*
|
| 1171 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1172 |
+
* \endcode
|
| 1173 |
+
*
|
| 1174 |
+
* \sa
|
| 1175 |
+
* ::nvtxDomainResourceCreate
|
| 1176 |
+
*/
|
| 1177 |
+
typedef struct nvtxResourceAttributes_v0
|
| 1178 |
+
{
|
| 1179 |
+
/**
|
| 1180 |
+
* \brief Version flag of the structure.
|
| 1181 |
+
*
|
| 1182 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 1183 |
+
* supported in this header file. This can optionally be overridden to
|
| 1184 |
+
* another version of the tools extension library.
|
| 1185 |
+
*/
|
| 1186 |
+
uint16_t version;
|
| 1187 |
+
|
| 1188 |
+
/**
|
| 1189 |
+
* \brief Size of the structure.
|
| 1190 |
+
*
|
| 1191 |
+
* Needs to be set to the size in bytes of this attribute
|
| 1192 |
+
* structure.
|
| 1193 |
+
*/
|
| 1194 |
+
uint16_t size;
|
| 1195 |
+
|
| 1196 |
+
/**
|
| 1197 |
+
* \brief Identifier type specifies how to interpret the identifier field
|
| 1198 |
+
*
|
| 1199 |
+
* Defines the identifier format of the attribute structure's \ref RESOURCE_IDENTIFIER_FIELD
|
| 1200 |
+
* "identifier" field.
|
| 1201 |
+
*
|
| 1202 |
+
* Default Value is NVTX_RESOURCE_TYPE_UNKNOWN
|
| 1203 |
+
*/
|
| 1204 |
+
int32_t identifierType; /* values from enums following the pattern nvtxResource[name]Type_t */
|
| 1205 |
+
|
| 1206 |
+
/**
|
| 1207 |
+
* \brief Identifier for the resource.
|
| 1208 |
+
* \anchor RESOURCE_IDENTIFIER_FIELD
|
| 1209 |
+
*
|
| 1210 |
+
* An identifier may be a pointer or a handle to an OS or middleware API object.
|
| 1211 |
+
* The resource type will assist in avoiding collisions where handles values may collide.
|
| 1212 |
+
*/
|
| 1213 |
+
union identifier_t
|
| 1214 |
+
{
|
| 1215 |
+
const void* pValue;
|
| 1216 |
+
uint64_t ullValue;
|
| 1217 |
+
} identifier;
|
| 1218 |
+
|
| 1219 |
+
/** \brief Message type specified in this attribute structure.
|
| 1220 |
+
*
|
| 1221 |
+
* Defines the message format of the attribute structure's \ref RESOURCE_MESSAGE_FIELD
|
| 1222 |
+
* "message" field.
|
| 1223 |
+
*
|
| 1224 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 1225 |
+
*/
|
| 1226 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 1227 |
+
|
| 1228 |
+
/** \brief Message assigned to this attribute structure. \anchor RESOURCE_MESSAGE_FIELD
|
| 1229 |
+
*
|
| 1230 |
+
* The text message that is attached to a resource.
|
| 1231 |
+
*/
|
| 1232 |
+
nvtxMessageValue_t message;
|
| 1233 |
+
|
| 1234 |
+
} nvtxResourceAttributes_v0;
|
| 1235 |
+
|
| 1236 |
+
typedef struct nvtxResourceAttributes_v0 nvtxResourceAttributes_t;
|
| 1237 |
+
|
| 1238 |
+
/* \cond SHOW_HIDDEN
|
| 1239 |
+
* \version \NVTX_VERSION_2
|
| 1240 |
+
*/
|
| 1241 |
+
#define NVTX_RESOURCE_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxResourceAttributes_v0) ) )
|
| 1242 |
+
typedef struct nvtxResourceHandle* nvtxResourceHandle_t;
|
| 1243 |
+
/** \endcond */
|
| 1244 |
+
|
| 1245 |
+
|
| 1246 |
+
|
| 1247 |
+
/* ------------------------------------------------------------------------- */
|
| 1248 |
+
/** \brief Create a resource object to track and associate data with OS and middleware objects
|
| 1249 |
+
*
|
| 1250 |
+
* Allows users to associate an API handle or pointer with a user-provided name.
|
| 1251 |
+
*
|
| 1252 |
+
*
|
| 1253 |
+
* \param domain - Domain to own the resource object
|
| 1254 |
+
* \param attribs - Attributes to be associated with the resource
|
| 1255 |
+
*
|
| 1256 |
+
* \return A handle that represents the newly created resource object.
|
| 1257 |
+
*
|
| 1258 |
+
* \par Example:
|
| 1259 |
+
* \code
|
| 1260 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1261 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1262 |
+
* attribs.version = NVTX_VERSION;
|
| 1263 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1264 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1265 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1266 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1267 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1268 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1269 |
+
* \endcode
|
| 1270 |
+
*
|
| 1271 |
+
* \sa
|
| 1272 |
+
* ::nvtxResourceAttributes_t
|
| 1273 |
+
* ::nvtxDomainResourceDestroy
|
| 1274 |
+
*
|
| 1275 |
+
* \version \NVTX_VERSION_2
|
| 1276 |
+
* @{ */
|
| 1277 |
+
NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
|
| 1278 |
+
/** @} */
|
| 1279 |
+
|
| 1280 |
+
/* ------------------------------------------------------------------------- */
|
| 1281 |
+
/** \brief Destroy a resource object to track and associate data with OS and middleware objects
|
| 1282 |
+
*
|
| 1283 |
+
* Allows users to associate an API handle or pointer with a user-provided name.
|
| 1284 |
+
*
|
| 1285 |
+
* \param resource - Handle to the resource in which to operate.
|
| 1286 |
+
*
|
| 1287 |
+
* \par Example:
|
| 1288 |
+
* \code
|
| 1289 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1290 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1291 |
+
* attribs.version = NVTX_VERSION;
|
| 1292 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1293 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1294 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1295 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1296 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1297 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1298 |
+
* nvtxDomainResourceDestroy(handle);
|
| 1299 |
+
* \endcode
|
| 1300 |
+
*
|
| 1301 |
+
* \sa
|
| 1302 |
+
* ::nvtxDomainResourceCreate
|
| 1303 |
+
*
|
| 1304 |
+
* \version \NVTX_VERSION_2
|
| 1305 |
+
* @{ */
|
| 1306 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource);
|
| 1307 |
+
/** @} */
|
| 1308 |
+
|
| 1309 |
+
|
| 1310 |
+
/** \name Functions for NVTX Category Naming*/
|
| 1311 |
+
|
| 1312 |
+
/* ------------------------------------------------------------------------- */
|
| 1313 |
+
/**
|
| 1314 |
+
* \brief Annotate an NVTX category used within a domain.
|
| 1315 |
+
*
|
| 1316 |
+
* Categories are used to group sets of events. Each category is identified
|
| 1317 |
+
* through a unique ID and that ID is passed into any of the marker/range
|
| 1318 |
+
* events to assign that event to a specific category. The nvtxDomainNameCategory
|
| 1319 |
+
* function calls allow the user to assign a name to a category ID that is
|
| 1320 |
+
* specific to the domain.
|
| 1321 |
+
*
|
| 1322 |
+
* nvtxDomainNameCategory(NULL, category, name) is equivalent to calling
|
| 1323 |
+
* nvtxNameCategory(category, name).
|
| 1324 |
+
*
|
| 1325 |
+
* \param domain - The domain of scoping the category.
|
| 1326 |
+
* \param category - The category ID to name.
|
| 1327 |
+
* \param name - The name of the category.
|
| 1328 |
+
*
|
| 1329 |
+
* \remarks The category names are tracked per domain.
|
| 1330 |
+
*
|
| 1331 |
+
* \par Example:
|
| 1332 |
+
* \code
|
| 1333 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example");
|
| 1334 |
+
* nvtxDomainNameCategoryA(domain, 1, "Memory Allocation");
|
| 1335 |
+
* nvtxDomainNameCategoryW(domain, 2, L"Memory Transfer");
|
| 1336 |
+
* \endcode
|
| 1337 |
+
*
|
| 1338 |
+
* \version \NVTX_VERSION_2
|
| 1339 |
+
* @{ */
|
| 1340 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name);
|
| 1341 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
|
| 1342 |
+
/** @} */
|
| 1343 |
+
|
| 1344 |
+
/** \brief Annotate an NVTX category.
|
| 1345 |
+
*
|
| 1346 |
+
* Categories are used to group sets of events. Each category is identified
|
| 1347 |
+
* through a unique ID and that ID is passed into any of the marker/range
|
| 1348 |
+
* events to assign that event to a specific category. The nvtxNameCategory
|
| 1349 |
+
* function calls allow the user to assign a name to a category ID.
|
| 1350 |
+
*
|
| 1351 |
+
* \param category - The category ID to name.
|
| 1352 |
+
* \param name - The name of the category.
|
| 1353 |
+
*
|
| 1354 |
+
* \remarks The category names are tracked per process.
|
| 1355 |
+
*
|
| 1356 |
+
* \par Example:
|
| 1357 |
+
* \code
|
| 1358 |
+
* nvtxNameCategory(1, "Memory Allocation");
|
| 1359 |
+
* nvtxNameCategory(2, "Memory Transfer");
|
| 1360 |
+
* nvtxNameCategory(3, "Memory Object Lifetime");
|
| 1361 |
+
* \endcode
|
| 1362 |
+
*
|
| 1363 |
+
* \version \NVTX_VERSION_1
|
| 1364 |
+
* @{ */
|
| 1365 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name);
|
| 1366 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name);
|
| 1367 |
+
/** @} */
|
| 1368 |
+
|
| 1369 |
+
/** \name Functions for OS Threads Naming*/
|
| 1370 |
+
|
| 1371 |
+
/* ------------------------------------------------------------------------- */
|
| 1372 |
+
/** \brief Annotate an OS thread.
|
| 1373 |
+
*
|
| 1374 |
+
* Allows the user to name an active thread of the current process. If an
|
| 1375 |
+
* invalid thread ID is provided or a thread ID from a different process is
|
| 1376 |
+
* used the behavior of the tool is implementation dependent.
|
| 1377 |
+
*
|
| 1378 |
+
* The thread name is associated to the default domain. To support domains
|
| 1379 |
+
* use resource objects via ::nvtxDomainResourceCreate.
|
| 1380 |
+
*
|
| 1381 |
+
* \param threadId - The ID of the thread to name.
|
| 1382 |
+
* \param name - The name of the thread.
|
| 1383 |
+
*
|
| 1384 |
+
* \par Example:
|
| 1385 |
+
* \code
|
| 1386 |
+
* nvtxNameOsThread(GetCurrentThreadId(), "MAIN_THREAD");
|
| 1387 |
+
* \endcode
|
| 1388 |
+
*
|
| 1389 |
+
* \version \NVTX_VERSION_1
|
| 1390 |
+
* @{ */
|
| 1391 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name);
|
| 1392 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name);
|
| 1393 |
+
/** @} */
|
| 1394 |
+
|
| 1395 |
+
|
| 1396 |
+
/** @} */ /*END defgroup*/
|
| 1397 |
+
/* ========================================================================= */
|
| 1398 |
+
/** \defgroup STRING_REGISTRATION String Registration
|
| 1399 |
+
*
|
| 1400 |
+
* Registered strings are intended to increase performance by lowering instrumentation
|
| 1401 |
+
* overhead. String may be registered once and the handle may be passed in place of
|
| 1402 |
+
* a string where an the APIs may allow.
|
| 1403 |
+
*
|
| 1404 |
+
* See \ref STRING_REGISTRATION for more details
|
| 1405 |
+
*
|
| 1406 |
+
* @{
|
| 1407 |
+
*/
|
| 1408 |
+
|
| 1409 |
+
/* ------------------------------------------------------------------------- */
|
| 1410 |
+
/** \brief Register a string.
|
| 1411 |
+
|
| 1412 |
+
* Registers an immutable string with NVTX. Once registered the pointer used
|
| 1413 |
+
* to register the domain name can be used in nvtxEventAttributes_t
|
| 1414 |
+
* \ref MESSAGE_FIELD. This allows NVTX implementation to skip copying the
|
| 1415 |
+
* contents of the message on each event invocation.
|
| 1416 |
+
*
|
| 1417 |
+
* String registration is an optimization. It is recommended to use string
|
| 1418 |
+
* registration if the string will be passed to an event many times.
|
| 1419 |
+
*
|
| 1420 |
+
* String are not unregistered, except that by unregistering the entire domain
|
| 1421 |
+
*
|
| 1422 |
+
* \param domain - Domain handle. If NULL then the global domain is used.
|
| 1423 |
+
* \param string - A unique pointer to a sequence of characters.
|
| 1424 |
+
*
|
| 1425 |
+
* \return A handle representing the registered string.
|
| 1426 |
+
*
|
| 1427 |
+
* \par Example:
|
| 1428 |
+
* \code
|
| 1429 |
+
* nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1430 |
+
* nvtxStringHandle_t message = nvtxDomainRegisterStringA(domain, "registered string");
|
| 1431 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 1432 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 1433 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1434 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_REGISTERED;
|
| 1435 |
+
* eventAttrib.message.registered = message;
|
| 1436 |
+
* \endcode
|
| 1437 |
+
*
|
| 1438 |
+
* \version \NVTX_VERSION_2
|
| 1439 |
+
* @{ */
|
| 1440 |
+
NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string);
|
| 1441 |
+
NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string);
|
| 1442 |
+
/** @} */
|
| 1443 |
+
|
| 1444 |
+
/** @} */ /*END defgroup*/
|
| 1445 |
+
/* ========================================================================= */
|
| 1446 |
+
/** \defgroup DOMAINS Domains
|
| 1447 |
+
*
|
| 1448 |
+
* Domains are used to group events to a developer defined scope. Middleware
|
| 1449 |
+
* vendors may also scope their own events to avoid collisions with the
|
| 1450 |
+
* the application developer's events, so that the application developer may
|
| 1451 |
+
* inspect both parts and easily differentiate or filter them. By default
|
| 1452 |
+
* all events are scoped to a global domain where NULL is provided or when
|
| 1453 |
+
* using APIs provided b versions of NVTX below v2
|
| 1454 |
+
*
|
| 1455 |
+
* Domains are intended to be typically long lived objects with the intention
|
| 1456 |
+
* of logically separating events of large modules from each other such as
|
| 1457 |
+
* middleware libraries from each other and the main application.
|
| 1458 |
+
*
|
| 1459 |
+
* See \ref DOMAINS for more details
|
| 1460 |
+
*
|
| 1461 |
+
* @{
|
| 1462 |
+
*/
|
| 1463 |
+
|
| 1464 |
+
/* ------------------------------------------------------------------------- */
|
| 1465 |
+
/** \brief Register a NVTX domain.
|
| 1466 |
+
*
|
| 1467 |
+
* Domains are used to scope annotations. All NVTX_VERSION_0 and NVTX_VERSION_1
|
| 1468 |
+
* annotations are scoped to the global domain. The function nvtxDomainCreate
|
| 1469 |
+
* creates a new named domain.
|
| 1470 |
+
*
|
| 1471 |
+
* Each domain maintains its own nvtxRangePush and nvtxRangePop stack.
|
| 1472 |
+
*
|
| 1473 |
+
* \param name - A unique string representing the domain.
|
| 1474 |
+
*
|
| 1475 |
+
* \return A handle representing the domain.
|
| 1476 |
+
*
|
| 1477 |
+
* \par Example:
|
| 1478 |
+
* \code
|
| 1479 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1480 |
+
*
|
| 1481 |
+
* nvtxMarkA("nvtxMarkA to global domain");
|
| 1482 |
+
*
|
| 1483 |
+
* nvtxEventAttributes_t eventAttrib1 = {0};
|
| 1484 |
+
* eventAttrib1.version = NVTX_VERSION;
|
| 1485 |
+
* eventAttrib1.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1486 |
+
* eventAttrib1.message.ascii = "nvtxDomainMarkEx to global domain";
|
| 1487 |
+
* nvtxDomainMarkEx(NULL, &eventAttrib1);
|
| 1488 |
+
*
|
| 1489 |
+
* nvtxEventAttributes_t eventAttrib2 = {0};
|
| 1490 |
+
* eventAttrib2.version = NVTX_VERSION;
|
| 1491 |
+
* eventAttrib2.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1492 |
+
* eventAttrib2.message.ascii = "nvtxDomainMarkEx to com.nvidia.nvtx.example";
|
| 1493 |
+
* nvtxDomainMarkEx(domain, &eventAttrib2);
|
| 1494 |
+
* nvtxDomainDestroy(domain);
|
| 1495 |
+
* \endcode
|
| 1496 |
+
*
|
| 1497 |
+
* \sa
|
| 1498 |
+
* ::nvtxDomainDestroy
|
| 1499 |
+
*
|
| 1500 |
+
* \version \NVTX_VERSION_2
|
| 1501 |
+
* @{ */
|
| 1502 |
+
NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* name);
|
| 1503 |
+
NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* name);
|
| 1504 |
+
/** @} */
|
| 1505 |
+
|
| 1506 |
+
/* ------------------------------------------------------------------------- */
|
| 1507 |
+
/** \brief Unregister a NVTX domain.
|
| 1508 |
+
*
|
| 1509 |
+
* Unregisters the domain handle and frees all domain specific resources.
|
| 1510 |
+
*
|
| 1511 |
+
* \param domain - the domain handle
|
| 1512 |
+
*
|
| 1513 |
+
* \par Example:
|
| 1514 |
+
* \code
|
| 1515 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1516 |
+
* nvtxDomainDestroy(domain);
|
| 1517 |
+
* \endcode
|
| 1518 |
+
*
|
| 1519 |
+
* \sa
|
| 1520 |
+
* ::nvtxDomainCreateA
|
| 1521 |
+
* ::nvtxDomainCreateW
|
| 1522 |
+
*
|
| 1523 |
+
* \version \NVTX_VERSION_2
|
| 1524 |
+
* @{ */
|
| 1525 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain);
|
| 1526 |
+
/** @} */
|
| 1527 |
+
|
| 1528 |
+
|
| 1529 |
+
/** @} */ /*END defgroup*/
|
| 1530 |
+
/* ========================================================================= */
|
| 1531 |
+
/** \cond SHOW_HIDDEN */
|
| 1532 |
+
|
| 1533 |
+
#ifdef UNICODE
|
| 1534 |
+
#define nvtxMark nvtxMarkW
|
| 1535 |
+
#define nvtxRangeStart nvtxRangeStartW
|
| 1536 |
+
#define nvtxRangePush nvtxRangePushW
|
| 1537 |
+
#define nvtxNameCategory nvtxNameCategoryW
|
| 1538 |
+
#define nvtxNameOsThread nvtxNameOsThreadW
|
| 1539 |
+
/* NVTX_VERSION_2 */
|
| 1540 |
+
#define nvtxDomainCreate nvtxDomainCreateW
|
| 1541 |
+
#define nvtxDomainRegisterString nvtxDomainRegisterStringW
|
| 1542 |
+
#define nvtxDomainNameCategory nvtxDomainNameCategoryW
|
| 1543 |
+
#else
|
| 1544 |
+
#define nvtxMark nvtxMarkA
|
| 1545 |
+
#define nvtxRangeStart nvtxRangeStartA
|
| 1546 |
+
#define nvtxRangePush nvtxRangePushA
|
| 1547 |
+
#define nvtxNameCategory nvtxNameCategoryA
|
| 1548 |
+
#define nvtxNameOsThread nvtxNameOsThreadA
|
| 1549 |
+
/* NVTX_VERSION_2 */
|
| 1550 |
+
#define nvtxDomainCreate nvtxDomainCreateA
|
| 1551 |
+
#define nvtxDomainRegisterString nvtxDomainRegisterStringA
|
| 1552 |
+
#define nvtxDomainNameCategory nvtxDomainNameCategoryA
|
| 1553 |
+
#endif
|
| 1554 |
+
|
| 1555 |
+
/** \endcond */
|
| 1556 |
+
|
| 1557 |
+
#ifdef __cplusplus
|
| 1558 |
+
}
|
| 1559 |
+
#endif /* __cplusplus */
|
| 1560 |
+
|
| 1561 |
+
#endif /* NVTOOLSEXT_H_ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExtCudaRt.h
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
#ifndef NVTOOLSEXT_CUDART_H_
|
| 39 |
+
#define NVTOOLSEXT_CUDART_H_
|
| 40 |
+
|
| 41 |
+
#include "cuda.h"
|
| 42 |
+
#include "driver_types.h"
|
| 43 |
+
|
| 44 |
+
#include "nvToolsExt.h"
|
| 45 |
+
|
| 46 |
+
#ifdef __cplusplus
|
| 47 |
+
extern "C" {
|
| 48 |
+
#endif /* __cplusplus */
|
| 49 |
+
|
| 50 |
+
/* ========================================================================= */
|
| 51 |
+
/** \name Functions for CUDA Resource Naming
|
| 52 |
+
*/
|
| 53 |
+
/** \addtogroup RESOURCE_NAMING
|
| 54 |
+
* \section RESOURCE_NAMING_CUDART CUDA Runtime Resource Naming
|
| 55 |
+
*
|
| 56 |
+
* This section covers the API functions that allow to annotate CUDA resources
|
| 57 |
+
* with user-provided names.
|
| 58 |
+
*
|
| 59 |
+
* @{
|
| 60 |
+
*/
|
| 61 |
+
|
| 62 |
+
/* ------------------------------------------------------------------------- */
|
| 63 |
+
/* \cond SHOW_HIDDEN
|
| 64 |
+
* \brief Used to build a non-colliding value for resource types separated class
|
| 65 |
+
* \version \NVTX_VERSION_2
|
| 66 |
+
*/
|
| 67 |
+
#define NVTX_RESOURCE_CLASS_CUDART 5
|
| 68 |
+
/** \endcond */
|
| 69 |
+
|
| 70 |
+
/* ------------------------------------------------------------------------- */
|
| 71 |
+
/** \brief Resource types for CUDART
|
| 72 |
+
*/
|
| 73 |
+
typedef enum nvtxResourceCUDARTType_t
|
| 74 |
+
{
|
| 75 |
+
NVTX_RESOURCE_TYPE_CUDART_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDART, 0), /* int device */
|
| 76 |
+
NVTX_RESOURCE_TYPE_CUDART_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDART, 1), /* cudaStream_t */
|
| 77 |
+
NVTX_RESOURCE_TYPE_CUDART_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDART, 2) /* cudaEvent_t */
|
| 78 |
+
} nvtxResourceCUDARTType_t;
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
/* ------------------------------------------------------------------------- */
|
| 82 |
+
/** \brief Annotates a CUDA device.
|
| 83 |
+
*
|
| 84 |
+
* Allows the user to associate a CUDA device with a user-provided name.
|
| 85 |
+
*
|
| 86 |
+
* \param device - The id of the CUDA device to name.
|
| 87 |
+
* \param name - The name of the CUDA device.
|
| 88 |
+
*
|
| 89 |
+
* \version \NVTX_VERSION_1
|
| 90 |
+
* @{ */
|
| 91 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceA(int device, const char* name);
|
| 92 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaDeviceW(int device, const wchar_t* name);
|
| 93 |
+
/** @} */
|
| 94 |
+
|
| 95 |
+
/* ------------------------------------------------------------------------- */
|
| 96 |
+
/** \brief Annotates a CUDA stream.
|
| 97 |
+
*
|
| 98 |
+
* Allows the user to associate a CUDA stream with a user-provided name.
|
| 99 |
+
*
|
| 100 |
+
* \param stream - The handle of the CUDA stream to name.
|
| 101 |
+
* \param name - The name of the CUDA stream.
|
| 102 |
+
*
|
| 103 |
+
* \version \NVTX_VERSION_1
|
| 104 |
+
* @{ */
|
| 105 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamA(cudaStream_t stream, const char* name);
|
| 106 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaStreamW(cudaStream_t stream, const wchar_t* name);
|
| 107 |
+
/** @} */
|
| 108 |
+
|
| 109 |
+
/* ------------------------------------------------------------------------- */
|
| 110 |
+
/** \brief Annotates a CUDA event.
|
| 111 |
+
*
|
| 112 |
+
* Allows the user to associate a CUDA event with a user-provided name.
|
| 113 |
+
*
|
| 114 |
+
* \param event - The handle of the CUDA event to name.
|
| 115 |
+
* \param name - The name of the CUDA event.
|
| 116 |
+
*
|
| 117 |
+
* \version \NVTX_VERSION_1
|
| 118 |
+
* @{ */
|
| 119 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventA(cudaEvent_t event, const char* name);
|
| 120 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCudaEventW(cudaEvent_t event, const wchar_t* name);
|
| 121 |
+
/** @} */
|
| 122 |
+
|
| 123 |
+
/** @} */ /* END RESOURCE_NAMING */
|
| 124 |
+
|
| 125 |
+
/* ========================================================================= */
|
| 126 |
+
#ifdef UNICODE
|
| 127 |
+
#define nvtxNameCudaDevice nvtxNameCudaDeviceW
|
| 128 |
+
#define nvtxNameCudaStream nvtxNameCudaStreamW
|
| 129 |
+
#define nvtxNameCudaEvent nvtxNameCudaEventW
|
| 130 |
+
#else
|
| 131 |
+
#define nvtxNameCudaDevice nvtxNameCudaDeviceA
|
| 132 |
+
#define nvtxNameCudaStream nvtxNameCudaStreamA
|
| 133 |
+
#define nvtxNameCudaEvent nvtxNameCudaEventA
|
| 134 |
+
#endif
|
| 135 |
+
|
| 136 |
+
#ifdef __cplusplus
|
| 137 |
+
}
|
| 138 |
+
#endif /* __cplusplus */
|
| 139 |
+
|
| 140 |
+
#endif /* NVTOOLSEXT_CUDART_H_ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvToolsExtSync.h
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2017 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
#ifndef NVTOOLSEXT_SYNC_H_
|
| 39 |
+
#define NVTOOLSEXT_SYNC_H_
|
| 40 |
+
|
| 41 |
+
#include "nvToolsExt.h"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
#ifdef __cplusplus
|
| 45 |
+
extern "C" {
|
| 46 |
+
#endif /* __cplusplus */
|
| 47 |
+
|
| 48 |
+
/* \cond SHOW_HIDDEN
|
| 49 |
+
* \version \NVTX_VERSION_2
|
| 50 |
+
*/
|
| 51 |
+
#define NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxSyncUserAttributes_v0) ) )
|
| 52 |
+
/** \endcond */
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* \page PAGE_SYNCHRONIZATION Synchronization
|
| 57 |
+
*
|
| 58 |
+
* This section covers a subset of the API that allow users to track additional
|
| 59 |
+
* synchronization details of their application. Naming OS synchronization primitives
|
| 60 |
+
* may allow users to better understand the data collected by traced synchronization
|
| 61 |
+
* APIs. Additionally, a user defined synchronization object can allow the users to
|
| 62 |
+
* to tell the tools when the user is building their own synchronization system
|
| 63 |
+
* that do not rely on the OS to provide behaviors and instead use techniques like
|
| 64 |
+
* atomic operations and spinlocks.
|
| 65 |
+
*
|
| 66 |
+
* See module \ref SYNCHRONIZATION for details.
|
| 67 |
+
*
|
| 68 |
+
* \par Example:
|
| 69 |
+
* \code
|
| 70 |
+
* class MyMutex
|
| 71 |
+
* {
|
| 72 |
+
* volatile long bLocked;
|
| 73 |
+
* nvtxSyncUser_t hSync;
|
| 74 |
+
* public:
|
| 75 |
+
* MyMutex(const char* name, nvtxDomainHandle_t d){
|
| 76 |
+
* bLocked = 0;
|
| 77 |
+
*
|
| 78 |
+
* nvtxSyncUserAttributes_t attribs = { 0 };
|
| 79 |
+
* attribs.version = NVTX_VERSION;
|
| 80 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 81 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 82 |
+
* attribs.message.ascii = name;
|
| 83 |
+
* hSync = nvtxDomainSyncUserCreate(d, &attribs);
|
| 84 |
+
* }
|
| 85 |
+
*
|
| 86 |
+
* ~MyMutex() {
|
| 87 |
+
* nvtxDomainSyncUserDestroy(hSync);
|
| 88 |
+
* }
|
| 89 |
+
*
|
| 90 |
+
* bool Lock() {
|
| 91 |
+
* nvtxDomainSyncUserAcquireStart(hSync);
|
| 92 |
+
* bool acquired = __sync_bool_compare_and_swap(&bLocked, 0, 1);//atomic compiler intrinsic
|
| 93 |
+
|
| 94 |
+
* if (acquired) {
|
| 95 |
+
* nvtxDomainSyncUserAcquireSuccess(hSync);
|
| 96 |
+
* }
|
| 97 |
+
* else {
|
| 98 |
+
* nvtxDomainSyncUserAcquireFailed(hSync);
|
| 99 |
+
* }
|
| 100 |
+
* return acquired;
|
| 101 |
+
* }
|
| 102 |
+
|
| 103 |
+
* void Unlock() {
|
| 104 |
+
* nvtxDomainSyncUserReleasing(hSync);
|
| 105 |
+
* bLocked = false;
|
| 106 |
+
* }
|
| 107 |
+
* };
|
| 108 |
+
* \endcode
|
| 109 |
+
*
|
| 110 |
+
* \version \NVTX_VERSION_2
|
| 111 |
+
*/
|
| 112 |
+
|
| 113 |
+
/* ------------------------------------------------------------------------- */
|
| 114 |
+
/* \cond SHOW_HIDDEN
|
| 115 |
+
* \brief Used to build a non-colliding value for resource types separated class
|
| 116 |
+
* \version \NVTX_VERSION_2
|
| 117 |
+
*/
|
| 118 |
+
#define NVTX_RESOURCE_CLASS_SYNC_OS 2 /**< Synchronization objects that are OS specific. */
|
| 119 |
+
#define NVTX_RESOURCE_CLASS_SYNC_PTHREAD 3 /**< Synchronization objects that are from the POSIX Threads API (pthread)*/
|
| 120 |
+
/** \endcond */
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
/* ------------------------------------------------------------------------- */
|
| 124 |
+
/** \defgroup SYNCHRONIZATION Synchronization
|
| 125 |
+
* See page \ref PAGE_SYNCHRONIZATION.
|
| 126 |
+
* @{
|
| 127 |
+
*/
|
| 128 |
+
|
| 129 |
+
/** \brief Resource type values for OSs with POSIX Thread API support
|
| 130 |
+
*/
|
| 131 |
+
typedef enum nvtxResourceSyncPosixThreadType_t
|
| 132 |
+
{
|
| 133 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 1), /* pthread_mutex_t */
|
| 134 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_CONDITION = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 2), /* pthread_cond_t */
|
| 135 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_RWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 3), /* pthread_rwlock_t */
|
| 136 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_BARRIER = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 4), /* pthread_barrier_t */
|
| 137 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 5), /* pthread_spinlock_t */
|
| 138 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_ONCE = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 6) /* pthread_once_t */
|
| 139 |
+
} nvtxResourceSyncPosixThreadType_t;
|
| 140 |
+
|
| 141 |
+
/** \brief Resource type values for Windows OSs
|
| 142 |
+
*/
|
| 143 |
+
typedef enum nvtxResourceSyncWindowsType_t
|
| 144 |
+
{
|
| 145 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
|
| 146 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
|
| 147 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_EVENT = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
|
| 148 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_CRITICAL_SECTION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
|
| 149 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SRWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5)
|
| 150 |
+
} nvtxResourceSyncWindowsType_t;
|
| 151 |
+
|
| 152 |
+
/** \brief Resource type values for Linux and Linux derived OSs such as Android
|
| 153 |
+
* \sa
|
| 154 |
+
* ::nvtxResourceSyncPosixThreadType_t
|
| 155 |
+
*/
|
| 156 |
+
typedef enum nvtxResourceSyncLinuxType_t
|
| 157 |
+
{
|
| 158 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
|
| 159 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_FUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
|
| 160 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
|
| 161 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_COMPLETION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
|
| 162 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5),
|
| 163 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SEQLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 6),
|
| 164 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_RCU = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 7)
|
| 165 |
+
} nvtxResourceSyncLinuxType_t;
|
| 166 |
+
|
| 167 |
+
/** \brief Resource type values for Android come from Linux.
|
| 168 |
+
* \sa
|
| 169 |
+
* ::nvtxResourceSyncLinuxType_t
|
| 170 |
+
* ::nvtxResourceSyncPosixThreadType_t
|
| 171 |
+
*/
|
| 172 |
+
typedef enum nvtxResourceSyncLinuxType_t nvtxResourceSyncAndroidType_t;
|
| 173 |
+
|
| 174 |
+
/** \brief User Defined Synchronization Object Handle .
|
| 175 |
+
* \anchor SYNCUSER_HANDLE_STRUCTURE
|
| 176 |
+
*
|
| 177 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 178 |
+
* a user defined syncrhonization object. The tools will return a pointer through the API for the application
|
| 179 |
+
* to hold on it's behalf to reference the string in the future.
|
| 180 |
+
*
|
| 181 |
+
*/
|
| 182 |
+
typedef struct nvtxSyncUser* nvtxSyncUser_t;
|
| 183 |
+
|
| 184 |
+
/** \brief User Defined Synchronization Object Attributes Structure.
|
| 185 |
+
* \anchor USERDEF_SYNC_ATTRIBUTES_STRUCTURE
|
| 186 |
+
*
|
| 187 |
+
* This structure is used to describe the attributes of a user defined synchronization
|
| 188 |
+
* object. The layout of the structure is defined by a specific version of the tools
|
| 189 |
+
* extension library and can change between different versions of the Tools Extension
|
| 190 |
+
* library.
|
| 191 |
+
*
|
| 192 |
+
* \par Initializing the Attributes
|
| 193 |
+
*
|
| 194 |
+
* The caller should always perform the following three tasks when using
|
| 195 |
+
* attributes:
|
| 196 |
+
* <ul>
|
| 197 |
+
* <li>Zero the structure
|
| 198 |
+
* <li>Set the version field
|
| 199 |
+
* <li>Set the size field
|
| 200 |
+
* </ul>
|
| 201 |
+
*
|
| 202 |
+
* Zeroing the structure sets all the event attributes types and values
|
| 203 |
+
* to the default value.
|
| 204 |
+
*
|
| 205 |
+
* The version and size field are used by the Tools Extension
|
| 206 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 207 |
+
*
|
| 208 |
+
* It is recommended that the caller use one of the following to methods
|
| 209 |
+
* to initialize the event attributes structure:
|
| 210 |
+
*
|
| 211 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 212 |
+
* \code
|
| 213 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 214 |
+
* attribs.version = NVTX_VERSION;
|
| 215 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 216 |
+
* \endcode
|
| 217 |
+
*
|
| 218 |
+
* \par Method 2: Initializing nvtxSyncUserAttributes_t for a specific version
|
| 219 |
+
* \code
|
| 220 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 221 |
+
* attribs.version = 1;
|
| 222 |
+
* attribs.size = (uint16_t)(sizeof(nvtxSyncUserAttributes_t));
|
| 223 |
+
* \endcode
|
| 224 |
+
*
|
| 225 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 226 |
+
* layout of the structure be configured to 0 so that all fields
|
| 227 |
+
* are initialized to the default value.
|
| 228 |
+
*
|
| 229 |
+
* The caller should either use both NVTX_VERSION and
|
| 230 |
+
* NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 231 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 232 |
+
* will likely cause either source level incompatibility or binary
|
| 233 |
+
* incompatibility in the future.
|
| 234 |
+
*
|
| 235 |
+
* \par Settings Attribute Types and Values
|
| 236 |
+
*
|
| 237 |
+
*
|
| 238 |
+
* \par Example:
|
| 239 |
+
* \code
|
| 240 |
+
* // Initialize
|
| 241 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 242 |
+
* attribs.version = NVTX_VERSION;
|
| 243 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 244 |
+
*
|
| 245 |
+
* // Configure the Attributes
|
| 246 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 247 |
+
* attribs.message.ascii = "Example";
|
| 248 |
+
* \endcode
|
| 249 |
+
*
|
| 250 |
+
* \sa
|
| 251 |
+
* ::nvtxDomainSyncUserCreate
|
| 252 |
+
*/
|
| 253 |
+
typedef struct nvtxSyncUserAttributes_v0
|
| 254 |
+
{
|
| 255 |
+
/**
|
| 256 |
+
* \brief Version flag of the structure.
|
| 257 |
+
*
|
| 258 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 259 |
+
* supported in this header file. This can optionally be overridden to
|
| 260 |
+
* another version of the tools extension library.
|
| 261 |
+
*/
|
| 262 |
+
uint16_t version;
|
| 263 |
+
|
| 264 |
+
/**
|
| 265 |
+
* \brief Size of the structure.
|
| 266 |
+
*
|
| 267 |
+
* Needs to be set to the size in bytes of the event attribute
|
| 268 |
+
* structure used to specify the event.
|
| 269 |
+
*/
|
| 270 |
+
uint16_t size;
|
| 271 |
+
|
| 272 |
+
/** \brief Message type specified in this attribute structure.
|
| 273 |
+
*
|
| 274 |
+
* Defines the message format of the attribute structure's \ref nvtxSyncUserAttributes_v0::message
|
| 275 |
+
* "message" field.
|
| 276 |
+
*
|
| 277 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 278 |
+
*/
|
| 279 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 280 |
+
|
| 281 |
+
/** \brief Message assigned to this attribute structure.
|
| 282 |
+
*
|
| 283 |
+
* The text message that is attached to an event.
|
| 284 |
+
*/
|
| 285 |
+
nvtxMessageValue_t message;
|
| 286 |
+
|
| 287 |
+
} nvtxSyncUserAttributes_v0;
|
| 288 |
+
|
| 289 |
+
typedef struct nvtxSyncUserAttributes_v0 nvtxSyncUserAttributes_t;
|
| 290 |
+
|
| 291 |
+
/* ------------------------------------------------------------------------- */
|
| 292 |
+
/** \brief Create a user defined synchronization object
|
| 293 |
+
* This is used to track non-OS synchronization working with spinlocks and atomics
|
| 294 |
+
*
|
| 295 |
+
* \param domain - Domain to own the resource
|
| 296 |
+
* \param attribs - A structure to assign multiple attributes to the object.
|
| 297 |
+
*
|
| 298 |
+
* \return A handle that represents the newly created user defined synchronization object.
|
| 299 |
+
*
|
| 300 |
+
* \sa
|
| 301 |
+
* ::nvtxDomainSyncUserCreate
|
| 302 |
+
* ::nvtxDomainSyncUserDestroy
|
| 303 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 304 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 305 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 306 |
+
* ::nvtxDomainSyncUserReleasing
|
| 307 |
+
*
|
| 308 |
+
* \version \NVTX_VERSION_2
|
| 309 |
+
*/
|
| 310 |
+
NVTX_DECLSPEC nvtxSyncUser_t NVTX_API nvtxDomainSyncUserCreate(nvtxDomainHandle_t domain, const nvtxSyncUserAttributes_t* attribs);
|
| 311 |
+
|
| 312 |
+
/* ------------------------------------------------------------------------- */
|
| 313 |
+
/** \brief Destroy a user defined synchronization object
|
| 314 |
+
* This is used to track non-OS synchronization working with spinlocks and atomics
|
| 315 |
+
*
|
| 316 |
+
* \param handle - A handle to the object to operate on.
|
| 317 |
+
*
|
| 318 |
+
* \sa
|
| 319 |
+
* ::nvtxDomainSyncUserCreate
|
| 320 |
+
* ::nvtxDomainSyncUserDestroy
|
| 321 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 322 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 323 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 324 |
+
* ::nvtxDomainSyncUserReleasing
|
| 325 |
+
*
|
| 326 |
+
* \version \NVTX_VERSION_2
|
| 327 |
+
*/
|
| 328 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserDestroy(nvtxSyncUser_t handle);
|
| 329 |
+
|
| 330 |
+
/* ------------------------------------------------------------------------- */
|
| 331 |
+
/** \brief Signal to tools that an attempt to acquire a user defined synchronization object
|
| 332 |
+
*
|
| 333 |
+
* \param handle - A handle to the object to operate on.
|
| 334 |
+
*
|
| 335 |
+
* \sa
|
| 336 |
+
* ::nvtxDomainSyncUserCreate
|
| 337 |
+
* ::nvtxDomainSyncUserDestroy
|
| 338 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 339 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 340 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 341 |
+
* ::nvtxDomainSyncUserReleasing
|
| 342 |
+
*
|
| 343 |
+
* \version \NVTX_VERSION_2
|
| 344 |
+
*/
|
| 345 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireStart(nvtxSyncUser_t handle);
|
| 346 |
+
|
| 347 |
+
/* ------------------------------------------------------------------------- */
|
| 348 |
+
/** \brief Signal to tools of failure in acquiring a user defined synchronization object
|
| 349 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireStart
|
| 350 |
+
*
|
| 351 |
+
* \param handle - A handle to the object to operate on.
|
| 352 |
+
*
|
| 353 |
+
* \sa
|
| 354 |
+
* ::nvtxDomainSyncUserCreate
|
| 355 |
+
* ::nvtxDomainSyncUserDestroy
|
| 356 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 357 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 358 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 359 |
+
* ::nvtxDomainSyncUserReleasing
|
| 360 |
+
*
|
| 361 |
+
* \version \NVTX_VERSION_2
|
| 362 |
+
*/NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireFailed(nvtxSyncUser_t handle);
|
| 363 |
+
|
| 364 |
+
/* ------------------------------------------------------------------------- */
|
| 365 |
+
/** \brief Signal to tools of success in acquiring a user defined synchronization object
|
| 366 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireStart.
|
| 367 |
+
*
|
| 368 |
+
* \param handle - A handle to the object to operate on.
|
| 369 |
+
*
|
| 370 |
+
* \sa
|
| 371 |
+
* ::nvtxDomainSyncUserCreate
|
| 372 |
+
* ::nvtxDomainSyncUserDestroy
|
| 373 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 374 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 375 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 376 |
+
* ::nvtxDomainSyncUserReleasing
|
| 377 |
+
*
|
| 378 |
+
* \version \NVTX_VERSION_2
|
| 379 |
+
*/NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireSuccess(nvtxSyncUser_t handle);
|
| 380 |
+
|
| 381 |
+
/* ------------------------------------------------------------------------- */
|
| 382 |
+
/** \brief Signal to tools of releasing a reservation on user defined synchronization object
|
| 383 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireSuccess.
|
| 384 |
+
*
|
| 385 |
+
* \param handle - A handle to the object to operate on.
|
| 386 |
+
*
|
| 387 |
+
* \sa
|
| 388 |
+
* ::nvtxDomainSyncUserCreate
|
| 389 |
+
* ::nvtxDomainSyncUserDestroy
|
| 390 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 391 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 392 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 393 |
+
* ::nvtxDomainSyncUserReleasing
|
| 394 |
+
*
|
| 395 |
+
* \version \NVTX_VERSION_2
|
| 396 |
+
*/
|
| 397 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserReleasing(nvtxSyncUser_t handle);
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
/** @} */ /*END defgroup*/
|
| 401 |
+
|
| 402 |
+
#ifdef __cplusplus
|
| 403 |
+
}
|
| 404 |
+
#endif /* __cplusplus */
|
| 405 |
+
|
| 406 |
+
#endif /* NVTOOLSEXT_SYNC_H_ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExt.h
ADDED
|
@@ -0,0 +1,1499 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
/** \file nvToolsExt.h
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
/* ========================================================================= */
|
| 42 |
+
/** \mainpage
|
| 43 |
+
* \tableofcontents
|
| 44 |
+
* \section INTRODUCTION Introduction
|
| 45 |
+
*
|
| 46 |
+
* The NVIDIA Tools Extension library is a set of functions that a
|
| 47 |
+
* developer can use to provide additional information to tools.
|
| 48 |
+
* The additional information is used by the tool to improve
|
| 49 |
+
* analysis and visualization of data.
|
| 50 |
+
*
|
| 51 |
+
* The library introduces close to zero overhead if no tool is
|
| 52 |
+
* attached to the application. The overhead when a tool is
|
| 53 |
+
* attached is specific to the tool.
|
| 54 |
+
*
|
| 55 |
+
* \section INITIALIZATION_SECTION Initialization
|
| 56 |
+
*
|
| 57 |
+
* Typically the tool's library that plugs into NVTX is indirectly
|
| 58 |
+
* loaded via enviromental properties that are platform specific.
|
| 59 |
+
* For some platform or special cases, the user may be required
|
| 60 |
+
* to instead explicity initialize instead though. This can also
|
| 61 |
+
* be helpful to control when the API loads a tool's library instead
|
| 62 |
+
* of what would typically be the first function call to emit info.
|
| 63 |
+
* For these rare case, see \ref INITIALIZATION for additional information.
|
| 64 |
+
*
|
| 65 |
+
* \section MARKERS_AND_RANGES Markers and Ranges
|
| 66 |
+
*
|
| 67 |
+
* Markers and ranges are used to describe events at a specific time (markers)
|
| 68 |
+
* or over a time span (ranges) during the execution of the application
|
| 69 |
+
* respectively.
|
| 70 |
+
*
|
| 71 |
+
* \subsection MARKERS Markers
|
| 72 |
+
*
|
| 73 |
+
* Markers denote specific moments in time.
|
| 74 |
+
*
|
| 75 |
+
*
|
| 76 |
+
* See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
|
| 77 |
+
* how to specify the domain.
|
| 78 |
+
*
|
| 79 |
+
* \subsection THREAD_RANGES Thread Ranges
|
| 80 |
+
*
|
| 81 |
+
* Thread ranges denote nested time ranges. Nesting is maintained per thread
|
| 82 |
+
* per domain and does not require any additional correlation mechanism. The
|
| 83 |
+
* duration of a thread range is defined by the corresponding pair of
|
| 84 |
+
* nvtxRangePush* to nvtxRangePop API calls.
|
| 85 |
+
*
|
| 86 |
+
* See \ref DOMAINS and \ref EVENT_ATTRIBUTES for additional information on
|
| 87 |
+
* how to specify the domain.
|
| 88 |
+
*
|
| 89 |
+
* \subsection PROCESS_RANGES Process Ranges
|
| 90 |
+
*
|
| 91 |
+
* Process ranges denote a time span that can expose arbitrary concurrency, as
|
| 92 |
+
* opposed to thread ranges that only support nesting. In addition the range
|
| 93 |
+
* start event can happen on a different thread than the end marker. For the
|
| 94 |
+
* correlation of a start/end pair an unique correlation ID is used that is
|
| 95 |
+
* returned from the start API call and needs to be passed into the end API
|
| 96 |
+
* call.
|
| 97 |
+
*
|
| 98 |
+
* \subsection EVENT_ATTRIBUTES Event Attributes
|
| 99 |
+
*
|
| 100 |
+
* \ref MARKERS_AND_RANGES can be annotated with various attributes to provide
|
| 101 |
+
* additional information for an event or to guide the tool's visualization of
|
| 102 |
+
* the data. Each of the attributes is optional and if left unused the
|
| 103 |
+
* attributes fall back to a default value. The attributes include:
|
| 104 |
+
* - color
|
| 105 |
+
* - category
|
| 106 |
+
*
|
| 107 |
+
* To specify any attribute other than the text message, the \ref
|
| 108 |
+
* EVENT_ATTRIBUTE_STRUCTURE "Event Attribute Structure" must be used.
|
| 109 |
+
*
|
| 110 |
+
* \section DOMAINS Domains
|
| 111 |
+
*
|
| 112 |
+
* Domains enable developers to scope annotations. By default all events and
|
| 113 |
+
* annotations are in the default domain. Additional domains can be registered.
|
| 114 |
+
* This allows developers to scope markers, ranges, and resources names to
|
| 115 |
+
* avoid conflicts.
|
| 116 |
+
*
|
| 117 |
+
* The function ::nvtxDomainCreateA or ::nvtxDomainCreateW is used to create
|
| 118 |
+
* a named domain.
|
| 119 |
+
*
|
| 120 |
+
* Each domain maintains its own
|
| 121 |
+
* - categories
|
| 122 |
+
* - thread range stacks
|
| 123 |
+
* - registered strings
|
| 124 |
+
*
|
| 125 |
+
* The function ::nvtxDomainDestroy marks the end of the domain. Destroying
|
| 126 |
+
* a domain unregisters and destroys all objects associated with it such as
|
| 127 |
+
* registered strings, resource objects, named categories, and started ranges.
|
| 128 |
+
*
|
| 129 |
+
* \section RESOURCE_NAMING Resource Naming
|
| 130 |
+
*
|
| 131 |
+
* This section covers calls that allow to annotate objects with user-provided
|
| 132 |
+
* names in order to allow for a better analysis of complex trace data. All of
|
| 133 |
+
* the functions take the handle or the ID of the object to name and the name.
|
| 134 |
+
* The functions can be called multiple times during the execution of an
|
| 135 |
+
* application, however, in that case it is implementation dependent which
|
| 136 |
+
* name will be reported by the tool.
|
| 137 |
+
*
|
| 138 |
+
* \subsection CATEGORY_NAMING Category Naming
|
| 139 |
+
*
|
| 140 |
+
* Some function in this library support associating an integer category
|
| 141 |
+
* to enable filtering and sorting. The category naming functions allow
|
| 142 |
+
* the application to associate a user friendly name with the integer
|
| 143 |
+
* category. Support for domains have been added in NVTX_VERSION_2 to
|
| 144 |
+
* avoid collisions when domains are developed independantly.
|
| 145 |
+
*
|
| 146 |
+
* \subsection RESOURCE_OBJECTS Resource Objects
|
| 147 |
+
*
|
| 148 |
+
* Resource objects are a generic mechanism for attaching data to an application
|
| 149 |
+
* resource. The identifier field makes the association to a pointer or handle,
|
| 150 |
+
* while the type field helps provide deeper understanding of the identifier as
|
| 151 |
+
* well as enabling differentiation in cases where handles generated by different
|
| 152 |
+
* APIs may collide. The resource object may also have an associated message to
|
| 153 |
+
* associate with the application resource, enabling further annotation of this
|
| 154 |
+
* object and how it is used.
|
| 155 |
+
*
|
| 156 |
+
* The resource object was introduced in NVTX_VERSION_2 to supersede existing naming
|
| 157 |
+
* functions and allow the application resource identified by those functions to be
|
| 158 |
+
* associated to a domain. The other naming functions are still supported for backward
|
| 159 |
+
* compatibility but will be associated only to the default domain.
|
| 160 |
+
*
|
| 161 |
+
* \subsection RESOURCE_NAMING_OS Resource Naming
|
| 162 |
+
*
|
| 163 |
+
* Some operating system resources creation APIs do not support providing a user friendly
|
| 164 |
+
* name, such as some OS thread creation APIs. This API support resource naming though
|
| 165 |
+
* both through resource objects and functions following the pattern
|
| 166 |
+
* nvtxName[RESOURCE_TYPE][A|W](identifier, name). Resource objects introduced in NVTX_VERSION 2
|
| 167 |
+
* supersede the other functions with a a more general method of assigning names to OS resources,
|
| 168 |
+
* along with associating them to domains too. The older nvtxName* functions are only associated
|
| 169 |
+
* with the default domain.
|
| 170 |
+
* \section EXTENSIONS Optional Extensions
|
| 171 |
+
* Optional extensions will either appear within the existing sections the extend or appear
|
| 172 |
+
* in the "Related Pages" when they introduce new concepts.
|
| 173 |
+
*/
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* Tools Extension API version
|
| 177 |
+
*/
|
| 178 |
+
#if defined(NVTX_VERSION) && NVTX_VERSION < 3
|
| 179 |
+
#error "Trying to #include NVTX version 3 in a source file where an older NVTX version has already been included. If you are not directly using NVTX (the NVIDIA Tools Extension library), you are getting this error because libraries you are using have included different versions of NVTX. Suggested solutions are: (1) reorder #includes so the newest NVTX version is included first, (2) avoid using the conflicting libraries in the same .c/.cpp file, or (3) update the library using the older NVTX version to use the newer version instead."
|
| 180 |
+
#endif
|
| 181 |
+
|
| 182 |
+
/* Header guard */
|
| 183 |
+
#if !defined(NVTX_VERSION)
|
| 184 |
+
#define NVTX_VERSION 3
|
| 185 |
+
|
| 186 |
+
#if defined(_MSC_VER)
|
| 187 |
+
#define NVTX_API __stdcall
|
| 188 |
+
#define NVTX_INLINE_STATIC __inline static
|
| 189 |
+
#else /*defined(__GNUC__)*/
|
| 190 |
+
#define NVTX_API
|
| 191 |
+
#define NVTX_INLINE_STATIC inline static
|
| 192 |
+
#endif /* Platform */
|
| 193 |
+
|
| 194 |
+
#if defined(NVTX_NO_IMPL)
|
| 195 |
+
/* When omitting implementation, avoid declaring functions inline */
|
| 196 |
+
/* without definitions, since this causes compiler warnings. */
|
| 197 |
+
#define NVTX_DECLSPEC
|
| 198 |
+
#elif defined(NVTX_EXPORT_API)
|
| 199 |
+
/* Allow overriding definition of NVTX_DECLSPEC when exporting API. */
|
| 200 |
+
/* Default is empty, meaning non-inline with external linkage. */
|
| 201 |
+
#if !defined(NVTX_DECLSPEC)
|
| 202 |
+
#define NVTX_DECLSPEC
|
| 203 |
+
#endif
|
| 204 |
+
#else
|
| 205 |
+
/* Normal NVTX usage defines the NVTX API inline with static */
|
| 206 |
+
/* (internal) linkage. */
|
| 207 |
+
#define NVTX_DECLSPEC NVTX_INLINE_STATIC
|
| 208 |
+
#endif
|
| 209 |
+
|
| 210 |
+
#include "nvtxDetail/nvtxLinkOnce.h"
|
| 211 |
+
|
| 212 |
+
#define NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION) NAME##_v##VERSION
|
| 213 |
+
#define NVTX_VERSIONED_IDENTIFIER_L2(NAME, VERSION) NVTX_VERSIONED_IDENTIFIER_L3(NAME, VERSION)
|
| 214 |
+
#define NVTX_VERSIONED_IDENTIFIER(NAME) NVTX_VERSIONED_IDENTIFIER_L2(NAME, NVTX_VERSION)
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* The nvToolsExt library depends on stdint.h. If the build tool chain in use
|
| 218 |
+
* does not include stdint.h then define NVTX_STDINT_TYPES_ALREADY_DEFINED
|
| 219 |
+
* and define the following types:
|
| 220 |
+
* <ul>
|
| 221 |
+
* <li>uint8_t
|
| 222 |
+
* <li>int8_t
|
| 223 |
+
* <li>uint16_t
|
| 224 |
+
* <li>int16_t
|
| 225 |
+
* <li>uint32_t
|
| 226 |
+
* <li>int32_t
|
| 227 |
+
* <li>uint64_t
|
| 228 |
+
* <li>int64_t
|
| 229 |
+
* <li>uintptr_t
|
| 230 |
+
* <li>intptr_t
|
| 231 |
+
* </ul>
|
| 232 |
+
* #define NVTX_STDINT_TYPES_ALREADY_DEFINED if you are using your own header file.
|
| 233 |
+
*/
|
| 234 |
+
#ifndef NVTX_STDINT_TYPES_ALREADY_DEFINED
|
| 235 |
+
#include <stdint.h>
|
| 236 |
+
#endif
|
| 237 |
+
|
| 238 |
+
#include <stddef.h>
|
| 239 |
+
|
| 240 |
+
#ifdef __cplusplus
|
| 241 |
+
extern "C" {
|
| 242 |
+
#endif /* __cplusplus */
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* Result Codes
|
| 246 |
+
*/
|
| 247 |
+
|
| 248 |
+
#define NVTX_SUCCESS 0
|
| 249 |
+
#define NVTX_FAIL 1
|
| 250 |
+
#define NVTX_ERR_INIT_LOAD_PROPERTY 2
|
| 251 |
+
#define NVTX_ERR_INIT_ACCESS_LIBRARY 3
|
| 252 |
+
#define NVTX_ERR_INIT_LOAD_LIBRARY 4
|
| 253 |
+
#define NVTX_ERR_INIT_MISSING_LIBRARY_ENTRY_POINT 5
|
| 254 |
+
#define NVTX_ERR_INIT_FAILED_LIBRARY_ENTRY_POINT 6
|
| 255 |
+
#define NVTX_ERR_NO_INJECTION_LIBRARY_AVAILABLE 7
|
| 256 |
+
|
| 257 |
+
/**
|
| 258 |
+
* Size of the nvtxEventAttributes_t structure.
|
| 259 |
+
*/
|
| 260 |
+
#define NVTX_EVENT_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxEventAttributes_t) ) )
|
| 261 |
+
|
| 262 |
+
#define NVTX_NO_PUSH_POP_TRACKING ((int)-2)
|
| 263 |
+
|
| 264 |
+
typedef uint64_t nvtxRangeId_t;
|
| 265 |
+
|
| 266 |
+
/* Forward declaration of opaque domain registration structure */
|
| 267 |
+
struct nvtxDomainRegistration_st;
|
| 268 |
+
typedef struct nvtxDomainRegistration_st nvtxDomainRegistration;
|
| 269 |
+
|
| 270 |
+
/* \brief Domain Handle Structure.
|
| 271 |
+
* \anchor DOMAIN_HANDLE_STRUCTURE
|
| 272 |
+
*
|
| 273 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 274 |
+
* a domain. This type is returned from tools when using the NVTX API to
|
| 275 |
+
* create a domain.
|
| 276 |
+
*
|
| 277 |
+
*/
|
| 278 |
+
typedef nvtxDomainRegistration* nvtxDomainHandle_t;
|
| 279 |
+
|
| 280 |
+
/* Forward declaration of opaque string registration structure */
|
| 281 |
+
struct nvtxStringRegistration_st;
|
| 282 |
+
typedef struct nvtxStringRegistration_st nvtxStringRegistration;
|
| 283 |
+
|
| 284 |
+
/* \brief Registered String Handle Structure.
|
| 285 |
+
* \anchor REGISTERED_STRING_HANDLE_STRUCTURE
|
| 286 |
+
*
|
| 287 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 288 |
+
* a registered string. This type is returned from tools when using the NVTX
|
| 289 |
+
* API to create a registered string.
|
| 290 |
+
*
|
| 291 |
+
*/
|
| 292 |
+
typedef nvtxStringRegistration* nvtxStringHandle_t;
|
| 293 |
+
|
| 294 |
+
/* ========================================================================= */
|
| 295 |
+
/** \defgroup GENERAL General
|
| 296 |
+
* @{
|
| 297 |
+
*/
|
| 298 |
+
|
| 299 |
+
/** ---------------------------------------------------------------------------
|
| 300 |
+
* Color Types
|
| 301 |
+
* ------------------------------------------------------------------------- */
|
| 302 |
+
typedef enum nvtxColorType_t
|
| 303 |
+
{
|
| 304 |
+
NVTX_COLOR_UNKNOWN = 0, /**< Color attribute is unused. */
|
| 305 |
+
NVTX_COLOR_ARGB = 1 /**< An ARGB color is provided. */
|
| 306 |
+
} nvtxColorType_t;
|
| 307 |
+
|
| 308 |
+
/** ---------------------------------------------------------------------------
|
| 309 |
+
* Message Types
|
| 310 |
+
* ------------------------------------------------------------------------- */
|
| 311 |
+
typedef enum nvtxMessageType_t
|
| 312 |
+
{
|
| 313 |
+
NVTX_MESSAGE_UNKNOWN = 0, /**< Message payload is unused. */
|
| 314 |
+
NVTX_MESSAGE_TYPE_ASCII = 1, /**< A character sequence is used as payload. */
|
| 315 |
+
NVTX_MESSAGE_TYPE_UNICODE = 2, /**< A wide character sequence is used as payload. */
|
| 316 |
+
/* NVTX_VERSION_2 */
|
| 317 |
+
NVTX_MESSAGE_TYPE_REGISTERED = 3, /**< A unique string handle that was registered
|
| 318 |
+
with \ref nvtxDomainRegisterStringA() or
|
| 319 |
+
\ref nvtxDomainRegisterStringW(). */
|
| 320 |
+
} nvtxMessageType_t;
|
| 321 |
+
|
| 322 |
+
typedef union nvtxMessageValue_t
|
| 323 |
+
{
|
| 324 |
+
const char* ascii;
|
| 325 |
+
const wchar_t* unicode;
|
| 326 |
+
/* NVTX_VERSION_2 */
|
| 327 |
+
nvtxStringHandle_t registered;
|
| 328 |
+
} nvtxMessageValue_t;
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
/** @} */ /*END defgroup*/
|
| 332 |
+
/* ------------------------------------------------------------------------- */
|
| 333 |
+
/** \brief Force initialization (optional)
|
| 334 |
+
*
|
| 335 |
+
* Force NVTX library to initialize. The first call to any NVTX API function
|
| 336 |
+
* will automatically initialize the entire API. This can make the first call
|
| 337 |
+
* much slower than subsequent calls. In applications where the first call to
|
| 338 |
+
* NVTX may be in a performance-critical section, calling nvtxInitialize before
|
| 339 |
+
* any performance-critical sections will ensure NVTX initialization occurs at
|
| 340 |
+
* an acceptable time. Since nvtxInitialize takes no parameters and has no
|
| 341 |
+
* expected behavior besides initialization, it is convenient to add a call to
|
| 342 |
+
* nvtxInitialize in NVTX-instrumented applications that need to force earlier
|
| 343 |
+
* initialization without changing any other code. For example, if an app's
|
| 344 |
+
* first NVTX call is nvtxDomainCreate, and it is difficult to move that call
|
| 345 |
+
* earlier because the domain handle must be stored in an object only created
|
| 346 |
+
* at that point, adding a call to nvtxInitialize at the top of main() will
|
| 347 |
+
* ensure the later call to nvtxDomainCreate is as fast as possible.
|
| 348 |
+
*
|
| 349 |
+
* \version \NVTX_VERSION_3
|
| 350 |
+
*
|
| 351 |
+
* \param reserved - must be zero or NULL.
|
| 352 |
+
*
|
| 353 |
+
* @{ */
|
| 354 |
+
NVTX_DECLSPEC void NVTX_API nvtxInitialize(const void* reserved);
|
| 355 |
+
/** @} */
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
/** @} */ /*END defgroup*/
|
| 359 |
+
|
| 360 |
+
/* ========================================================================= */
|
| 361 |
+
/** \defgroup EVENT_ATTRIBUTES Event Attributes
|
| 362 |
+
* @{
|
| 363 |
+
*/
|
| 364 |
+
|
| 365 |
+
/** ---------------------------------------------------------------------------
|
| 366 |
+
* Payload Types
|
| 367 |
+
* ------------------------------------------------------------------------- */
|
| 368 |
+
typedef enum nvtxPayloadType_t
|
| 369 |
+
{
|
| 370 |
+
NVTX_PAYLOAD_UNKNOWN = 0, /**< Color payload is unused. */
|
| 371 |
+
NVTX_PAYLOAD_TYPE_UNSIGNED_INT64 = 1, /**< A 64 bit unsigned integer value is used as payload. */
|
| 372 |
+
NVTX_PAYLOAD_TYPE_INT64 = 2, /**< A 64 bit signed integer value is used as payload. */
|
| 373 |
+
NVTX_PAYLOAD_TYPE_DOUBLE = 3, /**< A 64 bit floating point value is used as payload. */
|
| 374 |
+
/* NVTX_VERSION_2 */
|
| 375 |
+
NVTX_PAYLOAD_TYPE_UNSIGNED_INT32 = 4, /**< A 32 bit floating point value is used as payload. */
|
| 376 |
+
NVTX_PAYLOAD_TYPE_INT32 = 5, /**< A 32 bit floating point value is used as payload. */
|
| 377 |
+
NVTX_PAYLOAD_TYPE_FLOAT = 6 /**< A 32 bit floating point value is used as payload. */
|
| 378 |
+
} nvtxPayloadType_t;
|
| 379 |
+
|
| 380 |
+
/** \brief Event Attribute Structure.
|
| 381 |
+
* \anchor EVENT_ATTRIBUTE_STRUCTURE
|
| 382 |
+
*
|
| 383 |
+
* This structure is used to describe the attributes of an event. The layout of
|
| 384 |
+
* the structure is defined by a specific version of the tools extension
|
| 385 |
+
* library and can change between different versions of the Tools Extension
|
| 386 |
+
* library.
|
| 387 |
+
*
|
| 388 |
+
* \par Initializing the Attributes
|
| 389 |
+
*
|
| 390 |
+
* The caller should always perform the following three tasks when using
|
| 391 |
+
* attributes:
|
| 392 |
+
* <ul>
|
| 393 |
+
* <li>Zero the structure
|
| 394 |
+
* <li>Set the version field
|
| 395 |
+
* <li>Set the size field
|
| 396 |
+
* </ul>
|
| 397 |
+
*
|
| 398 |
+
* Zeroing the structure sets all the event attributes types and values
|
| 399 |
+
* to the default value.
|
| 400 |
+
*
|
| 401 |
+
* The version and size field are used by the Tools Extension
|
| 402 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 403 |
+
*
|
| 404 |
+
* It is recommended that the caller use one of the following to methods
|
| 405 |
+
* to initialize the event attributes structure:
|
| 406 |
+
*
|
| 407 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 408 |
+
* \code
|
| 409 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 410 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 411 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 412 |
+
* \endcode
|
| 413 |
+
*
|
| 414 |
+
* \par Method 2: Initializing nvtxEventAttributes for a specific version
|
| 415 |
+
* \code
|
| 416 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 417 |
+
* eventAttrib.version = 1;
|
| 418 |
+
* eventAttrib.size = (uint16_t)(sizeof(nvtxEventAttributes_v1));
|
| 419 |
+
* \endcode
|
| 420 |
+
*
|
| 421 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 422 |
+
* layout of the structure be configured to 0 so that all fields
|
| 423 |
+
* are initialized to the default value.
|
| 424 |
+
*
|
| 425 |
+
* The caller should either use both NVTX_VERSION and
|
| 426 |
+
* NVTX_EVENT_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 427 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 428 |
+
* will likely cause either source level incompatibility or binary
|
| 429 |
+
* incompatibility in the future.
|
| 430 |
+
*
|
| 431 |
+
* \par Settings Attribute Types and Values
|
| 432 |
+
*
|
| 433 |
+
*
|
| 434 |
+
* \par Example:
|
| 435 |
+
* \code
|
| 436 |
+
* // Initialize
|
| 437 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 438 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 439 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 440 |
+
*
|
| 441 |
+
* // Configure the Attributes
|
| 442 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 443 |
+
* eventAttrib.color = 0xFF880000;
|
| 444 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 445 |
+
* eventAttrib.message.ascii = "Example";
|
| 446 |
+
* \endcode
|
| 447 |
+
*
|
| 448 |
+
* In the example the caller does not have to set the value of
|
| 449 |
+
* \ref ::nvtxEventAttributes_v2::category or
|
| 450 |
+
* \ref ::nvtxEventAttributes_v2::payload as these fields were set to
|
| 451 |
+
* the default value by {0}.
|
| 452 |
+
* \sa
|
| 453 |
+
* ::nvtxDomainMarkEx
|
| 454 |
+
* ::nvtxDomainRangeStartEx
|
| 455 |
+
* ::nvtxDomainRangePushEx
|
| 456 |
+
*/
|
| 457 |
+
typedef struct nvtxEventAttributes_v2
|
| 458 |
+
{
|
| 459 |
+
/**
|
| 460 |
+
* \brief Version flag of the structure.
|
| 461 |
+
*
|
| 462 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 463 |
+
* supported in this header file. This can optionally be overridden to
|
| 464 |
+
* another version of the tools extension library.
|
| 465 |
+
*/
|
| 466 |
+
uint16_t version;
|
| 467 |
+
|
| 468 |
+
/**
|
| 469 |
+
* \brief Size of the structure.
|
| 470 |
+
*
|
| 471 |
+
* Needs to be set to the size in bytes of the event attribute
|
| 472 |
+
* structure used to specify the event.
|
| 473 |
+
*/
|
| 474 |
+
uint16_t size;
|
| 475 |
+
|
| 476 |
+
/**
|
| 477 |
+
* \brief ID of the category the event is assigned to.
|
| 478 |
+
*
|
| 479 |
+
* A category is a user-controlled ID that can be used to group
|
| 480 |
+
* events. The tool may use category IDs to improve filtering or
|
| 481 |
+
* enable grouping of events in the same category. The functions
|
| 482 |
+
* \ref ::nvtxNameCategoryA or \ref ::nvtxNameCategoryW can be used
|
| 483 |
+
* to name a category.
|
| 484 |
+
*
|
| 485 |
+
* Default Value is 0
|
| 486 |
+
*/
|
| 487 |
+
uint32_t category;
|
| 488 |
+
|
| 489 |
+
/** \brief Color type specified in this attribute structure.
|
| 490 |
+
*
|
| 491 |
+
* Defines the color format of the attribute structure's \ref COLOR_FIELD
|
| 492 |
+
* "color" field.
|
| 493 |
+
*
|
| 494 |
+
* Default Value is NVTX_COLOR_UNKNOWN
|
| 495 |
+
*/
|
| 496 |
+
int32_t colorType; /* nvtxColorType_t */
|
| 497 |
+
|
| 498 |
+
/** \brief Color assigned to this event. \anchor COLOR_FIELD
|
| 499 |
+
*
|
| 500 |
+
* The color that the tool should use to visualize the event.
|
| 501 |
+
*/
|
| 502 |
+
uint32_t color;
|
| 503 |
+
|
| 504 |
+
/**
|
| 505 |
+
* \brief Payload type specified in this attribute structure.
|
| 506 |
+
*
|
| 507 |
+
* Defines the payload format of the attribute structure's \ref PAYLOAD_FIELD
|
| 508 |
+
* "payload" field.
|
| 509 |
+
*
|
| 510 |
+
* Default Value is NVTX_PAYLOAD_UNKNOWN
|
| 511 |
+
*/
|
| 512 |
+
int32_t payloadType; /* nvtxPayloadType_t */
|
| 513 |
+
|
| 514 |
+
int32_t reserved0;
|
| 515 |
+
|
| 516 |
+
/**
|
| 517 |
+
* \brief Payload assigned to this event. \anchor PAYLOAD_FIELD
|
| 518 |
+
*
|
| 519 |
+
* A numerical value that can be used to annotate an event. The tool could
|
| 520 |
+
* use the payload data to reconstruct graphs and diagrams.
|
| 521 |
+
*/
|
| 522 |
+
union payload_t
|
| 523 |
+
{
|
| 524 |
+
uint64_t ullValue;
|
| 525 |
+
int64_t llValue;
|
| 526 |
+
double dValue;
|
| 527 |
+
/* NVTX_VERSION_2 */
|
| 528 |
+
uint32_t uiValue;
|
| 529 |
+
int32_t iValue;
|
| 530 |
+
float fValue;
|
| 531 |
+
} payload;
|
| 532 |
+
|
| 533 |
+
/** \brief Message type specified in this attribute structure.
|
| 534 |
+
*
|
| 535 |
+
* Defines the message format of the attribute structure's \ref MESSAGE_FIELD
|
| 536 |
+
* "message" field.
|
| 537 |
+
*
|
| 538 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 539 |
+
*/
|
| 540 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 541 |
+
|
| 542 |
+
/** \brief Message assigned to this attribute structure. \anchor MESSAGE_FIELD
|
| 543 |
+
*
|
| 544 |
+
* The text message that is attached to an event.
|
| 545 |
+
*/
|
| 546 |
+
nvtxMessageValue_t message;
|
| 547 |
+
|
| 548 |
+
} nvtxEventAttributes_v2;
|
| 549 |
+
|
| 550 |
+
typedef struct nvtxEventAttributes_v2 nvtxEventAttributes_t;
|
| 551 |
+
|
| 552 |
+
/** @} */ /*END defgroup*/
|
| 553 |
+
/* ========================================================================= */
|
| 554 |
+
/** \defgroup MARKERS_AND_RANGES Markers and Ranges
|
| 555 |
+
*
|
| 556 |
+
* See \ref MARKERS_AND_RANGES for more details
|
| 557 |
+
*
|
| 558 |
+
* @{
|
| 559 |
+
*/
|
| 560 |
+
|
| 561 |
+
/** \name Marker */
|
| 562 |
+
|
| 563 |
+
/* ------------------------------------------------------------------------- */
|
| 564 |
+
/** \brief Marks an instantaneous event in the application.
|
| 565 |
+
*
|
| 566 |
+
* A marker can contain a text message or specify additional information
|
| 567 |
+
* using the event attributes structure. These attributes include a text
|
| 568 |
+
* message, color, category, and a payload. Each of the attributes is optional
|
| 569 |
+
* and can only be sent out using the \ref nvtxDomainMarkEx function.
|
| 570 |
+
*
|
| 571 |
+
* nvtxDomainMarkEx(NULL, event) is equivalent to calling
|
| 572 |
+
* nvtxMarkEx(event).
|
| 573 |
+
*
|
| 574 |
+
* \param domain - The domain of scoping the category.
|
| 575 |
+
* \param eventAttrib - The event attribute structure defining the marker's
|
| 576 |
+
* attribute types and attribute values.
|
| 577 |
+
*
|
| 578 |
+
* \sa
|
| 579 |
+
* ::nvtxMarkEx
|
| 580 |
+
*
|
| 581 |
+
* \version \NVTX_VERSION_2
|
| 582 |
+
* @{ */
|
| 583 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainMarkEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 584 |
+
/** @} */
|
| 585 |
+
|
| 586 |
+
/* ------------------------------------------------------------------------- */
|
| 587 |
+
/** \brief Marks an instantaneous event in the application.
|
| 588 |
+
*
|
| 589 |
+
* A marker can contain a text message or specify additional information
|
| 590 |
+
* using the event attributes structure. These attributes include a text
|
| 591 |
+
* message, color, category, and a payload. Each of the attributes is optional
|
| 592 |
+
* and can only be sent out using the \ref nvtxMarkEx function.
|
| 593 |
+
* If \ref nvtxMarkA or \ref nvtxMarkW are used to specify the marker
|
| 594 |
+
* or if an attribute is unspecified then a default value will be used.
|
| 595 |
+
*
|
| 596 |
+
* \param eventAttrib - The event attribute structure defining the marker's
|
| 597 |
+
* attribute types and attribute values.
|
| 598 |
+
*
|
| 599 |
+
* \par Example:
|
| 600 |
+
* \code
|
| 601 |
+
* // zero the structure
|
| 602 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 603 |
+
* // set the version and the size information
|
| 604 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 605 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 606 |
+
* // configure the attributes. 0 is the default for all attributes.
|
| 607 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 608 |
+
* eventAttrib.color = 0xFF880000;
|
| 609 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 610 |
+
* eventAttrib.message.ascii = "Example nvtxMarkEx";
|
| 611 |
+
* nvtxMarkEx(&eventAttrib);
|
| 612 |
+
* \endcode
|
| 613 |
+
*
|
| 614 |
+
* \sa
|
| 615 |
+
* ::nvtxDomainMarkEx
|
| 616 |
+
*
|
| 617 |
+
* \version \NVTX_VERSION_1
|
| 618 |
+
* @{ */
|
| 619 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkEx(const nvtxEventAttributes_t* eventAttrib);
|
| 620 |
+
/** @} */
|
| 621 |
+
|
| 622 |
+
/* ------------------------------------------------------------------------- */
|
| 623 |
+
/** \brief Marks an instantaneous event in the application.
|
| 624 |
+
*
|
| 625 |
+
* A marker created using \ref nvtxMarkA or \ref nvtxMarkW contains only a
|
| 626 |
+
* text message.
|
| 627 |
+
*
|
| 628 |
+
* \param message - The message associated to this marker event.
|
| 629 |
+
*
|
| 630 |
+
* \par Example:
|
| 631 |
+
* \code
|
| 632 |
+
* nvtxMarkA("Example nvtxMarkA");
|
| 633 |
+
* nvtxMarkW(L"Example nvtxMarkW");
|
| 634 |
+
* \endcode
|
| 635 |
+
*
|
| 636 |
+
* \sa
|
| 637 |
+
* ::nvtxDomainMarkEx
|
| 638 |
+
* ::nvtxMarkEx
|
| 639 |
+
*
|
| 640 |
+
* \version \NVTX_VERSION_0
|
| 641 |
+
* @{ */
|
| 642 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkA(const char* message);
|
| 643 |
+
NVTX_DECLSPEC void NVTX_API nvtxMarkW(const wchar_t* message);
|
| 644 |
+
/** @} */
|
| 645 |
+
|
| 646 |
+
|
| 647 |
+
/** \name Process Ranges */
|
| 648 |
+
|
| 649 |
+
/* ------------------------------------------------------------------------- */
|
| 650 |
+
/** \brief Starts a process range in a domain.
|
| 651 |
+
*
|
| 652 |
+
* \param domain - The domain of scoping the category.
|
| 653 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 654 |
+
* attribute types and attribute values.
|
| 655 |
+
*
|
| 656 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 657 |
+
*
|
| 658 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 659 |
+
*
|
| 660 |
+
* \par Example:
|
| 661 |
+
* \code
|
| 662 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
|
| 663 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 664 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 665 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 666 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 667 |
+
* eventAttrib.message.ascii = "my range";
|
| 668 |
+
* nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
|
| 669 |
+
* // ...
|
| 670 |
+
* nvtxDomainRangeEnd(rangeId);
|
| 671 |
+
* \endcode
|
| 672 |
+
*
|
| 673 |
+
* \sa
|
| 674 |
+
* ::nvtxDomainRangeEnd
|
| 675 |
+
*
|
| 676 |
+
* \version \NVTX_VERSION_2
|
| 677 |
+
* @{ */
|
| 678 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxDomainRangeStartEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 679 |
+
/** @} */
|
| 680 |
+
|
| 681 |
+
/* ------------------------------------------------------------------------- */
|
| 682 |
+
/** \brief Starts a process range.
|
| 683 |
+
*
|
| 684 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 685 |
+
* attribute types and attribute values.
|
| 686 |
+
*
|
| 687 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 688 |
+
*
|
| 689 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 690 |
+
*
|
| 691 |
+
* \par Example:
|
| 692 |
+
* \code
|
| 693 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 694 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 695 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 696 |
+
* eventAttrib.category = 3;
|
| 697 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 698 |
+
* eventAttrib.color = 0xFF0088FF;
|
| 699 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 700 |
+
* eventAttrib.message.ascii = "Example Range";
|
| 701 |
+
* nvtxRangeId_t rangeId = nvtxRangeStartEx(&eventAttrib);
|
| 702 |
+
* // ...
|
| 703 |
+
* nvtxRangeEnd(rangeId);
|
| 704 |
+
* \endcode
|
| 705 |
+
*
|
| 706 |
+
* \sa
|
| 707 |
+
* ::nvtxRangeEnd
|
| 708 |
+
* ::nvtxDomainRangeStartEx
|
| 709 |
+
*
|
| 710 |
+
* \version \NVTX_VERSION_1
|
| 711 |
+
* @{ */
|
| 712 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx(const nvtxEventAttributes_t* eventAttrib);
|
| 713 |
+
/** @} */
|
| 714 |
+
|
| 715 |
+
/* ------------------------------------------------------------------------- */
|
| 716 |
+
/** \brief Starts a process range.
|
| 717 |
+
*
|
| 718 |
+
* \param message - The event message associated to this range event.
|
| 719 |
+
*
|
| 720 |
+
* \return The unique ID used to correlate a pair of Start and End events.
|
| 721 |
+
*
|
| 722 |
+
* \remarks Ranges defined by Start/End can overlap.
|
| 723 |
+
*
|
| 724 |
+
* \par Example:
|
| 725 |
+
* \code
|
| 726 |
+
* nvtxRangeId_t r1 = nvtxRangeStartA("Range 1");
|
| 727 |
+
* nvtxRangeId_t r2 = nvtxRangeStartW(L"Range 2");
|
| 728 |
+
* nvtxRangeEnd(r1);
|
| 729 |
+
* nvtxRangeEnd(r2);
|
| 730 |
+
* \endcode
|
| 731 |
+
*
|
| 732 |
+
* \sa
|
| 733 |
+
* ::nvtxRangeEnd
|
| 734 |
+
* ::nvtxRangeStartEx
|
| 735 |
+
* ::nvtxDomainRangeStartEx
|
| 736 |
+
*
|
| 737 |
+
* \version \NVTX_VERSION_0
|
| 738 |
+
* @{ */
|
| 739 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartA(const char* message);
|
| 740 |
+
NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartW(const wchar_t* message);
|
| 741 |
+
/** @} */
|
| 742 |
+
|
| 743 |
+
/* ------------------------------------------------------------------------- */
|
| 744 |
+
/** \brief Ends a process range.
|
| 745 |
+
*
|
| 746 |
+
* \param domain - The domain
|
| 747 |
+
* \param id - The correlation ID returned from a nvtxRangeStart call.
|
| 748 |
+
*
|
| 749 |
+
* \remarks This function is offered completeness but is an alias for ::nvtxRangeEnd.
|
| 750 |
+
* It does not need a domain param since that is associated iwth the range ID at ::nvtxDomainRangeStartEx
|
| 751 |
+
*
|
| 752 |
+
* \par Example:
|
| 753 |
+
* \code
|
| 754 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("my domain");
|
| 755 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 756 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 757 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 758 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 759 |
+
* eventAttrib.message.ascii = "my range";
|
| 760 |
+
* nvtxRangeId_t rangeId = nvtxDomainRangeStartEx(&eventAttrib);
|
| 761 |
+
* // ...
|
| 762 |
+
* nvtxDomainRangeEnd(rangeId);
|
| 763 |
+
* \endcode
|
| 764 |
+
*
|
| 765 |
+
* \sa
|
| 766 |
+
* ::nvtxDomainRangeStartEx
|
| 767 |
+
*
|
| 768 |
+
* \version \NVTX_VERSION_2
|
| 769 |
+
* @{ */
|
| 770 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainRangeEnd(nvtxDomainHandle_t domain, nvtxRangeId_t id);
|
| 771 |
+
/** @} */
|
| 772 |
+
|
| 773 |
+
/* ------------------------------------------------------------------------- */
|
| 774 |
+
/** \brief Ends a process range.
|
| 775 |
+
*
|
| 776 |
+
* \param id - The correlation ID returned from an nvtxRangeStart call.
|
| 777 |
+
*
|
| 778 |
+
* \sa
|
| 779 |
+
* ::nvtxDomainRangeStartEx
|
| 780 |
+
* ::nvtxRangeStartEx
|
| 781 |
+
* ::nvtxRangeStartA
|
| 782 |
+
* ::nvtxRangeStartW
|
| 783 |
+
*
|
| 784 |
+
* \version \NVTX_VERSION_0
|
| 785 |
+
* @{ */
|
| 786 |
+
NVTX_DECLSPEC void NVTX_API nvtxRangeEnd(nvtxRangeId_t id);
|
| 787 |
+
/** @} */
|
| 788 |
+
|
| 789 |
+
/** \name Thread Ranges */
|
| 790 |
+
|
| 791 |
+
/* ------------------------------------------------------------------------- */
|
| 792 |
+
/** \brief Starts a nested thread range.
|
| 793 |
+
*
|
| 794 |
+
* \param domain - The domain of scoping.
|
| 795 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 796 |
+
* attribute types and attribute values.
|
| 797 |
+
*
|
| 798 |
+
* \return The 0 based level of range being started. This value is scoped to the domain.
|
| 799 |
+
* If an error occurs, a negative value is returned.
|
| 800 |
+
*
|
| 801 |
+
* \par Example:
|
| 802 |
+
* \code
|
| 803 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 804 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 805 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 806 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 807 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 808 |
+
* eventAttrib.color = 0xFFFF0000;
|
| 809 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 810 |
+
* eventAttrib.message.ascii = "Level 0";
|
| 811 |
+
* nvtxDomainRangePushEx(domain, &eventAttrib);
|
| 812 |
+
*
|
| 813 |
+
* // Re-use eventAttrib
|
| 814 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
|
| 815 |
+
* eventAttrib.message.unicode = L"Level 1";
|
| 816 |
+
* nvtxDomainRangePushEx(domain, &eventAttrib);
|
| 817 |
+
*
|
| 818 |
+
* nvtxDomainRangePop(domain); //level 1
|
| 819 |
+
* nvtxDomainRangePop(domain); //level 0
|
| 820 |
+
* \endcode
|
| 821 |
+
*
|
| 822 |
+
* \sa
|
| 823 |
+
* ::nvtxDomainRangePop
|
| 824 |
+
*
|
| 825 |
+
* \version \NVTX_VERSION_2
|
| 826 |
+
* @{ */
|
| 827 |
+
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePushEx(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 828 |
+
/** @} */
|
| 829 |
+
|
| 830 |
+
/* ------------------------------------------------------------------------- */
|
| 831 |
+
/** \brief Starts a nested thread range.
|
| 832 |
+
*
|
| 833 |
+
* \param eventAttrib - The event attribute structure defining the range's
|
| 834 |
+
* attribute types and attribute values.
|
| 835 |
+
*
|
| 836 |
+
* \return The 0 based level of range being started. This level is per domain.
|
| 837 |
+
* If an error occurs a negative value is returned.
|
| 838 |
+
*
|
| 839 |
+
* \par Example:
|
| 840 |
+
* \code
|
| 841 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 842 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 843 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 844 |
+
* eventAttrib.colorType = NVTX_COLOR_ARGB;
|
| 845 |
+
* eventAttrib.color = 0xFFFF0000;
|
| 846 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 847 |
+
* eventAttrib.message.ascii = "Level 0";
|
| 848 |
+
* nvtxRangePushEx(&eventAttrib);
|
| 849 |
+
*
|
| 850 |
+
* // Re-use eventAttrib
|
| 851 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_UNICODE;
|
| 852 |
+
* eventAttrib.message.unicode = L"Level 1";
|
| 853 |
+
* nvtxRangePushEx(&eventAttrib);
|
| 854 |
+
*
|
| 855 |
+
* nvtxRangePop();
|
| 856 |
+
* nvtxRangePop();
|
| 857 |
+
* \endcode
|
| 858 |
+
*
|
| 859 |
+
* \sa
|
| 860 |
+
* ::nvtxDomainRangePushEx
|
| 861 |
+
* ::nvtxRangePop
|
| 862 |
+
*
|
| 863 |
+
* \version \NVTX_VERSION_1
|
| 864 |
+
* @{ */
|
| 865 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushEx(const nvtxEventAttributes_t* eventAttrib);
|
| 866 |
+
/** @} */
|
| 867 |
+
|
| 868 |
+
/* ------------------------------------------------------------------------- */
|
| 869 |
+
/** \brief Starts a nested thread range.
|
| 870 |
+
*
|
| 871 |
+
* \param message - The event message associated to this range event.
|
| 872 |
+
*
|
| 873 |
+
* \return The 0 based level of range being started. If an error occurs a
|
| 874 |
+
* negative value is returned.
|
| 875 |
+
*
|
| 876 |
+
* \par Example:
|
| 877 |
+
* \code
|
| 878 |
+
* nvtxRangePushA("Level 0");
|
| 879 |
+
* nvtxRangePushW(L"Level 1");
|
| 880 |
+
* nvtxRangePop();
|
| 881 |
+
* nvtxRangePop();
|
| 882 |
+
* \endcode
|
| 883 |
+
*
|
| 884 |
+
* \sa
|
| 885 |
+
* ::nvtxDomainRangePushEx
|
| 886 |
+
* ::nvtxRangePop
|
| 887 |
+
*
|
| 888 |
+
* \version \NVTX_VERSION_0
|
| 889 |
+
* @{ */
|
| 890 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushA(const char* message);
|
| 891 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePushW(const wchar_t* message);
|
| 892 |
+
/** @} */
|
| 893 |
+
|
| 894 |
+
|
| 895 |
+
/* ------------------------------------------------------------------------- */
|
| 896 |
+
/** \brief Ends a nested thread range.
|
| 897 |
+
*
|
| 898 |
+
* \return The level of the range being ended. If an error occurs a negative
|
| 899 |
+
* value is returned on the current thread.
|
| 900 |
+
*
|
| 901 |
+
* \par Example:
|
| 902 |
+
* \code
|
| 903 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreate("example library");
|
| 904 |
+
* nvtxDomainRangePushA(domain, "Level 0");
|
| 905 |
+
* nvtxDomainRangePushW(domain, L"Level 1");
|
| 906 |
+
* nvtxDomainRangePop(domain);
|
| 907 |
+
* nvtxDomainRangePop(domain);
|
| 908 |
+
* \endcode
|
| 909 |
+
*
|
| 910 |
+
* \sa
|
| 911 |
+
* ::nvtxRangePushEx
|
| 912 |
+
* ::nvtxRangePushA
|
| 913 |
+
* ::nvtxRangePushW
|
| 914 |
+
*
|
| 915 |
+
* \version \NVTX_VERSION_2
|
| 916 |
+
* @{ */
|
| 917 |
+
NVTX_DECLSPEC int NVTX_API nvtxDomainRangePop(nvtxDomainHandle_t domain);
|
| 918 |
+
/** @} */
|
| 919 |
+
|
| 920 |
+
/* ------------------------------------------------------------------------- */
|
| 921 |
+
/** \brief Ends a nested thread range.
|
| 922 |
+
*
|
| 923 |
+
* \return The level of the range being ended. If an error occurs a negative
|
| 924 |
+
* value is returned on the current thread.
|
| 925 |
+
*
|
| 926 |
+
* \par Example:
|
| 927 |
+
* \code
|
| 928 |
+
* nvtxRangePushA("Level 0");
|
| 929 |
+
* nvtxRangePushW(L"Level 1");
|
| 930 |
+
* nvtxRangePop();
|
| 931 |
+
* nvtxRangePop();
|
| 932 |
+
* \endcode
|
| 933 |
+
*
|
| 934 |
+
* \sa
|
| 935 |
+
* ::nvtxRangePushEx
|
| 936 |
+
* ::nvtxRangePushA
|
| 937 |
+
* ::nvtxRangePushW
|
| 938 |
+
*
|
| 939 |
+
* \version \NVTX_VERSION_0
|
| 940 |
+
* @{ */
|
| 941 |
+
NVTX_DECLSPEC int NVTX_API nvtxRangePop(void);
|
| 942 |
+
/** @} */
|
| 943 |
+
|
| 944 |
+
|
| 945 |
+
/** @} */ /*END defgroup*/
|
| 946 |
+
/* ========================================================================= */
|
| 947 |
+
/** \defgroup RESOURCE_NAMING Resource Naming
|
| 948 |
+
*
|
| 949 |
+
* See \ref RESOURCE_NAMING for more details
|
| 950 |
+
*
|
| 951 |
+
* @{
|
| 952 |
+
*/
|
| 953 |
+
|
| 954 |
+
|
| 955 |
+
/* ------------------------------------------------------------------------- */
|
| 956 |
+
/** \name Functions for Generic Resource Naming*/
|
| 957 |
+
/* ------------------------------------------------------------------------- */
|
| 958 |
+
|
| 959 |
+
/* ------------------------------------------------------------------------- */
|
| 960 |
+
/** \cond SHOW_HIDDEN
|
| 961 |
+
* \brief Resource typing helpers.
|
| 962 |
+
*
|
| 963 |
+
* Classes are used to make it easy to create a series of resource types
|
| 964 |
+
* per API without collisions
|
| 965 |
+
*/
|
| 966 |
+
#define NVTX_RESOURCE_MAKE_TYPE(CLASS, INDEX) ((((uint32_t)(NVTX_RESOURCE_CLASS_ ## CLASS))<<16)|((uint32_t)(INDEX)))
|
| 967 |
+
#define NVTX_RESOURCE_CLASS_GENERIC 1
|
| 968 |
+
/** \endcond */
|
| 969 |
+
|
| 970 |
+
/* ------------------------------------------------------------------------- */
|
| 971 |
+
/** \brief Generic resource type for when a resource class is not available.
|
| 972 |
+
*
|
| 973 |
+
* \sa
|
| 974 |
+
* ::nvtxDomainResourceCreate
|
| 975 |
+
*
|
| 976 |
+
* \version \NVTX_VERSION_2
|
| 977 |
+
*/
|
| 978 |
+
typedef enum nvtxResourceGenericType_t
|
| 979 |
+
{
|
| 980 |
+
NVTX_RESOURCE_TYPE_UNKNOWN = 0,
|
| 981 |
+
NVTX_RESOURCE_TYPE_GENERIC_POINTER = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 1), /**< Generic pointer assumed to have no collisions with other pointers. */
|
| 982 |
+
NVTX_RESOURCE_TYPE_GENERIC_HANDLE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 2), /**< Generic handle assumed to have no collisions with other handles. */
|
| 983 |
+
NVTX_RESOURCE_TYPE_GENERIC_THREAD_NATIVE = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 3), /**< OS native thread identifier. */
|
| 984 |
+
NVTX_RESOURCE_TYPE_GENERIC_THREAD_POSIX = NVTX_RESOURCE_MAKE_TYPE(GENERIC, 4) /**< POSIX pthread identifier. */
|
| 985 |
+
} nvtxResourceGenericType_t;
|
| 986 |
+
|
| 987 |
+
|
| 988 |
+
|
| 989 |
+
/** \brief Resource Attribute Structure.
|
| 990 |
+
* \anchor RESOURCE_ATTRIBUTE_STRUCTURE
|
| 991 |
+
*
|
| 992 |
+
* This structure is used to describe the attributes of a resource. The layout of
|
| 993 |
+
* the structure is defined by a specific version of the tools extension
|
| 994 |
+
* library and can change between different versions of the Tools Extension
|
| 995 |
+
* library.
|
| 996 |
+
*
|
| 997 |
+
* \par Initializing the Attributes
|
| 998 |
+
*
|
| 999 |
+
* The caller should always perform the following three tasks when using
|
| 1000 |
+
* attributes:
|
| 1001 |
+
* <ul>
|
| 1002 |
+
* <li>Zero the structure
|
| 1003 |
+
* <li>Set the version field
|
| 1004 |
+
* <li>Set the size field
|
| 1005 |
+
* </ul>
|
| 1006 |
+
*
|
| 1007 |
+
* Zeroing the structure sets all the resource attributes types and values
|
| 1008 |
+
* to the default value.
|
| 1009 |
+
*
|
| 1010 |
+
* The version and size field are used by the Tools Extension
|
| 1011 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 1012 |
+
*
|
| 1013 |
+
* It is recommended that the caller use one of the following to methods
|
| 1014 |
+
* to initialize the event attributes structure:
|
| 1015 |
+
*
|
| 1016 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 1017 |
+
* \code
|
| 1018 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1019 |
+
* attribs.version = NVTX_VERSION;
|
| 1020 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1021 |
+
* \endcode
|
| 1022 |
+
*
|
| 1023 |
+
* \par Method 2: Initializing nvtxEventAttributes for a specific version
|
| 1024 |
+
* \code
|
| 1025 |
+
* nvtxResourceAttributes_v0 attribs = {0};
|
| 1026 |
+
* attribs.version = 2;
|
| 1027 |
+
* attribs.size = (uint16_t)(sizeof(nvtxResourceAttributes_v0));
|
| 1028 |
+
* \endcode
|
| 1029 |
+
*
|
| 1030 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 1031 |
+
* layout of the structure be configured to 0 so that all fields
|
| 1032 |
+
* are initialized to the default value.
|
| 1033 |
+
*
|
| 1034 |
+
* The caller should either use both NVTX_VERSION and
|
| 1035 |
+
* NVTX_RESOURCE_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 1036 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 1037 |
+
* will likely cause either source level incompatibility or binary
|
| 1038 |
+
* incompatibility in the future.
|
| 1039 |
+
*
|
| 1040 |
+
* \par Settings Attribute Types and Values
|
| 1041 |
+
*
|
| 1042 |
+
*
|
| 1043 |
+
* \par Example:
|
| 1044 |
+
* \code
|
| 1045 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1046 |
+
*
|
| 1047 |
+
* // Initialize
|
| 1048 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1049 |
+
* attribs.version = NVTX_VERSION;
|
| 1050 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1051 |
+
*
|
| 1052 |
+
* // Configure the Attributes
|
| 1053 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1054 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1055 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1056 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1057 |
+
*
|
| 1058 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1059 |
+
* \endcode
|
| 1060 |
+
*
|
| 1061 |
+
* \sa
|
| 1062 |
+
* ::nvtxDomainResourceCreate
|
| 1063 |
+
*/
|
| 1064 |
+
typedef struct nvtxResourceAttributes_v0
|
| 1065 |
+
{
|
| 1066 |
+
/**
|
| 1067 |
+
* \brief Version flag of the structure.
|
| 1068 |
+
*
|
| 1069 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 1070 |
+
* supported in this header file. This can optionally be overridden to
|
| 1071 |
+
* another version of the tools extension library.
|
| 1072 |
+
*/
|
| 1073 |
+
uint16_t version;
|
| 1074 |
+
|
| 1075 |
+
/**
|
| 1076 |
+
* \brief Size of the structure.
|
| 1077 |
+
*
|
| 1078 |
+
* Needs to be set to the size in bytes of this attribute
|
| 1079 |
+
* structure.
|
| 1080 |
+
*/
|
| 1081 |
+
uint16_t size;
|
| 1082 |
+
|
| 1083 |
+
/**
|
| 1084 |
+
* \brief Identifier type specifies how to interpret the identifier field
|
| 1085 |
+
*
|
| 1086 |
+
* Defines the identifier format of the attribute structure's \ref RESOURCE_IDENTIFIER_FIELD
|
| 1087 |
+
* "identifier" field.
|
| 1088 |
+
*
|
| 1089 |
+
* Default Value is NVTX_RESOURCE_TYPE_UNKNOWN
|
| 1090 |
+
*/
|
| 1091 |
+
int32_t identifierType; /* values from enums following the pattern nvtxResource[name]Type_t */
|
| 1092 |
+
|
| 1093 |
+
/**
|
| 1094 |
+
* \brief Identifier for the resource.
|
| 1095 |
+
* \anchor RESOURCE_IDENTIFIER_FIELD
|
| 1096 |
+
*
|
| 1097 |
+
* An identifier may be a pointer or a handle to an OS or middleware API object.
|
| 1098 |
+
* The resource type will assist in avoiding collisions where handles values may collide.
|
| 1099 |
+
*/
|
| 1100 |
+
union identifier_t
|
| 1101 |
+
{
|
| 1102 |
+
const void* pValue;
|
| 1103 |
+
uint64_t ullValue;
|
| 1104 |
+
} identifier;
|
| 1105 |
+
|
| 1106 |
+
/** \brief Message type specified in this attribute structure.
|
| 1107 |
+
*
|
| 1108 |
+
* Defines the message format of the attribute structure's \ref RESOURCE_MESSAGE_FIELD
|
| 1109 |
+
* "message" field.
|
| 1110 |
+
*
|
| 1111 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 1112 |
+
*/
|
| 1113 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 1114 |
+
|
| 1115 |
+
/** \brief Message assigned to this attribute structure. \anchor RESOURCE_MESSAGE_FIELD
|
| 1116 |
+
*
|
| 1117 |
+
* The text message that is attached to a resource.
|
| 1118 |
+
*/
|
| 1119 |
+
nvtxMessageValue_t message;
|
| 1120 |
+
|
| 1121 |
+
} nvtxResourceAttributes_v0;
|
| 1122 |
+
|
| 1123 |
+
typedef struct nvtxResourceAttributes_v0 nvtxResourceAttributes_t;
|
| 1124 |
+
|
| 1125 |
+
/* \cond SHOW_HIDDEN
|
| 1126 |
+
* \version \NVTX_VERSION_2
|
| 1127 |
+
*/
|
| 1128 |
+
#define NVTX_RESOURCE_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxResourceAttributes_v0) ) )
|
| 1129 |
+
typedef struct nvtxResourceHandle* nvtxResourceHandle_t;
|
| 1130 |
+
/** \endcond */
|
| 1131 |
+
|
| 1132 |
+
|
| 1133 |
+
|
| 1134 |
+
/* ------------------------------------------------------------------------- */
|
| 1135 |
+
/** \brief Create a resource object to track and associate data with OS and middleware objects
|
| 1136 |
+
*
|
| 1137 |
+
* Allows users to associate an API handle or pointer with a user-provided name.
|
| 1138 |
+
*
|
| 1139 |
+
*
|
| 1140 |
+
* \param domain - Domain to own the resource object
|
| 1141 |
+
* \param attribs - Attributes to be associated with the resource
|
| 1142 |
+
*
|
| 1143 |
+
* \return A handle that represents the newly created resource object.
|
| 1144 |
+
*
|
| 1145 |
+
* \par Example:
|
| 1146 |
+
* \code
|
| 1147 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1148 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1149 |
+
* attribs.version = NVTX_VERSION;
|
| 1150 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1151 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1152 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1153 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1154 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1155 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1156 |
+
* \endcode
|
| 1157 |
+
*
|
| 1158 |
+
* \sa
|
| 1159 |
+
* ::nvtxResourceAttributes_t
|
| 1160 |
+
* ::nvtxDomainResourceDestroy
|
| 1161 |
+
*
|
| 1162 |
+
* \version \NVTX_VERSION_2
|
| 1163 |
+
* @{ */
|
| 1164 |
+
NVTX_DECLSPEC nvtxResourceHandle_t NVTX_API nvtxDomainResourceCreate(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
|
| 1165 |
+
/** @} */
|
| 1166 |
+
|
| 1167 |
+
/* ------------------------------------------------------------------------- */
|
| 1168 |
+
/** \brief Destroy a resource object to track and associate data with OS and middleware objects
|
| 1169 |
+
*
|
| 1170 |
+
* Allows users to associate an API handle or pointer with a user-provided name.
|
| 1171 |
+
*
|
| 1172 |
+
* \param resource - Handle to the resource in which to operate.
|
| 1173 |
+
*
|
| 1174 |
+
* \par Example:
|
| 1175 |
+
* \code
|
| 1176 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example domain");
|
| 1177 |
+
* nvtxResourceAttributes_t attribs = {0};
|
| 1178 |
+
* attribs.version = NVTX_VERSION;
|
| 1179 |
+
* attribs.size = NVTX_RESOURCE_ATTRIB_STRUCT_SIZE;
|
| 1180 |
+
* attribs.identifierType = NVTX_RESOURCE_TYPE_GENERIC_POINTER;
|
| 1181 |
+
* attribs.identifier.pValue = (const void*)pMutex;
|
| 1182 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 1183 |
+
* attribs.message.ascii = "Single thread access to database.";
|
| 1184 |
+
* nvtxResourceHandle_t handle = nvtxDomainResourceCreate(domain, attribs);
|
| 1185 |
+
* nvtxDomainResourceDestroy(handle);
|
| 1186 |
+
* \endcode
|
| 1187 |
+
*
|
| 1188 |
+
* \sa
|
| 1189 |
+
* ::nvtxDomainResourceCreate
|
| 1190 |
+
*
|
| 1191 |
+
* \version \NVTX_VERSION_2
|
| 1192 |
+
* @{ */
|
| 1193 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainResourceDestroy(nvtxResourceHandle_t resource);
|
| 1194 |
+
/** @} */
|
| 1195 |
+
|
| 1196 |
+
|
| 1197 |
+
/** \name Functions for NVTX Category Naming*/
|
| 1198 |
+
|
| 1199 |
+
/* ------------------------------------------------------------------------- */
|
| 1200 |
+
/**
|
| 1201 |
+
* \brief Annotate an NVTX category used within a domain.
|
| 1202 |
+
*
|
| 1203 |
+
* Categories are used to group sets of events. Each category is identified
|
| 1204 |
+
* through a unique ID and that ID is passed into any of the marker/range
|
| 1205 |
+
* events to assign that event to a specific category. The nvtxDomainNameCategory
|
| 1206 |
+
* function calls allow the user to assign a name to a category ID that is
|
| 1207 |
+
* specific to the domain.
|
| 1208 |
+
*
|
| 1209 |
+
* nvtxDomainNameCategory(NULL, category, name) is equivalent to calling
|
| 1210 |
+
* nvtxNameCategory(category, name).
|
| 1211 |
+
*
|
| 1212 |
+
* \param domain - The domain of scoping the category.
|
| 1213 |
+
* \param category - The category ID to name.
|
| 1214 |
+
* \param name - The name of the category.
|
| 1215 |
+
*
|
| 1216 |
+
* \remarks The category names are tracked per domain.
|
| 1217 |
+
*
|
| 1218 |
+
* \par Example:
|
| 1219 |
+
* \code
|
| 1220 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("example");
|
| 1221 |
+
* nvtxDomainNameCategoryA(domain, 1, "Memory Allocation");
|
| 1222 |
+
* nvtxDomainNameCategoryW(domain, 2, L"Memory Transfer");
|
| 1223 |
+
* \endcode
|
| 1224 |
+
*
|
| 1225 |
+
* \version \NVTX_VERSION_2
|
| 1226 |
+
* @{ */
|
| 1227 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryA(nvtxDomainHandle_t domain, uint32_t category, const char* name);
|
| 1228 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainNameCategoryW(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
|
| 1229 |
+
/** @} */
|
| 1230 |
+
|
| 1231 |
+
/** \brief Annotate an NVTX category.
|
| 1232 |
+
*
|
| 1233 |
+
* Categories are used to group sets of events. Each category is identified
|
| 1234 |
+
* through a unique ID and that ID is passed into any of the marker/range
|
| 1235 |
+
* events to assign that event to a specific category. The nvtxNameCategory
|
| 1236 |
+
* function calls allow the user to assign a name to a category ID.
|
| 1237 |
+
*
|
| 1238 |
+
* \param category - The category ID to name.
|
| 1239 |
+
* \param name - The name of the category.
|
| 1240 |
+
*
|
| 1241 |
+
* \remarks The category names are tracked per process.
|
| 1242 |
+
*
|
| 1243 |
+
* \par Example:
|
| 1244 |
+
* \code
|
| 1245 |
+
* nvtxNameCategory(1, "Memory Allocation");
|
| 1246 |
+
* nvtxNameCategory(2, "Memory Transfer");
|
| 1247 |
+
* nvtxNameCategory(3, "Memory Object Lifetime");
|
| 1248 |
+
* \endcode
|
| 1249 |
+
*
|
| 1250 |
+
* \version \NVTX_VERSION_1
|
| 1251 |
+
* @{ */
|
| 1252 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCategoryA(uint32_t category, const char* name);
|
| 1253 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCategoryW(uint32_t category, const wchar_t* name);
|
| 1254 |
+
/** @} */
|
| 1255 |
+
|
| 1256 |
+
/** \name Functions for OS Threads Naming*/
|
| 1257 |
+
|
| 1258 |
+
/* ------------------------------------------------------------------------- */
|
| 1259 |
+
/** \brief Annotate an OS thread.
|
| 1260 |
+
*
|
| 1261 |
+
* Allows the user to name an active thread of the current process. If an
|
| 1262 |
+
* invalid thread ID is provided or a thread ID from a different process is
|
| 1263 |
+
* used the behavior of the tool is implementation dependent.
|
| 1264 |
+
*
|
| 1265 |
+
* Tools expect thread ID to be a number that uniquely identifies the thread
|
| 1266 |
+
* at the time of the call. Note that a thread's ID can be reused after
|
| 1267 |
+
* it is destroyed. Tools may choose how to handle aliasing of thread IDs.
|
| 1268 |
+
*
|
| 1269 |
+
* POSIX pthread_t type returned by pthread_self() may not comply with these
|
| 1270 |
+
* expectations. Please use OS-specific thread ID instead of pthread_t.
|
| 1271 |
+
*
|
| 1272 |
+
* The thread name is associated to the default domain. To support domains
|
| 1273 |
+
* use resource objects via ::nvtxDomainResourceCreate.
|
| 1274 |
+
*
|
| 1275 |
+
* \param threadId - The ID of the thread to name.
|
| 1276 |
+
* \param name - The name of the thread.
|
| 1277 |
+
*
|
| 1278 |
+
* \par Examples:
|
| 1279 |
+
* MS Windows:
|
| 1280 |
+
* \code
|
| 1281 |
+
* #include <windows.h>
|
| 1282 |
+
* nvtxNameOsThread(GetCurrentThreadId(), "Current thread");
|
| 1283 |
+
* nvtxNameOsThread(GetThreadId(SomeThreadHandle), "Other thread");
|
| 1284 |
+
* \endcode
|
| 1285 |
+
*
|
| 1286 |
+
* Android:
|
| 1287 |
+
* \code
|
| 1288 |
+
* #include <unistd.h>
|
| 1289 |
+
* nvtxNameOsThreadA(gettid(), "Current thread");
|
| 1290 |
+
* nvtxNameOsThreadA(getpid(), "Main thread");
|
| 1291 |
+
* \endcode
|
| 1292 |
+
*
|
| 1293 |
+
* Linux:
|
| 1294 |
+
* \code
|
| 1295 |
+
* #include <sys/syscall.h>
|
| 1296 |
+
* nvtxNameOsThreadA(syscall(SYS_gettid), "Current thread");
|
| 1297 |
+
* \endcode
|
| 1298 |
+
* \code
|
| 1299 |
+
* #include <unistd.h>
|
| 1300 |
+
* nvtxNameOsThreadA(getpid(), "Main thread");
|
| 1301 |
+
* \endcode
|
| 1302 |
+
*
|
| 1303 |
+
* OS X:
|
| 1304 |
+
* \code
|
| 1305 |
+
* #include <sys/syscall.h>
|
| 1306 |
+
* nvtxNameOsThreadA(syscall(SYS_thread_selfid), "Current thread");
|
| 1307 |
+
* \endcode
|
| 1308 |
+
* \code
|
| 1309 |
+
* #include <pthread.h>
|
| 1310 |
+
* __uint64_t id;
|
| 1311 |
+
* pthread_threadid_np(pthread_self(), &id);
|
| 1312 |
+
* nvtxNameOsThreadA(id, "Current thread");
|
| 1313 |
+
* pthread_threadid_np(somePThreadId, &id);
|
| 1314 |
+
* nvtxNameOsThreadA(id, "Other thread");
|
| 1315 |
+
* \endcode
|
| 1316 |
+
*
|
| 1317 |
+
* \version \NVTX_VERSION_1
|
| 1318 |
+
* @{ */
|
| 1319 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadA(uint32_t threadId, const char* name);
|
| 1320 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameOsThreadW(uint32_t threadId, const wchar_t* name);
|
| 1321 |
+
/** @} */
|
| 1322 |
+
|
| 1323 |
+
|
| 1324 |
+
/** @} */ /*END defgroup*/
|
| 1325 |
+
/* ========================================================================= */
|
| 1326 |
+
/** \defgroup STRING_REGISTRATION String Registration
|
| 1327 |
+
*
|
| 1328 |
+
* Registered strings are intended to increase performance by lowering instrumentation
|
| 1329 |
+
* overhead. String may be registered once and the handle may be passed in place of
|
| 1330 |
+
* a string where an the APIs may allow.
|
| 1331 |
+
*
|
| 1332 |
+
* See \ref STRING_REGISTRATION for more details
|
| 1333 |
+
*
|
| 1334 |
+
* @{
|
| 1335 |
+
*/
|
| 1336 |
+
|
| 1337 |
+
/* ------------------------------------------------------------------------- */
|
| 1338 |
+
/** \brief Register a string.
|
| 1339 |
+
|
| 1340 |
+
* Registers an immutable string with NVTX. Once registered the pointer used
|
| 1341 |
+
* to register the domain name can be used in nvtxEventAttributes_t
|
| 1342 |
+
* \ref MESSAGE_FIELD. This allows NVTX implementation to skip copying the
|
| 1343 |
+
* contents of the message on each event invocation.
|
| 1344 |
+
*
|
| 1345 |
+
* String registration is an optimization. It is recommended to use string
|
| 1346 |
+
* registration if the string will be passed to an event many times.
|
| 1347 |
+
*
|
| 1348 |
+
* String are not unregistered, except that by unregistering the entire domain
|
| 1349 |
+
*
|
| 1350 |
+
* \param domain - Domain handle. If NULL then the global domain is used.
|
| 1351 |
+
* \param string - A unique pointer to a sequence of characters.
|
| 1352 |
+
*
|
| 1353 |
+
* \return A handle representing the registered string.
|
| 1354 |
+
*
|
| 1355 |
+
* \par Example:
|
| 1356 |
+
* \code
|
| 1357 |
+
* nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1358 |
+
* nvtxStringHandle_t message = nvtxDomainRegisterStringA(domain, "registered string");
|
| 1359 |
+
* nvtxEventAttributes_t eventAttrib = {0};
|
| 1360 |
+
* eventAttrib.version = NVTX_VERSION;
|
| 1361 |
+
* eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1362 |
+
* eventAttrib.messageType = NVTX_MESSAGE_TYPE_REGISTERED;
|
| 1363 |
+
* eventAttrib.message.registered = message;
|
| 1364 |
+
* \endcode
|
| 1365 |
+
*
|
| 1366 |
+
* \version \NVTX_VERSION_2
|
| 1367 |
+
* @{ */
|
| 1368 |
+
NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringA(nvtxDomainHandle_t domain, const char* string);
|
| 1369 |
+
NVTX_DECLSPEC nvtxStringHandle_t NVTX_API nvtxDomainRegisterStringW(nvtxDomainHandle_t domain, const wchar_t* string);
|
| 1370 |
+
/** @} */
|
| 1371 |
+
|
| 1372 |
+
/** @} */ /*END defgroup*/
|
| 1373 |
+
/* ========================================================================= */
|
| 1374 |
+
/** \defgroup DOMAINS Domains
|
| 1375 |
+
*
|
| 1376 |
+
* Domains are used to group events to a developer defined scope. Middleware
|
| 1377 |
+
* vendors may also scope their own events to avoid collisions with the
|
| 1378 |
+
* the application developer's events, so that the application developer may
|
| 1379 |
+
* inspect both parts and easily differentiate or filter them. By default
|
| 1380 |
+
* all events are scoped to a global domain where NULL is provided or when
|
| 1381 |
+
* using APIs provided b versions of NVTX below v2
|
| 1382 |
+
*
|
| 1383 |
+
* Domains are intended to be typically long lived objects with the intention
|
| 1384 |
+
* of logically separating events of large modules from each other such as
|
| 1385 |
+
* middleware libraries from each other and the main application.
|
| 1386 |
+
*
|
| 1387 |
+
* See \ref DOMAINS for more details
|
| 1388 |
+
*
|
| 1389 |
+
* @{
|
| 1390 |
+
*/
|
| 1391 |
+
|
| 1392 |
+
/* ------------------------------------------------------------------------- */
|
| 1393 |
+
/** \brief Register a NVTX domain.
|
| 1394 |
+
*
|
| 1395 |
+
* Domains are used to scope annotations. All NVTX_VERSION_0 and NVTX_VERSION_1
|
| 1396 |
+
* annotations are scoped to the global domain. The function nvtxDomainCreate
|
| 1397 |
+
* creates a new named domain.
|
| 1398 |
+
*
|
| 1399 |
+
* Each domain maintains its own nvtxRangePush and nvtxRangePop stack.
|
| 1400 |
+
*
|
| 1401 |
+
* \param name - A unique string representing the domain.
|
| 1402 |
+
*
|
| 1403 |
+
* \return A handle representing the domain.
|
| 1404 |
+
*
|
| 1405 |
+
* \par Example:
|
| 1406 |
+
* \code
|
| 1407 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1408 |
+
*
|
| 1409 |
+
* nvtxMarkA("nvtxMarkA to global domain");
|
| 1410 |
+
*
|
| 1411 |
+
* nvtxEventAttributes_t eventAttrib1 = {0};
|
| 1412 |
+
* eventAttrib1.version = NVTX_VERSION;
|
| 1413 |
+
* eventAttrib1.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1414 |
+
* eventAttrib1.message.ascii = "nvtxDomainMarkEx to global domain";
|
| 1415 |
+
* nvtxDomainMarkEx(NULL, &eventAttrib1);
|
| 1416 |
+
*
|
| 1417 |
+
* nvtxEventAttributes_t eventAttrib2 = {0};
|
| 1418 |
+
* eventAttrib2.version = NVTX_VERSION;
|
| 1419 |
+
* eventAttrib2.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
|
| 1420 |
+
* eventAttrib2.message.ascii = "nvtxDomainMarkEx to com.nvidia.nvtx.example";
|
| 1421 |
+
* nvtxDomainMarkEx(domain, &eventAttrib2);
|
| 1422 |
+
* nvtxDomainDestroy(domain);
|
| 1423 |
+
* \endcode
|
| 1424 |
+
*
|
| 1425 |
+
* \sa
|
| 1426 |
+
* ::nvtxDomainDestroy
|
| 1427 |
+
*
|
| 1428 |
+
* \version \NVTX_VERSION_2
|
| 1429 |
+
* @{ */
|
| 1430 |
+
NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateA(const char* name);
|
| 1431 |
+
NVTX_DECLSPEC nvtxDomainHandle_t NVTX_API nvtxDomainCreateW(const wchar_t* name);
|
| 1432 |
+
/** @} */
|
| 1433 |
+
|
| 1434 |
+
/* ------------------------------------------------------------------------- */
|
| 1435 |
+
/** \brief Unregister a NVTX domain.
|
| 1436 |
+
*
|
| 1437 |
+
* Unregisters the domain handle and frees all domain specific resources.
|
| 1438 |
+
*
|
| 1439 |
+
* \param domain - the domain handle
|
| 1440 |
+
*
|
| 1441 |
+
* \par Example:
|
| 1442 |
+
* \code
|
| 1443 |
+
* nvtxDomainHandle_t domain = nvtxDomainCreateA("com.nvidia.nvtx.example");
|
| 1444 |
+
* nvtxDomainDestroy(domain);
|
| 1445 |
+
* \endcode
|
| 1446 |
+
*
|
| 1447 |
+
* \sa
|
| 1448 |
+
* ::nvtxDomainCreateA
|
| 1449 |
+
* ::nvtxDomainCreateW
|
| 1450 |
+
*
|
| 1451 |
+
* \version \NVTX_VERSION_2
|
| 1452 |
+
* @{ */
|
| 1453 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainDestroy(nvtxDomainHandle_t domain);
|
| 1454 |
+
/** @} */
|
| 1455 |
+
|
| 1456 |
+
|
| 1457 |
+
/** @} */ /*END defgroup*/
|
| 1458 |
+
/* ========================================================================= */
|
| 1459 |
+
/** \cond SHOW_HIDDEN */
|
| 1460 |
+
|
| 1461 |
+
#ifdef UNICODE
|
| 1462 |
+
#define nvtxMark nvtxMarkW
|
| 1463 |
+
#define nvtxRangeStart nvtxRangeStartW
|
| 1464 |
+
#define nvtxRangePush nvtxRangePushW
|
| 1465 |
+
#define nvtxNameCategory nvtxNameCategoryW
|
| 1466 |
+
#define nvtxNameOsThread nvtxNameOsThreadW
|
| 1467 |
+
/* NVTX_VERSION_2 */
|
| 1468 |
+
#define nvtxDomainCreate nvtxDomainCreateW
|
| 1469 |
+
#define nvtxDomainRegisterString nvtxDomainRegisterStringW
|
| 1470 |
+
#define nvtxDomainNameCategory nvtxDomainNameCategoryW
|
| 1471 |
+
#else
|
| 1472 |
+
#define nvtxMark nvtxMarkA
|
| 1473 |
+
#define nvtxRangeStart nvtxRangeStartA
|
| 1474 |
+
#define nvtxRangePush nvtxRangePushA
|
| 1475 |
+
#define nvtxNameCategory nvtxNameCategoryA
|
| 1476 |
+
#define nvtxNameOsThread nvtxNameOsThreadA
|
| 1477 |
+
/* NVTX_VERSION_2 */
|
| 1478 |
+
#define nvtxDomainCreate nvtxDomainCreateA
|
| 1479 |
+
#define nvtxDomainRegisterString nvtxDomainRegisterStringA
|
| 1480 |
+
#define nvtxDomainNameCategory nvtxDomainNameCategoryA
|
| 1481 |
+
#endif
|
| 1482 |
+
|
| 1483 |
+
/** \endcond */
|
| 1484 |
+
|
| 1485 |
+
#ifdef __cplusplus
|
| 1486 |
+
} /* extern "C" */
|
| 1487 |
+
#endif /* __cplusplus */
|
| 1488 |
+
|
| 1489 |
+
#define NVTX_IMPL_GUARD /* Ensure other headers cannot included directly */
|
| 1490 |
+
|
| 1491 |
+
#include "nvtxDetail/nvtxTypes.h"
|
| 1492 |
+
|
| 1493 |
+
#ifndef NVTX_NO_IMPL
|
| 1494 |
+
#include "nvtxDetail/nvtxImpl.h"
|
| 1495 |
+
#endif /*NVTX_NO_IMPL*/
|
| 1496 |
+
|
| 1497 |
+
#undef NVTX_IMPL_GUARD
|
| 1498 |
+
|
| 1499 |
+
#endif /* !defined(NVTX_VERSION) */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvToolsExtCuda.h
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
#include "nvToolsExt.h"
|
| 39 |
+
|
| 40 |
+
#include "cuda.h"
|
| 41 |
+
|
| 42 |
+
#ifndef NVTOOLSEXT_CUDA_V3
|
| 43 |
+
#define NVTOOLSEXT_CUDA_V3
|
| 44 |
+
|
| 45 |
+
#ifdef __cplusplus
|
| 46 |
+
extern "C" {
|
| 47 |
+
#endif /* __cplusplus */
|
| 48 |
+
|
| 49 |
+
/* ========================================================================= */
|
| 50 |
+
/** \name Functions for CUDA Resource Naming
|
| 51 |
+
*/
|
| 52 |
+
/** \addtogroup RESOURCE_NAMING
|
| 53 |
+
* \section RESOURCE_NAMING_CUDA CUDA Resource Naming
|
| 54 |
+
*
|
| 55 |
+
* This section covers the API functions that allow to annotate CUDA resources
|
| 56 |
+
* with user-provided names.
|
| 57 |
+
*
|
| 58 |
+
* @{
|
| 59 |
+
*/
|
| 60 |
+
|
| 61 |
+
/* ------------------------------------------------------------------------- */
|
| 62 |
+
/* \cond SHOW_HIDDEN
|
| 63 |
+
* \brief Used to build a non-colliding value for resource types separated class
|
| 64 |
+
* \version \NVTX_VERSION_2
|
| 65 |
+
*/
|
| 66 |
+
#define NVTX_RESOURCE_CLASS_CUDA 4
|
| 67 |
+
/** \endcond */
|
| 68 |
+
|
| 69 |
+
/* ------------------------------------------------------------------------- */
|
| 70 |
+
/** \brief Resource types for CUDA
|
| 71 |
+
*/
|
| 72 |
+
typedef enum nvtxResourceCUDAType_t
|
| 73 |
+
{
|
| 74 |
+
NVTX_RESOURCE_TYPE_CUDA_DEVICE = NVTX_RESOURCE_MAKE_TYPE(CUDA, 1), /* CUdevice */
|
| 75 |
+
NVTX_RESOURCE_TYPE_CUDA_CONTEXT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 2), /* CUcontext */
|
| 76 |
+
NVTX_RESOURCE_TYPE_CUDA_STREAM = NVTX_RESOURCE_MAKE_TYPE(CUDA, 3), /* CUstream */
|
| 77 |
+
NVTX_RESOURCE_TYPE_CUDA_EVENT = NVTX_RESOURCE_MAKE_TYPE(CUDA, 4), /* CUevent */
|
| 78 |
+
} nvtxResourceCUDAType_t;
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
/* ------------------------------------------------------------------------- */
|
| 82 |
+
/** \brief Annotates a CUDA device.
|
| 83 |
+
*
|
| 84 |
+
* Allows the user to associate a CUDA device with a user-provided name.
|
| 85 |
+
*
|
| 86 |
+
* \param device - The handle of the CUDA device to name.
|
| 87 |
+
* \param name - The name of the CUDA device.
|
| 88 |
+
*
|
| 89 |
+
* \version \NVTX_VERSION_1
|
| 90 |
+
* @{ */
|
| 91 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceA(CUdevice device, const char* name);
|
| 92 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuDeviceW(CUdevice device, const wchar_t* name);
|
| 93 |
+
/** @} */
|
| 94 |
+
|
| 95 |
+
/* ------------------------------------------------------------------------- */
|
| 96 |
+
/** \brief Annotates a CUDA context.
|
| 97 |
+
*
|
| 98 |
+
* Allows the user to associate a CUDA context with a user-provided name.
|
| 99 |
+
*
|
| 100 |
+
* \param context - The handle of the CUDA context to name.
|
| 101 |
+
* \param name - The name of the CUDA context.
|
| 102 |
+
*
|
| 103 |
+
* \par Example:
|
| 104 |
+
* \code
|
| 105 |
+
* CUresult status = cuCtxCreate( &cuContext, 0, cuDevice );
|
| 106 |
+
* if ( CUDA_SUCCESS != status )
|
| 107 |
+
* goto Error;
|
| 108 |
+
* nvtxNameCuContext(cuContext, "CTX_NAME");
|
| 109 |
+
* \endcode
|
| 110 |
+
*
|
| 111 |
+
* \version \NVTX_VERSION_1
|
| 112 |
+
* @{ */
|
| 113 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuContextA(CUcontext context, const char* name);
|
| 114 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuContextW(CUcontext context, const wchar_t* name);
|
| 115 |
+
/** @} */
|
| 116 |
+
|
| 117 |
+
/* ------------------------------------------------------------------------- */
|
| 118 |
+
/** \brief Annotates a CUDA stream.
|
| 119 |
+
*
|
| 120 |
+
* Allows the user to associate a CUDA stream with a user-provided name.
|
| 121 |
+
*
|
| 122 |
+
* \param stream - The handle of the CUDA stream to name.
|
| 123 |
+
* \param name - The name of the CUDA stream.
|
| 124 |
+
*
|
| 125 |
+
* \version \NVTX_VERSION_1
|
| 126 |
+
* @{ */
|
| 127 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamA(CUstream stream, const char* name);
|
| 128 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuStreamW(CUstream stream, const wchar_t* name);
|
| 129 |
+
/** @} */
|
| 130 |
+
|
| 131 |
+
/* ------------------------------------------------------------------------- */
|
| 132 |
+
/** \brief Annotates a CUDA event.
|
| 133 |
+
*
|
| 134 |
+
* Allows the user to associate a CUDA event with a user-provided name.
|
| 135 |
+
*
|
| 136 |
+
* \param event - The handle of the CUDA event to name.
|
| 137 |
+
* \param name - The name of the CUDA event.
|
| 138 |
+
*
|
| 139 |
+
* \version \NVTX_VERSION_1
|
| 140 |
+
* @{ */
|
| 141 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuEventA(CUevent event, const char* name);
|
| 142 |
+
NVTX_DECLSPEC void NVTX_API nvtxNameCuEventW(CUevent event, const wchar_t* name);
|
| 143 |
+
/** @} */
|
| 144 |
+
|
| 145 |
+
/** @} */ /* END RESOURCE_NAMING */
|
| 146 |
+
|
| 147 |
+
/* ========================================================================= */
|
| 148 |
+
#ifdef UNICODE
|
| 149 |
+
#define nvtxNameCuDevice nvtxNameCuDeviceW
|
| 150 |
+
#define nvtxNameCuContext nvtxNameCuContextW
|
| 151 |
+
#define nvtxNameCuStream nvtxNameCuStreamW
|
| 152 |
+
#define nvtxNameCuEvent nvtxNameCuEventW
|
| 153 |
+
#else
|
| 154 |
+
#define nvtxNameCuDevice nvtxNameCuDeviceA
|
| 155 |
+
#define nvtxNameCuContext nvtxNameCuContextA
|
| 156 |
+
#define nvtxNameCuStream nvtxNameCuStreamA
|
| 157 |
+
#define nvtxNameCuEvent nvtxNameCuEventA
|
| 158 |
+
#endif
|
| 159 |
+
|
| 160 |
+
#ifdef __cplusplus
|
| 161 |
+
}
|
| 162 |
+
#endif /* __cplusplus */
|
| 163 |
+
|
| 164 |
+
#ifndef NVTX_NO_IMPL
|
| 165 |
+
#define NVTX_IMPL_GUARD_CUDA /* Ensure other headers cannot included directly */
|
| 166 |
+
#include "nvtxDetail/nvtxImplCuda_v3.h"
|
| 167 |
+
#undef NVTX_IMPL_G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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2009-2016 NVIDIA Corporation. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NOTICE TO USER:
|
| 5 |
+
*
|
| 6 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 7 |
+
* international Copyright laws.
|
| 8 |
+
*
|
| 9 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 10 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 11 |
+
* of a form of NVIDIA software license agreement.
|
| 12 |
+
*
|
| 13 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 14 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 15 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 16 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 17 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 18 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 19 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 20 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 21 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 22 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 23 |
+
*
|
| 24 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 25 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 26 |
+
* "commercial computer software" and "commercial computer software
|
| 27 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 28 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 29 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 30 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 31 |
+
* source code with only those rights set forth herein.
|
| 32 |
+
*
|
| 33 |
+
* Any use of this source code in individual and commercial software must
|
| 34 |
+
* include, in the user documentation and internal comments to the code,
|
| 35 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 36 |
+
*/
|
| 37 |
+
|
| 38 |
+
#include "nvToolsExt.h"
|
| 39 |
+
|
| 40 |
+
#ifndef NVTOOLSEXT_SYNC_V3
|
| 41 |
+
#define NVTOOLSEXT_SYNC_V3
|
| 42 |
+
|
| 43 |
+
#ifdef __cplusplus
|
| 44 |
+
extern "C" {
|
| 45 |
+
#endif /* __cplusplus */
|
| 46 |
+
|
| 47 |
+
/* \cond SHOW_HIDDEN
|
| 48 |
+
* \version \NVTX_VERSION_2
|
| 49 |
+
*/
|
| 50 |
+
#define NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE ( (uint16_t)( sizeof(nvtxSyncUserAttributes_v0) ) )
|
| 51 |
+
/** \endcond */
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* \page PAGE_SYNCHRONIZATION Synchronization
|
| 56 |
+
*
|
| 57 |
+
* This section covers a subset of the API that allow users to track additional
|
| 58 |
+
* synchronization details of their application. Naming OS synchronization primitives
|
| 59 |
+
* may allow users to better understand the data collected by traced synchronization
|
| 60 |
+
* APIs. Additionally, a user defined synchronization object can allow the users to
|
| 61 |
+
* to tell the tools when the user is building their own synchronization system
|
| 62 |
+
* that do not rely on the OS to provide behaviors and instead use techniques like
|
| 63 |
+
* atomic operations and spinlocks.
|
| 64 |
+
*
|
| 65 |
+
* See module \ref SYNCHRONIZATION for details.
|
| 66 |
+
*
|
| 67 |
+
* \par Example:
|
| 68 |
+
* \code
|
| 69 |
+
* class MyMutex
|
| 70 |
+
* {
|
| 71 |
+
* volatile long bLocked;
|
| 72 |
+
* nvtxSyncUser_t hSync;
|
| 73 |
+
* public:
|
| 74 |
+
* MyMutex(const char* name, nvtxDomainHandle_t d){
|
| 75 |
+
* bLocked = 0;
|
| 76 |
+
*
|
| 77 |
+
* nvtxSyncUserAttributes_t attribs = { 0 };
|
| 78 |
+
* attribs.version = NVTX_VERSION;
|
| 79 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 80 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 81 |
+
* attribs.message.ascii = name;
|
| 82 |
+
* hSync = nvtxDomainSyncUserCreate(d, &attribs);
|
| 83 |
+
* }
|
| 84 |
+
*
|
| 85 |
+
* ~MyMutex() {
|
| 86 |
+
* nvtxDomainSyncUserDestroy(hSync);
|
| 87 |
+
* }
|
| 88 |
+
*
|
| 89 |
+
* bool Lock() {
|
| 90 |
+
* nvtxDomainSyncUserAcquireStart(hSync);
|
| 91 |
+
* bool acquired = __sync_bool_compare_and_swap(&bLocked, 0, 1);//atomic compiler intrinsic
|
| 92 |
+
|
| 93 |
+
* if (acquired) {
|
| 94 |
+
* nvtxDomainSyncUserAcquireSuccess(hSync);
|
| 95 |
+
* }
|
| 96 |
+
* else {
|
| 97 |
+
* nvtxDomainSyncUserAcquireFailed(hSync);
|
| 98 |
+
* }
|
| 99 |
+
* return acquired;
|
| 100 |
+
* }
|
| 101 |
+
|
| 102 |
+
* void Unlock() {
|
| 103 |
+
* nvtxDomainSyncUserReleasing(hSync);
|
| 104 |
+
* bLocked = false;
|
| 105 |
+
* }
|
| 106 |
+
* };
|
| 107 |
+
* \endcode
|
| 108 |
+
*
|
| 109 |
+
* \version \NVTX_VERSION_2
|
| 110 |
+
*/
|
| 111 |
+
|
| 112 |
+
/* ------------------------------------------------------------------------- */
|
| 113 |
+
/* \cond SHOW_HIDDEN
|
| 114 |
+
* \brief Used to build a non-colliding value for resource types separated class
|
| 115 |
+
* \version \NVTX_VERSION_2
|
| 116 |
+
*/
|
| 117 |
+
#define NVTX_RESOURCE_CLASS_SYNC_OS 2 /**< Synchronization objects that are OS specific. */
|
| 118 |
+
#define NVTX_RESOURCE_CLASS_SYNC_PTHREAD 3 /**< Synchronization objects that are from the POSIX Threads API (pthread)*/
|
| 119 |
+
/** \endcond */
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
/* ------------------------------------------------------------------------- */
|
| 123 |
+
/** \defgroup SYNCHRONIZATION Synchronization
|
| 124 |
+
* See page \ref PAGE_SYNCHRONIZATION.
|
| 125 |
+
* @{
|
| 126 |
+
*/
|
| 127 |
+
|
| 128 |
+
/** \brief Resource type values for OSs with POSIX Thread API support
|
| 129 |
+
*/
|
| 130 |
+
typedef enum nvtxResourceSyncPosixThreadType_t
|
| 131 |
+
{
|
| 132 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 1), /* pthread_mutex_t */
|
| 133 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_CONDITION = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 2), /* pthread_cond_t */
|
| 134 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_RWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 3), /* pthread_rwlock_t */
|
| 135 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_BARRIER = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 4), /* pthread_barrier_t */
|
| 136 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 5), /* pthread_spinlock_t */
|
| 137 |
+
NVTX_RESOURCE_TYPE_SYNC_PTHREAD_ONCE = NVTX_RESOURCE_MAKE_TYPE(SYNC_PTHREAD, 6) /* pthread_once_t */
|
| 138 |
+
} nvtxResourceSyncPosixThreadType_t;
|
| 139 |
+
|
| 140 |
+
/** \brief Resource type values for Windows OSs
|
| 141 |
+
*/
|
| 142 |
+
typedef enum nvtxResourceSyncWindowsType_t
|
| 143 |
+
{
|
| 144 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
|
| 145 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
|
| 146 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_EVENT = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
|
| 147 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_CRITICAL_SECTION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
|
| 148 |
+
NVTX_RESOURCE_TYPE_SYNC_WINDOWS_SRWLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5)
|
| 149 |
+
} nvtxResourceSyncWindowsType_t;
|
| 150 |
+
|
| 151 |
+
/** \brief Resource type values for Linux and Linux derived OSs such as Android
|
| 152 |
+
* \sa
|
| 153 |
+
* ::nvtxResourceSyncPosixThreadType_t
|
| 154 |
+
*/
|
| 155 |
+
typedef enum nvtxResourceSyncLinuxType_t
|
| 156 |
+
{
|
| 157 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_MUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 1),
|
| 158 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_FUTEX = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 2),
|
| 159 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SEMAPHORE = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 3),
|
| 160 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_COMPLETION = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 4),
|
| 161 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SPINLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 5),
|
| 162 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_SEQLOCK = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 6),
|
| 163 |
+
NVTX_RESOURCE_TYPE_SYNC_LINUX_RCU = NVTX_RESOURCE_MAKE_TYPE(SYNC_OS, 7)
|
| 164 |
+
} nvtxResourceSyncLinuxType_t;
|
| 165 |
+
|
| 166 |
+
/** \brief Resource type values for Android come from Linux.
|
| 167 |
+
* \sa
|
| 168 |
+
* ::nvtxResourceSyncLinuxType_t
|
| 169 |
+
* ::nvtxResourceSyncPosixThreadType_t
|
| 170 |
+
*/
|
| 171 |
+
typedef enum nvtxResourceSyncLinuxType_t nvtxResourceSyncAndroidType_t;
|
| 172 |
+
|
| 173 |
+
/** \brief User Defined Synchronization Object Handle .
|
| 174 |
+
* \anchor SYNCUSER_HANDLE_STRUCTURE
|
| 175 |
+
*
|
| 176 |
+
* This structure is opaque to the user and is used as a handle to reference
|
| 177 |
+
* a user defined syncrhonization object. The tools will return a pointer through the API for the application
|
| 178 |
+
* to hold on it's behalf to reference the string in the future.
|
| 179 |
+
*
|
| 180 |
+
*/
|
| 181 |
+
typedef struct nvtxSyncUser* nvtxSyncUser_t;
|
| 182 |
+
|
| 183 |
+
/** \brief User Defined Synchronization Object Attributes Structure.
|
| 184 |
+
* \anchor USERDEF_SYNC_ATTRIBUTES_STRUCTURE
|
| 185 |
+
*
|
| 186 |
+
* This structure is used to describe the attributes of a user defined synchronization
|
| 187 |
+
* object. The layout of the structure is defined by a specific version of the tools
|
| 188 |
+
* extension library and can change between different versions of the Tools Extension
|
| 189 |
+
* library.
|
| 190 |
+
*
|
| 191 |
+
* \par Initializing the Attributes
|
| 192 |
+
*
|
| 193 |
+
* The caller should always perform the following three tasks when using
|
| 194 |
+
* attributes:
|
| 195 |
+
* <ul>
|
| 196 |
+
* <li>Zero the structure
|
| 197 |
+
* <li>Set the version field
|
| 198 |
+
* <li>Set the size field
|
| 199 |
+
* </ul>
|
| 200 |
+
*
|
| 201 |
+
* Zeroing the structure sets all the event attributes types and values
|
| 202 |
+
* to the default value.
|
| 203 |
+
*
|
| 204 |
+
* The version and size field are used by the Tools Extension
|
| 205 |
+
* implementation to handle multiple versions of the attributes structure.
|
| 206 |
+
*
|
| 207 |
+
* It is recommended that the caller use one of the following to methods
|
| 208 |
+
* to initialize the event attributes structure:
|
| 209 |
+
*
|
| 210 |
+
* \par Method 1: Initializing nvtxEventAttributes for future compatibility
|
| 211 |
+
* \code
|
| 212 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 213 |
+
* attribs.version = NVTX_VERSION;
|
| 214 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 215 |
+
* \endcode
|
| 216 |
+
*
|
| 217 |
+
* \par Method 2: Initializing nvtxSyncUserAttributes_t for a specific version
|
| 218 |
+
* \code
|
| 219 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 220 |
+
* attribs.version = 1;
|
| 221 |
+
* attribs.size = (uint16_t)(sizeof(nvtxSyncUserAttributes_t));
|
| 222 |
+
* \endcode
|
| 223 |
+
*
|
| 224 |
+
* If the caller uses Method 1 it is critical that the entire binary
|
| 225 |
+
* layout of the structure be configured to 0 so that all fields
|
| 226 |
+
* are initialized to the default value.
|
| 227 |
+
*
|
| 228 |
+
* The caller should either use both NVTX_VERSION and
|
| 229 |
+
* NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE (Method 1) or use explicit values
|
| 230 |
+
* and a versioned type (Method 2). Using a mix of the two methods
|
| 231 |
+
* will likely cause either source level incompatibility or binary
|
| 232 |
+
* incompatibility in the future.
|
| 233 |
+
*
|
| 234 |
+
* \par Settings Attribute Types and Values
|
| 235 |
+
*
|
| 236 |
+
*
|
| 237 |
+
* \par Example:
|
| 238 |
+
* \code
|
| 239 |
+
* // Initialize
|
| 240 |
+
* nvtxSyncUserAttributes_t attribs = {0};
|
| 241 |
+
* attribs.version = NVTX_VERSION;
|
| 242 |
+
* attribs.size = NVTX_SYNCUSER_ATTRIB_STRUCT_SIZE;
|
| 243 |
+
*
|
| 244 |
+
* // Configure the Attributes
|
| 245 |
+
* attribs.messageType = NVTX_MESSAGE_TYPE_ASCII;
|
| 246 |
+
* attribs.message.ascii = "Example";
|
| 247 |
+
* \endcode
|
| 248 |
+
*
|
| 249 |
+
* \sa
|
| 250 |
+
* ::nvtxDomainSyncUserCreate
|
| 251 |
+
*/
|
| 252 |
+
typedef struct nvtxSyncUserAttributes_v0
|
| 253 |
+
{
|
| 254 |
+
/**
|
| 255 |
+
* \brief Version flag of the structure.
|
| 256 |
+
*
|
| 257 |
+
* Needs to be set to NVTX_VERSION to indicate the version of NVTX APIs
|
| 258 |
+
* supported in this header file. This can optionally be overridden to
|
| 259 |
+
* another version of the tools extension library.
|
| 260 |
+
*/
|
| 261 |
+
uint16_t version;
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* \brief Size of the structure.
|
| 265 |
+
*
|
| 266 |
+
* Needs to be set to the size in bytes of the event attribute
|
| 267 |
+
* structure used to specify the event.
|
| 268 |
+
*/
|
| 269 |
+
uint16_t size;
|
| 270 |
+
|
| 271 |
+
/** \brief Message type specified in this attribute structure.
|
| 272 |
+
*
|
| 273 |
+
* Defines the message format of the attribute structure's \ref nvtxSyncUserAttributes_v0::message
|
| 274 |
+
* "message" field.
|
| 275 |
+
*
|
| 276 |
+
* Default Value is NVTX_MESSAGE_UNKNOWN
|
| 277 |
+
*/
|
| 278 |
+
int32_t messageType; /* nvtxMessageType_t */
|
| 279 |
+
|
| 280 |
+
/** \brief Message assigned to this attribute structure.
|
| 281 |
+
*
|
| 282 |
+
* The text message that is attached to an event.
|
| 283 |
+
*/
|
| 284 |
+
nvtxMessageValue_t message;
|
| 285 |
+
|
| 286 |
+
} nvtxSyncUserAttributes_v0;
|
| 287 |
+
|
| 288 |
+
typedef struct nvtxSyncUserAttributes_v0 nvtxSyncUserAttributes_t;
|
| 289 |
+
|
| 290 |
+
/* ------------------------------------------------------------------------- */
|
| 291 |
+
/** \brief Create a user defined synchronization object
|
| 292 |
+
* This is used to track non-OS synchronization working with spinlocks and atomics
|
| 293 |
+
*
|
| 294 |
+
* \param domain - Domain to own the resource
|
| 295 |
+
* \param attribs - A structure to assign multiple attributes to the object.
|
| 296 |
+
*
|
| 297 |
+
* \return A handle that represents the newly created user defined synchronization object.
|
| 298 |
+
*
|
| 299 |
+
* \sa
|
| 300 |
+
* ::nvtxDomainSyncUserCreate
|
| 301 |
+
* ::nvtxDomainSyncUserDestroy
|
| 302 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 303 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 304 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 305 |
+
* ::nvtxDomainSyncUserReleasing
|
| 306 |
+
*
|
| 307 |
+
* \version \NVTX_VERSION_2
|
| 308 |
+
*/
|
| 309 |
+
NVTX_DECLSPEC nvtxSyncUser_t NVTX_API nvtxDomainSyncUserCreate(nvtxDomainHandle_t domain, const nvtxSyncUserAttributes_t* attribs);
|
| 310 |
+
|
| 311 |
+
/* ------------------------------------------------------------------------- */
|
| 312 |
+
/** \brief Destroy a user defined synchronization object
|
| 313 |
+
* This is used to track non-OS synchronization working with spinlocks and atomics
|
| 314 |
+
*
|
| 315 |
+
* \param handle - A handle to the object to operate on.
|
| 316 |
+
*
|
| 317 |
+
* \sa
|
| 318 |
+
* ::nvtxDomainSyncUserCreate
|
| 319 |
+
* ::nvtxDomainSyncUserDestroy
|
| 320 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 321 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 322 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 323 |
+
* ::nvtxDomainSyncUserReleasing
|
| 324 |
+
*
|
| 325 |
+
* \version \NVTX_VERSION_2
|
| 326 |
+
*/
|
| 327 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserDestroy(nvtxSyncUser_t handle);
|
| 328 |
+
|
| 329 |
+
/* ------------------------------------------------------------------------- */
|
| 330 |
+
/** \brief Signal to tools that an attempt to acquire a user defined synchronization object
|
| 331 |
+
*
|
| 332 |
+
* \param handle - A handle to the object to operate on.
|
| 333 |
+
*
|
| 334 |
+
* \sa
|
| 335 |
+
* ::nvtxDomainSyncUserCreate
|
| 336 |
+
* ::nvtxDomainSyncUserDestroy
|
| 337 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 338 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 339 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 340 |
+
* ::nvtxDomainSyncUserReleasing
|
| 341 |
+
*
|
| 342 |
+
* \version \NVTX_VERSION_2
|
| 343 |
+
*/
|
| 344 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireStart(nvtxSyncUser_t handle);
|
| 345 |
+
|
| 346 |
+
/* ------------------------------------------------------------------------- */
|
| 347 |
+
/** \brief Signal to tools of failure in acquiring a user defined synchronization object
|
| 348 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireStart
|
| 349 |
+
*
|
| 350 |
+
* \param handle - A handle to the object to operate on.
|
| 351 |
+
*
|
| 352 |
+
* \sa
|
| 353 |
+
* ::nvtxDomainSyncUserCreate
|
| 354 |
+
* ::nvtxDomainSyncUserDestroy
|
| 355 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 356 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 357 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 358 |
+
* ::nvtxDomainSyncUserReleasing
|
| 359 |
+
*
|
| 360 |
+
* \version \NVTX_VERSION_2
|
| 361 |
+
*/NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireFailed(nvtxSyncUser_t handle);
|
| 362 |
+
|
| 363 |
+
/* ------------------------------------------------------------------------- */
|
| 364 |
+
/** \brief Signal to tools of success in acquiring a user defined synchronization object
|
| 365 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireStart.
|
| 366 |
+
*
|
| 367 |
+
* \param handle - A handle to the object to operate on.
|
| 368 |
+
*
|
| 369 |
+
* \sa
|
| 370 |
+
* ::nvtxDomainSyncUserCreate
|
| 371 |
+
* ::nvtxDomainSyncUserDestroy
|
| 372 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 373 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 374 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 375 |
+
* ::nvtxDomainSyncUserReleasing
|
| 376 |
+
*
|
| 377 |
+
* \version \NVTX_VERSION_2
|
| 378 |
+
*/NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserAcquireSuccess(nvtxSyncUser_t handle);
|
| 379 |
+
|
| 380 |
+
/* ------------------------------------------------------------------------- */
|
| 381 |
+
/** \brief Signal to tools of releasing a reservation on user defined synchronization object
|
| 382 |
+
* This should be called after \ref nvtxDomainSyncUserAcquireSuccess.
|
| 383 |
+
*
|
| 384 |
+
* \param handle - A handle to the object to operate on.
|
| 385 |
+
*
|
| 386 |
+
* \sa
|
| 387 |
+
* ::nvtxDomainSyncUserCreate
|
| 388 |
+
* ::nvtxDomainSyncUserDestroy
|
| 389 |
+
* ::nvtxDomainSyncUserAcquireStart
|
| 390 |
+
* ::nvtxDomainSyncUserAcquireFailed
|
| 391 |
+
* ::nvtxDomainSyncUserAcquireSuccess
|
| 392 |
+
* ::nvtxDomainSyncUserReleasing
|
| 393 |
+
*
|
| 394 |
+
* \version \NVTX_VERSION_2
|
| 395 |
+
*/
|
| 396 |
+
NVTX_DECLSPEC void NVTX_API nvtxDomainSyncUserReleasing(nvtxSyncUser_t handle);
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
/** @} */ /*END defgroup*/
|
| 400 |
+
|
| 401 |
+
#ifdef __cplusplus
|
| 402 |
+
}
|
| 403 |
+
#endif /* __cplusplus */
|
| 404 |
+
|
| 405 |
+
#ifndef NVTX_NO_IMPL
|
| 406 |
+
#define NVTX_IMPL_GUARD_SYNC /* Ensure other headers cannot included directly */
|
| 407 |
+
#include "nvtxDetail/nvtxImplSync_v3.h"
|
| 408 |
+
#undef NVTX_IMPL_GUARD_SYNC
|
| 409 |
+
#endif /*NVTX_NO_IMPL*/
|
| 410 |
+
|
| 411 |
+
#endif /* NVTOOLSEXT_SYNC_V3 */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxInit.h
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
*
|
| 6 |
+
* NOTICE TO USER:
|
| 7 |
+
*
|
| 8 |
+
* This source code is subject to NVIDIA ownership rights under U.S. and
|
| 9 |
+
* international Copyright laws.
|
| 10 |
+
*
|
| 11 |
+
* This software and the information contained herein is PROPRIETARY and
|
| 12 |
+
* CONFIDENTIAL to NVIDIA and is being provided under the terms and conditions
|
| 13 |
+
* of a form of NVIDIA software license agreement.
|
| 14 |
+
*
|
| 15 |
+
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
|
| 16 |
+
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
|
| 17 |
+
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
|
| 18 |
+
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
|
| 19 |
+
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
|
| 20 |
+
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
|
| 21 |
+
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
| 22 |
+
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
| 23 |
+
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
| 24 |
+
* OR PERFORMANCE OF THIS SOURCE CODE.
|
| 25 |
+
*
|
| 26 |
+
* U.S. Government End Users. This source code is a "commercial item" as
|
| 27 |
+
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
|
| 28 |
+
* "commercial computer software" and "commercial computer software
|
| 29 |
+
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
|
| 30 |
+
* and is provided to the U.S. Government only as a commercial end item.
|
| 31 |
+
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
|
| 32 |
+
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
|
| 33 |
+
* source code with only those rights set forth herein.
|
| 34 |
+
*
|
| 35 |
+
* Any use of this source code in individual and commercial software must
|
| 36 |
+
* include, in the user documentation and internal comments to the code,
|
| 37 |
+
* the above Disclaimer and U.S. Government End Users Notice.
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
#ifndef NVTX_IMPL_GUARD
|
| 41 |
+
#error Never include this file directly -- it is automatically included by nvToolsExt.h (except when NVTX_NO_IMPL is defined).
|
| 42 |
+
#endif
|
| 43 |
+
|
| 44 |
+
/* ---- Platform-independent helper definitions and functions ---- */
|
| 45 |
+
|
| 46 |
+
/* Prefer macros over inline functions to reduce symbol resolution at link time */
|
| 47 |
+
|
| 48 |
+
#if defined(_WIN32)
|
| 49 |
+
#define NVTX_PATHCHAR wchar_t
|
| 50 |
+
#define NVTX_STR(x) L##x
|
| 51 |
+
#define NVTX_GETENV _wgetenv
|
| 52 |
+
#define NVTX_BUFSIZE MAX_PATH
|
| 53 |
+
#define NVTX_DLLHANDLE HMODULE
|
| 54 |
+
#define NVTX_DLLOPEN(x) LoadLibraryW(x)
|
| 55 |
+
#define NVTX_DLLFUNC GetProcAddress
|
| 56 |
+
#define NVTX_DLLCLOSE FreeLibrary
|
| 57 |
+
#define NVTX_YIELD() SwitchToThread()
|
| 58 |
+
#define NVTX_MEMBAR() MemoryBarrier()
|
| 59 |
+
#define NVTX_ATOMIC_WRITE_32(address, value) InterlockedExchange((volatile LONG*)address, value)
|
| 60 |
+
#define NVTX_ATOMIC_CAS_32(old, address, exchange, comparand) old = InterlockedCompareExchange((volatile LONG*)address, exchange, comparand)
|
| 61 |
+
#elif defined(__GNUC__)
|
| 62 |
+
#define NVTX_PATHCHAR char
|
| 63 |
+
#define NVTX_STR(x) x
|
| 64 |
+
#define NVTX_GETENV getenv
|
| 65 |
+
#define NVTX_BUFSIZE PATH_MAX
|
| 66 |
+
#define NVTX_DLLHANDLE void*
|
| 67 |
+
#define NVTX_DLLOPEN(x) dlopen(x, RTLD_LAZY)
|
| 68 |
+
#define NVTX_DLLFUNC dlsym
|
| 69 |
+
#define NVTX_DLLCLOSE dlclose
|
| 70 |
+
#define NVTX_YIELD() sched_yield()
|
| 71 |
+
#define NVTX_MEMBAR() __sync_synchronize()
|
| 72 |
+
/* Ensure full memory barrier for atomics, to match Windows functions */
|
| 73 |
+
#define NVTX_ATOMIC_WRITE_32(address, value) __sync_synchronize(); __sync_lock_test_and_set(address, value)
|
| 74 |
+
#define NVTX_ATOMIC_CAS_32(old, address, exchange, comparand) __sync_synchronize(); old = __sync_val_compare_and_swap(address, exchange, comparand)
|
| 75 |
+
#else
|
| 76 |
+
#error The library does not support your configuration!
|
| 77 |
+
#endif
|
| 78 |
+
|
| 79 |
+
/* Define this to 1 for platforms that where pre-injected libraries can be discovered. */
|
| 80 |
+
#if defined(_WIN32)
|
| 81 |
+
/* TODO */
|
| 82 |
+
#define NVTX_SUPPORT_ALREADY_INJECTED_LIBRARY 0
|
| 83 |
+
#else
|
| 84 |
+
#define NVTX_SUPPORT_ALREADY_INJECTED_LIBRARY 0
|
| 85 |
+
#endif
|
| 86 |
+
|
| 87 |
+
/* Define this to 1 for platforms that support environment variables */
|
| 88 |
+
/* TODO: Detect UWP, a.k.a. Windows Store app, and set this to 0. */
|
| 89 |
+
/* Try: #if defined(WINAPI_FAMILY_PARTITION) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
|
| 90 |
+
#define NVTX_SUPPORT_ENV_VARS 1
|
| 91 |
+
|
| 92 |
+
/* Define this to 1 for platforms that support dynamic/shared libraries */
|
| 93 |
+
#define NVTX_SUPPORT_DYNAMIC_INJECTION_LIBRARY 1
|
| 94 |
+
|
| 95 |
+
/* Injection libraries implementing InitializeInjectionNvtx2 may be statically linked,
|
| 96 |
+
* and this will override any dynamic injection. Useful for platforms where dynamic
|
| 97 |
+
* injection is not available. Since weak symbols not explicitly marked extern are
|
| 98 |
+
* guaranteed to be initialized to zero if no definitions are found by the linker, the
|
| 99 |
+
* dynamic injection process proceeds normally if pfnInitializeInjectionNvtx2 is 0. */
|
| 100 |
+
#if defined(__GNUC__) && !defined(_WIN32) && !defined(__CYGWIN__)
|
| 101 |
+
#define NVTX_SUPPORT_STATIC_INJECTION_LIBRARY 1
|
| 102 |
+
/* To statically inject an NVTX library, define InitializeInjectionNvtx2_fnptr as a normal
|
| 103 |
+
* symbol (not weak) pointing to the implementation of InitializeInjectionNvtx2 (which
|
| 104 |
+
* does not need to be named "InitializeInjectionNvtx2" as is necessary in a dynamic
|
| 105 |
+
* injection library. */
|
| 106 |
+
__attribute__((weak)) NvtxInitializeInjectionNvtxFunc_t InitializeInjectionNvtx2_fnptr;
|
| 107 |
+
#else
|
| 108 |
+
#define NVTX_SUPPORT_STATIC_INJECTION_LIBRARY 0
|
| 109 |
+
#endif
|
| 110 |
+
|
| 111 |
+
/* This function tries to find or load an NVTX injection library and get the
|
| 112 |
+
* address of its InitializeInjection2 function. If such a function pointer
|
| 113 |
+
* is found, it is called, and passed the address of this NVTX instance's
|
| 114 |
+
* nvtxGetExportTable function, so the injection can attach to this instance.
|
| 115 |
+
* If the initialization fails for any reason, any dynamic library loaded will
|
| 116 |
+
* be freed, and all NVTX implementation functions will be set to no-ops. If
|
| 117 |
+
* initialization succeeds, NVTX functions not attached to the tool will be set
|
| 118 |
+
* to no-ops. This is implemented as one function instead of several small
|
| 119 |
+
* functions to minimize the number of weak symbols the linker must resolve.
|
| 120 |
+
* Order of search is:
|
| 121 |
+
* - Pre-injected library exporting InitializeInjectionNvtx2
|
| 122 |
+
* - Loadable library exporting InitializeInjectionNvtx2
|
| 123 |
+
* - Path specified by env var NVTX_INJECTION??_PATH (?? is 32 or 64)
|
| 124 |
+
* - On Android, libNvtxInjection??.so within the package (?? is 32 or 64)
|
| 125 |
+
* - Statically-linked injection library defining InitializeInjectionNvtx2_fnptr
|
| 126 |
+
*/
|
| 127 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_VERSIONED_IDENTIFIER(nvtxInitializeInjectionLibrary)(void);
|
| 128 |
+
NVTX_LINKONCE_DEFINE_FUNCTION int NVTX_VERSIONED_IDENTIFIER(nvtxInitializeInjectionLibrary)(void)
|
| 129 |
+
{
|
| 130 |
+
const char* const initFuncName = "InitializeInjectionNvtx2";
|
| 131 |
+
NvtxInitializeInjectionNvtxFunc_t init_fnptr = (NvtxInitializeInjectionNvtxFunc_t)0;
|
| 132 |
+
NVTX_DLLHANDLE injectionLibraryHandle = (NVTX_DLLHANDLE)0;
|
| 133 |
+
int entryPointStatus = 0;
|
| 134 |
+
|
| 135 |
+
#if NVTX_SUPPORT_ALREADY_INJECTED_LIBRARY
|
| 136 |
+
/* Use POSIX global symbol chain to query for init function from any module */
|
| 137 |
+
init_fnptr = (NvtxInitializeInjectionNvtxFunc_t)NVTX_DLLFUNC(0, initFuncName);
|
| 138 |
+
#endif
|
| 139 |
+
|
| 140 |
+
#if NVTX_SUPPORT_DYNAMIC_INJECTION_LIBRARY
|
| 141 |
+
/* Try discovering dynamic injection library to load */
|
| 142 |
+
if (!init_fnptr)
|
| 143 |
+
{
|
| 144 |
+
#if NVTX_SUPPORT_ENV_VARS
|
| 145 |
+
/* If env var NVTX_INJECTION64_PATH is set, it should contain the path
|
| 146 |
+
* to a 64-bit dynamic NVTX injection library (and similar for 32-bit). */
|
| 147 |
+
const NVTX_PATHCHAR* const nvtxEnvVarName = (sizeof(void*) == 4)
|
| 148 |
+
? NVTX_STR("NVTX_INJECTION32_PATH")
|
| 149 |
+
: NVTX_STR("NVTX_INJECTION64_PATH");
|
| 150 |
+
#endif /* NVTX_SUPPORT_ENV_VARS */
|
| 151 |
+
NVTX_PATHCHAR injectionLibraryPathBuf[NVTX_BUFSIZE];
|
| 152 |
+
const NVTX_PATHCHAR* injectionLibraryPath = (const NVTX_PATHCHAR*)0;
|
| 153 |
+
|
| 154 |
+
/* Refer to this variable explicitly in case all references to it are #if'ed out */
|
| 155 |
+
(void)injectionLibraryPathBuf;
|
| 156 |
+
|
| 157 |
+
#if NVTX_SUPPORT_ENV_VARS
|
| 158 |
+
/* Disable the warning for getenv & _wgetenv -- this usage is safe because
|
| 159 |
+
* these functions are not called again before using the returned value. */
|
| 160 |
+
#if defined(_MSC_VER)
|
| 161 |
+
#pragma warning( push )
|
| 162 |
+
#pragma warning( disable : 4996 )
|
| 163 |
+
#endif
|
| 164 |
+
injectionLibraryPath = NVTX_GETENV(nvtxEnvVarName);
|
| 165 |
+
#if defined(_MSC_VER)
|
| 166 |
+
#pragma warning( pop )
|
| 167 |
+
#endif
|
| 168 |
+
#endif
|
| 169 |
+
|
| 170 |
+
#if defined(__ANDROID__)
|
| 171 |
+
if (!injectionLibraryPath)
|
| 172 |
+
{
|
| 173 |
+
const char *bits = (sizeof(void*) == 4) ? "32" : "64";
|
| 174 |
+
char cmdlineBuf[32];
|
| 175 |
+
char pkgName[PATH_MAX];
|
| 176 |
+
int count;
|
| 177 |
+
int pid;
|
| 178 |
+
FILE *fp;
|
| 179 |
+
size_t bytesRead;
|
| 180 |
+
size_t pos;
|
| 181 |
+
|
| 182 |
+
pid = (int)getpid();
|
| 183 |
+
count = snprintf(cmdlineBuf, sizeof(cmdlineBuf), "/proc/%d/cmdline", pid);
|
| 184 |
+
if (count <= 0 || count >= (int)sizeof(cmdlineBuf))
|
| 185 |
+
{
|
| 186 |
+
NVTX_ERR("Path buffer too small for: /proc/%d/cmdline\n", pid);
|
| 187 |
+
return NVTX_ERR_INIT_ACCESS_LIBRARY;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
fp = fopen(cmdlineBuf, "r");
|
| 191 |
+
if (!fp)
|
| 192 |
+
{
|
| 193 |
+
NVTX_ERR("File couldn't be opened: %s\n", cmdlineBuf);
|
| 194 |
+
return NVTX_ERR_INIT_ACCESS_LIBRARY;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
bytesRead = fread(pkgName, 1, sizeof(pkgName) - 1, fp);
|
| 198 |
+
fclose(fp);
|
| 199 |
+
if (bytesRead == 0)
|
| 200 |
+
{
|
| 201 |
+
NVTX_ERR("Package name couldn't be read from file: %s\n", cmdlineBuf);
|
| 202 |
+
return NVTX_ERR_INIT_ACCESS_LIBRARY;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
pkgName[bytesRead] = 0;
|
| 206 |
+
|
| 207 |
+
/* String can contain colon as a process separator. In this case the package name is before the colon. */
|
| 208 |
+
pos = 0;
|
| 209 |
+
while (pos < bytesRead && pkgName[pos] != ':' && pkgName[pos] != '\0')
|
| 210 |
+
{
|
| 211 |
+
++pos;
|
| 212 |
+
}
|
| 213 |
+
pkgName[pos] = 0;
|
| 214 |
+
|
| 215 |
+
count = snprintf(injectionLibraryPathBuf, NVTX_BUFSIZE, "/data/data/%s/files/libNvtxInjection%s.so", pkgName, bits);
|
| 216 |
+
if (count <= 0 || count >= NVTX_BUFSIZE)
|
| 217 |
+
{
|
| 218 |
+
NVTX_ERR("Path buffer too small for: /data/data/%s/files/libNvtxInjection%s.so\n", pkgName, bits);
|
| 219 |
+
return NVTX_ERR_INIT_ACCESS_LIBRARY;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
/* On Android, verify path is accessible due to aggressive file access restrictions. */
|
| 223 |
+
/* For dlopen, if the filename contains a leading slash, then it is interpreted as a */
|
| 224 |
+
/* relative or absolute pathname; otherwise it will follow the rules in ld.so. */
|
| 225 |
+
if (injectionLibraryPathBuf[0] == '/')
|
| 226 |
+
{
|
| 227 |
+
#if (__ANDROID_API__ < 21)
|
| 228 |
+
int access_err = access(injectionLibraryPathBuf, F_OK | R_OK);
|
| 229 |
+
#else
|
| 230 |
+
int access_err = faccessat(AT_FDCWD, injectionLibraryPathBuf, F_OK | R_OK, 0);
|
| 231 |
+
#endif
|
| 232 |
+
if (access_err != 0)
|
| 233 |
+
{
|
| 234 |
+
NVTX_ERR("Injection library path wasn't accessible [code=%s] [path=%s]\n", strerror(errno), injectionLibraryPathBuf);
|
| 235 |
+
return NVTX_ERR_INIT_ACCESS_LIBRARY;
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
injectionLibraryPath = injectionLibraryPathBuf;
|
| 239 |
+
}
|
| 240 |
+
#endif
|
| 241 |
+
|
| 242 |
+
/* At this point, injectionLibraryPath is specified if a dynamic
|
| 243 |
+
* injection library was specified by a tool. */
|
| 244 |
+
if (injectionLibraryPath)
|
| 245 |
+
{
|
| 246 |
+
/* Load the injection library */
|
| 247 |
+
injectionLibraryHandle = NVTX_DLLOPEN(injectionLibraryPath);
|
| 248 |
+
if (!injectionLibraryHandle)
|
| 249 |
+
{
|
| 250 |
+
NVTX_ERR("Failed to load injection library\n");
|
| 251 |
+
return NVTX_ERR_INIT_LOAD_LIBRARY;
|
| 252 |
+
}
|
| 253 |
+
else
|
| 254 |
+
{
|
| 255 |
+
/* Attempt to get the injection library's entry-point */
|
| 256 |
+
init_fnptr = (NvtxInitializeInjectionNvtxFunc_t)NVTX_DLLFUNC(injectionLibraryHandle, initFuncName);
|
| 257 |
+
if (!init_fnptr)
|
| 258 |
+
{
|
| 259 |
+
NVTX_DLLCLOSE(injectionLibraryHandle);
|
| 260 |
+
NVTX_ERR("Failed to get address of function InitializeInjectionNvtx2 from injection library\n");
|
| 261 |
+
return NVTX_ERR_INIT_MISSING_LIBRARY_ENTRY_POINT;
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
#endif
|
| 267 |
+
|
| 268 |
+
#if NVTX_SUPPORT_STATIC_INJECTION_LIBRARY
|
| 269 |
+
if (!init_fnptr)
|
| 270 |
+
{
|
| 271 |
+
/* Check weakly-defined function pointer. A statically-linked injection can define this as
|
| 272 |
+
* a normal symbol and it will take precedence over a dynamic injection. */
|
| 273 |
+
if (InitializeInjectionNvtx2_fnptr)
|
| 274 |
+
{
|
| 275 |
+
init_fnptr = InitializeInjectionNvtx2_fnptr;
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
#endif
|
| 279 |
+
|
| 280 |
+
/* At this point, if init_fnptr is not set, then no tool has specified
|
| 281 |
+
* an NVTX injection library -- return non-success result so all NVTX
|
| 282 |
+
* API functions will be set to no-ops. */
|
| 283 |
+
if (!init_fnptr)
|
| 284 |
+
{
|
| 285 |
+
return NVTX_ERR_NO_INJECTION_LIBRARY_AVAILABLE;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/* Invoke injection library's initialization function. If it returns
|
| 289 |
+
* 0 (failure) and a dynamic injection was loaded, unload it. */
|
| 290 |
+
entryPointStatus = init_fnptr(NVTX_VERSIONED_IDENTIFIER(nvtxGetExportTable));
|
| 291 |
+
if (entryPointStatus == 0)
|
| 292 |
+
{
|
| 293 |
+
NVTX_ERR("Failed to initialize injection library -- initialization function returned 0\n");
|
| 294 |
+
if (injectionLibraryHandle)
|
| 295 |
+
{
|
| 296 |
+
NVTX_DLLCLOSE(injectionLibraryHandle);
|
| 297 |
+
}
|
| 298 |
+
return NVTX_ERR_INIT_FAILED_LIBRARY_ENTRY_POINT;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
return NVTX_SUCCESS;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
NVTX_LINKONCE_DEFINE_FUNCTION void NVTX_VERSIONED_IDENTIFIER(nvtxInitOnce)(void)
|
| 305 |
+
{
|
| 306 |
+
unsigned int old;
|
| 307 |
+
if (NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).initState == NVTX_INIT_STATE_COMPLETE)
|
| 308 |
+
{
|
| 309 |
+
return;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
NVTX_ATOMIC_CAS_32(
|
| 313 |
+
old,
|
| 314 |
+
&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).initState,
|
| 315 |
+
NVTX_INIT_STATE_STARTED,
|
| 316 |
+
NVTX_INIT_STATE_FRESH);
|
| 317 |
+
if (old == NVTX_INIT_STATE_FRESH)
|
| 318 |
+
{
|
| 319 |
+
int result;
|
| 320 |
+
int forceAllToNoops;
|
| 321 |
+
|
| 322 |
+
/* Load & initialize injection library -- it will assign the function pointers */
|
| 323 |
+
result = NVTX_VERSIONED_IDENTIFIER(nvtxInitializeInjectionLibrary)();
|
| 324 |
+
|
| 325 |
+
/* Set all pointers not assigned by the injection to null */
|
| 326 |
+
forceAllToNoops = result != NVTX_SUCCESS; /* Set all to null if injection init failed */
|
| 327 |
+
NVTX_VERSIONED_IDENTIFIER(nvtxSetInitFunctionsToNoops)(forceAllToNoops);
|
| 328 |
+
|
| 329 |
+
/* Signal that initialization has finished, so now the assigned function pointers will be used */
|
| 330 |
+
NVTX_ATOMIC_WRITE_32(
|
| 331 |
+
&NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).initState,
|
| 332 |
+
NVTX_INIT_STATE_COMPLETE);
|
| 333 |
+
}
|
| 334 |
+
else /* Spin-wait until initialization has finished */
|
| 335 |
+
{
|
| 336 |
+
NVTX_MEMBAR();
|
| 337 |
+
while (NVTX_VERSIONED_IDENTIFIER(nvtxGlobals).initState != NVTX_INIT_STATE_COMPLETE)
|
| 338 |
+
{
|
| 339 |
+
NVTX_YIELD();
|
| 340 |
+
NVTX_MEMBAR();
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
}
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxInitDecls.h
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef NVTX_IMPL_GUARD
|
| 2 |
+
#error Never include this file directly -- it is automatically included by nvToolsExt.h (except when NVTX_NO_IMPL is defined).
|
| 3 |
+
#endif
|
| 4 |
+
|
| 5 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxMarkEx_impl_init)(const nvtxEventAttributes_t* eventAttrib);
|
| 6 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxMarkA_impl_init)(const char* message);
|
| 7 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxMarkW_impl_init)(const wchar_t* message);
|
| 8 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxRangeId_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartEx_impl_init)(const nvtxEventAttributes_t* eventAttrib);
|
| 9 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxRangeId_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartA_impl_init)(const char* message);
|
| 10 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxRangeId_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangeStartW_impl_init)(const wchar_t* message);
|
| 11 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangeEnd_impl_init)(nvtxRangeId_t id);
|
| 12 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangePushEx_impl_init)(const nvtxEventAttributes_t* eventAttrib);
|
| 13 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangePushA_impl_init)(const char* message);
|
| 14 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangePushW_impl_init)(const wchar_t* message);
|
| 15 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxRangePop_impl_init)(void);
|
| 16 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCategoryA_impl_init)(uint32_t category, const char* name);
|
| 17 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCategoryW_impl_init)(uint32_t category, const wchar_t* name);
|
| 18 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameOsThreadA_impl_init)(uint32_t threadId, const char* name);
|
| 19 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameOsThreadW_impl_init)(uint32_t threadId, const wchar_t* name);
|
| 20 |
+
|
| 21 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuDeviceA_impl_init)(nvtx_CUdevice device, const char* name);
|
| 22 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuDeviceW_impl_init)(nvtx_CUdevice device, const wchar_t* name);
|
| 23 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuContextA_impl_init)(nvtx_CUcontext context, const char* name);
|
| 24 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuContextW_impl_init)(nvtx_CUcontext context, const wchar_t* name);
|
| 25 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuStreamA_impl_init)(nvtx_CUstream stream, const char* name);
|
| 26 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuStreamW_impl_init)(nvtx_CUstream stream, const wchar_t* name);
|
| 27 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuEventA_impl_init)(nvtx_CUevent event, const char* name);
|
| 28 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCuEventW_impl_init)(nvtx_CUevent event, const wchar_t* name);
|
| 29 |
+
|
| 30 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClDeviceA_impl_init)(nvtx_cl_device_id device, const char* name);
|
| 31 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClDeviceW_impl_init)(nvtx_cl_device_id device, const wchar_t* name);
|
| 32 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClContextA_impl_init)(nvtx_cl_context context, const char* name);
|
| 33 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClContextW_impl_init)(nvtx_cl_context context, const wchar_t* name);
|
| 34 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClCommandQueueA_impl_init)(nvtx_cl_command_queue command_queue, const char* name);
|
| 35 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClCommandQueueW_impl_init)(nvtx_cl_command_queue command_queue, const wchar_t* name);
|
| 36 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClMemObjectA_impl_init)(nvtx_cl_mem memobj, const char* name);
|
| 37 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClMemObjectW_impl_init)(nvtx_cl_mem memobj, const wchar_t* name);
|
| 38 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClSamplerA_impl_init)(nvtx_cl_sampler sampler, const char* name);
|
| 39 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClSamplerW_impl_init)(nvtx_cl_sampler sampler, const wchar_t* name);
|
| 40 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClProgramA_impl_init)(nvtx_cl_program program, const char* name);
|
| 41 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClProgramW_impl_init)(nvtx_cl_program program, const wchar_t* name);
|
| 42 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClEventA_impl_init)(nvtx_cl_event evnt, const char* name);
|
| 43 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameClEventW_impl_init)(nvtx_cl_event evnt, const wchar_t* name);
|
| 44 |
+
|
| 45 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaDeviceA_impl_init)(int device, const char* name);
|
| 46 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaDeviceW_impl_init)(int device, const wchar_t* name);
|
| 47 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaStreamA_impl_init)(nvtx_cudaStream_t stream, const char* name);
|
| 48 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaStreamW_impl_init)(nvtx_cudaStream_t stream, const wchar_t* name);
|
| 49 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaEventA_impl_init)(nvtx_cudaEvent_t event, const char* name);
|
| 50 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxNameCudaEventW_impl_init)(nvtx_cudaEvent_t event, const wchar_t* name);
|
| 51 |
+
|
| 52 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainMarkEx_impl_init)(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 53 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxRangeId_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangeStartEx_impl_init)(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 54 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangeEnd_impl_init)(nvtxDomainHandle_t domain, nvtxRangeId_t id);
|
| 55 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangePushEx_impl_init)(nvtxDomainHandle_t domain, const nvtxEventAttributes_t* eventAttrib);
|
| 56 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION int NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRangePop_impl_init)(nvtxDomainHandle_t domain);
|
| 57 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxResourceHandle_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainResourceCreate_impl_init)(nvtxDomainHandle_t domain, nvtxResourceAttributes_t* attribs);
|
| 58 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainResourceDestroy_impl_init)(nvtxResourceHandle_t resource);
|
| 59 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainNameCategoryA_impl_init)(nvtxDomainHandle_t domain, uint32_t category, const char* name);
|
| 60 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainNameCategoryW_impl_init)(nvtxDomainHandle_t domain, uint32_t category, const wchar_t* name);
|
| 61 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxStringHandle_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRegisterStringA_impl_init)(nvtxDomainHandle_t domain, const char* string);
|
| 62 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxStringHandle_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainRegisterStringW_impl_init)(nvtxDomainHandle_t domain, const wchar_t* string);
|
| 63 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxDomainHandle_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainCreateA_impl_init)(const char* message);
|
| 64 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxDomainHandle_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainCreateW_impl_init)(const wchar_t* message);
|
| 65 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainDestroy_impl_init)(nvtxDomainHandle_t domain);
|
| 66 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxInitialize_impl_init)(const void* reserved);
|
| 67 |
+
|
| 68 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION nvtxSyncUser_t NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserCreate_impl_init)(nvtxDomainHandle_t domain, const nvtxSyncUserAttributes_t* attribs);
|
| 69 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserDestroy_impl_init)(nvtxSyncUser_t handle);
|
| 70 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireStart_impl_init)(nvtxSyncUser_t handle);
|
| 71 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireFailed_impl_init)(nvtxSyncUser_t handle);
|
| 72 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserAcquireSuccess_impl_init)(nvtxSyncUser_t handle);
|
| 73 |
+
NVTX_LINKONCE_FWDDECL_FUNCTION void NVTX_API NVTX_VERSIONED_IDENTIFIER(nvtxDomainSyncUserReleasing_impl_init)(nvtxSyncUser_t handle);
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/nvidia/nvtx/include/nvtx3/nvtxDetail/nvtxLinkOnce.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef __NVTX_LINKONCE_H__
|
| 2 |
+
#define __NVTX_LINKONCE_H__
|
| 3 |
+
|
| 4 |
+
/* This header defines macros to permit making definitions of global variables
|
| 5 |
+
* and functions in C/C++ header files which may be included multiple times in
|
| 6 |
+
* a translation unit or linkage unit. It allows authoring header-only libraries
|
| 7 |
+
* which can be used by multiple other header-only libraries (either as the same
|
| 8 |
+
* copy or multiple copies), and does not require any build changes, such as
|
| 9 |
+
* adding another .c file, linking a static library, or deploying a dynamic
|
| 10 |
+
* library. Globals defined with these macros have the property that they have
|
| 11 |
+
* the same address, pointing to a single instance, for the entire linkage unit.
|
| 12 |
+
* It is expected but not guaranteed that each linkage unit will have a separate
|
| 13 |
+
* instance.
|
| 14 |
+
*
|
| 15 |
+
* In some situations it is desirable to declare a variable without initializing
|
| 16 |
+
* it, refer to it in code or other variables' initializers, and then initialize
|
| 17 |
+
* it later. Similarly, functions can be prototyped, have their address taken,
|
| 18 |
+
* and then have their body defined later. In such cases, use the FWDDECL macros
|
| 19 |
+
* when forward-declaring LINKONCE global variables without initializers and
|
| 20 |
+
* function prototypes, and then use the DEFINE macros when later defining them.
|
| 21 |
+
* Although in many cases the FWDDECL macro is equivalent to the DEFINE macro,
|
| 22 |
+
* following this pattern makes code maximally portable.
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
#if defined(__MINGW32__) /* MinGW */
|
| 26 |
+
#define NVTX_LINKONCE_WEAK __attribute__((section(".gnu.linkonce.0.")))
|
| 27 |
+
#if defined(__cplusplus)
|
| 28 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL __declspec(selectany)
|
| 29 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION extern "C" inline NVTX_LINKONCE_WEAK
|
| 30 |
+
#else
|
| 31 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL __declspec(selectany)
|
| 32 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION NVTX_LINKONCE_WEAK
|
| 33 |
+
#endif
|
| 34 |
+
#elif defined(_MSC_VER) /* MSVC */
|
| 35 |
+
#if defined(__cplusplus)
|
| 36 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL extern "C" __declspec(selectany)
|
| 37 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION extern "C" inline
|
| 38 |
+
#else
|
| 39 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL __declspec(selectany)
|
| 40 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION __inline
|
| 41 |
+
#endif
|
| 42 |
+
#elif defined(__CYGWIN__) && defined(__clang__) /* Clang on Cygwin */
|
| 43 |
+
#define NVTX_LINKONCE_WEAK __attribute__((section(".gnu.linkonce.0.")))
|
| 44 |
+
#if defined(__cplusplus)
|
| 45 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL NVTX_LINKONCE_WEAK
|
| 46 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION extern "C" NVTX_LINKONCE_WEAK
|
| 47 |
+
#else
|
| 48 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL NVTX_LINKONCE_WEAK
|
| 49 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION NVTX_LINKONCE_WEAK
|
| 50 |
+
#endif
|
| 51 |
+
#elif defined(__CYGWIN__) /* Assume GCC or compatible */
|
| 52 |
+
#define NVTX_LINKONCE_WEAK __attribute__((weak))
|
| 53 |
+
#if defined(__cplusplus)
|
| 54 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL __declspec(selectany)
|
| 55 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION extern "C" inline
|
| 56 |
+
#else
|
| 57 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL NVTX_LINKONCE_WEAK
|
| 58 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION NVTX_LINKONCE_WEAK
|
| 59 |
+
#endif
|
| 60 |
+
#else /* All others: Assume GCC, clang, or compatible */
|
| 61 |
+
#define NVTX_LINKONCE_WEAK __attribute__((weak))
|
| 62 |
+
#define NVTX_LINKONCE_HIDDEN __attribute__((visibility("hidden")))
|
| 63 |
+
#if defined(__cplusplus)
|
| 64 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL NVTX_LINKONCE_HIDDEN NVTX_LINKONCE_WEAK
|
| 65 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION extern "C" NVTX_LINKONCE_HIDDEN inline
|
| 66 |
+
#else
|
| 67 |
+
#define NVTX_LINKONCE_DEFINE_GLOBAL NVTX_LINKONCE_HIDDEN NVTX_LINKONCE_WEAK
|
| 68 |
+
#define NVTX_LINKONCE_DEFINE_FUNCTION NVTX_LINKONCE_HIDDEN NVTX_LINKONCE_WEAK
|
| 69 |
+
#endif
|
| 70 |
+
#endif
|
| 71 |
+
|
| 72 |
+
#define NVTX_LINKONCE_FWDDECL_GLOBAL NVTX_LINKONCE_DEFINE_GLOBAL extern
|
| 73 |
+
#define NVTX_LINKONCE_FWDDECL_FUNCTION NVTX_LINKONCE_DEFINE_FUNCTION
|
| 74 |
+
|
| 75 |
+
#endif /* __NVTX_LINKONCE_H__ */
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/cmdline.py
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import os
|
| 12 |
+
import sys
|
| 13 |
+
import shutil
|
| 14 |
+
import argparse
|
| 15 |
+
from textwrap import dedent
|
| 16 |
+
|
| 17 |
+
from pip._vendor.pygments import __version__, highlight
|
| 18 |
+
from pip._vendor.pygments.util import ClassNotFound, OptionError, docstring_headline, \
|
| 19 |
+
guess_decode, guess_decode_from_terminal, terminal_encoding, \
|
| 20 |
+
UnclosingTextIOWrapper
|
| 21 |
+
from pip._vendor.pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
|
| 22 |
+
load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
|
| 23 |
+
from pip._vendor.pygments.lexers.special import TextLexer
|
| 24 |
+
from pip._vendor.pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
|
| 25 |
+
from pip._vendor.pygments.formatters import get_all_formatters, get_formatter_by_name, \
|
| 26 |
+
load_formatter_from_file, get_formatter_for_filename, find_formatter_class
|
| 27 |
+
from pip._vendor.pygments.formatters.terminal import TerminalFormatter
|
| 28 |
+
from pip._vendor.pygments.formatters.terminal256 import Terminal256Formatter, TerminalTrueColorFormatter
|
| 29 |
+
from pip._vendor.pygments.filters import get_all_filters, find_filter_class
|
| 30 |
+
from pip._vendor.pygments.styles import get_all_styles, get_style_by_name
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _parse_options(o_strs):
|
| 34 |
+
opts = {}
|
| 35 |
+
if not o_strs:
|
| 36 |
+
return opts
|
| 37 |
+
for o_str in o_strs:
|
| 38 |
+
if not o_str.strip():
|
| 39 |
+
continue
|
| 40 |
+
o_args = o_str.split(',')
|
| 41 |
+
for o_arg in o_args:
|
| 42 |
+
o_arg = o_arg.strip()
|
| 43 |
+
try:
|
| 44 |
+
o_key, o_val = o_arg.split('=', 1)
|
| 45 |
+
o_key = o_key.strip()
|
| 46 |
+
o_val = o_val.strip()
|
| 47 |
+
except ValueError:
|
| 48 |
+
opts[o_arg] = True
|
| 49 |
+
else:
|
| 50 |
+
opts[o_key] = o_val
|
| 51 |
+
return opts
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _parse_filters(f_strs):
|
| 55 |
+
filters = []
|
| 56 |
+
if not f_strs:
|
| 57 |
+
return filters
|
| 58 |
+
for f_str in f_strs:
|
| 59 |
+
if ':' in f_str:
|
| 60 |
+
fname, fopts = f_str.split(':', 1)
|
| 61 |
+
filters.append((fname, _parse_options([fopts])))
|
| 62 |
+
else:
|
| 63 |
+
filters.append((f_str, {}))
|
| 64 |
+
return filters
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _print_help(what, name):
|
| 68 |
+
try:
|
| 69 |
+
if what == 'lexer':
|
| 70 |
+
cls = get_lexer_by_name(name)
|
| 71 |
+
print(f"Help on the {cls.name} lexer:")
|
| 72 |
+
print(dedent(cls.__doc__))
|
| 73 |
+
elif what == 'formatter':
|
| 74 |
+
cls = find_formatter_class(name)
|
| 75 |
+
print(f"Help on the {cls.name} formatter:")
|
| 76 |
+
print(dedent(cls.__doc__))
|
| 77 |
+
elif what == 'filter':
|
| 78 |
+
cls = find_filter_class(name)
|
| 79 |
+
print(f"Help on the {name} filter:")
|
| 80 |
+
print(dedent(cls.__doc__))
|
| 81 |
+
return 0
|
| 82 |
+
except (AttributeError, ValueError):
|
| 83 |
+
print(f"{what} not found!", file=sys.stderr)
|
| 84 |
+
return 1
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _print_list(what):
|
| 88 |
+
if what == 'lexer':
|
| 89 |
+
print()
|
| 90 |
+
print("Lexers:")
|
| 91 |
+
print("~~~~~~~")
|
| 92 |
+
|
| 93 |
+
info = []
|
| 94 |
+
for fullname, names, exts, _ in get_all_lexers():
|
| 95 |
+
tup = (', '.join(names)+':', fullname,
|
| 96 |
+
exts and '(filenames ' + ', '.join(exts) + ')' or '')
|
| 97 |
+
info.append(tup)
|
| 98 |
+
info.sort()
|
| 99 |
+
for i in info:
|
| 100 |
+
print(('* {}\n {} {}').format(*i))
|
| 101 |
+
|
| 102 |
+
elif what == 'formatter':
|
| 103 |
+
print()
|
| 104 |
+
print("Formatters:")
|
| 105 |
+
print("~~~~~~~~~~~")
|
| 106 |
+
|
| 107 |
+
info = []
|
| 108 |
+
for cls in get_all_formatters():
|
| 109 |
+
doc = docstring_headline(cls)
|
| 110 |
+
tup = (', '.join(cls.aliases) + ':', doc, cls.filenames and
|
| 111 |
+
'(filenames ' + ', '.join(cls.filenames) + ')' or '')
|
| 112 |
+
info.append(tup)
|
| 113 |
+
info.sort()
|
| 114 |
+
for i in info:
|
| 115 |
+
print(('* {}\n {} {}').format(*i))
|
| 116 |
+
|
| 117 |
+
elif what == 'filter':
|
| 118 |
+
print()
|
| 119 |
+
print("Filters:")
|
| 120 |
+
print("~~~~~~~~")
|
| 121 |
+
|
| 122 |
+
for name in get_all_filters():
|
| 123 |
+
cls = find_filter_class(name)
|
| 124 |
+
print("* " + name + ':')
|
| 125 |
+
print(f" {docstring_headline(cls)}")
|
| 126 |
+
|
| 127 |
+
elif what == 'style':
|
| 128 |
+
print()
|
| 129 |
+
print("Styles:")
|
| 130 |
+
print("~~~~~~~")
|
| 131 |
+
|
| 132 |
+
for name in get_all_styles():
|
| 133 |
+
cls = get_style_by_name(name)
|
| 134 |
+
print("* " + name + ':')
|
| 135 |
+
print(f" {docstring_headline(cls)}")
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def _print_list_as_json(requested_items):
|
| 139 |
+
import json
|
| 140 |
+
result = {}
|
| 141 |
+
if 'lexer' in requested_items:
|
| 142 |
+
info = {}
|
| 143 |
+
for fullname, names, filenames, mimetypes in get_all_lexers():
|
| 144 |
+
info[fullname] = {
|
| 145 |
+
'aliases': names,
|
| 146 |
+
'filenames': filenames,
|
| 147 |
+
'mimetypes': mimetypes
|
| 148 |
+
}
|
| 149 |
+
result['lexers'] = info
|
| 150 |
+
|
| 151 |
+
if 'formatter' in requested_items:
|
| 152 |
+
info = {}
|
| 153 |
+
for cls in get_all_formatters():
|
| 154 |
+
doc = docstring_headline(cls)
|
| 155 |
+
info[cls.name] = {
|
| 156 |
+
'aliases': cls.aliases,
|
| 157 |
+
'filenames': cls.filenames,
|
| 158 |
+
'doc': doc
|
| 159 |
+
}
|
| 160 |
+
result['formatters'] = info
|
| 161 |
+
|
| 162 |
+
if 'filter' in requested_items:
|
| 163 |
+
info = {}
|
| 164 |
+
for name in get_all_filters():
|
| 165 |
+
cls = find_filter_class(name)
|
| 166 |
+
info[name] = {
|
| 167 |
+
'doc': docstring_headline(cls)
|
| 168 |
+
}
|
| 169 |
+
result['filters'] = info
|
| 170 |
+
|
| 171 |
+
if 'style' in requested_items:
|
| 172 |
+
info = {}
|
| 173 |
+
for name in get_all_styles():
|
| 174 |
+
cls = get_style_by_name(name)
|
| 175 |
+
info[name] = {
|
| 176 |
+
'doc': docstring_headline(cls)
|
| 177 |
+
}
|
| 178 |
+
result['styles'] = info
|
| 179 |
+
|
| 180 |
+
json.dump(result, sys.stdout)
|
| 181 |
+
|
| 182 |
+
def main_inner(parser, argns):
|
| 183 |
+
if argns.help:
|
| 184 |
+
parser.print_help()
|
| 185 |
+
return 0
|
| 186 |
+
|
| 187 |
+
if argns.V:
|
| 188 |
+
print(f'Pygments version {__version__}, (c) 2006-2024 by Georg Brandl, Matthäus '
|
| 189 |
+
'Chajdas and contributors.')
|
| 190 |
+
return 0
|
| 191 |
+
|
| 192 |
+
def is_only_option(opt):
|
| 193 |
+
return not any(v for (k, v) in vars(argns).items() if k != opt)
|
| 194 |
+
|
| 195 |
+
# handle ``pygmentize -L``
|
| 196 |
+
if argns.L is not None:
|
| 197 |
+
arg_set = set()
|
| 198 |
+
for k, v in vars(argns).items():
|
| 199 |
+
if v:
|
| 200 |
+
arg_set.add(k)
|
| 201 |
+
|
| 202 |
+
arg_set.discard('L')
|
| 203 |
+
arg_set.discard('json')
|
| 204 |
+
|
| 205 |
+
if arg_set:
|
| 206 |
+
parser.print_help(sys.stderr)
|
| 207 |
+
return 2
|
| 208 |
+
|
| 209 |
+
# print version
|
| 210 |
+
if not argns.json:
|
| 211 |
+
main(['', '-V'])
|
| 212 |
+
allowed_types = {'lexer', 'formatter', 'filter', 'style'}
|
| 213 |
+
largs = [arg.rstrip('s') for arg in argns.L]
|
| 214 |
+
if any(arg not in allowed_types for arg in largs):
|
| 215 |
+
parser.print_help(sys.stderr)
|
| 216 |
+
return 0
|
| 217 |
+
if not largs:
|
| 218 |
+
largs = allowed_types
|
| 219 |
+
if not argns.json:
|
| 220 |
+
for arg in largs:
|
| 221 |
+
_print_list(arg)
|
| 222 |
+
else:
|
| 223 |
+
_print_list_as_json(largs)
|
| 224 |
+
return 0
|
| 225 |
+
|
| 226 |
+
# handle ``pygmentize -H``
|
| 227 |
+
if argns.H:
|
| 228 |
+
if not is_only_option('H'):
|
| 229 |
+
parser.print_help(sys.stderr)
|
| 230 |
+
return 2
|
| 231 |
+
what, name = argns.H
|
| 232 |
+
if what not in ('lexer', 'formatter', 'filter'):
|
| 233 |
+
parser.print_help(sys.stderr)
|
| 234 |
+
return 2
|
| 235 |
+
return _print_help(what, name)
|
| 236 |
+
|
| 237 |
+
# parse -O options
|
| 238 |
+
parsed_opts = _parse_options(argns.O or [])
|
| 239 |
+
|
| 240 |
+
# parse -P options
|
| 241 |
+
for p_opt in argns.P or []:
|
| 242 |
+
try:
|
| 243 |
+
name, value = p_opt.split('=', 1)
|
| 244 |
+
except ValueError:
|
| 245 |
+
parsed_opts[p_opt] = True
|
| 246 |
+
else:
|
| 247 |
+
parsed_opts[name] = value
|
| 248 |
+
|
| 249 |
+
# encodings
|
| 250 |
+
inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
|
| 251 |
+
outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
|
| 252 |
+
|
| 253 |
+
# handle ``pygmentize -N``
|
| 254 |
+
if argns.N:
|
| 255 |
+
lexer = find_lexer_class_for_filename(argns.N)
|
| 256 |
+
if lexer is None:
|
| 257 |
+
lexer = TextLexer
|
| 258 |
+
|
| 259 |
+
print(lexer.aliases[0])
|
| 260 |
+
return 0
|
| 261 |
+
|
| 262 |
+
# handle ``pygmentize -C``
|
| 263 |
+
if argns.C:
|
| 264 |
+
inp = sys.stdin.buffer.read()
|
| 265 |
+
try:
|
| 266 |
+
lexer = guess_lexer(inp, inencoding=inencoding)
|
| 267 |
+
except ClassNotFound:
|
| 268 |
+
lexer = TextLexer
|
| 269 |
+
|
| 270 |
+
print(lexer.aliases[0])
|
| 271 |
+
return 0
|
| 272 |
+
|
| 273 |
+
# handle ``pygmentize -S``
|
| 274 |
+
S_opt = argns.S
|
| 275 |
+
a_opt = argns.a
|
| 276 |
+
if S_opt is not None:
|
| 277 |
+
f_opt = argns.f
|
| 278 |
+
if not f_opt:
|
| 279 |
+
parser.print_help(sys.stderr)
|
| 280 |
+
return 2
|
| 281 |
+
if argns.l or argns.INPUTFILE:
|
| 282 |
+
parser.print_help(sys.stderr)
|
| 283 |
+
return 2
|
| 284 |
+
|
| 285 |
+
try:
|
| 286 |
+
parsed_opts['style'] = S_opt
|
| 287 |
+
fmter = get_formatter_by_name(f_opt, **parsed_opts)
|
| 288 |
+
except ClassNotFound as err:
|
| 289 |
+
print(err, file=sys.stderr)
|
| 290 |
+
return 1
|
| 291 |
+
|
| 292 |
+
print(fmter.get_style_defs(a_opt or ''))
|
| 293 |
+
return 0
|
| 294 |
+
|
| 295 |
+
# if no -S is given, -a is not allowed
|
| 296 |
+
if argns.a is not None:
|
| 297 |
+
parser.print_help(sys.stderr)
|
| 298 |
+
return 2
|
| 299 |
+
|
| 300 |
+
# parse -F options
|
| 301 |
+
F_opts = _parse_filters(argns.F or [])
|
| 302 |
+
|
| 303 |
+
# -x: allow custom (eXternal) lexers and formatters
|
| 304 |
+
allow_custom_lexer_formatter = bool(argns.x)
|
| 305 |
+
|
| 306 |
+
# select lexer
|
| 307 |
+
lexer = None
|
| 308 |
+
|
| 309 |
+
# given by name?
|
| 310 |
+
lexername = argns.l
|
| 311 |
+
if lexername:
|
| 312 |
+
# custom lexer, located relative to user's cwd
|
| 313 |
+
if allow_custom_lexer_formatter and '.py' in lexername:
|
| 314 |
+
try:
|
| 315 |
+
filename = None
|
| 316 |
+
name = None
|
| 317 |
+
if ':' in lexername:
|
| 318 |
+
filename, name = lexername.rsplit(':', 1)
|
| 319 |
+
|
| 320 |
+
if '.py' in name:
|
| 321 |
+
# This can happen on Windows: If the lexername is
|
| 322 |
+
# C:\lexer.py -- return to normal load path in that case
|
| 323 |
+
name = None
|
| 324 |
+
|
| 325 |
+
if filename and name:
|
| 326 |
+
lexer = load_lexer_from_file(filename, name,
|
| 327 |
+
**parsed_opts)
|
| 328 |
+
else:
|
| 329 |
+
lexer = load_lexer_from_file(lexername, **parsed_opts)
|
| 330 |
+
except ClassNotFound as err:
|
| 331 |
+
print('Error:', err, file=sys.stderr)
|
| 332 |
+
return 1
|
| 333 |
+
else:
|
| 334 |
+
try:
|
| 335 |
+
lexer = get_lexer_by_name(lexername, **parsed_opts)
|
| 336 |
+
except (OptionError, ClassNotFound) as err:
|
| 337 |
+
print('Error:', err, file=sys.stderr)
|
| 338 |
+
return 1
|
| 339 |
+
|
| 340 |
+
# read input code
|
| 341 |
+
code = None
|
| 342 |
+
|
| 343 |
+
if argns.INPUTFILE:
|
| 344 |
+
if argns.s:
|
| 345 |
+
print('Error: -s option not usable when input file specified',
|
| 346 |
+
file=sys.stderr)
|
| 347 |
+
return 2
|
| 348 |
+
|
| 349 |
+
infn = argns.INPUTFILE
|
| 350 |
+
try:
|
| 351 |
+
with open(infn, 'rb') as infp:
|
| 352 |
+
code = infp.read()
|
| 353 |
+
except Exception as err:
|
| 354 |
+
print('Error: cannot read infile:', err, file=sys.stderr)
|
| 355 |
+
return 1
|
| 356 |
+
if not inencoding:
|
| 357 |
+
code, inencoding = guess_decode(code)
|
| 358 |
+
|
| 359 |
+
# do we have to guess the lexer?
|
| 360 |
+
if not lexer:
|
| 361 |
+
try:
|
| 362 |
+
lexer = get_lexer_for_filename(infn, code, **parsed_opts)
|
| 363 |
+
except ClassNotFound as err:
|
| 364 |
+
if argns.g:
|
| 365 |
+
try:
|
| 366 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 367 |
+
except ClassNotFound:
|
| 368 |
+
lexer = TextLexer(**parsed_opts)
|
| 369 |
+
else:
|
| 370 |
+
print('Error:', err, file=sys.stderr)
|
| 371 |
+
return 1
|
| 372 |
+
except OptionError as err:
|
| 373 |
+
print('Error:', err, file=sys.stderr)
|
| 374 |
+
return 1
|
| 375 |
+
|
| 376 |
+
elif not argns.s: # treat stdin as full file (-s support is later)
|
| 377 |
+
# read code from terminal, always in binary mode since we want to
|
| 378 |
+
# decode ourselves and be tolerant with it
|
| 379 |
+
code = sys.stdin.buffer.read() # use .buffer to get a binary stream
|
| 380 |
+
if not inencoding:
|
| 381 |
+
code, inencoding = guess_decode_from_terminal(code, sys.stdin)
|
| 382 |
+
# else the lexer will do the decoding
|
| 383 |
+
if not lexer:
|
| 384 |
+
try:
|
| 385 |
+
lexer = guess_lexer(code, **parsed_opts)
|
| 386 |
+
except ClassNotFound:
|
| 387 |
+
lexer = TextLexer(**parsed_opts)
|
| 388 |
+
|
| 389 |
+
else: # -s option needs a lexer with -l
|
| 390 |
+
if not lexer:
|
| 391 |
+
print('Error: when using -s a lexer has to be selected with -l',
|
| 392 |
+
file=sys.stderr)
|
| 393 |
+
return 2
|
| 394 |
+
|
| 395 |
+
# process filters
|
| 396 |
+
for fname, fopts in F_opts:
|
| 397 |
+
try:
|
| 398 |
+
lexer.add_filter(fname, **fopts)
|
| 399 |
+
except ClassNotFound as err:
|
| 400 |
+
print('Error:', err, file=sys.stderr)
|
| 401 |
+
return 1
|
| 402 |
+
|
| 403 |
+
# select formatter
|
| 404 |
+
outfn = argns.o
|
| 405 |
+
fmter = argns.f
|
| 406 |
+
if fmter:
|
| 407 |
+
# custom formatter, located relative to user's cwd
|
| 408 |
+
if allow_custom_lexer_formatter and '.py' in fmter:
|
| 409 |
+
try:
|
| 410 |
+
filename = None
|
| 411 |
+
name = None
|
| 412 |
+
if ':' in fmter:
|
| 413 |
+
# Same logic as above for custom lexer
|
| 414 |
+
filename, name = fmter.rsplit(':', 1)
|
| 415 |
+
|
| 416 |
+
if '.py' in name:
|
| 417 |
+
name = None
|
| 418 |
+
|
| 419 |
+
if filename and name:
|
| 420 |
+
fmter = load_formatter_from_file(filename, name,
|
| 421 |
+
**parsed_opts)
|
| 422 |
+
else:
|
| 423 |
+
fmter = load_formatter_from_file(fmter, **parsed_opts)
|
| 424 |
+
except ClassNotFound as err:
|
| 425 |
+
print('Error:', err, file=sys.stderr)
|
| 426 |
+
return 1
|
| 427 |
+
else:
|
| 428 |
+
try:
|
| 429 |
+
fmter = get_formatter_by_name(fmter, **parsed_opts)
|
| 430 |
+
except (OptionError, ClassNotFound) as err:
|
| 431 |
+
print('Error:', err, file=sys.stderr)
|
| 432 |
+
return 1
|
| 433 |
+
|
| 434 |
+
if outfn:
|
| 435 |
+
if not fmter:
|
| 436 |
+
try:
|
| 437 |
+
fmter = get_formatter_for_filename(outfn, **parsed_opts)
|
| 438 |
+
except (OptionError, ClassNotFound) as err:
|
| 439 |
+
print('Error:', err, file=sys.stderr)
|
| 440 |
+
return 1
|
| 441 |
+
try:
|
| 442 |
+
outfile = open(outfn, 'wb')
|
| 443 |
+
except Exception as err:
|
| 444 |
+
print('Error: cannot open outfile:', err, file=sys.stderr)
|
| 445 |
+
return 1
|
| 446 |
+
else:
|
| 447 |
+
if not fmter:
|
| 448 |
+
if os.environ.get('COLORTERM','') in ('truecolor', '24bit'):
|
| 449 |
+
fmter = TerminalTrueColorFormatter(**parsed_opts)
|
| 450 |
+
elif '256' in os.environ.get('TERM', ''):
|
| 451 |
+
fmter = Terminal256Formatter(**parsed_opts)
|
| 452 |
+
else:
|
| 453 |
+
fmter = TerminalFormatter(**parsed_opts)
|
| 454 |
+
outfile = sys.stdout.buffer
|
| 455 |
+
|
| 456 |
+
# determine output encoding if not explicitly selected
|
| 457 |
+
if not outencoding:
|
| 458 |
+
if outfn:
|
| 459 |
+
# output file? use lexer encoding for now (can still be None)
|
| 460 |
+
fmter.encoding = inencoding
|
| 461 |
+
else:
|
| 462 |
+
# else use terminal encoding
|
| 463 |
+
fmter.encoding = terminal_encoding(sys.stdout)
|
| 464 |
+
|
| 465 |
+
# provide coloring under Windows, if possible
|
| 466 |
+
if not outfn and sys.platform in ('win32', 'cygwin') and \
|
| 467 |
+
fmter.name in ('Terminal', 'Terminal256'): # pragma: no cover
|
| 468 |
+
# unfortunately colorama doesn't support binary streams on Py3
|
| 469 |
+
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
|
| 470 |
+
fmter.encoding = None
|
| 471 |
+
try:
|
| 472 |
+
import colorama.initialise
|
| 473 |
+
except ImportError:
|
| 474 |
+
pass
|
| 475 |
+
else:
|
| 476 |
+
outfile = colorama.initialise.wrap_stream(
|
| 477 |
+
outfile, convert=None, strip=None, autoreset=False, wrap=True)
|
| 478 |
+
|
| 479 |
+
# When using the LaTeX formatter and the option `escapeinside` is
|
| 480 |
+
# specified, we need a special lexer which collects escaped text
|
| 481 |
+
# before running the chosen language lexer.
|
| 482 |
+
escapeinside = parsed_opts.get('escapeinside', '')
|
| 483 |
+
if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter):
|
| 484 |
+
left = escapeinside[0]
|
| 485 |
+
right = escapeinside[1]
|
| 486 |
+
lexer = LatexEmbeddedLexer(left, right, lexer)
|
| 487 |
+
|
| 488 |
+
# ... and do it!
|
| 489 |
+
if not argns.s:
|
| 490 |
+
# process whole input as per normal...
|
| 491 |
+
try:
|
| 492 |
+
highlight(code, lexer, fmter, outfile)
|
| 493 |
+
finally:
|
| 494 |
+
if outfn:
|
| 495 |
+
outfile.close()
|
| 496 |
+
return 0
|
| 497 |
+
else:
|
| 498 |
+
# line by line processing of stdin (eg: for 'tail -f')...
|
| 499 |
+
try:
|
| 500 |
+
while 1:
|
| 501 |
+
line = sys.stdin.buffer.readline()
|
| 502 |
+
if not line:
|
| 503 |
+
break
|
| 504 |
+
if not inencoding:
|
| 505 |
+
line = guess_decode_from_terminal(line, sys.stdin)[0]
|
| 506 |
+
highlight(line, lexer, fmter, outfile)
|
| 507 |
+
if hasattr(outfile, 'flush'):
|
| 508 |
+
outfile.flush()
|
| 509 |
+
return 0
|
| 510 |
+
except KeyboardInterrupt: # pragma: no cover
|
| 511 |
+
return 0
|
| 512 |
+
finally:
|
| 513 |
+
if outfn:
|
| 514 |
+
outfile.close()
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
class HelpFormatter(argparse.HelpFormatter):
|
| 518 |
+
def __init__(self, prog, indent_increment=2, max_help_position=16, width=None):
|
| 519 |
+
if width is None:
|
| 520 |
+
try:
|
| 521 |
+
width = shutil.get_terminal_size().columns - 2
|
| 522 |
+
except Exception:
|
| 523 |
+
pass
|
| 524 |
+
argparse.HelpFormatter.__init__(self, prog, indent_increment,
|
| 525 |
+
max_help_position, width)
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
def main(args=sys.argv):
|
| 529 |
+
"""
|
| 530 |
+
Main command line entry point.
|
| 531 |
+
"""
|
| 532 |
+
desc = "Highlight an input file and write the result to an output file."
|
| 533 |
+
parser = argparse.ArgumentParser(description=desc, add_help=False,
|
| 534 |
+
formatter_class=HelpFormatter)
|
| 535 |
+
|
| 536 |
+
operation = parser.add_argument_group('Main operation')
|
| 537 |
+
lexersel = operation.add_mutually_exclusive_group()
|
| 538 |
+
lexersel.add_argument(
|
| 539 |
+
'-l', metavar='LEXER',
|
| 540 |
+
help='Specify the lexer to use. (Query names with -L.) If not '
|
| 541 |
+
'given and -g is not present, the lexer is guessed from the filename.')
|
| 542 |
+
lexersel.add_argument(
|
| 543 |
+
'-g', action='store_true',
|
| 544 |
+
help='Guess the lexer from the file contents, or pass through '
|
| 545 |
+
'as plain text if nothing can be guessed.')
|
| 546 |
+
operation.add_argument(
|
| 547 |
+
'-F', metavar='FILTER[:options]', action='append',
|
| 548 |
+
help='Add a filter to the token stream. (Query names with -L.) '
|
| 549 |
+
'Filter options are given after a colon if necessary.')
|
| 550 |
+
operation.add_argument(
|
| 551 |
+
'-f', metavar='FORMATTER',
|
| 552 |
+
help='Specify the formatter to use. (Query names with -L.) '
|
| 553 |
+
'If not given, the formatter is guessed from the output filename, '
|
| 554 |
+
'and defaults to the terminal formatter if the output is to the '
|
| 555 |
+
'terminal or an unknown file extension.')
|
| 556 |
+
operation.add_argument(
|
| 557 |
+
'-O', metavar='OPTION=value[,OPTION=value,...]', action='append',
|
| 558 |
+
help='Give options to the lexer and formatter as a comma-separated '
|
| 559 |
+
'list of key-value pairs. '
|
| 560 |
+
'Example: `-O bg=light,python=cool`.')
|
| 561 |
+
operation.add_argument(
|
| 562 |
+
'-P', metavar='OPTION=value', action='append',
|
| 563 |
+
help='Give a single option to the lexer and formatter - with this '
|
| 564 |
+
'you can pass options whose value contains commas and equal signs. '
|
| 565 |
+
'Example: `-P "heading=Pygments, the Python highlighter"`.')
|
| 566 |
+
operation.add_argument(
|
| 567 |
+
'-o', metavar='OUTPUTFILE',
|
| 568 |
+
help='Where to write the output. Defaults to standard output.')
|
| 569 |
+
|
| 570 |
+
operation.add_argument(
|
| 571 |
+
'INPUTFILE', nargs='?',
|
| 572 |
+
help='Where to read the input. Defaults to standard input.')
|
| 573 |
+
|
| 574 |
+
flags = parser.add_argument_group('Operation flags')
|
| 575 |
+
flags.add_argument(
|
| 576 |
+
'-v', action='store_true',
|
| 577 |
+
help='Print a detailed traceback on unhandled exceptions, which '
|
| 578 |
+
'is useful for debugging and bug reports.')
|
| 579 |
+
flags.add_argument(
|
| 580 |
+
'-s', action='store_true',
|
| 581 |
+
help='Process lines one at a time until EOF, rather than waiting to '
|
| 582 |
+
'process the entire file. This only works for stdin, only for lexers '
|
| 583 |
+
'with no line-spanning constructs, and is intended for streaming '
|
| 584 |
+
'input such as you get from `tail -f`. '
|
| 585 |
+
'Example usage: `tail -f sql.log | pygmentize -s -l sql`.')
|
| 586 |
+
flags.add_argument(
|
| 587 |
+
'-x', action='store_true',
|
| 588 |
+
help='Allow custom lexers and formatters to be loaded from a .py file '
|
| 589 |
+
'relative to the current working directory. For example, '
|
| 590 |
+
'`-l ./customlexer.py -x`. By default, this option expects a file '
|
| 591 |
+
'with a class named CustomLexer or CustomFormatter; you can also '
|
| 592 |
+
'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
|
| 593 |
+
'Users should be very careful not to use this option with untrusted '
|
| 594 |
+
'files, because it will import and run them.')
|
| 595 |
+
flags.add_argument('--json', help='Output as JSON. This can '
|
| 596 |
+
'be only used in conjunction with -L.',
|
| 597 |
+
default=False,
|
| 598 |
+
action='store_true')
|
| 599 |
+
|
| 600 |
+
special_modes_group = parser.add_argument_group(
|
| 601 |
+
'Special modes - do not do any highlighting')
|
| 602 |
+
special_modes = special_modes_group.add_mutually_exclusive_group()
|
| 603 |
+
special_modes.add_argument(
|
| 604 |
+
'-S', metavar='STYLE -f formatter',
|
| 605 |
+
help='Print style definitions for STYLE for a formatter '
|
| 606 |
+
'given with -f. The argument given by -a is formatter '
|
| 607 |
+
'dependent.')
|
| 608 |
+
special_modes.add_argument(
|
| 609 |
+
'-L', nargs='*', metavar='WHAT',
|
| 610 |
+
help='List lexers, formatters, styles or filters -- '
|
| 611 |
+
'give additional arguments for the thing(s) you want to list '
|
| 612 |
+
'(e.g. "styles"), or omit them to list everything.')
|
| 613 |
+
special_modes.add_argument(
|
| 614 |
+
'-N', metavar='FILENAME',
|
| 615 |
+
help='Guess and print out a lexer name based solely on the given '
|
| 616 |
+
'filename. Does not take input or highlight anything. If no specific '
|
| 617 |
+
'lexer can be determined, "text" is printed.')
|
| 618 |
+
special_modes.add_argument(
|
| 619 |
+
'-C', action='store_true',
|
| 620 |
+
help='Like -N, but print out a lexer name based solely on '
|
| 621 |
+
'a given content from standard input.')
|
| 622 |
+
special_modes.add_argument(
|
| 623 |
+
'-H', action='store', nargs=2, metavar=('NAME', 'TYPE'),
|
| 624 |
+
help='Print detailed help for the object <name> of type <type>, '
|
| 625 |
+
'where <type> is one of "lexer", "formatter" or "filter".')
|
| 626 |
+
special_modes.add_argument(
|
| 627 |
+
'-V', action='store_true',
|
| 628 |
+
help='Print the package version.')
|
| 629 |
+
special_modes.add_argument(
|
| 630 |
+
'-h', '--help', action='store_true',
|
| 631 |
+
help='Print this help.')
|
| 632 |
+
special_modes_group.add_argument(
|
| 633 |
+
'-a', metavar='ARG',
|
| 634 |
+
help='Formatter-specific additional argument for the -S (print '
|
| 635 |
+
'style sheet) mode.')
|
| 636 |
+
|
| 637 |
+
argns = parser.parse_args(args[1:])
|
| 638 |
+
|
| 639 |
+
try:
|
| 640 |
+
return main_inner(parser, argns)
|
| 641 |
+
except BrokenPipeError:
|
| 642 |
+
# someone closed our stdout, e.g. by quitting a pager.
|
| 643 |
+
return 0
|
| 644 |
+
except Exception:
|
| 645 |
+
if argns.v:
|
| 646 |
+
print(file=sys.stderr)
|
| 647 |
+
print('*' * 65, file=sys.stderr)
|
| 648 |
+
print('An unhandled exception occurred while highlighting.',
|
| 649 |
+
file=sys.stderr)
|
| 650 |
+
print('Please report the whole traceback to the issue tracker at',
|
| 651 |
+
file=sys.stderr)
|
| 652 |
+
print('<https://github.com/pygments/pygments/issues>.',
|
| 653 |
+
file=sys.stderr)
|
| 654 |
+
print('*' * 65, file=sys.stderr)
|
| 655 |
+
print(file=sys.stderr)
|
| 656 |
+
raise
|
| 657 |
+
import traceback
|
| 658 |
+
info = traceback.format_exception(*sys.exc_info())
|
| 659 |
+
msg = info[-1].strip()
|
| 660 |
+
if len(info) >= 3:
|
| 661 |
+
# extract relevant file and position info
|
| 662 |
+
msg += '\n (f{})'.format(info[-2].split('\n')[0].strip()[1:])
|
| 663 |
+
print(file=sys.stderr)
|
| 664 |
+
print('*** Error while highlighting:', file=sys.stderr)
|
| 665 |
+
print(msg, file=sys.stderr)
|
| 666 |
+
print('*** If this is a bug you want to report, please rer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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.filters
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Module containing filter lookup functions and default
|
| 6 |
+
filters.
|
| 7 |
+
|
| 8 |
+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
|
| 9 |
+
:license: BSD, see LICENSE for details.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import re
|
| 13 |
+
|
| 14 |
+
from pip._vendor.pygments.token import String, Comment, Keyword, Name, Error, Whitespace, \
|
| 15 |
+
string_to_tokentype
|
| 16 |
+
from pip._vendor.pygments.filter import Filter
|
| 17 |
+
from pip._vendor.pygments.util import get_list_opt, get_int_opt, get_bool_opt, \
|
| 18 |
+
get_choice_opt, ClassNotFound, OptionError
|
| 19 |
+
from pip._vendor.pygments.plugin import find_plugin_filters
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def find_filter_class(filtername):
|
| 23 |
+
"""Lookup a filter by name. Return None if not found."""
|
| 24 |
+
if filtername in FILTERS:
|
| 25 |
+
return FILTERS[filtername]
|
| 26 |
+
for name, cls in find_plugin_filters():
|
| 27 |
+
if name == filtername:
|
| 28 |
+
return cls
|
| 29 |
+
return None
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_filter_by_name(filtername, **options):
|
| 33 |
+
"""Return an instantiated filter.
|
| 34 |
+
|
| 35 |
+
Options are passed to the filter initializer if wanted.
|
| 36 |
+
Raise a ClassNotFound if not found.
|
| 37 |
+
"""
|
| 38 |
+
cls = find_filter_class(filtername)
|
| 39 |
+
if cls:
|
| 40 |
+
return cls(**options)
|
| 41 |
+
else:
|
| 42 |
+
raise ClassNotFound(f'filter {filtername!r} not found')
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def get_all_filters():
|
| 46 |
+
"""Return a generator of all filter names."""
|
| 47 |
+
yield from FILTERS
|
| 48 |
+
for name, _ in find_plugin_filters():
|
| 49 |
+
yield name
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _replace_special(ttype, value, regex, specialttype,
|
| 53 |
+
replacefunc=lambda x: x):
|
| 54 |
+
last = 0
|
| 55 |
+
for match in regex.finditer(value):
|
| 56 |
+
start, end = match.start(), match.end()
|
| 57 |
+
if start != last:
|
| 58 |
+
yield ttype, value[last:start]
|
| 59 |
+
yield specialttype, replacefunc(value[start:end])
|
| 60 |
+
last = end
|
| 61 |
+
if last != len(value):
|
| 62 |
+
yield ttype, value[last:]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class CodeTagFilter(Filter):
|
| 66 |
+
"""Highlight special code tags in comments and docstrings.
|
| 67 |
+
|
| 68 |
+
Options accepted:
|
| 69 |
+
|
| 70 |
+
`codetags` : list of strings
|
| 71 |
+
A list of strings that are flagged as code tags. The default is to
|
| 72 |
+
highlight ``XXX``, ``TODO``, ``FIXME``, ``BUG`` and ``NOTE``.
|
| 73 |
+
|
| 74 |
+
.. versionchanged:: 2.13
|
| 75 |
+
Now recognizes ``FIXME`` by default.
|
| 76 |
+
"""
|
| 77 |
+
|
| 78 |
+
def __init__(self, **options):
|
| 79 |
+
Filter.__init__(self, **options)
|
| 80 |
+
tags = get_list_opt(options, 'codetags',
|
| 81 |
+
['XXX', 'TODO', 'FIXME', 'BUG', 'NOTE'])
|
| 82 |
+
self.tag_re = re.compile(r'\b({})\b'.format('|'.join([
|
| 83 |
+
re.escape(tag) for tag in tags if tag
|
| 84 |
+
])))
|
| 85 |
+
|
| 86 |
+
def filter(self, lexer, stream):
|
| 87 |
+
regex = self.tag_re
|
| 88 |
+
for ttype, value in stream:
|
| 89 |
+
if ttype in String.Doc or \
|
| 90 |
+
ttype in Comment and \
|
| 91 |
+
ttype not in Comment.Preproc:
|
| 92 |
+
yield from _replace_special(ttype, value, regex, Comment.Special)
|
| 93 |
+
else:
|
| 94 |
+
yield ttype, value
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
class SymbolFilter(Filter):
|
| 98 |
+
"""Convert mathematical symbols such as \\<longrightarrow> in Isabelle
|
| 99 |
+
or \\longrightarrow in LaTeX into Unicode characters.
|
| 100 |
+
|
| 101 |
+
This is mostly useful for HTML or console output when you want to
|
| 102 |
+
approximate the source rendering you'd see in an IDE.
|
| 103 |
+
|
| 104 |
+
Options accepted:
|
| 105 |
+
|
| 106 |
+
`lang` : string
|
| 107 |
+
The symbol language. Must be one of ``'isabelle'`` or
|
| 108 |
+
``'latex'``. The default is ``'isabelle'``.
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
latex_symbols = {
|
| 112 |
+
'\\alpha' : '\U000003b1',
|
| 113 |
+
'\\beta' : '\U000003b2',
|
| 114 |
+
'\\gamma' : '\U000003b3',
|
| 115 |
+
'\\delta' : '\U000003b4',
|
| 116 |
+
'\\varepsilon' : '\U000003b5',
|
| 117 |
+
'\\zeta' : '\U000003b6',
|
| 118 |
+
'\\eta' : '\U000003b7',
|
| 119 |
+
'\\vartheta' : '\U000003b8',
|
| 120 |
+
'\\iota' : '\U000003b9',
|
| 121 |
+
'\\kappa' : '\U000003ba',
|
| 122 |
+
'\\lambda' : '\U000003bb',
|
| 123 |
+
'\\mu' : '\U000003bc',
|
| 124 |
+
'\\nu' : '\U000003bd',
|
| 125 |
+
'\\xi' : '\U000003be',
|
| 126 |
+
'\\pi' : '\U000003c0',
|
| 127 |
+
'\\varrho' : '\U000003c1',
|
| 128 |
+
'\\sigma' : '\U000003c3',
|
| 129 |
+
'\\tau' : '\U000003c4',
|
| 130 |
+
'\\upsilon' : '\U000003c5',
|
| 131 |
+
'\\varphi' : '\U000003c6',
|
| 132 |
+
'\\chi' : '\U000003c7',
|
| 133 |
+
'\\psi' : '\U000003c8',
|
| 134 |
+
'\\omega' : '\U000003c9',
|
| 135 |
+
'\\Gamma' : '\U00000393',
|
| 136 |
+
'\\Delta' : '\U00000394',
|
| 137 |
+
'\\Theta' : '\U00000398',
|
| 138 |
+
'\\Lambda' : '\U0000039b',
|
| 139 |
+
'\\Xi' : '\U0000039e',
|
| 140 |
+
'\\Pi' : '\U000003a0',
|
| 141 |
+
'\\Sigma' : '\U000003a3',
|
| 142 |
+
'\\Upsilon' : '\U000003a5',
|
| 143 |
+
'\\Phi' : '\U000003a6',
|
| 144 |
+
'\\Psi' : '\U000003a8',
|
| 145 |
+
'\\Omega' : '\U000003a9',
|
| 146 |
+
'\\leftarrow' : '\U00002190',
|
| 147 |
+
'\\longleftarrow' : '\U000027f5',
|
| 148 |
+
'\\rightarrow' : '\U00002192',
|
| 149 |
+
'\\longrightarrow' : '\U000027f6',
|
| 150 |
+
'\\Leftarrow' : '\U000021d0',
|
| 151 |
+
'\\Longleftarrow' : '\U000027f8',
|
| 152 |
+
'\\Rightarrow' : '\U000021d2',
|
| 153 |
+
'\\Longrightarrow' : '\U000027f9',
|
| 154 |
+
'\\leftrightarrow' : '\U00002194',
|
| 155 |
+
'\\longleftrightarrow' : '\U000027f7',
|
| 156 |
+
'\\Leftrightarrow' : '\U000021d4',
|
| 157 |
+
'\\Longleftrightarrow' : '\U000027fa',
|
| 158 |
+
'\\mapsto' : '\U000021a6',
|
| 159 |
+
'\\longmapsto' : '\U000027fc',
|
| 160 |
+
'\\relbar' : '\U00002500',
|
| 161 |
+
'\\Relbar' : '\U00002550',
|
| 162 |
+
'\\hookleftarrow' : '\U000021a9',
|
| 163 |
+
'\\hookrightarrow' : '\U000021aa',
|
| 164 |
+
'\\leftharpoondown' : '\U000021bd',
|
| 165 |
+
'\\rightharpoondown' : '\U000021c1',
|
| 166 |
+
'\\leftharpoonup' : '\U000021bc',
|
| 167 |
+
'\\rightharpoonup' : '\U000021c0',
|
| 168 |
+
'\\rightleftharpoons' : '\U000021cc',
|
| 169 |
+
'\\leadsto' : '\U0000219d',
|
| 170 |
+
'\\downharpoonleft' : '\U000021c3',
|
| 171 |
+
'\\downharpoonright' : '\U000021c2',
|
| 172 |
+
'\\upharpoonleft' : '\U000021bf',
|
| 173 |
+
'\\upharpoonright' : '\U000021be',
|
| 174 |
+
'\\restriction' : '\U000021be',
|
| 175 |
+
'\\uparrow' : '\U00002191',
|
| 176 |
+
'\\Uparrow' : '\U000021d1',
|
| 177 |
+
'\\downarrow' : '\U00002193',
|
| 178 |
+
'\\Downarrow' : '\U000021d3',
|
| 179 |
+
'\\updownarrow' : '\U00002195',
|
| 180 |
+
'\\Updownarrow' : '\U000021d5',
|
| 181 |
+
'\\langle' : '\U000027e8',
|
| 182 |
+
'\\rangle' : '\U000027e9',
|
| 183 |
+
'\\lceil' : '\U00002308',
|
| 184 |
+
'\\rceil' : '\U00002309',
|
| 185 |
+
'\\lfloor' : '\U0000230a',
|
| 186 |
+
'\\rfloor' : '\U0000230b',
|
| 187 |
+
'\\flqq' : '\U000000ab',
|
| 188 |
+
'\\frqq' : '\U000000bb',
|
| 189 |
+
'\\bot' : '\U000022a5',
|
| 190 |
+
'\\top' : '\U000022a4',
|
| 191 |
+
'\\wedge' : '\U00002227',
|
| 192 |
+
'\\bigwedge' : '\U000022c0',
|
| 193 |
+
'\\vee' : '\U00002228',
|
| 194 |
+
'\\bigvee' : '\U000022c1',
|
| 195 |
+
'\\forall' : '\U00002200',
|
| 196 |
+
'\\exists' : '\U00002203',
|
| 197 |
+
'\\nexists' : '\U00002204',
|
| 198 |
+
'\\neg' : '\U000000ac',
|
| 199 |
+
'\\Box' : '\U000025a1',
|
| 200 |
+
'\\Diamond' : '\U000025c7',
|
| 201 |
+
'\\vdash' : '\U000022a2',
|
| 202 |
+
'\\models' : '\U000022a8',
|
| 203 |
+
'\\dashv' : '\U000022a3',
|
| 204 |
+
'\\surd' : '\U0000221a',
|
| 205 |
+
'\\le' : '\U00002264',
|
| 206 |
+
'\\ge' : '\U00002265',
|
| 207 |
+
'\\ll' : '\U0000226a',
|
| 208 |
+
'\\gg' : '\U0000226b',
|
| 209 |
+
'\\lesssim' : '\U00002272',
|
| 210 |
+
'\\gtrsim' : '\U00002273',
|
| 211 |
+
'\\lessapprox' : '\U00002a85',
|
| 212 |
+
'\\gtrapprox' : '\U00002a86',
|
| 213 |
+
'\\in' : '\U00002208',
|
| 214 |
+
'\\notin' : '\U00002209',
|
| 215 |
+
'\\subset' : '\U00002282',
|
| 216 |
+
'\\supset' : '\U00002283',
|
| 217 |
+
'\\subseteq' : '\U00002286',
|
| 218 |
+
'\\supseteq' : '\U00002287',
|
| 219 |
+
'\\sqsubset' : '\U0000228f',
|
| 220 |
+
'\\sqsupset' : '\U00002290',
|
| 221 |
+
'\\sqsubseteq' : '\U00002291',
|
| 222 |
+
'\\sqsupseteq' : '\U00002292',
|
| 223 |
+
'\\cap' : '\U00002229',
|
| 224 |
+
'\\bigcap' : '\U000022c2',
|
| 225 |
+
'\\cup' : '\U0000222a',
|
| 226 |
+
'\\bigcup' : '\U000022c3',
|
| 227 |
+
'\\sqcup' : '\U00002294',
|
| 228 |
+
'\\bigsqcup' : '\U00002a06',
|
| 229 |
+
'\\sqcap' : '\U00002293',
|
| 230 |
+
'\\Bigsqcap' : '\U00002a05',
|
| 231 |
+
'\\setminus' : '\U00002216',
|
| 232 |
+
'\\propto' : '\U0000221d',
|
| 233 |
+
'\\uplus' : '\U0000228e',
|
| 234 |
+
'\\bigplus' : '\U00002a04',
|
| 235 |
+
'\\sim' : '\U0000223c',
|
| 236 |
+
'\\doteq' : '\U00002250',
|
| 237 |
+
'\\simeq' : '\U00002243',
|
| 238 |
+
'\\approx' : '\U00002248',
|
| 239 |
+
'\\asymp' : '\U0000224d',
|
| 240 |
+
'\\cong' : '\U00002245',
|
| 241 |
+
'\\equiv' : '\U00002261',
|
| 242 |
+
'\\Join' : '\U000022c8',
|
| 243 |
+
'\\bowtie' : '\U00002a1d',
|
| 244 |
+
'\\prec' : '\U0000227a',
|
| 245 |
+
'\\succ' : '\U0000227b',
|
| 246 |
+
'\\preceq' : '\U0000227c',
|
| 247 |
+
'\\succeq' : '\U0000227d',
|
| 248 |
+
'\\parallel' : '\U00002225',
|
| 249 |
+
'\\mid' : '\U000000a6',
|
| 250 |
+
'\\pm' : '\U000000b1',
|
| 251 |
+
'\\mp' : '\U00002213',
|
| 252 |
+
'\\times' : '\U000000d7',
|
| 253 |
+
'\\div' : '\U000000f7',
|
| 254 |
+
'\\cdot' : '\U000022c5',
|
| 255 |
+
'\\star' : '\U000022c6',
|
| 256 |
+
'\\circ' : '\U00002218',
|
| 257 |
+
'\\dagger' : '\U00002020',
|
| 258 |
+
'\\ddagger' : '\U00002021',
|
| 259 |
+
'\\lhd' : '\U000022b2',
|
| 260 |
+
'\\rhd' : '\U000022b3',
|
| 261 |
+
'\\unlhd' : '\U000022b4',
|
| 262 |
+
'\\unrhd' : '\U000022b5',
|
| 263 |
+
'\\triangleleft' : '\U000025c3',
|
| 264 |
+
'\\triangleright' : '\U000025b9',
|
| 265 |
+
'\\triangle' : '\U000025b3',
|
| 266 |
+
'\\triangleq' : '\U0000225c',
|
| 267 |
+
'\\oplus' : '\U00002295',
|
| 268 |
+
'\\bigoplus' : '\U00002a01',
|
| 269 |
+
'\\otimes' : '\U00002297',
|
| 270 |
+
'\\bigotimes' : '\U00002a02',
|
| 271 |
+
'\\odot' : '\U00002299',
|
| 272 |
+
'\\bigodot' : '\U00002a00',
|
| 273 |
+
'\\ominus' : '\U00002296',
|
| 274 |
+
'\\oslash' : '\U00002298',
|
| 275 |
+
'\\dots' : '\U00002026',
|
| 276 |
+
'\\cdots' : '\U000022ef',
|
| 277 |
+
'\\sum' : '\U00002211',
|
| 278 |
+
'\\prod' : '\U0000220f',
|
| 279 |
+
'\\coprod' : '\U00002210',
|
| 280 |
+
'\\infty' : '\U0000221e',
|
| 281 |
+
'\\int' : '\U0000222b',
|
| 282 |
+
'\\oint' : '\U0000222e',
|
| 283 |
+
'\\clubsuit' : '\U00002663',
|
| 284 |
+
'\\diamondsuit' : '\U00002662',
|
| 285 |
+
'\\heartsuit' : '\U00002661',
|
| 286 |
+
'\\spadesuit' : '\U00002660',
|
| 287 |
+
'\\aleph' : '\U00002135',
|
| 288 |
+
'\\emptyset' : '\U00002205',
|
| 289 |
+
'\\nabla' : '\U00002207',
|
| 290 |
+
'\\partial' : '\U00002202',
|
| 291 |
+
'\\flat' : '\U0000266d',
|
| 292 |
+
'\\natural' : '\U0000266e',
|
| 293 |
+
'\\sharp' : '\U0000266f',
|
| 294 |
+
'\\angle' : '\U00002220',
|
| 295 |
+
'\\copyright' : '\U000000a9',
|
| 296 |
+
'\\textregistered' : '\U000000ae',
|
| 297 |
+
'\\textonequarter' : '\U000000bc',
|
| 298 |
+
'\\textonehalf' : '\U000000bd',
|
| 299 |
+
'\\textthreequarters' : '\U000000be',
|
| 300 |
+
'\\textordfeminine' : '\U000000aa',
|
| 301 |
+
'\\textordmasculine' : '\U000000ba',
|
| 302 |
+
'\\euro' : '\U000020ac',
|
| 303 |
+
'\\pounds' : '\U000000a3',
|
| 304 |
+
'\\yen' : '\U000000a5',
|
| 305 |
+
'\\textcent' : '\U000000a2',
|
| 306 |
+
'\\textcurrency' : '\U000000a4',
|
| 307 |
+
'\\textdegree' : '\U000000b0',
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
isabelle_symbols = {
|
| 311 |
+
'\\<zero>' : '\U0001d7ec',
|
| 312 |
+
'\\<one>' : '\U0001d7ed',
|
| 313 |
+
'\\<two>' : '\U0001d7ee',
|
| 314 |
+
'\\<three>' : '\U0001d7ef',
|
| 315 |
+
'\\<four>' : '\U0001d7f0',
|
| 316 |
+
'\\<five>' : '\U0001d7f1',
|
| 317 |
+
'\\<six>' : '\U0001d7f2',
|
| 318 |
+
'\\<seven>' : '\U0001d7f3',
|
| 319 |
+
'\\<eight>' : '\U0001d7f4',
|
| 320 |
+
'\\<nine>' : '\U0001d7f5',
|
| 321 |
+
'\\<A>' : '\U0001d49c',
|
| 322 |
+
'\\<B>' : '\U0000212c',
|
| 323 |
+
'\\<C>' : '\U0001d49e',
|
| 324 |
+
'\\<D>' : '\U0001d49f',
|
| 325 |
+
'\\<E>' : '\U00002130',
|
| 326 |
+
'\\<F>' : '\U00002131',
|
| 327 |
+
'\\<G>' : '\U0001d4a2',
|
| 328 |
+
'\\<H>' : '\U0000210b',
|
| 329 |
+
'\\<I>' : '\U00002110',
|
| 330 |
+
'\\<J>' : '\U0001d4a5',
|
| 331 |
+
'\\<K>' : '\U0001d4a6',
|
| 332 |
+
'\\<L>' : '\U00002112',
|
| 333 |
+
'\\<M>' : '\U00002133',
|
| 334 |
+
'\\<N>' : '\U0001d4a9',
|
| 335 |
+
'\\<O>' : '\U0001d4aa',
|
| 336 |
+
'\\<P>' : '\U0001d4ab',
|
| 337 |
+
'\\<Q>' : '\U0001d4ac',
|
| 338 |
+
'\\<R>' : '\U0000211b',
|
| 339 |
+
'\\<S>' : '\U0001d4ae',
|
| 340 |
+
'\\<T>' : '\U0001d4af',
|
| 341 |
+
'\\<U>' : '\U0001d4b0',
|
| 342 |
+
'\\<V>' : '\U0001d4b1',
|
| 343 |
+
'\\<W>' : '\U0001d4b2',
|
| 344 |
+
'\\<X>' : '\U0001d4b3',
|
| 345 |
+
'\\<Y>' : '\U0001d4b4',
|
| 346 |
+
'\\<Z>' : '\U0001d4b5',
|
| 347 |
+
'\\<a>' : '\U0001d5ba',
|
| 348 |
+
'\\<b>' : '\U0001d5bb',
|
| 349 |
+
'\\<c>' : '\U0001d5bc',
|
| 350 |
+
'\\<d>' : '\U0001d5bd',
|
| 351 |
+
'\\<e>' : '\U0001d5be',
|
| 352 |
+
'\\<f>' : '\U0001d5bf',
|
| 353 |
+
'\\<g>' : '\U0001d5c0',
|
| 354 |
+
'\\<h>' : '\U0001d5c1',
|
| 355 |
+
'\\<i>' : '\U0001d5c2',
|
| 356 |
+
'\\<j>' : '\U0001d5c3',
|
| 357 |
+
'\\<k>' : '\U0001d5c4',
|
| 358 |
+
'\\<l>' : '\U0001d5c5',
|
| 359 |
+
'\\<m>' : '\U0001d5c6',
|
| 360 |
+
'\\<n>' : '\U0001d5c7',
|
| 361 |
+
'\\<o>' : '\U0001d5c8',
|
| 362 |
+
'\\<p>' : '\U0001d5c9',
|
| 363 |
+
'\\<q>' : '\U0001d5ca',
|
| 364 |
+
'\\<r>' : '\U0001d5cb',
|
| 365 |
+
'\\<s>' : '\U0001d5cc',
|
| 366 |
+
'\\<t>' : '\U0001d5cd',
|
| 367 |
+
'\\<u>' : '\U0001d5ce',
|
| 368 |
+
'\\<v>' : '\U0001d5cf',
|
| 369 |
+
'\\<w>' : '\U0001d5d0',
|
| 370 |
+
'\\<x>' : '\U0001d5d1',
|
| 371 |
+
'\\<y>' : '\U0001d5d2',
|
| 372 |
+
'\\<z>' : '\U0001d5d3',
|
| 373 |
+
'\\<AA>' : '\U0001d504',
|
| 374 |
+
'\\<BB>' : '\U0001d505',
|
| 375 |
+
'\\<CC>' : '\U0000212d',
|
| 376 |
+
'\\<DD>' : '\U0001d507',
|
| 377 |
+
'\\<EE>' : '\U0001d508',
|
| 378 |
+
'\\<FF>' : '\U0001d509',
|
| 379 |
+
'\\<GG>' : '\U0001d50a',
|
| 380 |
+
'\\<HH>' : '\U0000210c',
|
| 381 |
+
'\\<II>' : '\U00002111',
|
| 382 |
+
'\\<JJ>' : '\U0001d50d',
|
| 383 |
+
'\\<KK>' : '\U0001d50e',
|
| 384 |
+
'\\<LL>' : '\U0001d50f',
|
| 385 |
+
'\\<MM>' : '\U0001d510',
|
| 386 |
+
'\\<NN>' : '\U0001d511',
|
| 387 |
+
'\\<OO>' : '\U0001d512',
|
| 388 |
+
'\\<PP>' : '\U0001d513',
|
| 389 |
+
'\\<QQ>' : '\U0001d514',
|
| 390 |
+
'\\<RR>' : '\U0000211c',
|
| 391 |
+
'\\<SS>' : '\U0001d516',
|
| 392 |
+
'\\<TT>' : '\U0001d517',
|
| 393 |
+
'\\<UU>' : '\U0001d518',
|
| 394 |
+
'\\<VV>' : '\U0001d519',
|
| 395 |
+
'\\<WW>' : '\U0001d51a',
|
| 396 |
+
'\\<XX>' : '\U0001d51b',
|
| 397 |
+
'\\<YY>' : '\U0001d51c',
|
| 398 |
+
'\\<ZZ>' : '\U00002128',
|
| 399 |
+
'\\<aa>' : '\U0001d51e',
|
| 400 |
+
'\\<bb>' : '\U0001d51f',
|
| 401 |
+
'\\<cc>' : '\U0001d520',
|
| 402 |
+
'\\<dd>' : '\U0001d521',
|
| 403 |
+
'\\<ee>' : '\U0001d522',
|
| 404 |
+
'\\<ff>' : '\U0001d523',
|
| 405 |
+
'\\<gg>' : '\U0001d524',
|
| 406 |
+
'\\<hh>' : '\U0001d525',
|
| 407 |
+
'\\<ii>' : '\U0001d526',
|
| 408 |
+
'\\<jj>' : '\U0001d527',
|
| 409 |
+
'\\<kk>' : '\U0001d528',
|
| 410 |
+
'\\<ll>' : '\U0001d529',
|
| 411 |
+
'\\<mm>' : '\U0001d52a',
|
| 412 |
+
'\\<nn>' : '\U0001d52b',
|
| 413 |
+
'\\<oo>' : '\U0001d52c',
|
| 414 |
+
'\\<pp>' : '\U0001d52d',
|
| 415 |
+
'\\<qq>' : '\U0001d52e',
|
| 416 |
+
'\\<rr>' : '\U0001d52f',
|
| 417 |
+
'\\<ss>' : '\U0001d530',
|
| 418 |
+
'\\<tt>' : '\U0001d531',
|
| 419 |
+
'\\<uu>' : '\U0001d532',
|
| 420 |
+
'\\<vv>' : '\U0001d533',
|
| 421 |
+
'\\<ww>' : '\U0001d534',
|
| 422 |
+
'\\<xx>' : '\U0001d535',
|
| 423 |
+
'\\<yy>' : '\U0001d536',
|
| 424 |
+
'\\<zz>' : '\U0001d537',
|
| 425 |
+
'\\<alpha>' : '\U000003b1',
|
| 426 |
+
'\\<beta>' : '\U000003b2',
|
| 427 |
+
'\\<gamma>' : '\U000003b3',
|
| 428 |
+
'\\<delta>' : '\U000003b4',
|
| 429 |
+
'\\<epsilon>' : '\U000003b5',
|
| 430 |
+
'\\<zeta>' : '\U000003b6',
|
| 431 |
+
'\\<eta>' : '\U000003b7',
|
| 432 |
+
'\\<theta>' : '\U000003b8',
|
| 433 |
+
'\\<iota>' : '\U000003b9',
|
| 434 |
+
'\\<kappa>' : '\U000003ba',
|
| 435 |
+
'\\<lambda>' : '\U000003bb',
|
| 436 |
+
'\\<mu>' : '\U000003bc',
|
| 437 |
+
'\\<nu>' : '\U000003bd',
|
| 438 |
+
'\\<xi>' : '\U000003be',
|
| 439 |
+
'\\<pi>' : '\U000003c0',
|
| 440 |
+
'\\<rho>' : '\U000003c1',
|
| 441 |
+
'\\<sigma>' : '\U000003c3',
|
| 442 |
+
'\\<tau>' : '\U000003c4',
|
| 443 |
+
'\\<upsilon>' : '\U000003c5',
|
| 444 |
+
'\\<phi>' : '\U000003c6',
|
| 445 |
+
'\\<chi>' : '\U000003c7',
|
| 446 |
+
'\\<psi>' : '\U000003c8',
|
| 447 |
+
'\\<omega>' : '\U000003c9',
|
| 448 |
+
'\\<Gamma>' : '\U00000393',
|
| 449 |
+
'\\<Delta>' : '\U00000394',
|
| 450 |
+
'\\<Theta>' : '\U00000398',
|
| 451 |
+
'\\<Lambda>' : '\U0000039b',
|
| 452 |
+
'\\<Xi>' : '\U0000039e',
|
| 453 |
+
'\\<Pi>' : '\U000003a0',
|
| 454 |
+
'\\<Sigma>' : '\U000003a3',
|
| 455 |
+
'\\<Upsilon>' : '\U000003a5',
|
| 456 |
+
'\\<Phi>' : '\U000003a6',
|
| 457 |
+
'\\<Psi>' : '\U000003a8',
|
| 458 |
+
'\\<Omega>' : '\U000003a9',
|
| 459 |
+
'\\<bool>' : '\U0001d539',
|
| 460 |
+
'\\<complex>' : '\U00002102',
|
| 461 |
+
'\\<nat>' : '\U00002115',
|
| 462 |
+
'\\<rat>' : '\U0000211a',
|
| 463 |
+
'\\<real>' : '\U0000211d',
|
| 464 |
+
'\\<int>' : '\U00002124',
|
| 465 |
+
'\\<leftarrow>' : '\U00002190',
|
| 466 |
+
'\\<longleftarrow>' : '\U000027f5',
|
| 467 |
+
'\\<rightarrow>' : '\U00002192',
|
| 468 |
+
'\\<longrightarrow>' : '\U000027f6',
|
| 469 |
+
'\\<Leftarrow>' : '\U000021d0',
|
| 470 |
+
'\\<Longleftarrow>' : '\U000027f8',
|
| 471 |
+
'\\<Rightarrow>' : '\U000021d2',
|
| 472 |
+
'\\<Longrightarrow>' : '\U000027f9',
|
| 473 |
+
'\\<leftrightarrow>' : '\U00002194',
|
| 474 |
+
'\\<longleftrightarrow>' : '\U000027f7',
|
| 475 |
+
'\\<Leftrightarrow>' : '\U000021d4',
|
| 476 |
+
'\\<Longleftrightarrow>' : '\U000027fa',
|
| 477 |
+
'\\<mapsto>' : '\U000021a6',
|
| 478 |
+
'\\<longmapsto>' : '\U000027fc',
|
| 479 |
+
'\\<midarrow>' : '\U00002500',
|
| 480 |
+
'\\<Midarrow>' : '\U00002550',
|
| 481 |
+
'\\<hookleftarrow>' : '\U000021a9',
|
| 482 |
+
'\\<hookrightarrow>' : '\U000021aa',
|
| 483 |
+
'\\<leftharpoondown>' : '\U000021bd',
|
| 484 |
+
'\\<rightharpoondown>' : '\U000021c1',
|
| 485 |
+
'\\<leftharpoonup>' : '\U000021bc',
|
| 486 |
+
'\\<rightharpoonup>' : '\U000021c0',
|
| 487 |
+
'\\<rightleftharpoons>' : '\U000021cc',
|
| 488 |
+
'\\<leadsto>' : '\U0000219d',
|
| 489 |
+
'\\<downharpoonleft>' : '\U000021c3',
|
| 490 |
+
'\\<downharpoonright>' : '\U000021c2',
|
| 491 |
+
'\\<upharpoonleft>' : '\U000021bf',
|
| 492 |
+
'\\<upharpoonright>' : '\U000021be',
|
| 493 |
+
'\\<restriction>' : '\U000021be',
|
| 494 |
+
'\\<Colon>' : '\U00002237',
|
| 495 |
+
'\\<up>' : '\U00002191',
|
| 496 |
+
'\\<Up>' : '\U000021d1',
|
| 497 |
+
'\\<down>' : '\U00002193',
|
| 498 |
+
'\\<Down>' : '\U000021d3',
|
| 499 |
+
'\\<updown>' : '\U00002195',
|
| 500 |
+
'\\<Updown>' : '\U000021d5',
|
| 501 |
+
'\\<langle>' : '\U000027e8',
|
| 502 |
+
'\\<rangle>' : '\U000027e9',
|
| 503 |
+
'\\<lceil>' : '\U00002308',
|
| 504 |
+
'\\<rceil>' : '\U00002309',
|
| 505 |
+
'\\<lfloor>' : '\U0000230a',
|
| 506 |
+
'\\<rfloor>' : '\U0000230b',
|
| 507 |
+
'\\<lparr>' : '\U00002987',
|
| 508 |
+
'\\<rparr>' : '\U00002988',
|
| 509 |
+
'\\<lbrakk>' : '\U000027e6',
|
| 510 |
+
'\\<rbrakk>' : '\U000027e7',
|
| 511 |
+
'\\<lbrace>' : '\U00002983',
|
| 512 |
+
'\\<rbrace>' : '\U00002984',
|
| 513 |
+
'\\<guillemotleft>' : '\U000000ab',
|
| 514 |
+
'\\<guillemotright>' : '\U000000bb',
|
| 515 |
+
'\\<bottom>' : '\U000022a5',
|
| 516 |
+
'\\<top>' : '\U000022a4',
|
| 517 |
+
'\\<and>' : '\U00002227',
|
| 518 |
+
'\\<And>' : '\U000022c0',
|
| 519 |
+
'\\<or>' : '\U00002228',
|
| 520 |
+
'\\<Or>' : '\U000022c1',
|
| 521 |
+
'\\<forall>' : '\U00002200',
|
| 522 |
+
'\\<exists>' : '\U00002203',
|
| 523 |
+
'\\<nexists>' : '\U00002204',
|
| 524 |
+
'\\<not>' : '\U000000ac',
|
| 525 |
+
'\\<box>' : '\U000025a1',
|
| 526 |
+
'\\<diamond>' : '\U000025c7',
|
| 527 |
+
'\\<turnstile>' : '\U000022a2',
|
| 528 |
+
'\\<Turnstile>' : '\U000022a8',
|
| 529 |
+
'\\<tturnstile>' : '\U000022a9',
|
| 530 |
+
'\\<TTurnstile>' : '\U000022ab',
|
| 531 |
+
'\\<stileturn>' : '\U000022a3',
|
| 532 |
+
'\\<surd>' : '\U0000221a',
|
| 533 |
+
'\\<le>' : '\U00002264',
|
| 534 |
+
'\\<ge>' : '\U00002265',
|
| 535 |
+
'\\<lless>' : '\U0000226a',
|
| 536 |
+
'\\<ggreater>' : '\U0000226b',
|
| 537 |
+
'\\<lesssim>' : '\U00002272',
|
| 538 |
+
'\\<greatersim>' : '\U00002273',
|
| 539 |
+
'\\<lessapprox>' : '\U00002a85',
|
| 540 |
+
'\\<greaterapprox>' : '\U00002a86',
|
| 541 |
+
'\\<in>' : '\U00002208',
|
| 542 |
+
'\\<notin>' : '\U00002209',
|
| 543 |
+
'\\<subset>' : '\U00002282',
|
| 544 |
+
'\\<supset>' : '\U00002283',
|
| 545 |
+
'\\<subseteq>' : '\U00002286',
|
| 546 |
+
'\\<supseteq>' : '\U00002287',
|
| 547 |
+
'\\<sqsubset>' : '\U0000228f',
|
| 548 |
+
'\\<sqsupset>' : '\U00002290',
|
| 549 |
+
'\\<sqsubseteq>' : '\U00002291',
|
| 550 |
+
'\\<sqsupseteq>' : '\U00002292',
|
| 551 |
+
'\\<inter>' : '\U00002229',
|
| 552 |
+
'\\<Inter>' : '\U000022c2',
|
| 553 |
+
'\\<union>' : '\U0000222a',
|
| 554 |
+
'\\<Union>' : '\U000022c3',
|
| 555 |
+
'\\<squnion>' : '\U00002294',
|
| 556 |
+
'\\<Squnion>' : '\U00002a06',
|
| 557 |
+
'\\<sqinter>' : '\U00002293',
|
| 558 |
+
'\\<Sqinter>' : '\U00002a05',
|
| 559 |
+
'\\<setminus>' : '\U00002216',
|
| 560 |
+
'\\<propto>' : '\U0000221d',
|
| 561 |
+
'\\<uplus>' : '\U0000228e',
|
| 562 |
+
'\\<Uplus>' : '\U00002a04',
|
| 563 |
+
'\\<noteq>' : '\U00002260',
|
| 564 |
+
'\\<sim>' : '\U0000223c',
|
| 565 |
+
'\\<doteq>' : '\U00002250',
|
| 566 |
+
'\\<simeq>' : '\U00002243',
|
| 567 |
+
'\\<approx>' : '\U00002248',
|
| 568 |
+
'\\<asymp>' : '\U0000224d',
|
| 569 |
+
'\\<cong>' : '\U00002245',
|
| 570 |
+
'\\<smile>' : '\U00002323',
|
| 571 |
+
'\\<equiv>' : '\U00002261',
|
| 572 |
+
'\\<frown>' : '\U00002322',
|
| 573 |
+
'\\<Join>' : '\U000022c8',
|
| 574 |
+
'\\<bowtie>' : '\U00002a1d',
|
| 575 |
+
'\\<prec>' : '\U0000227a',
|
| 576 |
+
'\\<succ>' : '\U0000227b',
|
| 577 |
+
'\\<preceq>' : '\U0000227c',
|
| 578 |
+
'\\<succeq>' : '\U0000227d',
|
| 579 |
+
'\\<parallel>' : '\U00002225',
|
| 580 |
+
'\\<bar>' : '\U000000a6',
|
| 581 |
+
'\\<plusminus>' : '\U000000b1',
|
| 582 |
+
'\\<minusplus>' : '\U00002213',
|
| 583 |
+
'\\<times>' : '\U000000d7',
|
| 584 |
+
'\\<div>' : '\U000000f7',
|
| 585 |
+
'\\<cdot>' : '\U000022c5',
|
| 586 |
+
'\\<star>' : '\U000022c6',
|
| 587 |
+
'\\<bullet>' : '\U00002219',
|
| 588 |
+
'\\<circ>' : '\U00002218',
|
| 589 |
+
'\\<dagger>' : '\U00002020',
|
| 590 |
+
'\\<ddagger>' : '\U00002021',
|
| 591 |
+
'\\<lhd>' : '\U000022b2',
|
| 592 |
+
'\\<rhd>' : '\U000022b3',
|
| 593 |
+
'\\<unlhd>' : '\U000022b4',
|
| 594 |
+
'\\<unrhd>' : '\U000022b5',
|
| 595 |
+
'\\<triangleleft>' : '\U000025c3',
|
| 596 |
+
'\\<triangleright>' : '\U000025b9',
|
| 597 |
+
'\\<triangle>' : '\U000025b3',
|
| 598 |
+
'\\<triangleq>' : '\U0000225c',
|
| 599 |
+
'\\<oplus>' : '\U00002295',
|
| 600 |
+
'\\<Oplus>' : '\U00002a01',
|
| 601 |
+
'\\<otimes>' : '\U00002297',
|
| 602 |
+
'\\<Otimes>' : '\U00002a02',
|
| 603 |
+
'\\<odot>' : '\U00002299',
|
| 604 |
+
'\\<Odot>' : '\U00002a00',
|
| 605 |
+
'\\<ominus>' : '\U00002296',
|
| 606 |
+
'\\<oslash>' : '\U00002298',
|
| 607 |
+
'\\<dots>' : '\U00002026',
|
| 608 |
+
'\\<cdots>' : '\U000022ef',
|
| 609 |
+
'\\<Sum>' : '\U00002211',
|
| 610 |
+
'\\<Prod>' : '\U0000220f',
|
| 611 |
+
'\\<Coprod>' : '\U00002210',
|
| 612 |
+
'\\<infinity>' : '\U0000221e',
|
| 613 |
+
'\\<integral>' : '\U0000222b',
|
| 614 |
+
'\\<ointegral>' : '\U0000222e',
|
| 615 |
+
'\\<clubsuit>' : '\U00002663',
|
| 616 |
+
'\\<diamondsuit>' : '\U00002662',
|
| 617 |
+
'\\<heartsuit>' : '\U00002661',
|
| 618 |
+
'\\<spadesuit>' : '\U00002660',
|
| 619 |
+
'\\<aleph>' : '\U00002135',
|
| 620 |
+
'\\<emptyset>' : '\U00002205',
|
| 621 |
+
'\\<nabla>' : '\U00002207',
|
| 622 |
+
'\\<partial>' : '\U00002202',
|
| 623 |
+
'\\<flat>' : '\U0000266d',
|
| 624 |
+
'\\<natural>' : '\U0000266e',
|
| 625 |
+
'\\<sharp>' : '\U0000266f',
|
| 626 |
+
'\\<angle>' : '\U00002220',
|
| 627 |
+
'\\<copyright>' : '\U000000a9',
|
| 628 |
+
'\\<registered>' : '\U000000ae',
|
| 629 |
+
'\\<hyphen>' : '\U000000ad',
|
| 630 |
+
'\\<inverse>' : '\U000000af',
|
| 631 |
+
'\\<onequarter>' : '\U000000bc',
|
| 632 |
+
'\\<onehalf>' : '\U000000bd',
|
| 633 |
+
'\\<threequarters>' : '\U000000be',
|
| 634 |
+
'\\<ordfeminine>' : '\U000000aa',
|
| 635 |
+
'\\<ordmasculine>' : '\U000000ba',
|
| 636 |
+
'\\<section>' : '\U000000a7',
|
| 637 |
+
'\\<paragraph>' : '\U000000b6',
|
| 638 |
+
'\\<exclamdown>' : '\U000000a1',
|
| 639 |
+
'\\<questiondown>' : '\U000000bf',
|
| 640 |
+
'\\<euro>' : '\U000020ac',
|
| 641 |
+
'\\<pounds>' : '\U000000a3',
|
| 642 |
+
'\\<yen>' : '\U000000a5',
|
| 643 |
+
'\\<cent>' : '\U000000a2',
|
| 644 |
+
'\\<currency>' : '\U000000a4',
|
| 645 |
+
'\\<degree>' : '\U000000b0',
|
| 646 |
+
'\\<amalg>' : '\U00002a3f',
|
| 647 |
+
'\\<mho>' : '\U00002127',
|
| 648 |
+
'\\<lozenge>' : '\U000025ca',
|
| 649 |
+
'\\<wp>' : '\U00002118',
|
| 650 |
+
'\\<wrong>' : '\U00002240',
|
| 651 |
+
'\\<struct>' : '\U000022c4',
|
| 652 |
+
'\\<acute>' : '\U000000b4',
|
| 653 |
+
'\\<index>' : '\U00000131',
|
| 654 |
+
'\\<dieresis>' : '\U000000a8',
|
| 655 |
+
'\\<cedilla>' : '\U000000b8',
|
| 656 |
+
'\\<hungarumlaut>' : '\U000002dd',
|
| 657 |
+
'\\<some>' : '\U000003f5',
|
| 658 |
+
'\\<newline>' : '\U000023ce',
|
| 659 |
+
'\\<open>' : '\U00002039',
|
| 660 |
+
'\\<close>' : '\U0000203a',
|
| 661 |
+
'\\<here>' : '\U00002302',
|
| 662 |
+
'\\<^sub>' : '\U000021e9',
|
| 663 |
+
'\\<^sup>' : '\U000021e7',
|
| 664 |
+
'\\<^bold>' : '\U00002759',
|
| 665 |
+
'\\<^bsub>' : '\U000021d8',
|
| 666 |
+
'\\<^esub>' : '\U000021d9',
|
| 667 |
+
'\\<^bsup>' : '\U000021d7',
|
| 668 |
+
'\\<^esup>' : '\U000021d6',
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
lang_map = {'isabelle' : isabelle_symbols, 'latex' : latex_symbols}
|
| 672 |
+
|
| 673 |
+
def __init__(self, **options):
|
| 674 |
+
Filter.__init__(self, **options)
|
| 675 |
+
lang = get_choice_opt(options, 'lang',
|
| 676 |
+
['isabelle', 'latex'], 'isabelle')
|
| 677 |
+
self.symbols = self.lang_map[lang]
|
| 678 |
+
|
| 679 |
+
def filter(self, lexer, stream):
|
| 680 |
+
for ttype, value in stream:
|
| 681 |
+
if value in self.symbols:
|
| 682 |
+
yield ttype, self.symbols[value]
|
| 683 |
+
else:
|
| 684 |
+
yield ttype, value
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
class KeywordCaseFilter(Filter):
|
| 688 |
+
"""Convert keywords to lowercase or uppercase or capitalize them, which
|
| 689 |
+
means first letter uppercase, rest lowercase.
|
| 690 |
+
|
| 691 |
+
This can be useful e.g. if you highlight Pascal code and want to adapt the
|
| 692 |
+
code to your styleguide.
|
| 693 |
+
|
| 694 |
+
Options accepted:
|
| 695 |
+
|
| 696 |
+
`case` : string
|
| 697 |
+
The casing to convert keywords to. Must be one of ``'lower'``,
|
| 698 |
+
``'upper'`` or ``'capitalize'``. The default is ``'lower'``.
|
| 699 |
+
"""
|
| 700 |
+
|
| 701 |
+
def __init__(self, **options):
|
| 702 |
+
Filter.__init__(self, **options)
|
| 703 |
+
case = get_choice_opt(options, 'case',
|
| 704 |
+
['lower', 'upper', 'capitalize'], 'lower')
|
| 705 |
+
self.convert = getattr(str, case)
|
| 706 |
+
|
| 707 |
+
def filter(self, lexer, stream):
|
| 708 |
+
for ttype, value in stream:
|
| 709 |
+
if ttype in Keyword:
|
| 710 |
+
yield ttype, self.convert(value)
|
| 711 |
+
else:
|
| 712 |
+
yield ttype, value
|
| 713 |
+
|
| 714 |
+
|
| 715 |
+
class NameHighlightFilter(Filter):
|
| 716 |
+
"""Highlight a normal Name (and Name.*) token with a different token type.
|
| 717 |
+
|
| 718 |
+
Example::
|
| 719 |
+
|
| 720 |
+
filter = NameHighlightFilter(
|
| 721 |
+
names=['foo', 'bar', 'baz'],
|
| 722 |
+
tokentype=Name.Function,
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
This would highlight the names "foo", "bar" and "baz"
|
| 726 |
+
as functions. `Name.Function` is the default token type.
|
| 727 |
+
|
| 728 |
+
Options accepted:
|
| 729 |
+
|
| 730 |
+
`names` : list of strings
|
| 731 |
+
A list of names that should be given the different token type.
|
| 732 |
+
There is no default.
|
| 733 |
+
`tokentype` : TokenType or string
|
| 734 |
+
A token type or a string containing a token type name that is
|
| 735 |
+
used for highlighting the strings in `names`. The default is
|
| 736 |
+
`Name.Function`.
|
| 737 |
+
"""
|
| 738 |
+
|
| 739 |
+
def __init__(self, **options):
|
| 740 |
+
Filter.__init__(self, **options)
|
| 741 |
+
self.names = set(get_list_opt(options, 'names', []))
|
| 742 |
+
tokentype = options.get('tokentype')
|
| 743 |
+
if tokentype:
|
| 744 |
+
self.tokentype = string_to_tokentype(tokentype)
|
| 745 |
+
else:
|
| 746 |
+
self.tokentype = Name.Function
|
| 747 |
+
|
| 748 |
+
def filter(self, lexer, stream):
|
| 749 |
+
for ttype, value in stream:
|
| 750 |
+
if ttype in Name and value in self.names:
|
| 751 |
+
yield self.tokentype, value
|
| 752 |
+
else:
|
| 753 |
+
yield ttype, value
|
| 754 |
+
|
| 755 |
+
|
| 756 |
+
class ErrorToken(Exception):
|
| 757 |
+
pass
|
| 758 |
+
|
| 759 |
+
|
| 760 |
+
class RaiseOnErrorTokenFilter(Filter):
|
| 761 |
+
"""Raise an exception when the lexer generates an error token.
|
| 762 |
+
|
| 763 |
+
Options accepted:
|
| 764 |
+
|
| 765 |
+
`excclass` : Exception class
|
| 766 |
+
The exception class to raise.
|
| 767 |
+
The default is `pygments.filters.ErrorToken`.
|
| 768 |
+
|
| 769 |
+
.. versionadded:: 0.8
|
| 770 |
+
"""
|
| 771 |
+
|
| 772 |
+
def __init__(self, **options):
|
| 773 |
+
Filter.__init__(self, **options)
|
| 774 |
+
self.exception = options.get('excclass', ErrorToken)
|
| 775 |
+
try:
|
| 776 |
+
# issubclass() will raise TypeError if first argument is not a class
|
| 777 |
+
if not issubclass(self.exception, Exception):
|
| 778 |
+
raise TypeError
|
| 779 |
+
except TypeError:
|
| 780 |
+
raise OptionError('excclass option is not an exception class')
|
| 781 |
+
|
| 782 |
+
def filter(self, lexer, stream):
|
| 783 |
+
for ttype, value in stream:
|
| 784 |
+
if ttype is Error:
|
| 785 |
+
raise self.exception(value)
|
| 786 |
+
yield ttype, value
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
class VisibleWhitespaceFilter(Filter):
|
| 790 |
+
"""Convert tabs, newlines and/or spaces to visible characters.
|
| 791 |
+
|
| 792 |
+
Options accepted:
|
| 793 |
+
|
| 794 |
+
`spaces` : string or bool
|
| 795 |
+
If this is a one-character string, spaces will be replaces by this string.
|
| 796 |
+
If it is another true value, spaces will be replaced by ``·`` (unicode
|
| 797 |
+
MIDDLE DOT). If it is a false value, spaces will not be replaced. The
|
| 798 |
+
default is ``False``.
|
| 799 |
+
`tabs` : string or bool
|
| 800 |
+
The same as for `spaces`, but the default replacement character is ``»``
|
| 801 |
+
(unicode RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK). The default value
|
| 802 |
+
is ``False``. Note: this will not work if the `tabsize` option for the
|
| 803 |
+
lexer is nonzero, as tabs will already have been expanded then.
|
| 804 |
+
`tabsize` : int
|
| 805 |
+
If tabs are to be replaced by this filter (see the `tabs` option), this
|
| 806 |
+
is the total number of characters that a tab should be expanded to.
|
| 807 |
+
The default is ``8``.
|
| 808 |
+
`newlines` : string or bool
|
| 809 |
+
The same as for `spaces`, but the default replacement character is ``¶``
|
| 810 |
+
(unicode PILCROW SIGN). The default value is ``False``.
|
| 811 |
+
`wstokentype` : bool
|
| 812 |
+
If true, give whitespace the special `Whitespace` token type. This allows
|
| 813 |
+
styling the visible whitespace differently (e.g. greyed out), but it can
|
| 814 |
+
disrupt background colors. The default is ``True``.
|
| 815 |
+
|
| 816 |
+
.. versionadded:: 0.8
|
| 817 |
+
"""
|
| 818 |
+
|
| 819 |
+
def __init__(self, **options):
|
| 820 |
+
Filter.__init__(self, **options)
|
| 821 |
+
for name, default in [('spaces', '·'),
|
| 822 |
+
('tabs', '»'),
|
| 823 |
+
('newlines', '¶')]:
|
| 824 |
+
opt = options.get(name, False)
|
| 825 |
+
if isinstance(opt, str) and len(opt) == 1:
|
| 826 |
+
setattr(self, name, opt)
|
| 827 |
+
else:
|
| 828 |
+
setattr(self, name, (opt and default or ''))
|
| 829 |
+
tabsize = get_int_opt(options, 'tabsize', 8)
|
| 830 |
+
if self.tabs:
|
| 831 |
+
self.tabs += ' ' * (tabsize - 1)
|
| 832 |
+
if self.newlines:
|
| 833 |
+
self.newlines += '\n'
|
| 834 |
+
self.wstt = get_bool_opt(options, 'wstokentype', True)
|
| 835 |
+
|
| 836 |
+
def filter(self, lexer, stream):
|
| 837 |
+
if self.wstt:
|
| 838 |
+
spaces = self.spaces or ' '
|
| 839 |
+
tabs = self.tabs or '\t'
|
| 840 |
+
newlines = self.newlines or '\n'
|
| 841 |
+
regex = re.compile(r'\s')
|
| 842 |
+
|
| 843 |
+
def replacefunc(wschar):
|
| 844 |
+
if wschar == ' ':
|
| 845 |
+
return spaces
|
| 846 |
+
elif wschar == '\t':
|
| 847 |
+
return tabs
|
| 848 |
+
elif wschar == '\n':
|
| 849 |
+
return newlines
|
| 850 |
+
return wschar
|
| 851 |
+
|
| 852 |
+
for ttype, value in stream:
|
| 853 |
+
yield from _replace_special(ttype, value, regex, Whitespace,
|
| 854 |
+
replacefunc)
|
| 855 |
+
else:
|
| 856 |
+
spaces, tabs, newlines = self.spaces, self.tabs, self.newlines
|
| 857 |
+
# simpler processing
|
| 858 |
+
for ttype, value in stream:
|
| 859 |
+
if spaces:
|
| 860 |
+
value = value.replace(' ', spaces)
|
| 861 |
+
if tabs:
|
| 862 |
+
value = value.replace('\t', tabs)
|
| 863 |
+
if newlines:
|
| 864 |
+
value = value.replace('\n', newlines)
|
| 865 |
+
yield ttype, value
|
| 866 |
+
|
| 867 |
+
|
| 868 |
+
class GobbleFilter(Filter):
|
| 869 |
+
"""Gobbles source code lines (eats initial characters).
|
| 870 |
+
|
| 871 |
+
This filter drops the first ``n`` characters off every line of code. This
|
| 872 |
+
may be useful when the source code fed to the lexer is indented by a fixed
|
| 873 |
+
amount of space that isn't desired in the output.
|
| 874 |
+
|
| 875 |
+
Options accepted:
|
| 876 |
+
|
| 877 |
+
`n` : int
|
| 878 |
+
The number of characters to gobble.
|
| 879 |
+
|
| 880 |
+
.. versionadded:: 1.2
|
| 881 |
+
"""
|
| 882 |
+
def __init__(self, **options):
|
| 883 |
+
Filter.__init__(self, **options)
|
| 884 |
+
self.n = get_int_opt(options, 'n', 0)
|
| 885 |
+
|
| 886 |
+
def gobble(self, value, left):
|
| 887 |
+
if left < len(value):
|
| 888 |
+
return value[left:], 0
|
| 889 |
+
else:
|
| 890 |
+
return '', left - len(value)
|
| 891 |
+
|
| 892 |
+
def filter(self, lexer, stream):
|
| 893 |
+
n = self.n
|
| 894 |
+
left = n # How many characters left to gobble.
|
| 895 |
+
for ttype, value in stream:
|
| 896 |
+
# Remove ``left`` tokens from first line, ``n`` from all others.
|
| 897 |
+
parts = value.split('\n')
|
| 898 |
+
(parts[0], left) = self.gobble(parts[0], left)
|
| 899 |
+
for i in range(1, len(parts)):
|
| 900 |
+
(parts[i], left) = self.gobble(parts[i], n)
|
| 901 |
+
value = '\n'.join(parts)
|
| 902 |
+
|
| 903 |
+
if value != '':
|
| 904 |
+
yield ttype, value
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
class TokenMergeFilter(Filter):
|
| 908 |
+
"""Merges consecutive tokens with the same token type in the output
|
| 909 |
+
stream of a lexer.
|
| 910 |
+
|
| 911 |
+
.. versionadded:: 1.2
|
| 912 |
+
"""
|
| 913 |
+
def __init__(self, **options):
|
| 914 |
+
Filter.__init__(self, **options)
|
| 915 |
+
|
| 916 |
+
def filter(self, lexer, stream):
|
| 917 |
+
current_type = None
|
| 918 |
+
current_value = None
|
| 919 |
+
for ttype, value in stream:
|
| 920 |
+
if ttype is current_type:
|
| 921 |
+
current_value += value
|
| 922 |
+
else:
|
| 923 |
+
if current_type is not None:
|
| 924 |
+
yield current_type, current_value
|
| 925 |
+
current_type = ttype
|
| 926 |
+
current_value = value
|
| 927 |
+
if current_type is not None:
|
| 928 |
+
yield current_type, current_value
|
| 929 |
+
|
| 930 |
+
|
| 931 |
+
FILTERS = {
|
| 932 |
+
'codetagify': CodeTagFilter,
|
| 933 |
+
'keywordcase': KeywordCaseFilter,
|
| 934 |
+
'highlight': NameHighlightFilter,
|
| 935 |
+
'raiseonerror': RaiseOnErrorTokenFilter,
|
| 936 |
+
'whitespace': VisibleWhitespaceFilter,
|
| 937 |
+
'gobble': GobbleFilter,
|
| 938 |
+
'tokenmerge': TokenMergeFilter,
|
| 939 |
+
'symbols': SymbolFilter,
|
| 940 |
+
}
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/filters/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (40.2 kB). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/formatters/rtf.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 1 |
+
"""
|
| 2 |
+
pygments.formatters.rtf
|
| 3 |
+
~~~~~~~~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
A formatter that generates RTF files.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from collections import OrderedDict
|
| 12 |
+
from pip._vendor.pygments.formatter import Formatter
|
| 13 |
+
from pip._vendor.pygments.style import _ansimap
|
| 14 |
+
from pip._vendor.pygments.util import get_bool_opt, get_int_opt, get_list_opt, surrogatepair
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
__all__ = ['RtfFormatter']
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class RtfFormatter(Formatter):
|
| 21 |
+
"""
|
| 22 |
+
Format tokens as RTF markup. This formatter automatically outputs full RTF
|
| 23 |
+
documents with color information and other useful stuff. Perfect for Copy and
|
| 24 |
+
Paste into Microsoft(R) Word(R) documents.
|
| 25 |
+
|
| 26 |
+
Please note that ``encoding`` and ``outencoding`` options are ignored.
|
| 27 |
+
The RTF format is ASCII natively, but handles unicode characters correctly
|
| 28 |
+
thanks to escape sequences.
|
| 29 |
+
|
| 30 |
+
.. versionadded:: 0.6
|
| 31 |
+
|
| 32 |
+
Additional options accepted:
|
| 33 |
+
|
| 34 |
+
`style`
|
| 35 |
+
The style to use, can be a string or a Style subclass (default:
|
| 36 |
+
``'default'``).
|
| 37 |
+
|
| 38 |
+
`fontface`
|
| 39 |
+
The used font family, for example ``Bitstream Vera Sans``. Defaults to
|
| 40 |
+
some generic font which is supposed to have fixed width.
|
| 41 |
+
|
| 42 |
+
`fontsize`
|
| 43 |
+
Size of the font used. Size is specified in half points. The
|
| 44 |
+
default is 24 half-points, giving a size 12 font.
|
| 45 |
+
|
| 46 |
+
.. versionadded:: 2.0
|
| 47 |
+
|
| 48 |
+
`linenos`
|
| 49 |
+
Turn on line numbering (default: ``False``).
|
| 50 |
+
|
| 51 |
+
.. versionadded:: 2.18
|
| 52 |
+
|
| 53 |
+
`lineno_fontsize`
|
| 54 |
+
Font size for line numbers. Size is specified in half points
|
| 55 |
+
(default: `fontsize`).
|
| 56 |
+
|
| 57 |
+
.. versionadded:: 2.18
|
| 58 |
+
|
| 59 |
+
`lineno_padding`
|
| 60 |
+
Number of spaces between the (inline) line numbers and the
|
| 61 |
+
source code (default: ``2``).
|
| 62 |
+
|
| 63 |
+
.. versionadded:: 2.18
|
| 64 |
+
|
| 65 |
+
`linenostart`
|
| 66 |
+
The line number for the first line (default: ``1``).
|
| 67 |
+
|
| 68 |
+
.. versionadded:: 2.18
|
| 69 |
+
|
| 70 |
+
`linenostep`
|
| 71 |
+
If set to a number n > 1, only every nth line number is printed.
|
| 72 |
+
|
| 73 |
+
.. versionadded:: 2.18
|
| 74 |
+
|
| 75 |
+
`lineno_color`
|
| 76 |
+
Color for line numbers specified as a hex triplet, e.g. ``'5e5e5e'``.
|
| 77 |
+
Defaults to the style's line number color if it is a hex triplet,
|
| 78 |
+
otherwise ansi bright black.
|
| 79 |
+
|
| 80 |
+
.. versionadded:: 2.18
|
| 81 |
+
|
| 82 |
+
`hl_lines`
|
| 83 |
+
Specify a list of lines to be highlighted, as line numbers separated by
|
| 84 |
+
spaces, e.g. ``'3 7 8'``. The line numbers are relative to the input
|
| 85 |
+
(i.e. the first line is line 1) unless `hl_linenostart` is set.
|
| 86 |
+
|
| 87 |
+
.. versionadded:: 2.18
|
| 88 |
+
|
| 89 |
+
`hl_color`
|
| 90 |
+
Color for highlighting the lines specified in `hl_lines`, specified as
|
| 91 |
+
a hex triplet (default: style's `highlight_color`).
|
| 92 |
+
|
| 93 |
+
.. versionadded:: 2.18
|
| 94 |
+
|
| 95 |
+
`hl_linenostart`
|
| 96 |
+
If set to ``True`` line numbers in `hl_lines` are specified
|
| 97 |
+
relative to `linenostart` (default ``False``).
|
| 98 |
+
|
| 99 |
+
.. versionadded:: 2.18
|
| 100 |
+
"""
|
| 101 |
+
name = 'RTF'
|
| 102 |
+
aliases = ['rtf']
|
| 103 |
+
filenames = ['*.rtf']
|
| 104 |
+
|
| 105 |
+
def __init__(self, **options):
|
| 106 |
+
r"""
|
| 107 |
+
Additional options accepted:
|
| 108 |
+
|
| 109 |
+
``fontface``
|
| 110 |
+
Name of the font used. Could for example be ``'Courier New'``
|
| 111 |
+
to further specify the default which is ``'\fmodern'``. The RTF
|
| 112 |
+
specification claims that ``\fmodern`` are "Fixed-pitch serif
|
| 113 |
+
and sans serif fonts". Hope every RTF implementation thinks
|
| 114 |
+
the same about modern...
|
| 115 |
+
|
| 116 |
+
"""
|
| 117 |
+
Formatter.__init__(self, **options)
|
| 118 |
+
self.fontface = options.get('fontface') or ''
|
| 119 |
+
self.fontsize = get_int_opt(options, 'fontsize', 0)
|
| 120 |
+
self.linenos = get_bool_opt(options, 'linenos', False)
|
| 121 |
+
self.lineno_fontsize = get_int_opt(options, 'lineno_fontsize',
|
| 122 |
+
self.fontsize)
|
| 123 |
+
self.lineno_padding = get_int_opt(options, 'lineno_padding', 2)
|
| 124 |
+
self.linenostart = abs(get_int_opt(options, 'linenostart', 1))
|
| 125 |
+
self.linenostep = abs(get_int_opt(options, 'linenostep', 1))
|
| 126 |
+
self.hl_linenostart = get_bool_opt(options, 'hl_linenostart', False)
|
| 127 |
+
|
| 128 |
+
self.hl_color = options.get('hl_color', '')
|
| 129 |
+
if not self.hl_color:
|
| 130 |
+
self.hl_color = self.style.highlight_color
|
| 131 |
+
|
| 132 |
+
self.hl_lines = []
|
| 133 |
+
for lineno in get_list_opt(options, 'hl_lines', []):
|
| 134 |
+
try:
|
| 135 |
+
lineno = int(lineno)
|
| 136 |
+
if self.hl_linenostart:
|
| 137 |
+
lineno = lineno - self.linenostart + 1
|
| 138 |
+
self.hl_lines.append(lineno)
|
| 139 |
+
except ValueError:
|
| 140 |
+
pass
|
| 141 |
+
|
| 142 |
+
self.lineno_color = options.get('lineno_color', '')
|
| 143 |
+
if not self.lineno_color:
|
| 144 |
+
if self.style.line_number_color == 'inherit':
|
| 145 |
+
# style color is the css value 'inherit'
|
| 146 |
+
# default to ansi bright-black
|
| 147 |
+
self.lineno_color = _ansimap['ansibrightblack']
|
| 148 |
+
else:
|
| 149 |
+
# style color is assumed to be a hex triplet as other
|
| 150 |
+
# colors in pygments/style.py
|
| 151 |
+
self.lineno_color = self.style.line_number_color
|
| 152 |
+
|
| 153 |
+
self.color_mapping = self._create_color_mapping()
|
| 154 |
+
|
| 155 |
+
def _escape(self, text):
|
| 156 |
+
return text.replace('\\', '\\\\') \
|
| 157 |
+
.replace('{', '\\{') \
|
| 158 |
+
.replace('}', '\\}')
|
| 159 |
+
|
| 160 |
+
def _escape_text(self, text):
|
| 161 |
+
# empty strings, should give a small performance improvement
|
| 162 |
+
if not text:
|
| 163 |
+
return ''
|
| 164 |
+
|
| 165 |
+
# escape text
|
| 166 |
+
text = self._escape(text)
|
| 167 |
+
|
| 168 |
+
buf = []
|
| 169 |
+
for c in text:
|
| 170 |
+
cn = ord(c)
|
| 171 |
+
if cn < (2**7):
|
| 172 |
+
# ASCII character
|
| 173 |
+
buf.append(str(c))
|
| 174 |
+
elif (2**7) <= cn < (2**16):
|
| 175 |
+
# single unicode escape sequence
|
| 176 |
+
buf.append('{\\u%d}' % cn)
|
| 177 |
+
elif (2**16) <= cn:
|
| 178 |
+
# RTF limits unicode to 16 bits.
|
| 179 |
+
# Force surrogate pairs
|
| 180 |
+
buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
|
| 181 |
+
|
| 182 |
+
return ''.join(buf).replace('\n', '\\par')
|
| 183 |
+
|
| 184 |
+
@staticmethod
|
| 185 |
+
def hex_to_rtf_color(hex_color):
|
| 186 |
+
if hex_color[0] == "#":
|
| 187 |
+
hex_color = hex_color[1:]
|
| 188 |
+
|
| 189 |
+
return '\\red%d\\green%d\\blue%d;' % (
|
| 190 |
+
int(hex_color[0:2], 16),
|
| 191 |
+
int(hex_color[2:4], 16),
|
| 192 |
+
int(hex_color[4:6], 16)
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
def _split_tokens_on_newlines(self, tokensource):
|
| 196 |
+
"""
|
| 197 |
+
Split tokens containing newline characters into multiple token
|
| 198 |
+
each representing a line of the input file. Needed for numbering
|
| 199 |
+
lines of e.g. multiline comments.
|
| 200 |
+
"""
|
| 201 |
+
for ttype, value in tokensource:
|
| 202 |
+
if value == '\n':
|
| 203 |
+
yield (ttype, value)
|
| 204 |
+
elif "\n" in value:
|
| 205 |
+
lines = value.split("\n")
|
| 206 |
+
for line in lines[:-1]:
|
| 207 |
+
yield (ttype, line+"\n")
|
| 208 |
+
if lines[-1]:
|
| 209 |
+
yield (ttype, lines[-1])
|
| 210 |
+
else:
|
| 211 |
+
yield (ttype, value)
|
| 212 |
+
|
| 213 |
+
def _create_color_mapping(self):
|
| 214 |
+
"""
|
| 215 |
+
Create a mapping of style hex colors to index/offset in
|
| 216 |
+
the RTF color table.
|
| 217 |
+
"""
|
| 218 |
+
color_mapping = OrderedDict()
|
| 219 |
+
offset = 1
|
| 220 |
+
|
| 221 |
+
if self.linenos:
|
| 222 |
+
color_mapping[self.lineno_color] = offset
|
| 223 |
+
offset += 1
|
| 224 |
+
|
| 225 |
+
if self.hl_lines:
|
| 226 |
+
color_mapping[self.hl_color] = offset
|
| 227 |
+
offset += 1
|
| 228 |
+
|
| 229 |
+
for _, style in self.style:
|
| 230 |
+
for color in style['color'], style['bgcolor'], style['border']:
|
| 231 |
+
if color and color not in color_mapping:
|
| 232 |
+
color_mapping[color] = offset
|
| 233 |
+
offset += 1
|
| 234 |
+
|
| 235 |
+
return color_mapping
|
| 236 |
+
|
| 237 |
+
@property
|
| 238 |
+
def _lineno_template(self):
|
| 239 |
+
if self.lineno_fontsize != self.fontsize:
|
| 240 |
+
return '{{\\fs{} \\cf{} %s{}}}'.format(self.lineno_fontsize,
|
| 241 |
+
self.color_mapping[self.lineno_color],
|
| 242 |
+
" " * self.lineno_padding)
|
| 243 |
+
|
| 244 |
+
return '{{\\cf{} %s{}}}'.format(self.color_mapping[self.lineno_color],
|
| 245 |
+
" " * self.lineno_padding)
|
| 246 |
+
|
| 247 |
+
@property
|
| 248 |
+
def _hl_open_str(self):
|
| 249 |
+
return rf'{{\highlight{self.color_mapping[self.hl_color]} '
|
| 250 |
+
|
| 251 |
+
@property
|
| 252 |
+
def _rtf_header(self):
|
| 253 |
+
lines = []
|
| 254 |
+
# rtf 1.8 header
|
| 255 |
+
lines.append('{\\rtf1\\ansi\\uc0\\deff0'
|
| 256 |
+
'{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
|
| 257 |
+
% (self.fontface and ' '
|
| 258 |
+
+ self._escape(self.fontface) or ''))
|
| 259 |
+
|
| 260 |
+
# color table
|
| 261 |
+
lines.append('{\\colortbl;')
|
| 262 |
+
for color, _ in self.color_mapping.items():
|
| 263 |
+
lines.append(self.hex_to_rtf_color(color))
|
| 264 |
+
lines.append('}')
|
| 265 |
+
|
| 266 |
+
# font and fontsize
|
| 267 |
+
lines.append('\\f0\\sa0')
|
| 268 |
+
if self.fontsize:
|
| 269 |
+
lines.append('\\fs%d' % self.fontsize)
|
| 270 |
+
|
| 271 |
+
# ensure Libre Office Writer imports and renders consecutive
|
| 272 |
+
# space characters the same width, needed for line numbering.
|
| 273 |
+
# https://bugs.documentfoundation.org/show_bug.cgi?id=144050
|
| 274 |
+
lines.append('\\dntblnsbdb')
|
| 275 |
+
|
| 276 |
+
return lines
|
| 277 |
+
|
| 278 |
+
def format_unencoded(self, tokensource, outfile):
|
| 279 |
+
for line in self._rtf_header:
|
| 280 |
+
outfile.write(line + "\n")
|
| 281 |
+
|
| 282 |
+
tokensource = self._split_tokens_on_newlines(tokensource)
|
| 283 |
+
|
| 284 |
+
# first pass of tokens to count lines, needed for line numbering
|
| 285 |
+
if self.linenos:
|
| 286 |
+
line_count = 0
|
| 287 |
+
tokens = [] # for copying the token source generator
|
| 288 |
+
for ttype, value in tokensource:
|
| 289 |
+
tokens.append((ttype, value))
|
| 290 |
+
if value.endswith("\n"):
|
| 291 |
+
line_count += 1
|
| 292 |
+
|
| 293 |
+
# width of line number strings (for padding with spaces)
|
| 294 |
+
linenos_width = len(str(line_count+self.linenostart-1))
|
| 295 |
+
|
| 296 |
+
tokensource = tokens
|
| 297 |
+
|
| 298 |
+
# highlight stream
|
| 299 |
+
lineno = 1
|
| 300 |
+
start_new_line = True
|
| 301 |
+
for ttype, value in tokensource:
|
| 302 |
+
if start_new_line and lineno in self.hl_lines:
|
| 303 |
+
outfile.write(self._hl_open_str)
|
| 304 |
+
|
| 305 |
+
if start_new_line and self.linenos:
|
| 306 |
+
if (lineno-self.linenostart+1)%self.linenostep == 0:
|
| 307 |
+
current_lineno = lineno + self.linenostart - 1
|
| 308 |
+
lineno_str = str(current_lineno).rjust(linenos_width)
|
| 309 |
+
else:
|
| 310 |
+
lineno_str = "".rjust(linenos_width)
|
| 311 |
+
outfile.write(self._lineno_template % lineno_str)
|
| 312 |
+
|
| 313 |
+
while not self.style.styles_token(ttype) and ttype.parent:
|
| 314 |
+
ttype = ttype.parent
|
| 315 |
+
style = self.style.style_for_token(ttype)
|
| 316 |
+
buf = []
|
| 317 |
+
if style['bgcolor']:
|
| 318 |
+
buf.append('\\cb%d' % self.color_mapping[style['bgcolor']])
|
| 319 |
+
if style['color']:
|
| 320 |
+
buf.append('\\cf%d' % self.color_mapping[style['color']])
|
| 321 |
+
if style['bold']:
|
| 322 |
+
buf.append('\\b')
|
| 323 |
+
if style['italic']:
|
| 324 |
+
buf.append('\\i')
|
| 325 |
+
if style['underline']:
|
| 326 |
+
buf.append('\\ul')
|
| 327 |
+
if style['border']:
|
| 328 |
+
buf.append('\\chbrdr\\chcfpat%d' %
|
| 329 |
+
self.color_mapping[style['border']])
|
| 330 |
+
start = ''.join(buf)
|
| 331 |
+
if start:
|
| 332 |
+
outfile.write(f'{{{start} ')
|
| 333 |
+
outfile.write(self._escape_text(value))
|
| 334 |
+
if start:
|
| 335 |
+
outfile.write('}')
|
| 336 |
+
start_new_line = False
|
| 337 |
+
|
| 338 |
+
# complete line of input
|
| 339 |
+
if value.endswith("\n"):
|
| 340 |
+
# close line highlighting
|
| 341 |
+
if lineno in self.hl_lines:
|
| 342 |
+
outfile.write('}')
|
| 343 |
+
# newline in RTF file after closing }
|
| 344 |
+
outfile.write("\n")
|
| 345 |
+
|
| 346 |
+
start_new_line = True
|
| 347 |
+
lineno += 1
|
| 348 |
+
|
| 349 |
+
outfile.write('}\n')
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/lexers/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (16.5 kB). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/scanner.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.scanner
|
| 3 |
+
~~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
This library implements a regex based scanner. Some languages
|
| 6 |
+
like Pascal are easy to parse but have some keywords that
|
| 7 |
+
depend on the context. Because of this it's impossible to lex
|
| 8 |
+
that just by using a regular expression lexer like the
|
| 9 |
+
`RegexLexer`.
|
| 10 |
+
|
| 11 |
+
Have a look at the `DelphiLexer` to get an idea of how to use
|
| 12 |
+
this scanner.
|
| 13 |
+
|
| 14 |
+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
|
| 15 |
+
:license: BSD, see LICENSE for details.
|
| 16 |
+
"""
|
| 17 |
+
import re
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class EndOfText(RuntimeError):
|
| 21 |
+
"""
|
| 22 |
+
Raise if end of text is reached and the user
|
| 23 |
+
tried to call a match function.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class Scanner:
|
| 28 |
+
"""
|
| 29 |
+
Simple scanner
|
| 30 |
+
|
| 31 |
+
All method patterns are regular expression strings (not
|
| 32 |
+
compiled expressions!)
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
def __init__(self, text, flags=0):
|
| 36 |
+
"""
|
| 37 |
+
:param text: The text which should be scanned
|
| 38 |
+
:param flags: default regular expression flags
|
| 39 |
+
"""
|
| 40 |
+
self.data = text
|
| 41 |
+
self.data_length = len(text)
|
| 42 |
+
self.start_pos = 0
|
| 43 |
+
self.pos = 0
|
| 44 |
+
self.flags = flags
|
| 45 |
+
self.last = None
|
| 46 |
+
self.match = None
|
| 47 |
+
self._re_cache = {}
|
| 48 |
+
|
| 49 |
+
def eos(self):
|
| 50 |
+
"""`True` if the scanner reached the end of text."""
|
| 51 |
+
return self.pos >= self.data_length
|
| 52 |
+
eos = property(eos, eos.__doc__)
|
| 53 |
+
|
| 54 |
+
def check(self, pattern):
|
| 55 |
+
"""
|
| 56 |
+
Apply `pattern` on the current position and return
|
| 57 |
+
the match object. (Doesn't touch pos). Use this for
|
| 58 |
+
lookahead.
|
| 59 |
+
"""
|
| 60 |
+
if self.eos:
|
| 61 |
+
raise EndOfText()
|
| 62 |
+
if pattern not in self._re_cache:
|
| 63 |
+
self._re_cache[pattern] = re.compile(pattern, self.flags)
|
| 64 |
+
return self._re_cache[pattern].match(self.data, self.pos)
|
| 65 |
+
|
| 66 |
+
def test(self, pattern):
|
| 67 |
+
"""Apply a pattern on the current position and check
|
| 68 |
+
if it patches. Doesn't touch pos.
|
| 69 |
+
"""
|
| 70 |
+
return self.check(pattern) is not None
|
| 71 |
+
|
| 72 |
+
def scan(self, pattern):
|
| 73 |
+
"""
|
| 74 |
+
Scan the text for the given pattern and update pos/match
|
| 75 |
+
and related fields. The return value is a boolean that
|
| 76 |
+
indicates if the pattern matched. The matched value is
|
| 77 |
+
stored on the instance as ``match``, the last value is
|
| 78 |
+
stored as ``last``. ``start_pos`` is the position of the
|
| 79 |
+
pointer before the pattern was matched, ``pos`` is the
|
| 80 |
+
end position.
|
| 81 |
+
"""
|
| 82 |
+
if self.eos:
|
| 83 |
+
raise EndOfText()
|
| 84 |
+
if pattern not in self._re_cache:
|
| 85 |
+
self._re_cache[pattern] = re.compile(pattern, self.flags)
|
| 86 |
+
self.last = self.match
|
| 87 |
+
m = self._re_cache[pattern].match(self.data, self.pos)
|
| 88 |
+
if m is None:
|
| 89 |
+
return False
|
| 90 |
+
self.start_pos = m.start()
|
| 91 |
+
self.pos = m.end()
|
| 92 |
+
self.match = m.group()
|
| 93 |
+
return True
|
| 94 |
+
|
| 95 |
+
def get_char(self):
|
| 96 |
+
"""Scan exactly one char."""
|
| 97 |
+
self.scan('.')
|
| 98 |
+
|
| 99 |
+
def __repr__(self):
|
| 100 |
+
return '<%s %d/%d>' % (
|
| 101 |
+
self.__class__.__name__,
|
| 102 |
+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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.style
|
| 3 |
+
~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Basic style object.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pip._vendor.pygments.token import Token, STANDARD_TYPES
|
| 12 |
+
|
| 13 |
+
# Default mapping of ansixxx to RGB colors.
|
| 14 |
+
_ansimap = {
|
| 15 |
+
# dark
|
| 16 |
+
'ansiblack': '000000',
|
| 17 |
+
'ansired': '7f0000',
|
| 18 |
+
'ansigreen': '007f00',
|
| 19 |
+
'ansiyellow': '7f7fe0',
|
| 20 |
+
'ansiblue': '00007f',
|
| 21 |
+
'ansimagenta': '7f007f',
|
| 22 |
+
'ansicyan': '007f7f',
|
| 23 |
+
'ansigray': 'e5e5e5',
|
| 24 |
+
# normal
|
| 25 |
+
'ansibrightblack': '555555',
|
| 26 |
+
'ansibrightred': 'ff0000',
|
| 27 |
+
'ansibrightgreen': '00ff00',
|
| 28 |
+
'ansibrightyellow': 'ffff00',
|
| 29 |
+
'ansibrightblue': '0000ff',
|
| 30 |
+
'ansibrightmagenta': 'ff00ff',
|
| 31 |
+
'ansibrightcyan': '00ffff',
|
| 32 |
+
'ansiwhite': 'ffffff',
|
| 33 |
+
}
|
| 34 |
+
# mapping of deprecated #ansixxx colors to new color names
|
| 35 |
+
_deprecated_ansicolors = {
|
| 36 |
+
# dark
|
| 37 |
+
'#ansiblack': 'ansiblack',
|
| 38 |
+
'#ansidarkred': 'ansired',
|
| 39 |
+
'#ansidarkgreen': 'ansigreen',
|
| 40 |
+
'#ansibrown': 'ansiyellow',
|
| 41 |
+
'#ansidarkblue': 'ansiblue',
|
| 42 |
+
'#ansipurple': 'ansimagenta',
|
| 43 |
+
'#ansiteal': 'ansicyan',
|
| 44 |
+
'#ansilightgray': 'ansigray',
|
| 45 |
+
# normal
|
| 46 |
+
'#ansidarkgray': 'ansibrightblack',
|
| 47 |
+
'#ansired': 'ansibrightred',
|
| 48 |
+
'#ansigreen': 'ansibrightgreen',
|
| 49 |
+
'#ansiyellow': 'ansibrightyellow',
|
| 50 |
+
'#ansiblue': 'ansibrightblue',
|
| 51 |
+
'#ansifuchsia': 'ansibrightmagenta',
|
| 52 |
+
'#ansiturquoise': 'ansibrightcyan',
|
| 53 |
+
'#ansiwhite': 'ansiwhite',
|
| 54 |
+
}
|
| 55 |
+
ansicolors = set(_ansimap)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class StyleMeta(type):
|
| 59 |
+
|
| 60 |
+
def __new__(mcs, name, bases, dct):
|
| 61 |
+
obj = type.__new__(mcs, name, bases, dct)
|
| 62 |
+
for token in STANDARD_TYPES:
|
| 63 |
+
if token not in obj.styles:
|
| 64 |
+
obj.styles[token] = ''
|
| 65 |
+
|
| 66 |
+
def colorformat(text):
|
| 67 |
+
if text in ansicolors:
|
| 68 |
+
return text
|
| 69 |
+
if text[0:1] == '#':
|
| 70 |
+
col = text[1:]
|
| 71 |
+
if len(col) == 6:
|
| 72 |
+
return col
|
| 73 |
+
elif len(col) == 3:
|
| 74 |
+
return col[0] * 2 + col[1] * 2 + col[2] * 2
|
| 75 |
+
elif text == '':
|
| 76 |
+
return ''
|
| 77 |
+
elif text.startswith('var') or text.startswith('calc'):
|
| 78 |
+
return text
|
| 79 |
+
assert False, f"wrong color format {text!r}"
|
| 80 |
+
|
| 81 |
+
_styles = obj._styles = {}
|
| 82 |
+
|
| 83 |
+
for ttype in obj.styles:
|
| 84 |
+
for token in ttype.split():
|
| 85 |
+
if token in _styles:
|
| 86 |
+
continue
|
| 87 |
+
ndef = _styles.get(token.parent, None)
|
| 88 |
+
styledefs = obj.styles.get(token, '').split()
|
| 89 |
+
if not ndef or token is None:
|
| 90 |
+
ndef = ['', 0, 0, 0, '', '', 0, 0, 0]
|
| 91 |
+
elif 'noinherit' in styledefs and token is not Token:
|
| 92 |
+
ndef = _styles[Token][:]
|
| 93 |
+
else:
|
| 94 |
+
ndef = ndef[:]
|
| 95 |
+
_styles[token] = ndef
|
| 96 |
+
for styledef in obj.styles.get(token, '').split():
|
| 97 |
+
if styledef == 'noinherit':
|
| 98 |
+
pass
|
| 99 |
+
elif styledef == 'bold':
|
| 100 |
+
ndef[1] = 1
|
| 101 |
+
elif styledef == 'nobold':
|
| 102 |
+
ndef[1] = 0
|
| 103 |
+
elif styledef == 'italic':
|
| 104 |
+
ndef[2] = 1
|
| 105 |
+
elif styledef == 'noitalic':
|
| 106 |
+
ndef[2] = 0
|
| 107 |
+
elif styledef == 'underline':
|
| 108 |
+
ndef[3] = 1
|
| 109 |
+
elif styledef == 'nounderline':
|
| 110 |
+
ndef[3] = 0
|
| 111 |
+
elif styledef[:3] == 'bg:':
|
| 112 |
+
ndef[4] = colorformat(styledef[3:])
|
| 113 |
+
elif styledef[:7] == 'border:':
|
| 114 |
+
ndef[5] = colorformat(styledef[7:])
|
| 115 |
+
elif styledef == 'roman':
|
| 116 |
+
ndef[6] = 1
|
| 117 |
+
elif styledef == 'sans':
|
| 118 |
+
ndef[7] = 1
|
| 119 |
+
elif styledef == 'mono':
|
| 120 |
+
ndef[8] = 1
|
| 121 |
+
else:
|
| 122 |
+
ndef[0] = colorformat(styledef)
|
| 123 |
+
|
| 124 |
+
return obj
|
| 125 |
+
|
| 126 |
+
def style_for_token(cls, token):
|
| 127 |
+
t = cls._styles[token]
|
| 128 |
+
ansicolor = bgansicolor = None
|
| 129 |
+
color = t[0]
|
| 130 |
+
if color in _deprecated_ansicolors:
|
| 131 |
+
color = _deprecated_ansicolors[color]
|
| 132 |
+
if color in ansicolors:
|
| 133 |
+
ansicolor = color
|
| 134 |
+
color = _ansimap[color]
|
| 135 |
+
bgcolor = t[4]
|
| 136 |
+
if bgcolor in _deprecated_ansicolors:
|
| 137 |
+
bgcolor = _deprecated_ansicolors[bgcolor]
|
| 138 |
+
if bgcolor in ansicolors:
|
| 139 |
+
bgansicolor = bgcolor
|
| 140 |
+
bgcolor = _ansimap[bgcolor]
|
| 141 |
+
|
| 142 |
+
return {
|
| 143 |
+
'color': color or None,
|
| 144 |
+
'bold': bool(t[1]),
|
| 145 |
+
'italic': bool(t[2]),
|
| 146 |
+
'underline': bool(t[3]),
|
| 147 |
+
'bgcolor': bgcolor or None,
|
| 148 |
+
'border': t[5] or None,
|
| 149 |
+
'roman': bool(t[6]) or None,
|
| 150 |
+
'sans': bool(t[7]) or None,
|
| 151 |
+
'mono': bool(t[8]) or None,
|
| 152 |
+
'ansicolor': ansicolor,
|
| 153 |
+
'bgansicolor': bgansicolor,
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
def list_styles(cls):
|
| 157 |
+
return list(cls)
|
| 158 |
+
|
| 159 |
+
def styles_token(cls, ttype):
|
| 160 |
+
return ttype in cls._styles
|
| 161 |
+
|
| 162 |
+
def __iter__(cls):
|
| 163 |
+
for token in cls._styles:
|
| 164 |
+
yield token, cls.style_for_token(token)
|
| 165 |
+
|
| 166 |
+
def __len__(cls):
|
| 167 |
+
return len(cls._styles)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class Style(metaclass=StyleMeta):
|
| 171 |
+
|
| 172 |
+
#: overall background color (``None`` means transparent)
|
| 173 |
+
background_color = '#ffffff'
|
| 174 |
+
|
| 175 |
+
#: highlight background color
|
| 176 |
+
highlight_color = '#ffffcc'
|
| 177 |
+
|
| 178 |
+
#: line number font color
|
| 179 |
+
line_number_color = 'inherit'
|
| 180 |
+
|
| 181 |
+
#: line number background color
|
| 182 |
+
line_number_background_color = 'transparent'
|
| 183 |
+
|
| 184 |
+
#: special line number font color
|
| 185 |
+
line_number_special_color = '#000000'
|
| 186 |
+
|
| 187 |
+
#: special line number background color
|
| 188 |
+
line_number_special_background_color = '#ffffc0'
|
| 189 |
+
|
| 190 |
+
#: Style definitions for individual token types.
|
| 191 |
+
styles = {}
|
| 192 |
+
|
| 193 |
+
#: user-friendly style name (used when selecting the style, so this
|
| 194 |
+
# should be all-lowercase, no spaces, hyphens)
|
| 195 |
+
name = 'unnamed'
|
| 196 |
+
|
| 197 |
+
aliases = []
|
| 198 |
+
|
| 199 |
+
# Attribute for lexers defined within Pygments. If set
|
| 200 |
+
# to True, the style is not shown in the style gallery
|
| 201 |
+
# on the website. This is intended for language-specific
|
| 202 |
+
# styles.
|
| 203 |
+
web_style_gallery_exclude = False
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__init__.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
pygments.styles
|
| 3 |
+
~~~~~~~~~~~~~~~
|
| 4 |
+
|
| 5 |
+
Contains built-in styles.
|
| 6 |
+
|
| 7 |
+
:copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
|
| 8 |
+
:license: BSD, see LICENSE for details.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from pip._vendor.pygments.plugin import find_plugin_styles
|
| 12 |
+
from pip._vendor.pygments.util import ClassNotFound
|
| 13 |
+
from pip._vendor.pygments.styles._mapping import STYLES
|
| 14 |
+
|
| 15 |
+
#: A dictionary of built-in styles, mapping style names to
|
| 16 |
+
#: ``'submodule::classname'`` strings.
|
| 17 |
+
#: This list is deprecated. Use `pygments.styles.STYLES` instead
|
| 18 |
+
STYLE_MAP = {v[1]: v[0].split('.')[-1] + '::' + k for k, v in STYLES.items()}
|
| 19 |
+
|
| 20 |
+
#: Internal reverse mapping to make `get_style_by_name` more efficient
|
| 21 |
+
_STYLE_NAME_TO_MODULE_MAP = {v[1]: (v[0], k) for k, v in STYLES.items()}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def get_style_by_name(name):
|
| 25 |
+
"""
|
| 26 |
+
Return a style class by its short name. The names of the builtin styles
|
| 27 |
+
are listed in :data:`pygments.styles.STYLE_MAP`.
|
| 28 |
+
|
| 29 |
+
Will raise :exc:`pygments.util.ClassNotFound` if no style of that name is
|
| 30 |
+
found.
|
| 31 |
+
"""
|
| 32 |
+
if name in _STYLE_NAME_TO_MODULE_MAP:
|
| 33 |
+
mod, cls = _STYLE_NAME_TO_MODULE_MAP[name]
|
| 34 |
+
builtin = "yes"
|
| 35 |
+
else:
|
| 36 |
+
for found_name, style in find_plugin_styles():
|
| 37 |
+
if name == found_name:
|
| 38 |
+
return style
|
| 39 |
+
# perhaps it got dropped into our styles package
|
| 40 |
+
builtin = ""
|
| 41 |
+
mod = 'pygments.styles.' + name
|
| 42 |
+
cls = name.title() + "Style"
|
| 43 |
+
|
| 44 |
+
try:
|
| 45 |
+
mod = __import__(mod, None, None, [cls])
|
| 46 |
+
except ImportError:
|
| 47 |
+
raise ClassNotFound(f"Could not find style module {mod!r}" +
|
| 48 |
+
(builtin and ", though it should be builtin")
|
| 49 |
+
+ ".")
|
| 50 |
+
try:
|
| 51 |
+
return getattr(mod, cls)
|
| 52 |
+
except AttributeError:
|
| 53 |
+
raise ClassNotFound(f"Could not find style class {cls!r} in style module.")
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def get_all_styles():
|
| 57 |
+
"""Return a generator for all styles by name, both builtin and plugin."""
|
| 58 |
+
for v in STYLES.values():
|
| 59 |
+
yield v[1]
|
| 60 |
+
for name, _ in find_plugin_styles():
|
| 61 |
+
yield name
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (3.13 kB). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/styles/__pycache__/_mapping.cpython-311.pyc
ADDED
|
Binary file (3.69 kB). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/pip/_vendor/pygments/token.py
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class _TokenType(tuple):
|
| 13 |
+
parent = None
|
| 14 |
+
|
| 15 |
+
def split(self):
|
| 16 |
+
buf = []
|
| 17 |
+
node = self
|
| 18 |
+
while node is not None:
|
| 19 |
+
buf.append(node)
|
| 20 |
+
node = node.parent
|
| 21 |
+
buf.reverse()
|
| 22 |
+
return buf
|
| 23 |
+
|
| 24 |
+
def __init__(self, *args):
|
| 25 |
+
# no need to call super.__init__
|
| 26 |
+
self.subtypes = set()
|
| 27 |
+
|
| 28 |
+
def __contains__(self, val):
|
| 29 |
+
return self is val or (
|
| 30 |
+
type(val) is self.__class__ and
|
| 31 |
+
val[:len(self)] == self
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def __getattr__(self, val):
|
| 35 |
+
if not val or not val[0].isupper():
|
| 36 |
+
return tuple.__getattribute__(self, val)
|
| 37 |
+
new = _TokenType(self + (val,))
|
| 38 |
+
setattr(self, val, new)
|
| 39 |
+
self.subtypes.add(new)
|
| 40 |
+
new.parent = self
|
| 41 |
+
return new
|
| 42 |
+
|
| 43 |
+
def __repr__(self):
|
| 44 |
+
return 'Token' + (self and '.' or '') + '.'.join(self)
|
| 45 |
+
|
| 46 |
+
def __copy__(self):
|
| 47 |
+
# These instances are supposed to be singletons
|
| 48 |
+
return self
|
| 49 |
+
|
| 50 |
+
def __deepcopy__(self, memo):
|
| 51 |
+
# These instances are supposed to be singletons
|
| 52 |
+
return self
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
Token = _TokenType()
|
| 56 |
+
|
| 57 |
+
# Special token types
|
| 58 |
+
Text = Token.Text
|
| 59 |
+
Whitespace = Text.Whitespace
|
| 60 |
+
Escape = Token.Escape
|
| 61 |
+
Error = Token.Error
|
| 62 |
+
# Text that doesn't belong to this lexer (e.g. HTML in PHP)
|
| 63 |
+
Other = Token.Other
|
| 64 |
+
|
| 65 |
+
# Common token types for source code
|
| 66 |
+
Keyword = Token.Keyword
|
| 67 |
+
Name = Token.Name
|
| 68 |
+
Literal = Token.Literal
|
| 69 |
+
String = Literal.String
|
| 70 |
+
Number = Literal.Number
|
| 71 |
+
Punctuation = Token.Punctuation
|
| 72 |
+
Operator = Token.Operator
|
| 73 |
+
Comment = Token.Comment
|
| 74 |
+
|
| 75 |
+
# Generic types for non-source code
|
| 76 |
+
Generic = Token.Generic
|
| 77 |
+
|
| 78 |
+
# String and some others are not direct children of Token.
|
| 79 |
+
# alias them:
|
| 80 |
+
Token.Token = Token
|
| 81 |
+
Token.String = String
|
| 82 |
+
Token.Number = Number
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def is_token_subtype(ttype, other):
|
| 86 |
+
"""
|
| 87 |
+
Return True if ``ttype`` is a subtype of ``other``.
|
| 88 |
+
|
| 89 |
+
exists for backwards compatibility. use ``ttype in other`` now.
|
| 90 |
+
"""
|
| 91 |
+
return ttype in other
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def string_to_tokentype(s):
|
| 95 |
+
"""
|
| 96 |
+
Convert a string into a token type::
|
| 97 |
+
|
| 98 |
+
>>> string_to_token('String.Double')
|
| 99 |
+
Token.Literal.String.Double
|
| 100 |
+
>>> string_to_token('Token.Literal.Number')
|
| 101 |
+
Token.Literal.Number
|
| 102 |
+
>>> string_to_token('')
|
| 103 |
+
Token
|
| 104 |
+
|
| 105 |
+
Tokens that are already tokens are returned unchanged:
|
| 106 |
+
|
| 107 |
+
>>> string_to_token(String)
|
| 108 |
+
Token.Literal.String
|
| 109 |
+
"""
|
| 110 |
+
if isinstance(s, _TokenType):
|
| 111 |
+
return s
|
| 112 |
+
if not s:
|
| 113 |
+
return Token
|
| 114 |
+
node = Token
|
| 115 |
+
for item in s.split('.'):
|
| 116 |
+
node = getattr(node, item)
|
| 117 |
+
return node
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
# Map standard token types to short names, used in CSS class naming.
|
| 121 |
+
# If you add a new item, please be sure to run this file to perform
|
| 122 |
+
# a consistency check for duplicate values.
|
| 123 |
+
STANDARD_TYPES = {
|
| 124 |
+
Token: '',
|
| 125 |
+
|
| 126 |
+
Text: '',
|
| 127 |
+
Whitespace: 'w',
|
| 128 |
+
Escape: 'esc',
|
| 129 |
+
Error: 'err',
|
| 130 |
+
Other: 'x',
|
| 131 |
+
|
| 132 |
+
Keyword: 'k',
|
| 133 |
+
Keyword.Constant: 'kc',
|
| 134 |
+
Keyword.Declaration: 'kd',
|
| 135 |
+
Keyword.Namespace: 'kn',
|
| 136 |
+
Keyword.Pseudo: 'kp',
|
| 137 |
+
Keyword.Reserved: 'kr',
|
| 138 |
+
Keyword.Type: 'kt',
|
| 139 |
+
|
| 140 |
+
Name: 'n',
|
| 141 |
+
Name.Attribute: 'na',
|
| 142 |
+
Name.Builtin: 'nb',
|
| 143 |
+
Name.Builtin.Pseudo: 'bp',
|
| 144 |
+
Name.Class: 'nc',
|
| 145 |
+
Name.Constant: 'no',
|
| 146 |
+
Name.Decorator: 'nd',
|
| 147 |
+
Name.Entity: 'ni',
|
| 148 |
+
Name.Exception: 'ne',
|
| 149 |
+
Name.Function: 'nf',
|
| 150 |
+
Name.Function.Magic: 'fm',
|
| 151 |
+
Name.Property: 'py',
|
| 152 |
+
Name.Label: 'nl',
|
| 153 |
+
Name.Namespace: 'nn',
|
| 154 |
+
Name.Other: 'nx',
|
| 155 |
+
Name.Tag: 'nt',
|
| 156 |
+
Name.Variable: 'nv',
|
| 157 |
+
Name.Variable.Class: 'vc',
|
| 158 |
+
Name.Variable.Global: 'vg',
|
| 159 |
+
Name.Variable.Instance: 'vi',
|
| 160 |
+
Name.Variable.Magic: 'vm',
|
| 161 |
+
|
| 162 |
+
Literal: 'l',
|
| 163 |
+
Literal.Date: 'ld',
|
| 164 |
+
|
| 165 |
+
String: 's',
|
| 166 |
+
String.Affix: 'sa',
|
| 167 |
+
String.Backtick: 'sb',
|
| 168 |
+
String.Char: 'sc',
|
| 169 |
+
String.Delimiter: 'dl',
|
| 170 |
+
String.Doc: 'sd',
|
| 171 |
+
String.Double: 's2',
|
| 172 |
+
String.Escape: 'se',
|
| 173 |
+
String.Heredoc: 'sh',
|
| 174 |
+
String.Interpol: 'si',
|
| 175 |
+
String.Other: 'sx',
|
| 176 |
+
String.Regex: 'sr',
|
| 177 |
+
String.Single: 's1',
|
| 178 |
+
String.Symbol: 'ss',
|
| 179 |
+
|
| 180 |
+
Number: 'm',
|
| 181 |
+
Number.Bin: 'mb',
|
| 182 |
+
Number.Float: 'mf',
|
| 183 |
+
Number.Hex: 'mh',
|
| 184 |
+
Number.Integer: 'mi',
|
| 185 |
+
Number.Integer.Long: 'il',
|
| 186 |
+
Number.Oct: 'mo',
|
| 187 |
+
|
| 188 |
+
Operator: 'o',
|
| 189 |
+
Operator.Word: 'ow',
|
| 190 |
+
|
| 191 |
+
Punctuation: 'p',
|
| 192 |
+
Punctuation.Marker: 'pm',
|
| 193 |
+
|
| 194 |
+
Comment: 'c',
|
| 195 |
+
Comment.Hashbang: 'ch',
|
| 196 |
+
Comment.Multiline: 'cm',
|
| 197 |
+
Comment.Preproc: 'cp',
|
| 198 |
+
Comment.PreprocFile: 'cpf',
|
| 199 |
+
Comment.Single: 'c1',
|
| 200 |
+
Comment.Special: 'cs',
|
| 201 |
+
|
| 202 |
+
Generic: 'g',
|
| 203 |
+
Generic.Deleted: 'gd',
|
| 204 |
+
Generic.Emph: 'ge',
|
| 205 |
+
Generic.Error: 'gr',
|
| 206 |
+
Generic.Heading: 'gh',
|
| 207 |
+
Generic.Inserted: 'gi',
|
| 208 |
+
Generic.Output: 'go',
|
| 209 |
+
Generic.Prompt: 'gp',
|
| 210 |
+
Generic.Strong: 'gs',
|
| 211 |
+
Generic.Subheading: 'gu',
|
| 212 |
+
Generic.EmphStrong: 'ges',
|
| 213 |
+
Generic.Traceback: 'gt',
|
| 214 |
+
}
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/qat/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from .modules import * # noqa: F403
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/qat/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (258 Bytes). View file
|
|
|
tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/ao/nn/intrinsic/quantized/modules/__init__.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .linear_relu import LinearReLU, LinearLeakyReLU, LinearTanh
|
| 2 |
+
from .conv_relu import ConvReLU1d, ConvReLU2d, ConvReLU3d
|
| 3 |
+
from .bn_relu import BNReLU2d, BNReLU3d
|
| 4 |
+
from .conv_add import ConvAdd2d, ConvAddReLU2d
|
| 5 |
+
|
| 6 |
+
__all__ = [
|
| 7 |
+
'LinearReLU',
|
| 8 |
+
'ConvReLU1d',
|
| 9 |
+
'ConvReLU2d',
|
| 10 |
+
'ConvReLU3d',
|
| 11 |
+
'BNReLU2d',
|
| 12 |
+
'BNReLU3d',
|
| 13 |
+
'LinearLeakyReLU',
|
| 14 |
+
'LinearTanh',
|
| 15 |
+
'ConvAdd2d',
|
| 16 |
+
'ConvAddReLU2d',
|
| 17 |
+
]
|