pyopencl 2025.2.7__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyopencl might be problematic. Click here for more details.

Files changed (46) hide show
  1. pyopencl/__init__.py +1995 -0
  2. pyopencl/_cl.cp314-win_amd64.pyd +0 -0
  3. pyopencl/_cl.pyi +2009 -0
  4. pyopencl/_cluda.py +57 -0
  5. pyopencl/_monkeypatch.py +1104 -0
  6. pyopencl/_mymako.py +17 -0
  7. pyopencl/algorithm.py +1454 -0
  8. pyopencl/array.py +3530 -0
  9. pyopencl/bitonic_sort.py +245 -0
  10. pyopencl/bitonic_sort_templates.py +597 -0
  11. pyopencl/cache.py +535 -0
  12. pyopencl/capture_call.py +200 -0
  13. pyopencl/characterize/__init__.py +461 -0
  14. pyopencl/characterize/performance.py +240 -0
  15. pyopencl/cl/pyopencl-airy.cl +324 -0
  16. pyopencl/cl/pyopencl-bessel-j-complex.cl +238 -0
  17. pyopencl/cl/pyopencl-bessel-j.cl +1084 -0
  18. pyopencl/cl/pyopencl-bessel-y.cl +435 -0
  19. pyopencl/cl/pyopencl-complex.h +303 -0
  20. pyopencl/cl/pyopencl-eval-tbl.cl +120 -0
  21. pyopencl/cl/pyopencl-hankel-complex.cl +444 -0
  22. pyopencl/cl/pyopencl-random123/array.h +325 -0
  23. pyopencl/cl/pyopencl-random123/openclfeatures.h +93 -0
  24. pyopencl/cl/pyopencl-random123/philox.cl +486 -0
  25. pyopencl/cl/pyopencl-random123/threefry.cl +864 -0
  26. pyopencl/clmath.py +281 -0
  27. pyopencl/clrandom.py +412 -0
  28. pyopencl/cltypes.py +217 -0
  29. pyopencl/compyte/.gitignore +21 -0
  30. pyopencl/compyte/__init__.py +0 -0
  31. pyopencl/compyte/array.py +211 -0
  32. pyopencl/compyte/dtypes.py +314 -0
  33. pyopencl/compyte/pyproject.toml +49 -0
  34. pyopencl/elementwise.py +1288 -0
  35. pyopencl/invoker.py +417 -0
  36. pyopencl/ipython_ext.py +70 -0
  37. pyopencl/py.typed +0 -0
  38. pyopencl/reduction.py +815 -0
  39. pyopencl/scan.py +1921 -0
  40. pyopencl/tools.py +1680 -0
  41. pyopencl/typing.py +61 -0
  42. pyopencl/version.py +11 -0
  43. pyopencl-2025.2.7.dist-info/METADATA +108 -0
  44. pyopencl-2025.2.7.dist-info/RECORD +46 -0
  45. pyopencl-2025.2.7.dist-info/WHEEL +5 -0
  46. pyopencl-2025.2.7.dist-info/licenses/LICENSE +282 -0
@@ -0,0 +1,238 @@
1
+ /*
2
+ Evaluate Bessel J function J_v(z) and J_{v+1}(z) with v a nonnegative integer
3
+ and z anywhere in the complex plane.
4
+
5
+ Copyright (C) Vladimir Rokhlin
6
+ Copyright (C) 2010-2012 Leslie Greengard and Zydrunas Gimbutas
7
+ Copyright (C) 2015 Shidong Jiang, Andreas Kloeckner
8
+
9
+ Manually translated from
10
+ https://github.com/zgimbutas/fmmlib2d/blob/master/src/cdjseval2d.f
11
+
12
+ Originally licensed under GPL, permission to license under MIT granted via email
13
+ by Vladimir Rokhlin on May 25, 2015 and by Zydrunas Gimbutas on May 17, 2015.
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in
23
+ all copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
+ THE SOFTWARE.
32
+
33
+ */
34
+
35
+ void bessel_j_complex(int v, cdouble_t z, cdouble_t *j_v, cdouble_t *j_vp1)
36
+ {
37
+ int n;
38
+ int nmax = 10000;
39
+
40
+ int k;
41
+ int kmax=8;
42
+
43
+ int vscale, vp1scale;
44
+ double vscaling, vp1scaling;
45
+
46
+ const double small = 2e-1;
47
+ const double median = 1.0e0;
48
+
49
+ const double upbound = 1e40;
50
+ const double upbound_inv = 1e-40;
51
+
52
+ double dd;
53
+ double k_factorial_inv, kv_factorial_inv, kvp1_factorial_inv;
54
+
55
+ cdouble_t z_half, mz_half2, mz_half_2k, z_half_v, z_half_vp1;
56
+
57
+ cdouble_t ima = cdouble_new(0, 1);
58
+ cdouble_t neg_ima = cdouble_new(0, -1);
59
+
60
+ cdouble_t zinv, ztmp;
61
+ cdouble_t j_nm1, j_n, j_np1;
62
+
63
+ cdouble_t psi, zsn, zmul, zmulinv;
64
+ cdouble_t unscaled_j_n, unscaled_j_nm1, unscaled_j_np1;
65
+ cdouble_t unscaled_j_v, unscaled_j_vp1;
66
+ cdouble_t scaling;
67
+
68
+ // assert( v >= 0 );
69
+
70
+ #if 0
71
+ if (cdouble_abs(z) < tiny)
72
+ {
73
+ if (v == 0)
74
+ {
75
+ *j_v = cdouble_new(1, 0);
76
+ *j_vp1 = cdouble_new(0, 0);
77
+ } else
78
+ {
79
+ *j_v = cdouble_new(0, 0);
80
+ *j_vp1 = cdouble_new(0, 0);
81
+ }
82
+ return;
83
+ }
84
+ #endif
85
+
86
+ // {{{ power series for (small z) or (large v and median z)
87
+ if ( (cdouble_abs(z) < small) || ( (v>12) && (cdouble_abs(z) < median)))
88
+ {
89
+ z_half = cdouble_divider(z,2.0);
90
+
91
+ mz_half2 = cdouble_neg(cdouble_mul(z_half, z_half));
92
+
93
+ z_half_v = cdouble_powr(z_half, v);
94
+ z_half_vp1 = cdouble_mul(z_half_v, z_half);
95
+
96
+
97
+ // compute 1/v!
98
+ kv_factorial_inv = 1.0;
99
+ for ( k = 1; k <= v; k++)
100
+ {
101
+ kv_factorial_inv /= k;
102
+ }
103
+
104
+ kvp1_factorial_inv = kv_factorial_inv / (v+1);
105
+
106
+ k_factorial_inv = 1.0;
107
+
108
+ // compute the power series of bessel j function
109
+ mz_half_2k = cdouble_new(1.0, 0);
110
+
111
+ *j_v = cdouble_new(0, 0);
112
+ *j_vp1 = cdouble_new(0, 0);
113
+
114
+ for ( k = 0; k < kmax; k++ )
115
+ {
116
+ *j_v = cdouble_add(
117
+ *j_v,
118
+ cdouble_mulr(mz_half_2k, kv_factorial_inv*k_factorial_inv));
119
+ *j_vp1 = cdouble_add(*j_vp1,
120
+ cdouble_mulr(mz_half_2k, kvp1_factorial_inv*k_factorial_inv));
121
+
122
+ mz_half_2k = cdouble_mul(mz_half_2k, mz_half2);
123
+ k_factorial_inv /= (k+1);
124
+ kv_factorial_inv /= (k+v+1);
125
+ kvp1_factorial_inv /= (k+v+2);
126
+ }
127
+
128
+ *j_v = cdouble_mul(*j_v, z_half_v );
129
+ *j_vp1 = cdouble_mul(*j_vp1, z_half_vp1 );
130
+
131
+ return;
132
+ }
133
+
134
+ // }}}
135
+
136
+ // {{{ use recurrence for large z
137
+
138
+ j_nm1 = cdouble_new(0, 0);
139
+ j_n = cdouble_new(1, 0);
140
+
141
+ n = v;
142
+
143
+ zinv = cdouble_rdivide(1,z);
144
+
145
+ while (true)
146
+ {
147
+ j_np1 = cdouble_sub(
148
+ cdouble_mul(cdouble_rmul(2*n, zinv), j_n),
149
+ j_nm1);
150
+
151
+ n += 1;
152
+ j_nm1 = j_n;
153
+ j_n = j_np1;
154
+
155
+ if (n > nmax)
156
+ {
157
+ *j_v = cdouble_new(nan(0x8e55e1u), 0);
158
+ *j_vp1 = cdouble_new(nan(0x8e55e1u), 0);
159
+ return;
160
+ }
161
+
162
+ if (cdouble_abs_squared(j_n) > upbound)
163
+ break;
164
+ }
165
+
166
+ // downward recursion, account for rescalings
167
+ // Record the number of times of the missed rescalings
168
+ // for j_v and j_vp1.
169
+
170
+ unscaled_j_np1 = cdouble_new(0, 0);
171
+ unscaled_j_n = cdouble_new(1, 0);
172
+
173
+ // Use normalization condition http://dlmf.nist.gov/10.12#E5
174
+ psi = cdouble_new(0, 0);
175
+
176
+ if (cdouble_imag(z) <= 0)
177
+ zmul = ima;
178
+ else
179
+ zmul = neg_ima;
180
+
181
+ zsn = cdouble_powr(zmul, n%4);
182
+
183
+ zmulinv = cdouble_rdivide(1, zmul);
184
+
185
+ vscale = 0;
186
+ vp1scale = 0;
187
+
188
+ while (n > 0)
189
+ {
190
+ ztmp = cdouble_sub(
191
+ cdouble_mul(cdouble_rmul(2*n, zinv), unscaled_j_n),
192
+ unscaled_j_np1);
193
+
194
+ unscaled_j_nm1 = ztmp;
195
+
196
+
197
+ psi = cdouble_add(psi, cdouble_mul(unscaled_j_n, zsn));
198
+ zsn = cdouble_mul(zsn, zmulinv);
199
+
200
+ n -= 1;
201
+ unscaled_j_np1 = unscaled_j_n;
202
+ unscaled_j_n = unscaled_j_nm1;
203
+
204
+ if (cdouble_abs_squared(ztmp) > upbound)
205
+ {
206
+ unscaled_j_np1 = cdouble_rmul(upbound_inv, unscaled_j_np1);
207
+ unscaled_j_n = cdouble_rmul(upbound_inv, unscaled_j_n);
208
+ psi = cdouble_rmul(upbound_inv,psi);
209
+ if (n < v) vscale++;
210
+ if (n < v+1) vp1scale++;
211
+ }
212
+
213
+ if (n == v)
214
+ unscaled_j_v = unscaled_j_n;
215
+ if (n == v+1)
216
+ unscaled_j_vp1 = unscaled_j_n;
217
+
218
+ }
219
+
220
+ psi = cdouble_add(cdouble_rmul(2, psi), unscaled_j_n);
221
+
222
+ if ( cdouble_imag(z) <= 0 )
223
+ {
224
+ scaling = cdouble_divide( cdouble_exp( cdouble_mul(ima,z) ), psi);
225
+ } else
226
+ {
227
+ scaling = cdouble_divide( cdouble_exp( cdouble_mul(neg_ima,z) ), psi);
228
+ }
229
+ vscaling = pow(upbound_inv, (double) vscale);
230
+ vp1scaling = pow(upbound_inv, (double) vp1scale);
231
+
232
+ *j_v = cdouble_mul(unscaled_j_v, cdouble_mulr(scaling, vscaling));
233
+ *j_vp1 = cdouble_mul(unscaled_j_vp1, cdouble_mulr(scaling,vp1scaling));
234
+
235
+ // }}}
236
+ }
237
+
238
+ // vim: fdm=marker