ADAPT-Chase commited on
Commit
de7d0fe
·
verified ·
1 Parent(s): 76d87a9

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +12 -0
  2. tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/__init__.cpython-312.pyc +0 -0
  3. tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_abc.cpython-312.pyc +0 -0
  4. tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_compat.cpython-312.pyc +0 -0
  5. tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_multidict_py.cpython-312.pyc +0 -0
  6. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__multiarray_api.c +376 -0
  7. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__multiarray_api.h +1613 -0
  8. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__ufunc_api.c +54 -0
  9. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__ufunc_api.h +340 -0
  10. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_neighborhood_iterator_imp.h +90 -0
  11. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_numpyconfig.h +33 -0
  12. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_public_dtype_api_table.h +86 -0
  13. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h +7 -0
  14. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayscalars.h +196 -0
  15. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/dtype_api.h +480 -0
  16. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/halffloat.h +70 -0
  17. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h +304 -0
  18. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h +1933 -0
  19. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_1_7_deprecated_api.h +112 -0
  20. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_2_compat.h +249 -0
  21. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_2_complexcompat.h +28 -0
  22. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_3kcompat.h +374 -0
  23. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_common.h +1070 -0
  24. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_cpu.h +134 -0
  25. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_endian.h +78 -0
  26. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_math.h +602 -0
  27. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_no_deprecated_api.h +20 -0
  28. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_os.h +42 -0
  29. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/numpyconfig.h +178 -0
  30. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/LICENSE.txt +21 -0
  31. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/bitgen.h +20 -0
  32. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/distributions.h +209 -0
  33. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/libdivide.h +2079 -0
  34. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ufuncobject.h +347 -0
  35. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/utils.h +37 -0
  36. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/npy-pkg-config/mlib.ini +12 -0
  37. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/npy-pkg-config/npymath.ini +20 -0
  38. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/pkgconfig/numpy.pc +7 -0
  39. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_casting_floatingpoint_errors.cpython-312.pyc +0 -0
  40. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_casting_unittests.cpython-312.pyc +0 -0
  41. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_conversion_utils.cpython-312.pyc +0 -0
  42. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cpu_dispatcher.cpython-312.pyc +0 -0
  43. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cpu_features.cpython-312.pyc +0 -0
  44. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_custom_dtypes.cpython-312.pyc +0 -0
  45. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cython.cpython-312.pyc +0 -0
  46. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_datetime.cpython-312.pyc +3 -0
  47. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_defchararray.cpython-312.pyc +0 -0
  48. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_deprecations.cpython-312.pyc +0 -0
  49. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dlpack.cpython-312.pyc +0 -0
  50. tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dtype.cpython-312.pyc +3 -0
.gitattributes CHANGED
@@ -3898,3 +3898,15 @@ tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/tes
3898
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_umath.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3899
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_nditer.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3900
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_numeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
3898
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_umath.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3899
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_nditer.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3900
  tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_numeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3901
+ tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_regression.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3902
+ tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_datetime.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3903
+ tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dtype.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3904
+ tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_multiarray.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3905
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/distlib/t64-arm.exe filter=lfs diff=lfs merge=lfs -text
3906
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/distlib/t64.exe filter=lfs diff=lfs merge=lfs -text
3907
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/distlib/w64-arm.exe filter=lfs diff=lfs merge=lfs -text
3908
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/distlib/w64.exe filter=lfs diff=lfs merge=lfs -text
3909
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/idna/__pycache__/uts46data.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3910
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/pkg_resources/__pycache__/__init__.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3911
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3912
+ tool_server/.venv/lib/python3.12/site-packages/pip/_vendor/rich/__pycache__/console.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (1.39 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_abc.cpython-312.pyc ADDED
Binary file (5.54 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_compat.cpython-312.pyc ADDED
Binary file (651 Bytes). View file
 
tool_server/.venv/lib/python3.12/site-packages/multidict/__pycache__/_multidict_py.cpython-312.pyc ADDED
Binary file (65.5 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__multiarray_api.c ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* These pointers will be stored in the C-object for use in other
3
+ extension modules
4
+ */
5
+
6
+ void *PyArray_API[] = {
7
+ (void *) PyArray_GetNDArrayCVersion,
8
+ NULL,
9
+ (void *) &PyArray_Type,
10
+ (void *) &PyArrayDescr_Type,
11
+ NULL,
12
+ (void *) &PyArrayIter_Type,
13
+ (void *) &PyArrayMultiIter_Type,
14
+ (int *) &NPY_NUMUSERTYPES,
15
+ (void *) &PyBoolArrType_Type,
16
+ (void *) &_PyArrayScalar_BoolValues,
17
+ (void *) &PyGenericArrType_Type,
18
+ (void *) &PyNumberArrType_Type,
19
+ (void *) &PyIntegerArrType_Type,
20
+ (void *) &PySignedIntegerArrType_Type,
21
+ (void *) &PyUnsignedIntegerArrType_Type,
22
+ (void *) &PyInexactArrType_Type,
23
+ (void *) &PyFloatingArrType_Type,
24
+ (void *) &PyComplexFloatingArrType_Type,
25
+ (void *) &PyFlexibleArrType_Type,
26
+ (void *) &PyCharacterArrType_Type,
27
+ (void *) &PyByteArrType_Type,
28
+ (void *) &PyShortArrType_Type,
29
+ (void *) &PyIntArrType_Type,
30
+ (void *) &PyLongArrType_Type,
31
+ (void *) &PyLongLongArrType_Type,
32
+ (void *) &PyUByteArrType_Type,
33
+ (void *) &PyUShortArrType_Type,
34
+ (void *) &PyUIntArrType_Type,
35
+ (void *) &PyULongArrType_Type,
36
+ (void *) &PyULongLongArrType_Type,
37
+ (void *) &PyFloatArrType_Type,
38
+ (void *) &PyDoubleArrType_Type,
39
+ (void *) &PyLongDoubleArrType_Type,
40
+ (void *) &PyCFloatArrType_Type,
41
+ (void *) &PyCDoubleArrType_Type,
42
+ (void *) &PyCLongDoubleArrType_Type,
43
+ (void *) &PyObjectArrType_Type,
44
+ (void *) &PyStringArrType_Type,
45
+ (void *) &PyUnicodeArrType_Type,
46
+ (void *) &PyVoidArrType_Type,
47
+ NULL,
48
+ NULL,
49
+ (void *) PyArray_INCREF,
50
+ (void *) PyArray_XDECREF,
51
+ (void *) PyArray_SetStringFunction,
52
+ (void *) PyArray_DescrFromType,
53
+ (void *) PyArray_TypeObjectFromType,
54
+ (void *) PyArray_Zero,
55
+ (void *) PyArray_One,
56
+ (void *) PyArray_CastToType,
57
+ (void *) PyArray_CopyInto,
58
+ (void *) PyArray_CopyAnyInto,
59
+ (void *) PyArray_CanCastSafely,
60
+ (void *) PyArray_CanCastTo,
61
+ (void *) PyArray_ObjectType,
62
+ (void *) PyArray_DescrFromObject,
63
+ (void *) PyArray_ConvertToCommonType,
64
+ (void *) PyArray_DescrFromScalar,
65
+ (void *) PyArray_DescrFromTypeObject,
66
+ (void *) PyArray_Size,
67
+ (void *) PyArray_Scalar,
68
+ (void *) PyArray_FromScalar,
69
+ (void *) PyArray_ScalarAsCtype,
70
+ (void *) PyArray_CastScalarToCtype,
71
+ (void *) PyArray_CastScalarDirect,
72
+ (void *) PyArray_Pack,
73
+ NULL,
74
+ NULL,
75
+ NULL,
76
+ (void *) PyArray_FromAny,
77
+ (void *) PyArray_EnsureArray,
78
+ (void *) PyArray_EnsureAnyArray,
79
+ (void *) PyArray_FromFile,
80
+ (void *) PyArray_FromString,
81
+ (void *) PyArray_FromBuffer,
82
+ (void *) PyArray_FromIter,
83
+ (void *) PyArray_Return,
84
+ (void *) PyArray_GetField,
85
+ (void *) PyArray_SetField,
86
+ (void *) PyArray_Byteswap,
87
+ (void *) PyArray_Resize,
88
+ NULL,
89
+ NULL,
90
+ NULL,
91
+ (void *) PyArray_CopyObject,
92
+ (void *) PyArray_NewCopy,
93
+ (void *) PyArray_ToList,
94
+ (void *) PyArray_ToString,
95
+ (void *) PyArray_ToFile,
96
+ (void *) PyArray_Dump,
97
+ (void *) PyArray_Dumps,
98
+ (void *) PyArray_ValidType,
99
+ (void *) PyArray_UpdateFlags,
100
+ (void *) PyArray_New,
101
+ (void *) PyArray_NewFromDescr,
102
+ (void *) PyArray_DescrNew,
103
+ (void *) PyArray_DescrNewFromType,
104
+ (void *) PyArray_GetPriority,
105
+ (void *) PyArray_IterNew,
106
+ (void *) PyArray_MultiIterNew,
107
+ (void *) PyArray_PyIntAsInt,
108
+ (void *) PyArray_PyIntAsIntp,
109
+ (void *) PyArray_Broadcast,
110
+ NULL,
111
+ (void *) PyArray_FillWithScalar,
112
+ (void *) PyArray_CheckStrides,
113
+ (void *) PyArray_DescrNewByteorder,
114
+ (void *) PyArray_IterAllButAxis,
115
+ (void *) PyArray_CheckFromAny,
116
+ (void *) PyArray_FromArray,
117
+ (void *) PyArray_FromInterface,
118
+ (void *) PyArray_FromStructInterface,
119
+ (void *) PyArray_FromArrayAttr,
120
+ (void *) PyArray_ScalarKind,
121
+ (void *) PyArray_CanCoerceScalar,
122
+ NULL,
123
+ (void *) PyArray_CanCastScalar,
124
+ NULL,
125
+ (void *) PyArray_RemoveSmallest,
126
+ (void *) PyArray_ElementStrides,
127
+ (void *) PyArray_Item_INCREF,
128
+ (void *) PyArray_Item_XDECREF,
129
+ NULL,
130
+ (void *) PyArray_Transpose,
131
+ (void *) PyArray_TakeFrom,
132
+ (void *) PyArray_PutTo,
133
+ (void *) PyArray_PutMask,
134
+ (void *) PyArray_Repeat,
135
+ (void *) PyArray_Choose,
136
+ (void *) PyArray_Sort,
137
+ (void *) PyArray_ArgSort,
138
+ (void *) PyArray_SearchSorted,
139
+ (void *) PyArray_ArgMax,
140
+ (void *) PyArray_ArgMin,
141
+ (void *) PyArray_Reshape,
142
+ (void *) PyArray_Newshape,
143
+ (void *) PyArray_Squeeze,
144
+ (void *) PyArray_View,
145
+ (void *) PyArray_SwapAxes,
146
+ (void *) PyArray_Max,
147
+ (void *) PyArray_Min,
148
+ (void *) PyArray_Ptp,
149
+ (void *) PyArray_Mean,
150
+ (void *) PyArray_Trace,
151
+ (void *) PyArray_Diagonal,
152
+ (void *) PyArray_Clip,
153
+ (void *) PyArray_Conjugate,
154
+ (void *) PyArray_Nonzero,
155
+ (void *) PyArray_Std,
156
+ (void *) PyArray_Sum,
157
+ (void *) PyArray_CumSum,
158
+ (void *) PyArray_Prod,
159
+ (void *) PyArray_CumProd,
160
+ (void *) PyArray_All,
161
+ (void *) PyArray_Any,
162
+ (void *) PyArray_Compress,
163
+ (void *) PyArray_Flatten,
164
+ (void *) PyArray_Ravel,
165
+ (void *) PyArray_MultiplyList,
166
+ (void *) PyArray_MultiplyIntList,
167
+ (void *) PyArray_GetPtr,
168
+ (void *) PyArray_CompareLists,
169
+ (void *) PyArray_AsCArray,
170
+ NULL,
171
+ NULL,
172
+ (void *) PyArray_Free,
173
+ (void *) PyArray_Converter,
174
+ (void *) PyArray_IntpFromSequence,
175
+ (void *) PyArray_Concatenate,
176
+ (void *) PyArray_InnerProduct,
177
+ (void *) PyArray_MatrixProduct,
178
+ NULL,
179
+ (void *) PyArray_Correlate,
180
+ NULL,
181
+ (void *) PyArray_DescrConverter,
182
+ (void *) PyArray_DescrConverter2,
183
+ (void *) PyArray_IntpConverter,
184
+ (void *) PyArray_BufferConverter,
185
+ (void *) PyArray_AxisConverter,
186
+ (void *) PyArray_BoolConverter,
187
+ (void *) PyArray_ByteorderConverter,
188
+ (void *) PyArray_OrderConverter,
189
+ (void *) PyArray_EquivTypes,
190
+ (void *) PyArray_Zeros,
191
+ (void *) PyArray_Empty,
192
+ (void *) PyArray_Where,
193
+ (void *) PyArray_Arange,
194
+ (void *) PyArray_ArangeObj,
195
+ (void *) PyArray_SortkindConverter,
196
+ (void *) PyArray_LexSort,
197
+ (void *) PyArray_Round,
198
+ (void *) PyArray_EquivTypenums,
199
+ (void *) PyArray_RegisterDataType,
200
+ (void *) PyArray_RegisterCastFunc,
201
+ (void *) PyArray_RegisterCanCast,
202
+ (void *) PyArray_InitArrFuncs,
203
+ (void *) PyArray_IntTupleFromIntp,
204
+ NULL,
205
+ (void *) PyArray_ClipmodeConverter,
206
+ (void *) PyArray_OutputConverter,
207
+ (void *) PyArray_BroadcastToShape,
208
+ NULL,
209
+ NULL,
210
+ (void *) PyArray_DescrAlignConverter,
211
+ (void *) PyArray_DescrAlignConverter2,
212
+ (void *) PyArray_SearchsideConverter,
213
+ (void *) PyArray_CheckAxis,
214
+ (void *) PyArray_OverflowMultiplyList,
215
+ NULL,
216
+ (void *) PyArray_MultiIterFromObjects,
217
+ (void *) PyArray_GetEndianness,
218
+ (void *) PyArray_GetNDArrayCFeatureVersion,
219
+ (void *) PyArray_Correlate2,
220
+ (void *) PyArray_NeighborhoodIterNew,
221
+ (void *) &PyTimeIntegerArrType_Type,
222
+ (void *) &PyDatetimeArrType_Type,
223
+ (void *) &PyTimedeltaArrType_Type,
224
+ (void *) &PyHalfArrType_Type,
225
+ (void *) &NpyIter_Type,
226
+ NULL,
227
+ NULL,
228
+ NULL,
229
+ NULL,
230
+ NULL,
231
+ (void *) NpyIter_New,
232
+ (void *) NpyIter_MultiNew,
233
+ (void *) NpyIter_AdvancedNew,
234
+ (void *) NpyIter_Copy,
235
+ (void *) NpyIter_Deallocate,
236
+ (void *) NpyIter_HasDelayedBufAlloc,
237
+ (void *) NpyIter_HasExternalLoop,
238
+ (void *) NpyIter_EnableExternalLoop,
239
+ (void *) NpyIter_GetInnerStrideArray,
240
+ (void *) NpyIter_GetInnerLoopSizePtr,
241
+ (void *) NpyIter_Reset,
242
+ (void *) NpyIter_ResetBasePointers,
243
+ (void *) NpyIter_ResetToIterIndexRange,
244
+ (void *) NpyIter_GetNDim,
245
+ (void *) NpyIter_GetNOp,
246
+ (void *) NpyIter_GetIterNext,
247
+ (void *) NpyIter_GetIterSize,
248
+ (void *) NpyIter_GetIterIndexRange,
249
+ (void *) NpyIter_GetIterIndex,
250
+ (void *) NpyIter_GotoIterIndex,
251
+ (void *) NpyIter_HasMultiIndex,
252
+ (void *) NpyIter_GetShape,
253
+ (void *) NpyIter_GetGetMultiIndex,
254
+ (void *) NpyIter_GotoMultiIndex,
255
+ (void *) NpyIter_RemoveMultiIndex,
256
+ (void *) NpyIter_HasIndex,
257
+ (void *) NpyIter_IsBuffered,
258
+ (void *) NpyIter_IsGrowInner,
259
+ (void *) NpyIter_GetBufferSize,
260
+ (void *) NpyIter_GetIndexPtr,
261
+ (void *) NpyIter_GotoIndex,
262
+ (void *) NpyIter_GetDataPtrArray,
263
+ (void *) NpyIter_GetDescrArray,
264
+ (void *) NpyIter_GetOperandArray,
265
+ (void *) NpyIter_GetIterView,
266
+ (void *) NpyIter_GetReadFlags,
267
+ (void *) NpyIter_GetWriteFlags,
268
+ (void *) NpyIter_DebugPrint,
269
+ (void *) NpyIter_IterationNeedsAPI,
270
+ (void *) NpyIter_GetInnerFixedStrideArray,
271
+ (void *) NpyIter_RemoveAxis,
272
+ (void *) NpyIter_GetAxisStrideArray,
273
+ (void *) NpyIter_RequiresBuffering,
274
+ (void *) NpyIter_GetInitialDataPtrArray,
275
+ (void *) NpyIter_CreateCompatibleStrides,
276
+ (void *) PyArray_CastingConverter,
277
+ (void *) PyArray_CountNonzero,
278
+ (void *) PyArray_PromoteTypes,
279
+ (void *) PyArray_MinScalarType,
280
+ (void *) PyArray_ResultType,
281
+ (void *) PyArray_CanCastArrayTo,
282
+ (void *) PyArray_CanCastTypeTo,
283
+ (void *) PyArray_EinsteinSum,
284
+ (void *) PyArray_NewLikeArray,
285
+ NULL,
286
+ (void *) PyArray_ConvertClipmodeSequence,
287
+ (void *) PyArray_MatrixProduct2,
288
+ (void *) NpyIter_IsFirstVisit,
289
+ (void *) PyArray_SetBaseObject,
290
+ (void *) PyArray_CreateSortedStridePerm,
291
+ (void *) PyArray_RemoveAxesInPlace,
292
+ (void *) PyArray_DebugPrint,
293
+ (void *) PyArray_FailUnlessWriteable,
294
+ (void *) PyArray_SetUpdateIfCopyBase,
295
+ (void *) PyDataMem_NEW,
296
+ (void *) PyDataMem_FREE,
297
+ (void *) PyDataMem_RENEW,
298
+ NULL,
299
+ (NPY_CASTING *) &NPY_DEFAULT_ASSIGN_CASTING,
300
+ NULL,
301
+ NULL,
302
+ NULL,
303
+ (void *) PyArray_Partition,
304
+ (void *) PyArray_ArgPartition,
305
+ (void *) PyArray_SelectkindConverter,
306
+ (void *) PyDataMem_NEW_ZEROED,
307
+ (void *) PyArray_CheckAnyScalarExact,
308
+ NULL,
309
+ (void *) PyArray_ResolveWritebackIfCopy,
310
+ (void *) PyArray_SetWritebackIfCopyBase,
311
+ (void *) PyDataMem_SetHandler,
312
+ (void *) PyDataMem_GetHandler,
313
+ (PyObject* *) &PyDataMem_DefaultHandler,
314
+ (void *) NpyDatetime_ConvertDatetime64ToDatetimeStruct,
315
+ (void *) NpyDatetime_ConvertDatetimeStructToDatetime64,
316
+ (void *) NpyDatetime_ConvertPyDateTimeToDatetimeStruct,
317
+ (void *) NpyDatetime_GetDatetimeISO8601StrLen,
318
+ (void *) NpyDatetime_MakeISO8601Datetime,
319
+ (void *) NpyDatetime_ParseISO8601Datetime,
320
+ (void *) NpyString_load,
321
+ (void *) NpyString_pack,
322
+ (void *) NpyString_pack_null,
323
+ (void *) NpyString_acquire_allocator,
324
+ (void *) NpyString_acquire_allocators,
325
+ (void *) NpyString_release_allocator,
326
+ (void *) NpyString_release_allocators,
327
+ NULL,
328
+ NULL,
329
+ NULL,
330
+ NULL,
331
+ NULL,
332
+ NULL,
333
+ NULL,
334
+ NULL,
335
+ NULL,
336
+ NULL,
337
+ NULL,
338
+ NULL,
339
+ NULL,
340
+ NULL,
341
+ NULL,
342
+ NULL,
343
+ NULL,
344
+ NULL,
345
+ NULL,
346
+ NULL,
347
+ NULL,
348
+ NULL,
349
+ NULL,
350
+ NULL,
351
+ NULL,
352
+ NULL,
353
+ NULL,
354
+ NULL,
355
+ NULL,
356
+ NULL,
357
+ NULL,
358
+ NULL,
359
+ NULL,
360
+ NULL,
361
+ NULL,
362
+ NULL,
363
+ NULL,
364
+ NULL,
365
+ NULL,
366
+ NULL,
367
+ NULL,
368
+ (void *) PyArray_GetDefaultDescr,
369
+ (void *) PyArrayInitDTypeMeta_FromSpec,
370
+ (void *) PyArray_CommonDType,
371
+ (void *) PyArray_PromoteDTypeSequence,
372
+ (void *) _PyDataType_GetArrFuncs,
373
+ NULL,
374
+ NULL,
375
+ NULL
376
+ };
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__multiarray_api.h ADDED
@@ -0,0 +1,1613 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #if defined(_MULTIARRAYMODULE) || defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
3
+
4
+ typedef struct {
5
+ PyObject_HEAD
6
+ npy_bool obval;
7
+ } PyBoolScalarObject;
8
+
9
+ extern NPY_NO_EXPORT PyTypeObject PyArrayNeighborhoodIter_Type;
10
+ extern NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2];
11
+
12
+ NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion \
13
+ (void);
14
+ extern NPY_NO_EXPORT PyTypeObject PyArray_Type;
15
+
16
+ extern NPY_NO_EXPORT PyArray_DTypeMeta PyArrayDescr_TypeFull;
17
+ #define PyArrayDescr_Type (*(PyTypeObject *)(&PyArrayDescr_TypeFull))
18
+
19
+ extern NPY_NO_EXPORT PyTypeObject PyArrayIter_Type;
20
+
21
+ extern NPY_NO_EXPORT PyTypeObject PyArrayMultiIter_Type;
22
+
23
+ extern NPY_NO_EXPORT int NPY_NUMUSERTYPES;
24
+
25
+ extern NPY_NO_EXPORT PyTypeObject PyBoolArrType_Type;
26
+
27
+ extern NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2];
28
+
29
+ extern NPY_NO_EXPORT PyTypeObject PyGenericArrType_Type;
30
+
31
+ extern NPY_NO_EXPORT PyTypeObject PyNumberArrType_Type;
32
+
33
+ extern NPY_NO_EXPORT PyTypeObject PyIntegerArrType_Type;
34
+
35
+ extern NPY_NO_EXPORT PyTypeObject PySignedIntegerArrType_Type;
36
+
37
+ extern NPY_NO_EXPORT PyTypeObject PyUnsignedIntegerArrType_Type;
38
+
39
+ extern NPY_NO_EXPORT PyTypeObject PyInexactArrType_Type;
40
+
41
+ extern NPY_NO_EXPORT PyTypeObject PyFloatingArrType_Type;
42
+
43
+ extern NPY_NO_EXPORT PyTypeObject PyComplexFloatingArrType_Type;
44
+
45
+ extern NPY_NO_EXPORT PyTypeObject PyFlexibleArrType_Type;
46
+
47
+ extern NPY_NO_EXPORT PyTypeObject PyCharacterArrType_Type;
48
+
49
+ extern NPY_NO_EXPORT PyTypeObject PyByteArrType_Type;
50
+
51
+ extern NPY_NO_EXPORT PyTypeObject PyShortArrType_Type;
52
+
53
+ extern NPY_NO_EXPORT PyTypeObject PyIntArrType_Type;
54
+
55
+ extern NPY_NO_EXPORT PyTypeObject PyLongArrType_Type;
56
+
57
+ extern NPY_NO_EXPORT PyTypeObject PyLongLongArrType_Type;
58
+
59
+ extern NPY_NO_EXPORT PyTypeObject PyUByteArrType_Type;
60
+
61
+ extern NPY_NO_EXPORT PyTypeObject PyUShortArrType_Type;
62
+
63
+ extern NPY_NO_EXPORT PyTypeObject PyUIntArrType_Type;
64
+
65
+ extern NPY_NO_EXPORT PyTypeObject PyULongArrType_Type;
66
+
67
+ extern NPY_NO_EXPORT PyTypeObject PyULongLongArrType_Type;
68
+
69
+ extern NPY_NO_EXPORT PyTypeObject PyFloatArrType_Type;
70
+
71
+ extern NPY_NO_EXPORT PyTypeObject PyDoubleArrType_Type;
72
+
73
+ extern NPY_NO_EXPORT PyTypeObject PyLongDoubleArrType_Type;
74
+
75
+ extern NPY_NO_EXPORT PyTypeObject PyCFloatArrType_Type;
76
+
77
+ extern NPY_NO_EXPORT PyTypeObject PyCDoubleArrType_Type;
78
+
79
+ extern NPY_NO_EXPORT PyTypeObject PyCLongDoubleArrType_Type;
80
+
81
+ extern NPY_NO_EXPORT PyTypeObject PyObjectArrType_Type;
82
+
83
+ extern NPY_NO_EXPORT PyTypeObject PyStringArrType_Type;
84
+
85
+ extern NPY_NO_EXPORT PyTypeObject PyUnicodeArrType_Type;
86
+
87
+ extern NPY_NO_EXPORT PyTypeObject PyVoidArrType_Type;
88
+
89
+ NPY_NO_EXPORT int PyArray_INCREF \
90
+ (PyArrayObject *);
91
+ NPY_NO_EXPORT int PyArray_XDECREF \
92
+ (PyArrayObject *);
93
+ NPY_NO_EXPORT void PyArray_SetStringFunction \
94
+ (PyObject *, int);
95
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromType \
96
+ (int);
97
+ NPY_NO_EXPORT PyObject * PyArray_TypeObjectFromType \
98
+ (int);
99
+ NPY_NO_EXPORT char * PyArray_Zero \
100
+ (PyArrayObject *);
101
+ NPY_NO_EXPORT char * PyArray_One \
102
+ (PyArrayObject *);
103
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_CastToType \
104
+ (PyArrayObject *, PyArray_Descr *, int);
105
+ NPY_NO_EXPORT int PyArray_CopyInto \
106
+ (PyArrayObject *, PyArrayObject *);
107
+ NPY_NO_EXPORT int PyArray_CopyAnyInto \
108
+ (PyArrayObject *, PyArrayObject *);
109
+ NPY_NO_EXPORT int PyArray_CanCastSafely \
110
+ (int, int);
111
+ NPY_NO_EXPORT npy_bool PyArray_CanCastTo \
112
+ (PyArray_Descr *, PyArray_Descr *);
113
+ NPY_NO_EXPORT int PyArray_ObjectType \
114
+ (PyObject *, int);
115
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromObject \
116
+ (PyObject *, PyArray_Descr *);
117
+ NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType \
118
+ (PyObject *, int *);
119
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromScalar \
120
+ (PyObject *);
121
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromTypeObject \
122
+ (PyObject *);
123
+ NPY_NO_EXPORT npy_intp PyArray_Size \
124
+ (PyObject *);
125
+ NPY_NO_EXPORT PyObject * PyArray_Scalar \
126
+ (void *, PyArray_Descr *, PyObject *);
127
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromScalar \
128
+ (PyObject *, PyArray_Descr *);
129
+ NPY_NO_EXPORT void PyArray_ScalarAsCtype \
130
+ (PyObject *, void *);
131
+ NPY_NO_EXPORT int PyArray_CastScalarToCtype \
132
+ (PyObject *, void *, PyArray_Descr *);
133
+ NPY_NO_EXPORT int PyArray_CastScalarDirect \
134
+ (PyObject *, PyArray_Descr *, void *, int);
135
+ NPY_NO_EXPORT int PyArray_Pack \
136
+ (PyArray_Descr *, void *, PyObject *);
137
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromAny \
138
+ (PyObject *, PyArray_Descr *, int, int, int, PyObject *);
139
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureArray \
140
+ (PyObject *);
141
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureAnyArray \
142
+ (PyObject *);
143
+ NPY_NO_EXPORT PyObject * PyArray_FromFile \
144
+ (FILE *, PyArray_Descr *, npy_intp, char *);
145
+ NPY_NO_EXPORT PyObject * PyArray_FromString \
146
+ (char *, npy_intp, PyArray_Descr *, npy_intp, char *);
147
+ NPY_NO_EXPORT PyObject * PyArray_FromBuffer \
148
+ (PyObject *, PyArray_Descr *, npy_intp, npy_intp);
149
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromIter \
150
+ (PyObject *, PyArray_Descr *, npy_intp);
151
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_Return \
152
+ (PyArrayObject *);
153
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_GetField \
154
+ (PyArrayObject *, PyArray_Descr *, int);
155
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetField \
156
+ (PyArrayObject *, PyArray_Descr *, int, PyObject *);
157
+ NPY_NO_EXPORT PyObject * PyArray_Byteswap \
158
+ (PyArrayObject *, npy_bool);
159
+ NPY_NO_EXPORT PyObject * PyArray_Resize \
160
+ (PyArrayObject *, PyArray_Dims *, int, NPY_ORDER NPY_UNUSED(order));
161
+ NPY_NO_EXPORT int PyArray_CopyObject \
162
+ (PyArrayObject *, PyObject *);
163
+ NPY_NO_EXPORT PyObject * PyArray_NewCopy \
164
+ (PyArrayObject *, NPY_ORDER);
165
+ NPY_NO_EXPORT PyObject * PyArray_ToList \
166
+ (PyArrayObject *);
167
+ NPY_NO_EXPORT PyObject * PyArray_ToString \
168
+ (PyArrayObject *, NPY_ORDER);
169
+ NPY_NO_EXPORT int PyArray_ToFile \
170
+ (PyArrayObject *, FILE *, char *, char *);
171
+ NPY_NO_EXPORT int PyArray_Dump \
172
+ (PyObject *, PyObject *, int);
173
+ NPY_NO_EXPORT PyObject * PyArray_Dumps \
174
+ (PyObject *, int);
175
+ NPY_NO_EXPORT int PyArray_ValidType \
176
+ (int);
177
+ NPY_NO_EXPORT void PyArray_UpdateFlags \
178
+ (PyArrayObject *, int);
179
+ NPY_NO_EXPORT PyObject * PyArray_New \
180
+ (PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *);
181
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_NewFromDescr \
182
+ (PyTypeObject *, PyArray_Descr *, int, npy_intp const *, npy_intp const *, void *, int, PyObject *);
183
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNew \
184
+ (PyArray_Descr *);
185
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewFromType \
186
+ (int);
187
+ NPY_NO_EXPORT double PyArray_GetPriority \
188
+ (PyObject *, double);
189
+ NPY_NO_EXPORT PyObject * PyArray_IterNew \
190
+ (PyObject *);
191
+ NPY_NO_EXPORT PyObject* PyArray_MultiIterNew \
192
+ (int, ...);
193
+ NPY_NO_EXPORT int PyArray_PyIntAsInt \
194
+ (PyObject *);
195
+ NPY_NO_EXPORT npy_intp PyArray_PyIntAsIntp \
196
+ (PyObject *);
197
+ NPY_NO_EXPORT int PyArray_Broadcast \
198
+ (PyArrayMultiIterObject *);
199
+ NPY_NO_EXPORT int PyArray_FillWithScalar \
200
+ (PyArrayObject *, PyObject *);
201
+ NPY_NO_EXPORT npy_bool PyArray_CheckStrides \
202
+ (int, int, npy_intp, npy_intp, npy_intp const *, npy_intp const *);
203
+ NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewByteorder \
204
+ (PyArray_Descr *, char);
205
+ NPY_NO_EXPORT PyObject * PyArray_IterAllButAxis \
206
+ (PyObject *, int *);
207
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_CheckFromAny \
208
+ (PyObject *, PyArray_Descr *, int, int, int, PyObject *);
209
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromArray \
210
+ (PyArrayObject *, PyArray_Descr *, int);
211
+ NPY_NO_EXPORT PyObject * PyArray_FromInterface \
212
+ (PyObject *);
213
+ NPY_NO_EXPORT PyObject * PyArray_FromStructInterface \
214
+ (PyObject *);
215
+ NPY_NO_EXPORT PyObject * PyArray_FromArrayAttr \
216
+ (PyObject *, PyArray_Descr *, PyObject *);
217
+ NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind \
218
+ (int, PyArrayObject **);
219
+ NPY_NO_EXPORT int PyArray_CanCoerceScalar \
220
+ (int, int, NPY_SCALARKIND);
221
+ NPY_NO_EXPORT npy_bool PyArray_CanCastScalar \
222
+ (PyTypeObject *, PyTypeObject *);
223
+ NPY_NO_EXPORT int PyArray_RemoveSmallest \
224
+ (PyArrayMultiIterObject *);
225
+ NPY_NO_EXPORT int PyArray_ElementStrides \
226
+ (PyObject *);
227
+ NPY_NO_EXPORT void PyArray_Item_INCREF \
228
+ (char *, PyArray_Descr *);
229
+ NPY_NO_EXPORT void PyArray_Item_XDECREF \
230
+ (char *, PyArray_Descr *);
231
+ NPY_NO_EXPORT PyObject * PyArray_Transpose \
232
+ (PyArrayObject *, PyArray_Dims *);
233
+ NPY_NO_EXPORT PyObject * PyArray_TakeFrom \
234
+ (PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE);
235
+ NPY_NO_EXPORT PyObject * PyArray_PutTo \
236
+ (PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE);
237
+ NPY_NO_EXPORT PyObject * PyArray_PutMask \
238
+ (PyArrayObject *, PyObject*, PyObject*);
239
+ NPY_NO_EXPORT PyObject * PyArray_Repeat \
240
+ (PyArrayObject *, PyObject *, int);
241
+ NPY_NO_EXPORT PyObject * PyArray_Choose \
242
+ (PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE);
243
+ NPY_NO_EXPORT int PyArray_Sort \
244
+ (PyArrayObject *, int, NPY_SORTKIND);
245
+ NPY_NO_EXPORT PyObject * PyArray_ArgSort \
246
+ (PyArrayObject *, int, NPY_SORTKIND);
247
+ NPY_NO_EXPORT PyObject * PyArray_SearchSorted \
248
+ (PyArrayObject *, PyObject *, NPY_SEARCHSIDE, PyObject *);
249
+ NPY_NO_EXPORT PyObject * PyArray_ArgMax \
250
+ (PyArrayObject *, int, PyArrayObject *);
251
+ NPY_NO_EXPORT PyObject * PyArray_ArgMin \
252
+ (PyArrayObject *, int, PyArrayObject *);
253
+ NPY_NO_EXPORT PyObject * PyArray_Reshape \
254
+ (PyArrayObject *, PyObject *);
255
+ NPY_NO_EXPORT PyObject * PyArray_Newshape \
256
+ (PyArrayObject *, PyArray_Dims *, NPY_ORDER);
257
+ NPY_NO_EXPORT PyObject * PyArray_Squeeze \
258
+ (PyArrayObject *);
259
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_View \
260
+ (PyArrayObject *, PyArray_Descr *, PyTypeObject *);
261
+ NPY_NO_EXPORT PyObject * PyArray_SwapAxes \
262
+ (PyArrayObject *, int, int);
263
+ NPY_NO_EXPORT PyObject * PyArray_Max \
264
+ (PyArrayObject *, int, PyArrayObject *);
265
+ NPY_NO_EXPORT PyObject * PyArray_Min \
266
+ (PyArrayObject *, int, PyArrayObject *);
267
+ NPY_NO_EXPORT PyObject * PyArray_Ptp \
268
+ (PyArrayObject *, int, PyArrayObject *);
269
+ NPY_NO_EXPORT PyObject * PyArray_Mean \
270
+ (PyArrayObject *, int, int, PyArrayObject *);
271
+ NPY_NO_EXPORT PyObject * PyArray_Trace \
272
+ (PyArrayObject *, int, int, int, int, PyArrayObject *);
273
+ NPY_NO_EXPORT PyObject * PyArray_Diagonal \
274
+ (PyArrayObject *, int, int, int);
275
+ NPY_NO_EXPORT PyObject * PyArray_Clip \
276
+ (PyArrayObject *, PyObject *, PyObject *, PyArrayObject *);
277
+ NPY_NO_EXPORT PyObject * PyArray_Conjugate \
278
+ (PyArrayObject *, PyArrayObject *);
279
+ NPY_NO_EXPORT PyObject * PyArray_Nonzero \
280
+ (PyArrayObject *);
281
+ NPY_NO_EXPORT PyObject * PyArray_Std \
282
+ (PyArrayObject *, int, int, PyArrayObject *, int);
283
+ NPY_NO_EXPORT PyObject * PyArray_Sum \
284
+ (PyArrayObject *, int, int, PyArrayObject *);
285
+ NPY_NO_EXPORT PyObject * PyArray_CumSum \
286
+ (PyArrayObject *, int, int, PyArrayObject *);
287
+ NPY_NO_EXPORT PyObject * PyArray_Prod \
288
+ (PyArrayObject *, int, int, PyArrayObject *);
289
+ NPY_NO_EXPORT PyObject * PyArray_CumProd \
290
+ (PyArrayObject *, int, int, PyArrayObject *);
291
+ NPY_NO_EXPORT PyObject * PyArray_All \
292
+ (PyArrayObject *, int, PyArrayObject *);
293
+ NPY_NO_EXPORT PyObject * PyArray_Any \
294
+ (PyArrayObject *, int, PyArrayObject *);
295
+ NPY_NO_EXPORT PyObject * PyArray_Compress \
296
+ (PyArrayObject *, PyObject *, int, PyArrayObject *);
297
+ NPY_NO_EXPORT PyObject * PyArray_Flatten \
298
+ (PyArrayObject *, NPY_ORDER);
299
+ NPY_NO_EXPORT PyObject * PyArray_Ravel \
300
+ (PyArrayObject *, NPY_ORDER);
301
+ NPY_NO_EXPORT npy_intp PyArray_MultiplyList \
302
+ (npy_intp const *, int);
303
+ NPY_NO_EXPORT int PyArray_MultiplyIntList \
304
+ (int const *, int);
305
+ NPY_NO_EXPORT void * PyArray_GetPtr \
306
+ (PyArrayObject *, npy_intp const*);
307
+ NPY_NO_EXPORT int PyArray_CompareLists \
308
+ (npy_intp const *, npy_intp const *, int);
309
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(5) int PyArray_AsCArray \
310
+ (PyObject **, void *, npy_intp *, int, PyArray_Descr*);
311
+ NPY_NO_EXPORT int PyArray_Free \
312
+ (PyObject *, void *);
313
+ NPY_NO_EXPORT int PyArray_Converter \
314
+ (PyObject *, PyObject **);
315
+ NPY_NO_EXPORT int PyArray_IntpFromSequence \
316
+ (PyObject *, npy_intp *, int);
317
+ NPY_NO_EXPORT PyObject * PyArray_Concatenate \
318
+ (PyObject *, int);
319
+ NPY_NO_EXPORT PyObject * PyArray_InnerProduct \
320
+ (PyObject *, PyObject *);
321
+ NPY_NO_EXPORT PyObject * PyArray_MatrixProduct \
322
+ (PyObject *, PyObject *);
323
+ NPY_NO_EXPORT PyObject * PyArray_Correlate \
324
+ (PyObject *, PyObject *, int);
325
+ NPY_NO_EXPORT int PyArray_DescrConverter \
326
+ (PyObject *, PyArray_Descr **);
327
+ NPY_NO_EXPORT int PyArray_DescrConverter2 \
328
+ (PyObject *, PyArray_Descr **);
329
+ NPY_NO_EXPORT int PyArray_IntpConverter \
330
+ (PyObject *, PyArray_Dims *);
331
+ NPY_NO_EXPORT int PyArray_BufferConverter \
332
+ (PyObject *, PyArray_Chunk *);
333
+ NPY_NO_EXPORT int PyArray_AxisConverter \
334
+ (PyObject *, int *);
335
+ NPY_NO_EXPORT int PyArray_BoolConverter \
336
+ (PyObject *, npy_bool *);
337
+ NPY_NO_EXPORT int PyArray_ByteorderConverter \
338
+ (PyObject *, char *);
339
+ NPY_NO_EXPORT int PyArray_OrderConverter \
340
+ (PyObject *, NPY_ORDER *);
341
+ NPY_NO_EXPORT unsigned char PyArray_EquivTypes \
342
+ (PyArray_Descr *, PyArray_Descr *);
343
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Zeros \
344
+ (int, npy_intp const *, PyArray_Descr *, int);
345
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Empty \
346
+ (int, npy_intp const *, PyArray_Descr *, int);
347
+ NPY_NO_EXPORT PyObject * PyArray_Where \
348
+ (PyObject *, PyObject *, PyObject *);
349
+ NPY_NO_EXPORT PyObject * PyArray_Arange \
350
+ (double, double, double, int);
351
+ NPY_NO_EXPORT PyObject * PyArray_ArangeObj \
352
+ (PyObject *, PyObject *, PyObject *, PyArray_Descr *);
353
+ NPY_NO_EXPORT int PyArray_SortkindConverter \
354
+ (PyObject *, NPY_SORTKIND *);
355
+ NPY_NO_EXPORT PyObject * PyArray_LexSort \
356
+ (PyObject *, int);
357
+ NPY_NO_EXPORT PyObject * PyArray_Round \
358
+ (PyArrayObject *, int, PyArrayObject *);
359
+ NPY_NO_EXPORT unsigned char PyArray_EquivTypenums \
360
+ (int, int);
361
+ NPY_NO_EXPORT int PyArray_RegisterDataType \
362
+ (PyArray_DescrProto *);
363
+ NPY_NO_EXPORT int PyArray_RegisterCastFunc \
364
+ (PyArray_Descr *, int, PyArray_VectorUnaryFunc *);
365
+ NPY_NO_EXPORT int PyArray_RegisterCanCast \
366
+ (PyArray_Descr *, int, NPY_SCALARKIND);
367
+ NPY_NO_EXPORT void PyArray_InitArrFuncs \
368
+ (PyArray_ArrFuncs *);
369
+ NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp \
370
+ (int, npy_intp const *);
371
+ NPY_NO_EXPORT int PyArray_ClipmodeConverter \
372
+ (PyObject *, NPY_CLIPMODE *);
373
+ NPY_NO_EXPORT int PyArray_OutputConverter \
374
+ (PyObject *, PyArrayObject **);
375
+ NPY_NO_EXPORT PyObject * PyArray_BroadcastToShape \
376
+ (PyObject *, npy_intp *, int);
377
+ NPY_NO_EXPORT int PyArray_DescrAlignConverter \
378
+ (PyObject *, PyArray_Descr **);
379
+ NPY_NO_EXPORT int PyArray_DescrAlignConverter2 \
380
+ (PyObject *, PyArray_Descr **);
381
+ NPY_NO_EXPORT int PyArray_SearchsideConverter \
382
+ (PyObject *, void *);
383
+ NPY_NO_EXPORT PyObject * PyArray_CheckAxis \
384
+ (PyArrayObject *, int *, int);
385
+ NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList \
386
+ (npy_intp const *, int);
387
+ NPY_NO_EXPORT PyObject* PyArray_MultiIterFromObjects \
388
+ (PyObject **, int, int, ...);
389
+ NPY_NO_EXPORT int PyArray_GetEndianness \
390
+ (void);
391
+ NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion \
392
+ (void);
393
+ NPY_NO_EXPORT PyObject * PyArray_Correlate2 \
394
+ (PyObject *, PyObject *, int);
395
+ NPY_NO_EXPORT PyObject* PyArray_NeighborhoodIterNew \
396
+ (PyArrayIterObject *, const npy_intp *, int, PyArrayObject*);
397
+ extern NPY_NO_EXPORT PyTypeObject PyTimeIntegerArrType_Type;
398
+
399
+ extern NPY_NO_EXPORT PyTypeObject PyDatetimeArrType_Type;
400
+
401
+ extern NPY_NO_EXPORT PyTypeObject PyTimedeltaArrType_Type;
402
+
403
+ extern NPY_NO_EXPORT PyTypeObject PyHalfArrType_Type;
404
+
405
+ extern NPY_NO_EXPORT PyTypeObject NpyIter_Type;
406
+
407
+ NPY_NO_EXPORT NpyIter * NpyIter_New \
408
+ (PyArrayObject *, npy_uint32, NPY_ORDER, NPY_CASTING, PyArray_Descr*);
409
+ NPY_NO_EXPORT NpyIter * NpyIter_MultiNew \
410
+ (int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **);
411
+ NPY_NO_EXPORT NpyIter * NpyIter_AdvancedNew \
412
+ (int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **, int, int **, npy_intp *, npy_intp);
413
+ NPY_NO_EXPORT NpyIter * NpyIter_Copy \
414
+ (NpyIter *);
415
+ NPY_NO_EXPORT int NpyIter_Deallocate \
416
+ (NpyIter *);
417
+ NPY_NO_EXPORT npy_bool NpyIter_HasDelayedBufAlloc \
418
+ (NpyIter *);
419
+ NPY_NO_EXPORT npy_bool NpyIter_HasExternalLoop \
420
+ (NpyIter *);
421
+ NPY_NO_EXPORT int NpyIter_EnableExternalLoop \
422
+ (NpyIter *);
423
+ NPY_NO_EXPORT npy_intp * NpyIter_GetInnerStrideArray \
424
+ (NpyIter *);
425
+ NPY_NO_EXPORT npy_intp * NpyIter_GetInnerLoopSizePtr \
426
+ (NpyIter *);
427
+ NPY_NO_EXPORT int NpyIter_Reset \
428
+ (NpyIter *, char **);
429
+ NPY_NO_EXPORT int NpyIter_ResetBasePointers \
430
+ (NpyIter *, char **, char **);
431
+ NPY_NO_EXPORT int NpyIter_ResetToIterIndexRange \
432
+ (NpyIter *, npy_intp, npy_intp, char **);
433
+ NPY_NO_EXPORT int NpyIter_GetNDim \
434
+ (NpyIter *);
435
+ NPY_NO_EXPORT int NpyIter_GetNOp \
436
+ (NpyIter *);
437
+ NPY_NO_EXPORT NpyIter_IterNextFunc * NpyIter_GetIterNext \
438
+ (NpyIter *, char **);
439
+ NPY_NO_EXPORT npy_intp NpyIter_GetIterSize \
440
+ (NpyIter *);
441
+ NPY_NO_EXPORT void NpyIter_GetIterIndexRange \
442
+ (NpyIter *, npy_intp *, npy_intp *);
443
+ NPY_NO_EXPORT npy_intp NpyIter_GetIterIndex \
444
+ (NpyIter *);
445
+ NPY_NO_EXPORT int NpyIter_GotoIterIndex \
446
+ (NpyIter *, npy_intp);
447
+ NPY_NO_EXPORT npy_bool NpyIter_HasMultiIndex \
448
+ (NpyIter *);
449
+ NPY_NO_EXPORT int NpyIter_GetShape \
450
+ (NpyIter *, npy_intp *);
451
+ NPY_NO_EXPORT NpyIter_GetMultiIndexFunc * NpyIter_GetGetMultiIndex \
452
+ (NpyIter *, char **);
453
+ NPY_NO_EXPORT int NpyIter_GotoMultiIndex \
454
+ (NpyIter *, npy_intp const *);
455
+ NPY_NO_EXPORT int NpyIter_RemoveMultiIndex \
456
+ (NpyIter *);
457
+ NPY_NO_EXPORT npy_bool NpyIter_HasIndex \
458
+ (NpyIter *);
459
+ NPY_NO_EXPORT npy_bool NpyIter_IsBuffered \
460
+ (NpyIter *);
461
+ NPY_NO_EXPORT npy_bool NpyIter_IsGrowInner \
462
+ (NpyIter *);
463
+ NPY_NO_EXPORT npy_intp NpyIter_GetBufferSize \
464
+ (NpyIter *);
465
+ NPY_NO_EXPORT npy_intp * NpyIter_GetIndexPtr \
466
+ (NpyIter *);
467
+ NPY_NO_EXPORT int NpyIter_GotoIndex \
468
+ (NpyIter *, npy_intp);
469
+ NPY_NO_EXPORT char ** NpyIter_GetDataPtrArray \
470
+ (NpyIter *);
471
+ NPY_NO_EXPORT PyArray_Descr ** NpyIter_GetDescrArray \
472
+ (NpyIter *);
473
+ NPY_NO_EXPORT PyArrayObject ** NpyIter_GetOperandArray \
474
+ (NpyIter *);
475
+ NPY_NO_EXPORT PyArrayObject * NpyIter_GetIterView \
476
+ (NpyIter *, npy_intp);
477
+ NPY_NO_EXPORT void NpyIter_GetReadFlags \
478
+ (NpyIter *, char *);
479
+ NPY_NO_EXPORT void NpyIter_GetWriteFlags \
480
+ (NpyIter *, char *);
481
+ NPY_NO_EXPORT void NpyIter_DebugPrint \
482
+ (NpyIter *);
483
+ NPY_NO_EXPORT npy_bool NpyIter_IterationNeedsAPI \
484
+ (NpyIter *);
485
+ NPY_NO_EXPORT void NpyIter_GetInnerFixedStrideArray \
486
+ (NpyIter *, npy_intp *);
487
+ NPY_NO_EXPORT int NpyIter_RemoveAxis \
488
+ (NpyIter *, int);
489
+ NPY_NO_EXPORT npy_intp * NpyIter_GetAxisStrideArray \
490
+ (NpyIter *, int);
491
+ NPY_NO_EXPORT npy_bool NpyIter_RequiresBuffering \
492
+ (NpyIter *);
493
+ NPY_NO_EXPORT char ** NpyIter_GetInitialDataPtrArray \
494
+ (NpyIter *);
495
+ NPY_NO_EXPORT int NpyIter_CreateCompatibleStrides \
496
+ (NpyIter *, npy_intp, npy_intp *);
497
+ NPY_NO_EXPORT int PyArray_CastingConverter \
498
+ (PyObject *, NPY_CASTING *);
499
+ NPY_NO_EXPORT npy_intp PyArray_CountNonzero \
500
+ (PyArrayObject *);
501
+ NPY_NO_EXPORT PyArray_Descr * PyArray_PromoteTypes \
502
+ (PyArray_Descr *, PyArray_Descr *);
503
+ NPY_NO_EXPORT PyArray_Descr * PyArray_MinScalarType \
504
+ (PyArrayObject *);
505
+ NPY_NO_EXPORT PyArray_Descr * PyArray_ResultType \
506
+ (npy_intp, PyArrayObject *arrs[], npy_intp, PyArray_Descr *descrs[]);
507
+ NPY_NO_EXPORT npy_bool PyArray_CanCastArrayTo \
508
+ (PyArrayObject *, PyArray_Descr *, NPY_CASTING);
509
+ NPY_NO_EXPORT npy_bool PyArray_CanCastTypeTo \
510
+ (PyArray_Descr *, PyArray_Descr *, NPY_CASTING);
511
+ NPY_NO_EXPORT PyArrayObject * PyArray_EinsteinSum \
512
+ (char *, npy_intp, PyArrayObject **, PyArray_Descr *, NPY_ORDER, NPY_CASTING, PyArrayObject *);
513
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_NewLikeArray \
514
+ (PyArrayObject *, NPY_ORDER, PyArray_Descr *, int);
515
+ NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence \
516
+ (PyObject *, NPY_CLIPMODE *, int);
517
+ NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 \
518
+ (PyObject *, PyObject *, PyArrayObject*);
519
+ NPY_NO_EXPORT npy_bool NpyIter_IsFirstVisit \
520
+ (NpyIter *, int);
521
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetBaseObject \
522
+ (PyArrayObject *, PyObject *);
523
+ NPY_NO_EXPORT void PyArray_CreateSortedStridePerm \
524
+ (int, npy_intp const *, npy_stride_sort_item *);
525
+ NPY_NO_EXPORT void PyArray_RemoveAxesInPlace \
526
+ (PyArrayObject *, const npy_bool *);
527
+ NPY_NO_EXPORT void PyArray_DebugPrint \
528
+ (PyArrayObject *);
529
+ NPY_NO_EXPORT int PyArray_FailUnlessWriteable \
530
+ (PyArrayObject *, const char *);
531
+ NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetUpdateIfCopyBase \
532
+ (PyArrayObject *, PyArrayObject *);
533
+ NPY_NO_EXPORT void * PyDataMem_NEW \
534
+ (size_t);
535
+ NPY_NO_EXPORT void PyDataMem_FREE \
536
+ (void *);
537
+ NPY_NO_EXPORT void * PyDataMem_RENEW \
538
+ (void *, size_t);
539
+ extern NPY_NO_EXPORT NPY_CASTING NPY_DEFAULT_ASSIGN_CASTING;
540
+
541
+ NPY_NO_EXPORT int PyArray_Partition \
542
+ (PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND);
543
+ NPY_NO_EXPORT PyObject * PyArray_ArgPartition \
544
+ (PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND);
545
+ NPY_NO_EXPORT int PyArray_SelectkindConverter \
546
+ (PyObject *, NPY_SELECTKIND *);
547
+ NPY_NO_EXPORT void * PyDataMem_NEW_ZEROED \
548
+ (size_t, size_t);
549
+ NPY_NO_EXPORT int PyArray_CheckAnyScalarExact \
550
+ (PyObject *);
551
+ NPY_NO_EXPORT int PyArray_ResolveWritebackIfCopy \
552
+ (PyArrayObject *);
553
+ NPY_NO_EXPORT int PyArray_SetWritebackIfCopyBase \
554
+ (PyArrayObject *, PyArrayObject *);
555
+ NPY_NO_EXPORT PyObject * PyDataMem_SetHandler \
556
+ (PyObject *);
557
+ NPY_NO_EXPORT PyObject * PyDataMem_GetHandler \
558
+ (void);
559
+ extern NPY_NO_EXPORT PyObject* PyDataMem_DefaultHandler;
560
+
561
+ NPY_NO_EXPORT int NpyDatetime_ConvertDatetime64ToDatetimeStruct \
562
+ (PyArray_DatetimeMetaData *, npy_datetime, npy_datetimestruct *);
563
+ NPY_NO_EXPORT int NpyDatetime_ConvertDatetimeStructToDatetime64 \
564
+ (PyArray_DatetimeMetaData *, const npy_datetimestruct *, npy_datetime *);
565
+ NPY_NO_EXPORT int NpyDatetime_ConvertPyDateTimeToDatetimeStruct \
566
+ (PyObject *, npy_datetimestruct *, NPY_DATETIMEUNIT *, int);
567
+ NPY_NO_EXPORT int NpyDatetime_GetDatetimeISO8601StrLen \
568
+ (int, NPY_DATETIMEUNIT);
569
+ NPY_NO_EXPORT int NpyDatetime_MakeISO8601Datetime \
570
+ (npy_datetimestruct *, char *, npy_intp, int, int, NPY_DATETIMEUNIT, int, NPY_CASTING);
571
+ NPY_NO_EXPORT int NpyDatetime_ParseISO8601Datetime \
572
+ (char const *, Py_ssize_t, NPY_DATETIMEUNIT, NPY_CASTING, npy_datetimestruct *, NPY_DATETIMEUNIT *, npy_bool *);
573
+ NPY_NO_EXPORT int NpyString_load \
574
+ (npy_string_allocator *, const npy_packed_static_string *, npy_static_string *);
575
+ NPY_NO_EXPORT int NpyString_pack \
576
+ (npy_string_allocator *, npy_packed_static_string *, const char *, size_t);
577
+ NPY_NO_EXPORT int NpyString_pack_null \
578
+ (npy_string_allocator *, npy_packed_static_string *);
579
+ NPY_NO_EXPORT npy_string_allocator * NpyString_acquire_allocator \
580
+ (const PyArray_StringDTypeObject *);
581
+ NPY_NO_EXPORT void NpyString_acquire_allocators \
582
+ (size_t, PyArray_Descr *const descrs[], npy_string_allocator *allocators[]);
583
+ NPY_NO_EXPORT void NpyString_release_allocator \
584
+ (npy_string_allocator *);
585
+ NPY_NO_EXPORT void NpyString_release_allocators \
586
+ (size_t, npy_string_allocator *allocators[]);
587
+ NPY_NO_EXPORT PyArray_Descr * PyArray_GetDefaultDescr \
588
+ (PyArray_DTypeMeta *);
589
+ NPY_NO_EXPORT int PyArrayInitDTypeMeta_FromSpec \
590
+ (PyArray_DTypeMeta *, PyArrayDTypeMeta_Spec *);
591
+ NPY_NO_EXPORT PyArray_DTypeMeta * PyArray_CommonDType \
592
+ (PyArray_DTypeMeta *, PyArray_DTypeMeta *);
593
+ NPY_NO_EXPORT PyArray_DTypeMeta * PyArray_PromoteDTypeSequence \
594
+ (npy_intp, PyArray_DTypeMeta **);
595
+ NPY_NO_EXPORT PyArray_ArrFuncs * _PyDataType_GetArrFuncs \
596
+ (const PyArray_Descr *);
597
+
598
+ #else
599
+
600
+ #if defined(PY_ARRAY_UNIQUE_SYMBOL)
601
+ #define PyArray_API PY_ARRAY_UNIQUE_SYMBOL
602
+ #define _NPY_VERSION_CONCAT_HELPER2(x, y) x ## y
603
+ #define _NPY_VERSION_CONCAT_HELPER(arg) \
604
+ _NPY_VERSION_CONCAT_HELPER2(arg, PyArray_RUNTIME_VERSION)
605
+ #define PyArray_RUNTIME_VERSION \
606
+ _NPY_VERSION_CONCAT_HELPER(PY_ARRAY_UNIQUE_SYMBOL)
607
+ #endif
608
+
609
+ /* By default do not export API in an .so (was never the case on windows) */
610
+ #ifndef NPY_API_SYMBOL_ATTRIBUTE
611
+ #define NPY_API_SYMBOL_ATTRIBUTE NPY_VISIBILITY_HIDDEN
612
+ #endif
613
+
614
+ #if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)
615
+ extern NPY_API_SYMBOL_ATTRIBUTE void **PyArray_API;
616
+ extern NPY_API_SYMBOL_ATTRIBUTE int PyArray_RUNTIME_VERSION;
617
+ #else
618
+ #if defined(PY_ARRAY_UNIQUE_SYMBOL)
619
+ NPY_API_SYMBOL_ATTRIBUTE void **PyArray_API;
620
+ NPY_API_SYMBOL_ATTRIBUTE int PyArray_RUNTIME_VERSION;
621
+ #else
622
+ static void **PyArray_API = NULL;
623
+ static int PyArray_RUNTIME_VERSION = 0;
624
+ #endif
625
+ #endif
626
+
627
+ #define PyArray_GetNDArrayCVersion \
628
+ (*(unsigned int (*)(void)) \
629
+ PyArray_API[0])
630
+ #define PyArray_Type (*(PyTypeObject *)PyArray_API[2])
631
+ #define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[3])
632
+ #define PyArrayIter_Type (*(PyTypeObject *)PyArray_API[5])
633
+ #define PyArrayMultiIter_Type (*(PyTypeObject *)PyArray_API[6])
634
+ #define NPY_NUMUSERTYPES (*(int *)PyArray_API[7])
635
+ #define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[8])
636
+ #define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[9])
637
+ #define PyGenericArrType_Type (*(PyTypeObject *)PyArray_API[10])
638
+ #define PyNumberArrType_Type (*(PyTypeObject *)PyArray_API[11])
639
+ #define PyIntegerArrType_Type (*(PyTypeObject *)PyArray_API[12])
640
+ #define PySignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[13])
641
+ #define PyUnsignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[14])
642
+ #define PyInexactArrType_Type (*(PyTypeObject *)PyArray_API[15])
643
+ #define PyFloatingArrType_Type (*(PyTypeObject *)PyArray_API[16])
644
+ #define PyComplexFloatingArrType_Type (*(PyTypeObject *)PyArray_API[17])
645
+ #define PyFlexibleArrType_Type (*(PyTypeObject *)PyArray_API[18])
646
+ #define PyCharacterArrType_Type (*(PyTypeObject *)PyArray_API[19])
647
+ #define PyByteArrType_Type (*(PyTypeObject *)PyArray_API[20])
648
+ #define PyShortArrType_Type (*(PyTypeObject *)PyArray_API[21])
649
+ #define PyIntArrType_Type (*(PyTypeObject *)PyArray_API[22])
650
+ #define PyLongArrType_Type (*(PyTypeObject *)PyArray_API[23])
651
+ #define PyLongLongArrType_Type (*(PyTypeObject *)PyArray_API[24])
652
+ #define PyUByteArrType_Type (*(PyTypeObject *)PyArray_API[25])
653
+ #define PyUShortArrType_Type (*(PyTypeObject *)PyArray_API[26])
654
+ #define PyUIntArrType_Type (*(PyTypeObject *)PyArray_API[27])
655
+ #define PyULongArrType_Type (*(PyTypeObject *)PyArray_API[28])
656
+ #define PyULongLongArrType_Type (*(PyTypeObject *)PyArray_API[29])
657
+ #define PyFloatArrType_Type (*(PyTypeObject *)PyArray_API[30])
658
+ #define PyDoubleArrType_Type (*(PyTypeObject *)PyArray_API[31])
659
+ #define PyLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[32])
660
+ #define PyCFloatArrType_Type (*(PyTypeObject *)PyArray_API[33])
661
+ #define PyCDoubleArrType_Type (*(PyTypeObject *)PyArray_API[34])
662
+ #define PyCLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[35])
663
+ #define PyObjectArrType_Type (*(PyTypeObject *)PyArray_API[36])
664
+ #define PyStringArrType_Type (*(PyTypeObject *)PyArray_API[37])
665
+ #define PyUnicodeArrType_Type (*(PyTypeObject *)PyArray_API[38])
666
+ #define PyVoidArrType_Type (*(PyTypeObject *)PyArray_API[39])
667
+ #define PyArray_INCREF \
668
+ (*(int (*)(PyArrayObject *)) \
669
+ PyArray_API[42])
670
+ #define PyArray_XDECREF \
671
+ (*(int (*)(PyArrayObject *)) \
672
+ PyArray_API[43])
673
+ #define PyArray_SetStringFunction \
674
+ (*(void (*)(PyObject *, int)) \
675
+ PyArray_API[44])
676
+ #define PyArray_DescrFromType \
677
+ (*(PyArray_Descr * (*)(int)) \
678
+ PyArray_API[45])
679
+ #define PyArray_TypeObjectFromType \
680
+ (*(PyObject * (*)(int)) \
681
+ PyArray_API[46])
682
+ #define PyArray_Zero \
683
+ (*(char * (*)(PyArrayObject *)) \
684
+ PyArray_API[47])
685
+ #define PyArray_One \
686
+ (*(char * (*)(PyArrayObject *)) \
687
+ PyArray_API[48])
688
+ #define PyArray_CastToType \
689
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
690
+ PyArray_API[49])
691
+ #define PyArray_CopyInto \
692
+ (*(int (*)(PyArrayObject *, PyArrayObject *)) \
693
+ PyArray_API[50])
694
+ #define PyArray_CopyAnyInto \
695
+ (*(int (*)(PyArrayObject *, PyArrayObject *)) \
696
+ PyArray_API[51])
697
+ #define PyArray_CanCastSafely \
698
+ (*(int (*)(int, int)) \
699
+ PyArray_API[52])
700
+ #define PyArray_CanCastTo \
701
+ (*(npy_bool (*)(PyArray_Descr *, PyArray_Descr *)) \
702
+ PyArray_API[53])
703
+ #define PyArray_ObjectType \
704
+ (*(int (*)(PyObject *, int)) \
705
+ PyArray_API[54])
706
+ #define PyArray_DescrFromObject \
707
+ (*(PyArray_Descr * (*)(PyObject *, PyArray_Descr *)) \
708
+ PyArray_API[55])
709
+ #define PyArray_ConvertToCommonType \
710
+ (*(PyArrayObject ** (*)(PyObject *, int *)) \
711
+ PyArray_API[56])
712
+ #define PyArray_DescrFromScalar \
713
+ (*(PyArray_Descr * (*)(PyObject *)) \
714
+ PyArray_API[57])
715
+ #define PyArray_DescrFromTypeObject \
716
+ (*(PyArray_Descr * (*)(PyObject *)) \
717
+ PyArray_API[58])
718
+ #define PyArray_Size \
719
+ (*(npy_intp (*)(PyObject *)) \
720
+ PyArray_API[59])
721
+ #define PyArray_Scalar \
722
+ (*(PyObject * (*)(void *, PyArray_Descr *, PyObject *)) \
723
+ PyArray_API[60])
724
+ #define PyArray_FromScalar \
725
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *)) \
726
+ PyArray_API[61])
727
+ #define PyArray_ScalarAsCtype \
728
+ (*(void (*)(PyObject *, void *)) \
729
+ PyArray_API[62])
730
+ #define PyArray_CastScalarToCtype \
731
+ (*(int (*)(PyObject *, void *, PyArray_Descr *)) \
732
+ PyArray_API[63])
733
+ #define PyArray_CastScalarDirect \
734
+ (*(int (*)(PyObject *, PyArray_Descr *, void *, int)) \
735
+ PyArray_API[64])
736
+
737
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
738
+ #define PyArray_Pack \
739
+ (*(int (*)(PyArray_Descr *, void *, PyObject *)) \
740
+ PyArray_API[65])
741
+ #endif
742
+ #define PyArray_FromAny \
743
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \
744
+ PyArray_API[69])
745
+ #define PyArray_EnsureArray \
746
+ (*(PyObject * (*)(PyObject *)) \
747
+ PyArray_API[70])
748
+ #define PyArray_EnsureAnyArray \
749
+ (*(PyObject * (*)(PyObject *)) \
750
+ PyArray_API[71])
751
+ #define PyArray_FromFile \
752
+ (*(PyObject * (*)(FILE *, PyArray_Descr *, npy_intp, char *)) \
753
+ PyArray_API[72])
754
+ #define PyArray_FromString \
755
+ (*(PyObject * (*)(char *, npy_intp, PyArray_Descr *, npy_intp, char *)) \
756
+ PyArray_API[73])
757
+ #define PyArray_FromBuffer \
758
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp, npy_intp)) \
759
+ PyArray_API[74])
760
+ #define PyArray_FromIter \
761
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp)) \
762
+ PyArray_API[75])
763
+ #define PyArray_Return \
764
+ (*(PyObject * (*)(PyArrayObject *)) \
765
+ PyArray_API[76])
766
+ #define PyArray_GetField \
767
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
768
+ PyArray_API[77])
769
+ #define PyArray_SetField \
770
+ (*(int (*)(PyArrayObject *, PyArray_Descr *, int, PyObject *)) \
771
+ PyArray_API[78])
772
+ #define PyArray_Byteswap \
773
+ (*(PyObject * (*)(PyArrayObject *, npy_bool)) \
774
+ PyArray_API[79])
775
+ #define PyArray_Resize \
776
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, int, NPY_ORDER NPY_UNUSED(order))) \
777
+ PyArray_API[80])
778
+ #define PyArray_CopyObject \
779
+ (*(int (*)(PyArrayObject *, PyObject *)) \
780
+ PyArray_API[84])
781
+ #define PyArray_NewCopy \
782
+ (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
783
+ PyArray_API[85])
784
+ #define PyArray_ToList \
785
+ (*(PyObject * (*)(PyArrayObject *)) \
786
+ PyArray_API[86])
787
+ #define PyArray_ToString \
788
+ (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
789
+ PyArray_API[87])
790
+ #define PyArray_ToFile \
791
+ (*(int (*)(PyArrayObject *, FILE *, char *, char *)) \
792
+ PyArray_API[88])
793
+ #define PyArray_Dump \
794
+ (*(int (*)(PyObject *, PyObject *, int)) \
795
+ PyArray_API[89])
796
+ #define PyArray_Dumps \
797
+ (*(PyObject * (*)(PyObject *, int)) \
798
+ PyArray_API[90])
799
+ #define PyArray_ValidType \
800
+ (*(int (*)(int)) \
801
+ PyArray_API[91])
802
+ #define PyArray_UpdateFlags \
803
+ (*(void (*)(PyArrayObject *, int)) \
804
+ PyArray_API[92])
805
+ #define PyArray_New \
806
+ (*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) \
807
+ PyArray_API[93])
808
+ #define PyArray_NewFromDescr \
809
+ (*(PyObject * (*)(PyTypeObject *, PyArray_Descr *, int, npy_intp const *, npy_intp const *, void *, int, PyObject *)) \
810
+ PyArray_API[94])
811
+ #define PyArray_DescrNew \
812
+ (*(PyArray_Descr * (*)(PyArray_Descr *)) \
813
+ PyArray_API[95])
814
+ #define PyArray_DescrNewFromType \
815
+ (*(PyArray_Descr * (*)(int)) \
816
+ PyArray_API[96])
817
+ #define PyArray_GetPriority \
818
+ (*(double (*)(PyObject *, double)) \
819
+ PyArray_API[97])
820
+ #define PyArray_IterNew \
821
+ (*(PyObject * (*)(PyObject *)) \
822
+ PyArray_API[98])
823
+ #define PyArray_MultiIterNew \
824
+ (*(PyObject* (*)(int, ...)) \
825
+ PyArray_API[99])
826
+ #define PyArray_PyIntAsInt \
827
+ (*(int (*)(PyObject *)) \
828
+ PyArray_API[100])
829
+ #define PyArray_PyIntAsIntp \
830
+ (*(npy_intp (*)(PyObject *)) \
831
+ PyArray_API[101])
832
+ #define PyArray_Broadcast \
833
+ (*(int (*)(PyArrayMultiIterObject *)) \
834
+ PyArray_API[102])
835
+ #define PyArray_FillWithScalar \
836
+ (*(int (*)(PyArrayObject *, PyObject *)) \
837
+ PyArray_API[104])
838
+ #define PyArray_CheckStrides \
839
+ (*(npy_bool (*)(int, int, npy_intp, npy_intp, npy_intp const *, npy_intp const *)) \
840
+ PyArray_API[105])
841
+ #define PyArray_DescrNewByteorder \
842
+ (*(PyArray_Descr * (*)(PyArray_Descr *, char)) \
843
+ PyArray_API[106])
844
+ #define PyArray_IterAllButAxis \
845
+ (*(PyObject * (*)(PyObject *, int *)) \
846
+ PyArray_API[107])
847
+ #define PyArray_CheckFromAny \
848
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \
849
+ PyArray_API[108])
850
+ #define PyArray_FromArray \
851
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
852
+ PyArray_API[109])
853
+ #define PyArray_FromInterface \
854
+ (*(PyObject * (*)(PyObject *)) \
855
+ PyArray_API[110])
856
+ #define PyArray_FromStructInterface \
857
+ (*(PyObject * (*)(PyObject *)) \
858
+ PyArray_API[111])
859
+ #define PyArray_FromArrayAttr \
860
+ (*(PyObject * (*)(PyObject *, PyArray_Descr *, PyObject *)) \
861
+ PyArray_API[112])
862
+ #define PyArray_ScalarKind \
863
+ (*(NPY_SCALARKIND (*)(int, PyArrayObject **)) \
864
+ PyArray_API[113])
865
+ #define PyArray_CanCoerceScalar \
866
+ (*(int (*)(int, int, NPY_SCALARKIND)) \
867
+ PyArray_API[114])
868
+ #define PyArray_CanCastScalar \
869
+ (*(npy_bool (*)(PyTypeObject *, PyTypeObject *)) \
870
+ PyArray_API[116])
871
+ #define PyArray_RemoveSmallest \
872
+ (*(int (*)(PyArrayMultiIterObject *)) \
873
+ PyArray_API[118])
874
+ #define PyArray_ElementStrides \
875
+ (*(int (*)(PyObject *)) \
876
+ PyArray_API[119])
877
+ #define PyArray_Item_INCREF \
878
+ (*(void (*)(char *, PyArray_Descr *)) \
879
+ PyArray_API[120])
880
+ #define PyArray_Item_XDECREF \
881
+ (*(void (*)(char *, PyArray_Descr *)) \
882
+ PyArray_API[121])
883
+ #define PyArray_Transpose \
884
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *)) \
885
+ PyArray_API[123])
886
+ #define PyArray_TakeFrom \
887
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE)) \
888
+ PyArray_API[124])
889
+ #define PyArray_PutTo \
890
+ (*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE)) \
891
+ PyArray_API[125])
892
+ #define PyArray_PutMask \
893
+ (*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject*)) \
894
+ PyArray_API[126])
895
+ #define PyArray_Repeat \
896
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, int)) \
897
+ PyArray_API[127])
898
+ #define PyArray_Choose \
899
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE)) \
900
+ PyArray_API[128])
901
+ #define PyArray_Sort \
902
+ (*(int (*)(PyArrayObject *, int, NPY_SORTKIND)) \
903
+ PyArray_API[129])
904
+ #define PyArray_ArgSort \
905
+ (*(PyObject * (*)(PyArrayObject *, int, NPY_SORTKIND)) \
906
+ PyArray_API[130])
907
+ #define PyArray_SearchSorted \
908
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, NPY_SEARCHSIDE, PyObject *)) \
909
+ PyArray_API[131])
910
+ #define PyArray_ArgMax \
911
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
912
+ PyArray_API[132])
913
+ #define PyArray_ArgMin \
914
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
915
+ PyArray_API[133])
916
+ #define PyArray_Reshape \
917
+ (*(PyObject * (*)(PyArrayObject *, PyObject *)) \
918
+ PyArray_API[134])
919
+ #define PyArray_Newshape \
920
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, NPY_ORDER)) \
921
+ PyArray_API[135])
922
+ #define PyArray_Squeeze \
923
+ (*(PyObject * (*)(PyArrayObject *)) \
924
+ PyArray_API[136])
925
+ #define PyArray_View \
926
+ (*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, PyTypeObject *)) \
927
+ PyArray_API[137])
928
+ #define PyArray_SwapAxes \
929
+ (*(PyObject * (*)(PyArrayObject *, int, int)) \
930
+ PyArray_API[138])
931
+ #define PyArray_Max \
932
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
933
+ PyArray_API[139])
934
+ #define PyArray_Min \
935
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
936
+ PyArray_API[140])
937
+ #define PyArray_Ptp \
938
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
939
+ PyArray_API[141])
940
+ #define PyArray_Mean \
941
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
942
+ PyArray_API[142])
943
+ #define PyArray_Trace \
944
+ (*(PyObject * (*)(PyArrayObject *, int, int, int, int, PyArrayObject *)) \
945
+ PyArray_API[143])
946
+ #define PyArray_Diagonal \
947
+ (*(PyObject * (*)(PyArrayObject *, int, int, int)) \
948
+ PyArray_API[144])
949
+ #define PyArray_Clip \
950
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, PyObject *, PyArrayObject *)) \
951
+ PyArray_API[145])
952
+ #define PyArray_Conjugate \
953
+ (*(PyObject * (*)(PyArrayObject *, PyArrayObject *)) \
954
+ PyArray_API[146])
955
+ #define PyArray_Nonzero \
956
+ (*(PyObject * (*)(PyArrayObject *)) \
957
+ PyArray_API[147])
958
+ #define PyArray_Std \
959
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *, int)) \
960
+ PyArray_API[148])
961
+ #define PyArray_Sum \
962
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
963
+ PyArray_API[149])
964
+ #define PyArray_CumSum \
965
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
966
+ PyArray_API[150])
967
+ #define PyArray_Prod \
968
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
969
+ PyArray_API[151])
970
+ #define PyArray_CumProd \
971
+ (*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
972
+ PyArray_API[152])
973
+ #define PyArray_All \
974
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
975
+ PyArray_API[153])
976
+ #define PyArray_Any \
977
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
978
+ PyArray_API[154])
979
+ #define PyArray_Compress \
980
+ (*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *)) \
981
+ PyArray_API[155])
982
+ #define PyArray_Flatten \
983
+ (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
984
+ PyArray_API[156])
985
+ #define PyArray_Ravel \
986
+ (*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
987
+ PyArray_API[157])
988
+ #define PyArray_MultiplyList \
989
+ (*(npy_intp (*)(npy_intp const *, int)) \
990
+ PyArray_API[158])
991
+ #define PyArray_MultiplyIntList \
992
+ (*(int (*)(int const *, int)) \
993
+ PyArray_API[159])
994
+ #define PyArray_GetPtr \
995
+ (*(void * (*)(PyArrayObject *, npy_intp const*)) \
996
+ PyArray_API[160])
997
+ #define PyArray_CompareLists \
998
+ (*(int (*)(npy_intp const *, npy_intp const *, int)) \
999
+ PyArray_API[161])
1000
+ #define PyArray_AsCArray \
1001
+ (*(int (*)(PyObject **, void *, npy_intp *, int, PyArray_Descr*)) \
1002
+ PyArray_API[162])
1003
+ #define PyArray_Free \
1004
+ (*(int (*)(PyObject *, void *)) \
1005
+ PyArray_API[165])
1006
+ #define PyArray_Converter \
1007
+ (*(int (*)(PyObject *, PyObject **)) \
1008
+ PyArray_API[166])
1009
+ #define PyArray_IntpFromSequence \
1010
+ (*(int (*)(PyObject *, npy_intp *, int)) \
1011
+ PyArray_API[167])
1012
+ #define PyArray_Concatenate \
1013
+ (*(PyObject * (*)(PyObject *, int)) \
1014
+ PyArray_API[168])
1015
+ #define PyArray_InnerProduct \
1016
+ (*(PyObject * (*)(PyObject *, PyObject *)) \
1017
+ PyArray_API[169])
1018
+ #define PyArray_MatrixProduct \
1019
+ (*(PyObject * (*)(PyObject *, PyObject *)) \
1020
+ PyArray_API[170])
1021
+ #define PyArray_Correlate \
1022
+ (*(PyObject * (*)(PyObject *, PyObject *, int)) \
1023
+ PyArray_API[172])
1024
+ #define PyArray_DescrConverter \
1025
+ (*(int (*)(PyObject *, PyArray_Descr **)) \
1026
+ PyArray_API[174])
1027
+ #define PyArray_DescrConverter2 \
1028
+ (*(int (*)(PyObject *, PyArray_Descr **)) \
1029
+ PyArray_API[175])
1030
+ #define PyArray_IntpConverter \
1031
+ (*(int (*)(PyObject *, PyArray_Dims *)) \
1032
+ PyArray_API[176])
1033
+ #define PyArray_BufferConverter \
1034
+ (*(int (*)(PyObject *, PyArray_Chunk *)) \
1035
+ PyArray_API[177])
1036
+ #define PyArray_AxisConverter \
1037
+ (*(int (*)(PyObject *, int *)) \
1038
+ PyArray_API[178])
1039
+ #define PyArray_BoolConverter \
1040
+ (*(int (*)(PyObject *, npy_bool *)) \
1041
+ PyArray_API[179])
1042
+ #define PyArray_ByteorderConverter \
1043
+ (*(int (*)(PyObject *, char *)) \
1044
+ PyArray_API[180])
1045
+ #define PyArray_OrderConverter \
1046
+ (*(int (*)(PyObject *, NPY_ORDER *)) \
1047
+ PyArray_API[181])
1048
+ #define PyArray_EquivTypes \
1049
+ (*(unsigned char (*)(PyArray_Descr *, PyArray_Descr *)) \
1050
+ PyArray_API[182])
1051
+ #define PyArray_Zeros \
1052
+ (*(PyObject * (*)(int, npy_intp const *, PyArray_Descr *, int)) \
1053
+ PyArray_API[183])
1054
+ #define PyArray_Empty \
1055
+ (*(PyObject * (*)(int, npy_intp const *, PyArray_Descr *, int)) \
1056
+ PyArray_API[184])
1057
+ #define PyArray_Where \
1058
+ (*(PyObject * (*)(PyObject *, PyObject *, PyObject *)) \
1059
+ PyArray_API[185])
1060
+ #define PyArray_Arange \
1061
+ (*(PyObject * (*)(double, double, double, int)) \
1062
+ PyArray_API[186])
1063
+ #define PyArray_ArangeObj \
1064
+ (*(PyObject * (*)(PyObject *, PyObject *, PyObject *, PyArray_Descr *)) \
1065
+ PyArray_API[187])
1066
+ #define PyArray_SortkindConverter \
1067
+ (*(int (*)(PyObject *, NPY_SORTKIND *)) \
1068
+ PyArray_API[188])
1069
+ #define PyArray_LexSort \
1070
+ (*(PyObject * (*)(PyObject *, int)) \
1071
+ PyArray_API[189])
1072
+ #define PyArray_Round \
1073
+ (*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
1074
+ PyArray_API[190])
1075
+ #define PyArray_EquivTypenums \
1076
+ (*(unsigned char (*)(int, int)) \
1077
+ PyArray_API[191])
1078
+ #define PyArray_RegisterDataType \
1079
+ (*(int (*)(PyArray_DescrProto *)) \
1080
+ PyArray_API[192])
1081
+ #define PyArray_RegisterCastFunc \
1082
+ (*(int (*)(PyArray_Descr *, int, PyArray_VectorUnaryFunc *)) \
1083
+ PyArray_API[193])
1084
+ #define PyArray_RegisterCanCast \
1085
+ (*(int (*)(PyArray_Descr *, int, NPY_SCALARKIND)) \
1086
+ PyArray_API[194])
1087
+ #define PyArray_InitArrFuncs \
1088
+ (*(void (*)(PyArray_ArrFuncs *)) \
1089
+ PyArray_API[195])
1090
+ #define PyArray_IntTupleFromIntp \
1091
+ (*(PyObject * (*)(int, npy_intp const *)) \
1092
+ PyArray_API[196])
1093
+ #define PyArray_ClipmodeConverter \
1094
+ (*(int (*)(PyObject *, NPY_CLIPMODE *)) \
1095
+ PyArray_API[198])
1096
+ #define PyArray_OutputConverter \
1097
+ (*(int (*)(PyObject *, PyArrayObject **)) \
1098
+ PyArray_API[199])
1099
+ #define PyArray_BroadcastToShape \
1100
+ (*(PyObject * (*)(PyObject *, npy_intp *, int)) \
1101
+ PyArray_API[200])
1102
+ #define PyArray_DescrAlignConverter \
1103
+ (*(int (*)(PyObject *, PyArray_Descr **)) \
1104
+ PyArray_API[203])
1105
+ #define PyArray_DescrAlignConverter2 \
1106
+ (*(int (*)(PyObject *, PyArray_Descr **)) \
1107
+ PyArray_API[204])
1108
+ #define PyArray_SearchsideConverter \
1109
+ (*(int (*)(PyObject *, void *)) \
1110
+ PyArray_API[205])
1111
+ #define PyArray_CheckAxis \
1112
+ (*(PyObject * (*)(PyArrayObject *, int *, int)) \
1113
+ PyArray_API[206])
1114
+ #define PyArray_OverflowMultiplyList \
1115
+ (*(npy_intp (*)(npy_intp const *, int)) \
1116
+ PyArray_API[207])
1117
+ #define PyArray_MultiIterFromObjects \
1118
+ (*(PyObject* (*)(PyObject **, int, int, ...)) \
1119
+ PyArray_API[209])
1120
+ #define PyArray_GetEndianness \
1121
+ (*(int (*)(void)) \
1122
+ PyArray_API[210])
1123
+ #define PyArray_GetNDArrayCFeatureVersion \
1124
+ (*(unsigned int (*)(void)) \
1125
+ PyArray_API[211])
1126
+ #define PyArray_Correlate2 \
1127
+ (*(PyObject * (*)(PyObject *, PyObject *, int)) \
1128
+ PyArray_API[212])
1129
+ #define PyArray_NeighborhoodIterNew \
1130
+ (*(PyObject* (*)(PyArrayIterObject *, const npy_intp *, int, PyArrayObject*)) \
1131
+ PyArray_API[213])
1132
+ #define PyTimeIntegerArrType_Type (*(PyTypeObject *)PyArray_API[214])
1133
+ #define PyDatetimeArrType_Type (*(PyTypeObject *)PyArray_API[215])
1134
+ #define PyTimedeltaArrType_Type (*(PyTypeObject *)PyArray_API[216])
1135
+ #define PyHalfArrType_Type (*(PyTypeObject *)PyArray_API[217])
1136
+ #define NpyIter_Type (*(PyTypeObject *)PyArray_API[218])
1137
+ #define NpyIter_New \
1138
+ (*(NpyIter * (*)(PyArrayObject *, npy_uint32, NPY_ORDER, NPY_CASTING, PyArray_Descr*)) \
1139
+ PyArray_API[224])
1140
+ #define NpyIter_MultiNew \
1141
+ (*(NpyIter * (*)(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **)) \
1142
+ PyArray_API[225])
1143
+ #define NpyIter_AdvancedNew \
1144
+ (*(NpyIter * (*)(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **, int, int **, npy_intp *, npy_intp)) \
1145
+ PyArray_API[226])
1146
+ #define NpyIter_Copy \
1147
+ (*(NpyIter * (*)(NpyIter *)) \
1148
+ PyArray_API[227])
1149
+ #define NpyIter_Deallocate \
1150
+ (*(int (*)(NpyIter *)) \
1151
+ PyArray_API[228])
1152
+ #define NpyIter_HasDelayedBufAlloc \
1153
+ (*(npy_bool (*)(NpyIter *)) \
1154
+ PyArray_API[229])
1155
+ #define NpyIter_HasExternalLoop \
1156
+ (*(npy_bool (*)(NpyIter *)) \
1157
+ PyArray_API[230])
1158
+ #define NpyIter_EnableExternalLoop \
1159
+ (*(int (*)(NpyIter *)) \
1160
+ PyArray_API[231])
1161
+ #define NpyIter_GetInnerStrideArray \
1162
+ (*(npy_intp * (*)(NpyIter *)) \
1163
+ PyArray_API[232])
1164
+ #define NpyIter_GetInnerLoopSizePtr \
1165
+ (*(npy_intp * (*)(NpyIter *)) \
1166
+ PyArray_API[233])
1167
+ #define NpyIter_Reset \
1168
+ (*(int (*)(NpyIter *, char **)) \
1169
+ PyArray_API[234])
1170
+ #define NpyIter_ResetBasePointers \
1171
+ (*(int (*)(NpyIter *, char **, char **)) \
1172
+ PyArray_API[235])
1173
+ #define NpyIter_ResetToIterIndexRange \
1174
+ (*(int (*)(NpyIter *, npy_intp, npy_intp, char **)) \
1175
+ PyArray_API[236])
1176
+ #define NpyIter_GetNDim \
1177
+ (*(int (*)(NpyIter *)) \
1178
+ PyArray_API[237])
1179
+ #define NpyIter_GetNOp \
1180
+ (*(int (*)(NpyIter *)) \
1181
+ PyArray_API[238])
1182
+ #define NpyIter_GetIterNext \
1183
+ (*(NpyIter_IterNextFunc * (*)(NpyIter *, char **)) \
1184
+ PyArray_API[239])
1185
+ #define NpyIter_GetIterSize \
1186
+ (*(npy_intp (*)(NpyIter *)) \
1187
+ PyArray_API[240])
1188
+ #define NpyIter_GetIterIndexRange \
1189
+ (*(void (*)(NpyIter *, npy_intp *, npy_intp *)) \
1190
+ PyArray_API[241])
1191
+ #define NpyIter_GetIterIndex \
1192
+ (*(npy_intp (*)(NpyIter *)) \
1193
+ PyArray_API[242])
1194
+ #define NpyIter_GotoIterIndex \
1195
+ (*(int (*)(NpyIter *, npy_intp)) \
1196
+ PyArray_API[243])
1197
+ #define NpyIter_HasMultiIndex \
1198
+ (*(npy_bool (*)(NpyIter *)) \
1199
+ PyArray_API[244])
1200
+ #define NpyIter_GetShape \
1201
+ (*(int (*)(NpyIter *, npy_intp *)) \
1202
+ PyArray_API[245])
1203
+ #define NpyIter_GetGetMultiIndex \
1204
+ (*(NpyIter_GetMultiIndexFunc * (*)(NpyIter *, char **)) \
1205
+ PyArray_API[246])
1206
+ #define NpyIter_GotoMultiIndex \
1207
+ (*(int (*)(NpyIter *, npy_intp const *)) \
1208
+ PyArray_API[247])
1209
+ #define NpyIter_RemoveMultiIndex \
1210
+ (*(int (*)(NpyIter *)) \
1211
+ PyArray_API[248])
1212
+ #define NpyIter_HasIndex \
1213
+ (*(npy_bool (*)(NpyIter *)) \
1214
+ PyArray_API[249])
1215
+ #define NpyIter_IsBuffered \
1216
+ (*(npy_bool (*)(NpyIter *)) \
1217
+ PyArray_API[250])
1218
+ #define NpyIter_IsGrowInner \
1219
+ (*(npy_bool (*)(NpyIter *)) \
1220
+ PyArray_API[251])
1221
+ #define NpyIter_GetBufferSize \
1222
+ (*(npy_intp (*)(NpyIter *)) \
1223
+ PyArray_API[252])
1224
+ #define NpyIter_GetIndexPtr \
1225
+ (*(npy_intp * (*)(NpyIter *)) \
1226
+ PyArray_API[253])
1227
+ #define NpyIter_GotoIndex \
1228
+ (*(int (*)(NpyIter *, npy_intp)) \
1229
+ PyArray_API[254])
1230
+ #define NpyIter_GetDataPtrArray \
1231
+ (*(char ** (*)(NpyIter *)) \
1232
+ PyArray_API[255])
1233
+ #define NpyIter_GetDescrArray \
1234
+ (*(PyArray_Descr ** (*)(NpyIter *)) \
1235
+ PyArray_API[256])
1236
+ #define NpyIter_GetOperandArray \
1237
+ (*(PyArrayObject ** (*)(NpyIter *)) \
1238
+ PyArray_API[257])
1239
+ #define NpyIter_GetIterView \
1240
+ (*(PyArrayObject * (*)(NpyIter *, npy_intp)) \
1241
+ PyArray_API[258])
1242
+ #define NpyIter_GetReadFlags \
1243
+ (*(void (*)(NpyIter *, char *)) \
1244
+ PyArray_API[259])
1245
+ #define NpyIter_GetWriteFlags \
1246
+ (*(void (*)(NpyIter *, char *)) \
1247
+ PyArray_API[260])
1248
+ #define NpyIter_DebugPrint \
1249
+ (*(void (*)(NpyIter *)) \
1250
+ PyArray_API[261])
1251
+ #define NpyIter_IterationNeedsAPI \
1252
+ (*(npy_bool (*)(NpyIter *)) \
1253
+ PyArray_API[262])
1254
+ #define NpyIter_GetInnerFixedStrideArray \
1255
+ (*(void (*)(NpyIter *, npy_intp *)) \
1256
+ PyArray_API[263])
1257
+ #define NpyIter_RemoveAxis \
1258
+ (*(int (*)(NpyIter *, int)) \
1259
+ PyArray_API[264])
1260
+ #define NpyIter_GetAxisStrideArray \
1261
+ (*(npy_intp * (*)(NpyIter *, int)) \
1262
+ PyArray_API[265])
1263
+ #define NpyIter_RequiresBuffering \
1264
+ (*(npy_bool (*)(NpyIter *)) \
1265
+ PyArray_API[266])
1266
+ #define NpyIter_GetInitialDataPtrArray \
1267
+ (*(char ** (*)(NpyIter *)) \
1268
+ PyArray_API[267])
1269
+ #define NpyIter_CreateCompatibleStrides \
1270
+ (*(int (*)(NpyIter *, npy_intp, npy_intp *)) \
1271
+ PyArray_API[268])
1272
+ #define PyArray_CastingConverter \
1273
+ (*(int (*)(PyObject *, NPY_CASTING *)) \
1274
+ PyArray_API[269])
1275
+ #define PyArray_CountNonzero \
1276
+ (*(npy_intp (*)(PyArrayObject *)) \
1277
+ PyArray_API[270])
1278
+ #define PyArray_PromoteTypes \
1279
+ (*(PyArray_Descr * (*)(PyArray_Descr *, PyArray_Descr *)) \
1280
+ PyArray_API[271])
1281
+ #define PyArray_MinScalarType \
1282
+ (*(PyArray_Descr * (*)(PyArrayObject *)) \
1283
+ PyArray_API[272])
1284
+ #define PyArray_ResultType \
1285
+ (*(PyArray_Descr * (*)(npy_intp, PyArrayObject *arrs[], npy_intp, PyArray_Descr *descrs[])) \
1286
+ PyArray_API[273])
1287
+ #define PyArray_CanCastArrayTo \
1288
+ (*(npy_bool (*)(PyArrayObject *, PyArray_Descr *, NPY_CASTING)) \
1289
+ PyArray_API[274])
1290
+ #define PyArray_CanCastTypeTo \
1291
+ (*(npy_bool (*)(PyArray_Descr *, PyArray_Descr *, NPY_CASTING)) \
1292
+ PyArray_API[275])
1293
+ #define PyArray_EinsteinSum \
1294
+ (*(PyArrayObject * (*)(char *, npy_intp, PyArrayObject **, PyArray_Descr *, NPY_ORDER, NPY_CASTING, PyArrayObject *)) \
1295
+ PyArray_API[276])
1296
+ #define PyArray_NewLikeArray \
1297
+ (*(PyObject * (*)(PyArrayObject *, NPY_ORDER, PyArray_Descr *, int)) \
1298
+ PyArray_API[277])
1299
+ #define PyArray_ConvertClipmodeSequence \
1300
+ (*(int (*)(PyObject *, NPY_CLIPMODE *, int)) \
1301
+ PyArray_API[279])
1302
+ #define PyArray_MatrixProduct2 \
1303
+ (*(PyObject * (*)(PyObject *, PyObject *, PyArrayObject*)) \
1304
+ PyArray_API[280])
1305
+ #define NpyIter_IsFirstVisit \
1306
+ (*(npy_bool (*)(NpyIter *, int)) \
1307
+ PyArray_API[281])
1308
+ #define PyArray_SetBaseObject \
1309
+ (*(int (*)(PyArrayObject *, PyObject *)) \
1310
+ PyArray_API[282])
1311
+ #define PyArray_CreateSortedStridePerm \
1312
+ (*(void (*)(int, npy_intp const *, npy_stride_sort_item *)) \
1313
+ PyArray_API[283])
1314
+ #define PyArray_RemoveAxesInPlace \
1315
+ (*(void (*)(PyArrayObject *, const npy_bool *)) \
1316
+ PyArray_API[284])
1317
+ #define PyArray_DebugPrint \
1318
+ (*(void (*)(PyArrayObject *)) \
1319
+ PyArray_API[285])
1320
+ #define PyArray_FailUnlessWriteable \
1321
+ (*(int (*)(PyArrayObject *, const char *)) \
1322
+ PyArray_API[286])
1323
+ #define PyArray_SetUpdateIfCopyBase \
1324
+ (*(int (*)(PyArrayObject *, PyArrayObject *)) \
1325
+ PyArray_API[287])
1326
+ #define PyDataMem_NEW \
1327
+ (*(void * (*)(size_t)) \
1328
+ PyArray_API[288])
1329
+ #define PyDataMem_FREE \
1330
+ (*(void (*)(void *)) \
1331
+ PyArray_API[289])
1332
+ #define PyDataMem_RENEW \
1333
+ (*(void * (*)(void *, size_t)) \
1334
+ PyArray_API[290])
1335
+ #define NPY_DEFAULT_ASSIGN_CASTING (*(NPY_CASTING *)PyArray_API[292])
1336
+ #define PyArray_Partition \
1337
+ (*(int (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \
1338
+ PyArray_API[296])
1339
+ #define PyArray_ArgPartition \
1340
+ (*(PyObject * (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \
1341
+ PyArray_API[297])
1342
+ #define PyArray_SelectkindConverter \
1343
+ (*(int (*)(PyObject *, NPY_SELECTKIND *)) \
1344
+ PyArray_API[298])
1345
+ #define PyDataMem_NEW_ZEROED \
1346
+ (*(void * (*)(size_t, size_t)) \
1347
+ PyArray_API[299])
1348
+ #define PyArray_CheckAnyScalarExact \
1349
+ (*(int (*)(PyObject *)) \
1350
+ PyArray_API[300])
1351
+ #define PyArray_ResolveWritebackIfCopy \
1352
+ (*(int (*)(PyArrayObject *)) \
1353
+ PyArray_API[302])
1354
+ #define PyArray_SetWritebackIfCopyBase \
1355
+ (*(int (*)(PyArrayObject *, PyArrayObject *)) \
1356
+ PyArray_API[303])
1357
+
1358
+ #if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
1359
+ #define PyDataMem_SetHandler \
1360
+ (*(PyObject * (*)(PyObject *)) \
1361
+ PyArray_API[304])
1362
+ #endif
1363
+
1364
+ #if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
1365
+ #define PyDataMem_GetHandler \
1366
+ (*(PyObject * (*)(void)) \
1367
+ PyArray_API[305])
1368
+ #endif
1369
+ #define PyDataMem_DefaultHandler (*(PyObject* *)PyArray_API[306])
1370
+
1371
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1372
+ #define NpyDatetime_ConvertDatetime64ToDatetimeStruct \
1373
+ (*(int (*)(PyArray_DatetimeMetaData *, npy_datetime, npy_datetimestruct *)) \
1374
+ PyArray_API[307])
1375
+ #endif
1376
+
1377
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1378
+ #define NpyDatetime_ConvertDatetimeStructToDatetime64 \
1379
+ (*(int (*)(PyArray_DatetimeMetaData *, const npy_datetimestruct *, npy_datetime *)) \
1380
+ PyArray_API[308])
1381
+ #endif
1382
+
1383
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1384
+ #define NpyDatetime_ConvertPyDateTimeToDatetimeStruct \
1385
+ (*(int (*)(PyObject *, npy_datetimestruct *, NPY_DATETIMEUNIT *, int)) \
1386
+ PyArray_API[309])
1387
+ #endif
1388
+
1389
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1390
+ #define NpyDatetime_GetDatetimeISO8601StrLen \
1391
+ (*(int (*)(int, NPY_DATETIMEUNIT)) \
1392
+ PyArray_API[310])
1393
+ #endif
1394
+
1395
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1396
+ #define NpyDatetime_MakeISO8601Datetime \
1397
+ (*(int (*)(npy_datetimestruct *, char *, npy_intp, int, int, NPY_DATETIMEUNIT, int, NPY_CASTING)) \
1398
+ PyArray_API[311])
1399
+ #endif
1400
+
1401
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1402
+ #define NpyDatetime_ParseISO8601Datetime \
1403
+ (*(int (*)(char const *, Py_ssize_t, NPY_DATETIMEUNIT, NPY_CASTING, npy_datetimestruct *, NPY_DATETIMEUNIT *, npy_bool *)) \
1404
+ PyArray_API[312])
1405
+ #endif
1406
+
1407
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1408
+ #define NpyString_load \
1409
+ (*(int (*)(npy_string_allocator *, const npy_packed_static_string *, npy_static_string *)) \
1410
+ PyArray_API[313])
1411
+ #endif
1412
+
1413
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1414
+ #define NpyString_pack \
1415
+ (*(int (*)(npy_string_allocator *, npy_packed_static_string *, const char *, size_t)) \
1416
+ PyArray_API[314])
1417
+ #endif
1418
+
1419
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1420
+ #define NpyString_pack_null \
1421
+ (*(int (*)(npy_string_allocator *, npy_packed_static_string *)) \
1422
+ PyArray_API[315])
1423
+ #endif
1424
+
1425
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1426
+ #define NpyString_acquire_allocator \
1427
+ (*(npy_string_allocator * (*)(const PyArray_StringDTypeObject *)) \
1428
+ PyArray_API[316])
1429
+ #endif
1430
+
1431
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1432
+ #define NpyString_acquire_allocators \
1433
+ (*(void (*)(size_t, PyArray_Descr *const descrs[], npy_string_allocator *allocators[])) \
1434
+ PyArray_API[317])
1435
+ #endif
1436
+
1437
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1438
+ #define NpyString_release_allocator \
1439
+ (*(void (*)(npy_string_allocator *)) \
1440
+ PyArray_API[318])
1441
+ #endif
1442
+
1443
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1444
+ #define NpyString_release_allocators \
1445
+ (*(void (*)(size_t, npy_string_allocator *allocators[])) \
1446
+ PyArray_API[319])
1447
+ #endif
1448
+
1449
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1450
+ #define PyArray_GetDefaultDescr \
1451
+ (*(PyArray_Descr * (*)(PyArray_DTypeMeta *)) \
1452
+ PyArray_API[361])
1453
+ #endif
1454
+
1455
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1456
+ #define PyArrayInitDTypeMeta_FromSpec \
1457
+ (*(int (*)(PyArray_DTypeMeta *, PyArrayDTypeMeta_Spec *)) \
1458
+ PyArray_API[362])
1459
+ #endif
1460
+
1461
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1462
+ #define PyArray_CommonDType \
1463
+ (*(PyArray_DTypeMeta * (*)(PyArray_DTypeMeta *, PyArray_DTypeMeta *)) \
1464
+ PyArray_API[363])
1465
+ #endif
1466
+
1467
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
1468
+ #define PyArray_PromoteDTypeSequence \
1469
+ (*(PyArray_DTypeMeta * (*)(npy_intp, PyArray_DTypeMeta **)) \
1470
+ PyArray_API[364])
1471
+ #endif
1472
+ #define _PyDataType_GetArrFuncs \
1473
+ (*(PyArray_ArrFuncs * (*)(const PyArray_Descr *)) \
1474
+ PyArray_API[365])
1475
+
1476
+ /*
1477
+ * The DType classes are inconvenient for the Python generation so exposed
1478
+ * manually in the header below (may be moved).
1479
+ */
1480
+ #include "numpy/_public_dtype_api_table.h"
1481
+
1482
+ #if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT)
1483
+ static int
1484
+ _import_array(void)
1485
+ {
1486
+ int st;
1487
+ PyObject *numpy = PyImport_ImportModule("numpy._core._multiarray_umath");
1488
+ if (numpy == NULL && PyErr_ExceptionMatches(PyExc_ModuleNotFoundError)) {
1489
+ PyErr_Clear();
1490
+ numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
1491
+ }
1492
+
1493
+ if (numpy == NULL) {
1494
+ return -1;
1495
+ }
1496
+
1497
+ PyObject *c_api = PyObject_GetAttrString(numpy, "_ARRAY_API");
1498
+ Py_DECREF(numpy);
1499
+ if (c_api == NULL) {
1500
+ return -1;
1501
+ }
1502
+
1503
+ if (!PyCapsule_CheckExact(c_api)) {
1504
+ PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is not PyCapsule object");
1505
+ Py_DECREF(c_api);
1506
+ return -1;
1507
+ }
1508
+ PyArray_API = (void **)PyCapsule_GetPointer(c_api, NULL);
1509
+ Py_DECREF(c_api);
1510
+ if (PyArray_API == NULL) {
1511
+ PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is NULL pointer");
1512
+ return -1;
1513
+ }
1514
+
1515
+ /*
1516
+ * On exceedingly few platforms these sizes may not match, in which case
1517
+ * We do not support older NumPy versions at all.
1518
+ */
1519
+ if (sizeof(Py_ssize_t) != sizeof(Py_intptr_t) &&
1520
+ PyArray_RUNTIME_VERSION < NPY_2_0_API_VERSION) {
1521
+ PyErr_Format(PyExc_RuntimeError,
1522
+ "module compiled against NumPy 2.0 but running on NumPy 1.x. "
1523
+ "Unfortunately, this is not supported on niche platforms where "
1524
+ "`sizeof(size_t) != sizeof(inptr_t)`.");
1525
+ }
1526
+ /*
1527
+ * Perform runtime check of C API version. As of now NumPy 2.0 is ABI
1528
+ * backwards compatible (in the exposed feature subset!) for all practical
1529
+ * purposes.
1530
+ */
1531
+ if (NPY_VERSION < PyArray_GetNDArrayCVersion()) {
1532
+ PyErr_Format(PyExc_RuntimeError, "module compiled against "\
1533
+ "ABI version 0x%x but this version of numpy is 0x%x", \
1534
+ (int) NPY_VERSION, (int) PyArray_GetNDArrayCVersion());
1535
+ return -1;
1536
+ }
1537
+ PyArray_RUNTIME_VERSION = (int)PyArray_GetNDArrayCFeatureVersion();
1538
+ if (NPY_FEATURE_VERSION > PyArray_RUNTIME_VERSION) {
1539
+ PyErr_Format(PyExc_RuntimeError,
1540
+ "module was compiled against NumPy C-API version 0x%x "
1541
+ "(NumPy " NPY_FEATURE_VERSION_STRING ") "
1542
+ "but the running NumPy has C-API version 0x%x. "
1543
+ "Check the section C-API incompatibility at the "
1544
+ "Troubleshooting ImportError section at "
1545
+ "https://numpy.org/devdocs/user/troubleshooting-importerror.html"
1546
+ "#c-api-incompatibility "
1547
+ "for indications on how to solve this problem.",
1548
+ (int)NPY_FEATURE_VERSION, PyArray_RUNTIME_VERSION);
1549
+ return -1;
1550
+ }
1551
+
1552
+ /*
1553
+ * Perform runtime check of endianness and check it matches the one set by
1554
+ * the headers (npy_endian.h) as a safeguard
1555
+ */
1556
+ st = PyArray_GetEndianness();
1557
+ if (st == NPY_CPU_UNKNOWN_ENDIAN) {
1558
+ PyErr_SetString(PyExc_RuntimeError,
1559
+ "FATAL: module compiled as unknown endian");
1560
+ return -1;
1561
+ }
1562
+ #if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
1563
+ if (st != NPY_CPU_BIG) {
1564
+ PyErr_SetString(PyExc_RuntimeError,
1565
+ "FATAL: module compiled as big endian, but "
1566
+ "detected different endianness at runtime");
1567
+ return -1;
1568
+ }
1569
+ #elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
1570
+ if (st != NPY_CPU_LITTLE) {
1571
+ PyErr_SetString(PyExc_RuntimeError,
1572
+ "FATAL: module compiled as little endian, but "
1573
+ "detected different endianness at runtime");
1574
+ return -1;
1575
+ }
1576
+ #endif
1577
+
1578
+ return 0;
1579
+ }
1580
+
1581
+ #define import_array() { \
1582
+ if (_import_array() < 0) { \
1583
+ PyErr_Print(); \
1584
+ PyErr_SetString( \
1585
+ PyExc_ImportError, \
1586
+ "numpy._core.multiarray failed to import" \
1587
+ ); \
1588
+ return NULL; \
1589
+ } \
1590
+ }
1591
+
1592
+ #define import_array1(ret) { \
1593
+ if (_import_array() < 0) { \
1594
+ PyErr_Print(); \
1595
+ PyErr_SetString( \
1596
+ PyExc_ImportError, \
1597
+ "numpy._core.multiarray failed to import" \
1598
+ ); \
1599
+ return ret; \
1600
+ } \
1601
+ }
1602
+
1603
+ #define import_array2(msg, ret) { \
1604
+ if (_import_array() < 0) { \
1605
+ PyErr_Print(); \
1606
+ PyErr_SetString(PyExc_ImportError, msg); \
1607
+ return ret; \
1608
+ } \
1609
+ }
1610
+
1611
+ #endif
1612
+
1613
+ #endif
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__ufunc_api.c ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* These pointers will be stored in the C-object for use in other
3
+ extension modules
4
+ */
5
+
6
+ void *PyUFunc_API[] = {
7
+ (void *) &PyUFunc_Type,
8
+ (void *) PyUFunc_FromFuncAndData,
9
+ (void *) PyUFunc_RegisterLoopForType,
10
+ NULL,
11
+ (void *) PyUFunc_f_f_As_d_d,
12
+ (void *) PyUFunc_d_d,
13
+ (void *) PyUFunc_f_f,
14
+ (void *) PyUFunc_g_g,
15
+ (void *) PyUFunc_F_F_As_D_D,
16
+ (void *) PyUFunc_F_F,
17
+ (void *) PyUFunc_D_D,
18
+ (void *) PyUFunc_G_G,
19
+ (void *) PyUFunc_O_O,
20
+ (void *) PyUFunc_ff_f_As_dd_d,
21
+ (void *) PyUFunc_ff_f,
22
+ (void *) PyUFunc_dd_d,
23
+ (void *) PyUFunc_gg_g,
24
+ (void *) PyUFunc_FF_F_As_DD_D,
25
+ (void *) PyUFunc_DD_D,
26
+ (void *) PyUFunc_FF_F,
27
+ (void *) PyUFunc_GG_G,
28
+ (void *) PyUFunc_OO_O,
29
+ (void *) PyUFunc_O_O_method,
30
+ (void *) PyUFunc_OO_O_method,
31
+ (void *) PyUFunc_On_Om,
32
+ NULL,
33
+ NULL,
34
+ (void *) PyUFunc_clearfperr,
35
+ (void *) PyUFunc_getfperr,
36
+ NULL,
37
+ (void *) PyUFunc_ReplaceLoopBySignature,
38
+ (void *) PyUFunc_FromFuncAndDataAndSignature,
39
+ NULL,
40
+ (void *) PyUFunc_e_e,
41
+ (void *) PyUFunc_e_e_As_f_f,
42
+ (void *) PyUFunc_e_e_As_d_d,
43
+ (void *) PyUFunc_ee_e,
44
+ (void *) PyUFunc_ee_e_As_ff_f,
45
+ (void *) PyUFunc_ee_e_As_dd_d,
46
+ (void *) PyUFunc_DefaultTypeResolver,
47
+ (void *) PyUFunc_ValidateCasting,
48
+ (void *) PyUFunc_RegisterLoopForDescr,
49
+ (void *) PyUFunc_FromFuncAndDataAndSignatureAndIdentity,
50
+ (void *) PyUFunc_AddLoopFromSpec,
51
+ (void *) PyUFunc_AddPromoter,
52
+ (void *) PyUFunc_AddWrappingLoop,
53
+ (void *) PyUFunc_GiveFloatingpointErrors
54
+ };
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/__ufunc_api.h ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #ifdef _UMATHMODULE
3
+
4
+ extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
5
+
6
+ extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
7
+
8
+ NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndData \
9
+ (PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int);
10
+ NPY_NO_EXPORT int PyUFunc_RegisterLoopForType \
11
+ (PyUFuncObject *, int, PyUFuncGenericFunction, const int *, void *);
12
+ NPY_NO_EXPORT void PyUFunc_f_f_As_d_d \
13
+ (char **, npy_intp const *, npy_intp const *, void *);
14
+ NPY_NO_EXPORT void PyUFunc_d_d \
15
+ (char **, npy_intp const *, npy_intp const *, void *);
16
+ NPY_NO_EXPORT void PyUFunc_f_f \
17
+ (char **, npy_intp const *, npy_intp const *, void *);
18
+ NPY_NO_EXPORT void PyUFunc_g_g \
19
+ (char **, npy_intp const *, npy_intp const *, void *);
20
+ NPY_NO_EXPORT void PyUFunc_F_F_As_D_D \
21
+ (char **, npy_intp const *, npy_intp const *, void *);
22
+ NPY_NO_EXPORT void PyUFunc_F_F \
23
+ (char **, npy_intp const *, npy_intp const *, void *);
24
+ NPY_NO_EXPORT void PyUFunc_D_D \
25
+ (char **, npy_intp const *, npy_intp const *, void *);
26
+ NPY_NO_EXPORT void PyUFunc_G_G \
27
+ (char **, npy_intp const *, npy_intp const *, void *);
28
+ NPY_NO_EXPORT void PyUFunc_O_O \
29
+ (char **, npy_intp const *, npy_intp const *, void *);
30
+ NPY_NO_EXPORT void PyUFunc_ff_f_As_dd_d \
31
+ (char **, npy_intp const *, npy_intp const *, void *);
32
+ NPY_NO_EXPORT void PyUFunc_ff_f \
33
+ (char **, npy_intp const *, npy_intp const *, void *);
34
+ NPY_NO_EXPORT void PyUFunc_dd_d \
35
+ (char **, npy_intp const *, npy_intp const *, void *);
36
+ NPY_NO_EXPORT void PyUFunc_gg_g \
37
+ (char **, npy_intp const *, npy_intp const *, void *);
38
+ NPY_NO_EXPORT void PyUFunc_FF_F_As_DD_D \
39
+ (char **, npy_intp const *, npy_intp const *, void *);
40
+ NPY_NO_EXPORT void PyUFunc_DD_D \
41
+ (char **, npy_intp const *, npy_intp const *, void *);
42
+ NPY_NO_EXPORT void PyUFunc_FF_F \
43
+ (char **, npy_intp const *, npy_intp const *, void *);
44
+ NPY_NO_EXPORT void PyUFunc_GG_G \
45
+ (char **, npy_intp const *, npy_intp const *, void *);
46
+ NPY_NO_EXPORT void PyUFunc_OO_O \
47
+ (char **, npy_intp const *, npy_intp const *, void *);
48
+ NPY_NO_EXPORT void PyUFunc_O_O_method \
49
+ (char **, npy_intp const *, npy_intp const *, void *);
50
+ NPY_NO_EXPORT void PyUFunc_OO_O_method \
51
+ (char **, npy_intp const *, npy_intp const *, void *);
52
+ NPY_NO_EXPORT void PyUFunc_On_Om \
53
+ (char **, npy_intp const *, npy_intp const *, void *);
54
+ NPY_NO_EXPORT void PyUFunc_clearfperr \
55
+ (void);
56
+ NPY_NO_EXPORT int PyUFunc_getfperr \
57
+ (void);
58
+ NPY_NO_EXPORT int PyUFunc_ReplaceLoopBySignature \
59
+ (PyUFuncObject *, PyUFuncGenericFunction, const int *, PyUFuncGenericFunction *);
60
+ NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignature \
61
+ (PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int, const char *);
62
+ NPY_NO_EXPORT void PyUFunc_e_e \
63
+ (char **, npy_intp const *, npy_intp const *, void *);
64
+ NPY_NO_EXPORT void PyUFunc_e_e_As_f_f \
65
+ (char **, npy_intp const *, npy_intp const *, void *);
66
+ NPY_NO_EXPORT void PyUFunc_e_e_As_d_d \
67
+ (char **, npy_intp const *, npy_intp const *, void *);
68
+ NPY_NO_EXPORT void PyUFunc_ee_e \
69
+ (char **, npy_intp const *, npy_intp const *, void *);
70
+ NPY_NO_EXPORT void PyUFunc_ee_e_As_ff_f \
71
+ (char **, npy_intp const *, npy_intp const *, void *);
72
+ NPY_NO_EXPORT void PyUFunc_ee_e_As_dd_d \
73
+ (char **, npy_intp const *, npy_intp const *, void *);
74
+ NPY_NO_EXPORT int PyUFunc_DefaultTypeResolver \
75
+ (PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyObject *, PyArray_Descr **);
76
+ NPY_NO_EXPORT int PyUFunc_ValidateCasting \
77
+ (PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr *const *);
78
+ NPY_NO_EXPORT int PyUFunc_RegisterLoopForDescr \
79
+ (PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *);
80
+ NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignatureAndIdentity \
81
+ (PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, const int, const char *, PyObject *);
82
+ NPY_NO_EXPORT int PyUFunc_AddLoopFromSpec \
83
+ (PyObject *, PyArrayMethod_Spec *);
84
+ NPY_NO_EXPORT int PyUFunc_AddPromoter \
85
+ (PyObject *, PyObject *, PyObject *);
86
+ NPY_NO_EXPORT int PyUFunc_AddWrappingLoop \
87
+ (PyObject *, PyArray_DTypeMeta *new_dtypes[], PyArray_DTypeMeta *wrapped_dtypes[], PyArrayMethod_TranslateGivenDescriptors *, PyArrayMethod_TranslateLoopDescriptors *);
88
+ NPY_NO_EXPORT int PyUFunc_GiveFloatingpointErrors \
89
+ (const char *, int);
90
+
91
+ #else
92
+
93
+ #if defined(PY_UFUNC_UNIQUE_SYMBOL)
94
+ #define PyUFunc_API PY_UFUNC_UNIQUE_SYMBOL
95
+ #endif
96
+
97
+ /* By default do not export API in an .so (was never the case on windows) */
98
+ #ifndef NPY_API_SYMBOL_ATTRIBUTE
99
+ #define NPY_API_SYMBOL_ATTRIBUTE NPY_VISIBILITY_HIDDEN
100
+ #endif
101
+
102
+ #if defined(NO_IMPORT) || defined(NO_IMPORT_UFUNC)
103
+ extern NPY_API_SYMBOL_ATTRIBUTE void **PyUFunc_API;
104
+ #else
105
+ #if defined(PY_UFUNC_UNIQUE_SYMBOL)
106
+ NPY_API_SYMBOL_ATTRIBUTE void **PyUFunc_API;
107
+ #else
108
+ static void **PyUFunc_API=NULL;
109
+ #endif
110
+ #endif
111
+
112
+ #define PyUFunc_Type (*(PyTypeObject *)PyUFunc_API[0])
113
+ #define PyUFunc_FromFuncAndData \
114
+ (*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int)) \
115
+ PyUFunc_API[1])
116
+ #define PyUFunc_RegisterLoopForType \
117
+ (*(int (*)(PyUFuncObject *, int, PyUFuncGenericFunction, const int *, void *)) \
118
+ PyUFunc_API[2])
119
+ #define PyUFunc_f_f_As_d_d \
120
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
121
+ PyUFunc_API[4])
122
+ #define PyUFunc_d_d \
123
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
124
+ PyUFunc_API[5])
125
+ #define PyUFunc_f_f \
126
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
127
+ PyUFunc_API[6])
128
+ #define PyUFunc_g_g \
129
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
130
+ PyUFunc_API[7])
131
+ #define PyUFunc_F_F_As_D_D \
132
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
133
+ PyUFunc_API[8])
134
+ #define PyUFunc_F_F \
135
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
136
+ PyUFunc_API[9])
137
+ #define PyUFunc_D_D \
138
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
139
+ PyUFunc_API[10])
140
+ #define PyUFunc_G_G \
141
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
142
+ PyUFunc_API[11])
143
+ #define PyUFunc_O_O \
144
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
145
+ PyUFunc_API[12])
146
+ #define PyUFunc_ff_f_As_dd_d \
147
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
148
+ PyUFunc_API[13])
149
+ #define PyUFunc_ff_f \
150
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
151
+ PyUFunc_API[14])
152
+ #define PyUFunc_dd_d \
153
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
154
+ PyUFunc_API[15])
155
+ #define PyUFunc_gg_g \
156
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
157
+ PyUFunc_API[16])
158
+ #define PyUFunc_FF_F_As_DD_D \
159
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
160
+ PyUFunc_API[17])
161
+ #define PyUFunc_DD_D \
162
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
163
+ PyUFunc_API[18])
164
+ #define PyUFunc_FF_F \
165
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
166
+ PyUFunc_API[19])
167
+ #define PyUFunc_GG_G \
168
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
169
+ PyUFunc_API[20])
170
+ #define PyUFunc_OO_O \
171
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
172
+ PyUFunc_API[21])
173
+ #define PyUFunc_O_O_method \
174
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
175
+ PyUFunc_API[22])
176
+ #define PyUFunc_OO_O_method \
177
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
178
+ PyUFunc_API[23])
179
+ #define PyUFunc_On_Om \
180
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
181
+ PyUFunc_API[24])
182
+ #define PyUFunc_clearfperr \
183
+ (*(void (*)(void)) \
184
+ PyUFunc_API[27])
185
+ #define PyUFunc_getfperr \
186
+ (*(int (*)(void)) \
187
+ PyUFunc_API[28])
188
+ #define PyUFunc_ReplaceLoopBySignature \
189
+ (*(int (*)(PyUFuncObject *, PyUFuncGenericFunction, const int *, PyUFuncGenericFunction *)) \
190
+ PyUFunc_API[30])
191
+ #define PyUFunc_FromFuncAndDataAndSignature \
192
+ (*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int, const char *)) \
193
+ PyUFunc_API[31])
194
+ #define PyUFunc_e_e \
195
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
196
+ PyUFunc_API[33])
197
+ #define PyUFunc_e_e_As_f_f \
198
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
199
+ PyUFunc_API[34])
200
+ #define PyUFunc_e_e_As_d_d \
201
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
202
+ PyUFunc_API[35])
203
+ #define PyUFunc_ee_e \
204
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
205
+ PyUFunc_API[36])
206
+ #define PyUFunc_ee_e_As_ff_f \
207
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
208
+ PyUFunc_API[37])
209
+ #define PyUFunc_ee_e_As_dd_d \
210
+ (*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
211
+ PyUFunc_API[38])
212
+ #define PyUFunc_DefaultTypeResolver \
213
+ (*(int (*)(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyObject *, PyArray_Descr **)) \
214
+ PyUFunc_API[39])
215
+ #define PyUFunc_ValidateCasting \
216
+ (*(int (*)(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr *const *)) \
217
+ PyUFunc_API[40])
218
+ #define PyUFunc_RegisterLoopForDescr \
219
+ (*(int (*)(PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *)) \
220
+ PyUFunc_API[41])
221
+
222
+ #if NPY_FEATURE_VERSION >= NPY_1_16_API_VERSION
223
+ #define PyUFunc_FromFuncAndDataAndSignatureAndIdentity \
224
+ (*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, const int, const char *, PyObject *)) \
225
+ PyUFunc_API[42])
226
+ #endif
227
+
228
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
229
+ #define PyUFunc_AddLoopFromSpec \
230
+ (*(int (*)(PyObject *, PyArrayMethod_Spec *)) \
231
+ PyUFunc_API[43])
232
+ #endif
233
+
234
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
235
+ #define PyUFunc_AddPromoter \
236
+ (*(int (*)(PyObject *, PyObject *, PyObject *)) \
237
+ PyUFunc_API[44])
238
+ #endif
239
+
240
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
241
+ #define PyUFunc_AddWrappingLoop \
242
+ (*(int (*)(PyObject *, PyArray_DTypeMeta *new_dtypes[], PyArray_DTypeMeta *wrapped_dtypes[], PyArrayMethod_TranslateGivenDescriptors *, PyArrayMethod_TranslateLoopDescriptors *)) \
243
+ PyUFunc_API[45])
244
+ #endif
245
+
246
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
247
+ #define PyUFunc_GiveFloatingpointErrors \
248
+ (*(int (*)(const char *, int)) \
249
+ PyUFunc_API[46])
250
+ #endif
251
+
252
+ static inline int
253
+ _import_umath(void)
254
+ {
255
+ PyObject *numpy = PyImport_ImportModule("numpy._core._multiarray_umath");
256
+ if (numpy == NULL && PyErr_ExceptionMatches(PyExc_ModuleNotFoundError)) {
257
+ PyErr_Clear();
258
+ numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
259
+ }
260
+
261
+ if (numpy == NULL) {
262
+ PyErr_SetString(PyExc_ImportError,
263
+ "_multiarray_umath failed to import");
264
+ return -1;
265
+ }
266
+
267
+ PyObject *c_api = PyObject_GetAttrString(numpy, "_UFUNC_API");
268
+ Py_DECREF(numpy);
269
+ if (c_api == NULL) {
270
+ PyErr_SetString(PyExc_AttributeError, "_UFUNC_API not found");
271
+ return -1;
272
+ }
273
+
274
+ if (!PyCapsule_CheckExact(c_api)) {
275
+ PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is not PyCapsule object");
276
+ Py_DECREF(c_api);
277
+ return -1;
278
+ }
279
+ PyUFunc_API = (void **)PyCapsule_GetPointer(c_api, NULL);
280
+ Py_DECREF(c_api);
281
+ if (PyUFunc_API == NULL) {
282
+ PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is NULL pointer");
283
+ return -1;
284
+ }
285
+ return 0;
286
+ }
287
+
288
+ #define import_umath() \
289
+ do {\
290
+ UFUNC_NOFPE\
291
+ if (_import_umath() < 0) {\
292
+ PyErr_Print();\
293
+ PyErr_SetString(PyExc_ImportError,\
294
+ "numpy._core.umath failed to import");\
295
+ return NULL;\
296
+ }\
297
+ } while(0)
298
+
299
+ #define import_umath1(ret) \
300
+ do {\
301
+ UFUNC_NOFPE\
302
+ if (_import_umath() < 0) {\
303
+ PyErr_Print();\
304
+ PyErr_SetString(PyExc_ImportError,\
305
+ "numpy._core.umath failed to import");\
306
+ return ret;\
307
+ }\
308
+ } while(0)
309
+
310
+ #define import_umath2(ret, msg) \
311
+ do {\
312
+ UFUNC_NOFPE\
313
+ if (_import_umath() < 0) {\
314
+ PyErr_Print();\
315
+ PyErr_SetString(PyExc_ImportError, msg);\
316
+ return ret;\
317
+ }\
318
+ } while(0)
319
+
320
+ #define import_ufunc() \
321
+ do {\
322
+ UFUNC_NOFPE\
323
+ if (_import_umath() < 0) {\
324
+ PyErr_Print();\
325
+ PyErr_SetString(PyExc_ImportError,\
326
+ "numpy._core.umath failed to import");\
327
+ }\
328
+ } while(0)
329
+
330
+
331
+ static inline int
332
+ PyUFunc_ImportUFuncAPI()
333
+ {
334
+ if (NPY_UNLIKELY(PyUFunc_API == NULL)) {
335
+ import_umath1(-1);
336
+ }
337
+ return 0;
338
+ }
339
+
340
+ #endif
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_neighborhood_iterator_imp.h ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
2
+ #error You should not include this header directly
3
+ #endif
4
+ /*
5
+ * Private API (here for inline)
6
+ */
7
+ static inline int
8
+ _PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter);
9
+
10
+ /*
11
+ * Update to next item of the iterator
12
+ *
13
+ * Note: this simply increment the coordinates vector, last dimension
14
+ * incremented first , i.e, for dimension 3
15
+ * ...
16
+ * -1, -1, -1
17
+ * -1, -1, 0
18
+ * -1, -1, 1
19
+ * ....
20
+ * -1, 0, -1
21
+ * -1, 0, 0
22
+ * ....
23
+ * 0, -1, -1
24
+ * 0, -1, 0
25
+ * ....
26
+ */
27
+ #define _UPDATE_COORD_ITER(c) \
28
+ wb = iter->coordinates[c] < iter->bounds[c][1]; \
29
+ if (wb) { \
30
+ iter->coordinates[c] += 1; \
31
+ return 0; \
32
+ } \
33
+ else { \
34
+ iter->coordinates[c] = iter->bounds[c][0]; \
35
+ }
36
+
37
+ static inline int
38
+ _PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter)
39
+ {
40
+ npy_intp i, wb;
41
+
42
+ for (i = iter->nd - 1; i >= 0; --i) {
43
+ _UPDATE_COORD_ITER(i)
44
+ }
45
+
46
+ return 0;
47
+ }
48
+
49
+ /*
50
+ * Version optimized for 2d arrays, manual loop unrolling
51
+ */
52
+ static inline int
53
+ _PyArrayNeighborhoodIter_IncrCoord2D(PyArrayNeighborhoodIterObject* iter)
54
+ {
55
+ npy_intp wb;
56
+
57
+ _UPDATE_COORD_ITER(1)
58
+ _UPDATE_COORD_ITER(0)
59
+
60
+ return 0;
61
+ }
62
+ #undef _UPDATE_COORD_ITER
63
+
64
+ /*
65
+ * Advance to the next neighbour
66
+ */
67
+ static inline int
68
+ PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter)
69
+ {
70
+ _PyArrayNeighborhoodIter_IncrCoord (iter);
71
+ iter->dataptr = iter->translate((PyArrayIterObject*)iter, iter->coordinates);
72
+
73
+ return 0;
74
+ }
75
+
76
+ /*
77
+ * Reset functions
78
+ */
79
+ static inline int
80
+ PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter)
81
+ {
82
+ npy_intp i;
83
+
84
+ for (i = 0; i < iter->nd; ++i) {
85
+ iter->coordinates[i] = iter->bounds[i][0];
86
+ }
87
+ iter->dataptr = iter->translate((PyArrayIterObject*)iter, iter->coordinates);
88
+
89
+ return 0;
90
+ }
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_numpyconfig.h ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #define NPY_HAVE_ENDIAN_H 1
2
+
3
+ #define NPY_SIZEOF_SHORT 2
4
+ #define NPY_SIZEOF_INT 4
5
+ #define NPY_SIZEOF_LONG 8
6
+ #define NPY_SIZEOF_FLOAT 4
7
+ #define NPY_SIZEOF_COMPLEX_FLOAT 8
8
+ #define NPY_SIZEOF_DOUBLE 8
9
+ #define NPY_SIZEOF_COMPLEX_DOUBLE 16
10
+ #define NPY_SIZEOF_LONGDOUBLE 16
11
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
12
+ #define NPY_SIZEOF_PY_INTPTR_T 8
13
+ #define NPY_SIZEOF_INTP 8
14
+ #define NPY_SIZEOF_UINTP 8
15
+ #define NPY_SIZEOF_WCHAR_T 4
16
+ #define NPY_SIZEOF_OFF_T 8
17
+ #define NPY_SIZEOF_PY_LONG_LONG 8
18
+ #define NPY_SIZEOF_LONGLONG 8
19
+
20
+ /*
21
+ * Defined to 1 or 0. Note that Pyodide hardcodes NPY_NO_SMP (and other defines
22
+ * in this header) for better cross-compilation, so don't rename them without a
23
+ * good reason.
24
+ */
25
+ #define NPY_NO_SMP 0
26
+
27
+ #define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
28
+ #define NPY_ABI_VERSION 0x02000000
29
+ #define NPY_API_VERSION 0x00000013
30
+
31
+ #ifndef __STDC_FORMAT_MACROS
32
+ #define __STDC_FORMAT_MACROS 1
33
+ #endif
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/_public_dtype_api_table.h ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Public exposure of the DType Classes. These are tricky to expose
3
+ * via the Python API, so they are exposed through this header for now.
4
+ *
5
+ * These definitions are only relevant for the public API and we reserve
6
+ * the slots 320-360 in the API table generation for this (currently).
7
+ *
8
+ * TODO: This file should be consolidated with the API table generation
9
+ * (although not sure the current generation is worth preserving).
10
+ */
11
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_
12
+ #define NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_
13
+
14
+ #if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
15
+
16
+ /* All of these require NumPy 2.0 support */
17
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
18
+
19
+ /*
20
+ * The type of the DType metaclass
21
+ */
22
+ #define PyArrayDTypeMeta_Type (*(PyTypeObject *)(PyArray_API + 320)[0])
23
+ /*
24
+ * NumPy's builtin DTypes:
25
+ */
26
+ #define PyArray_BoolDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[1])
27
+ /* Integers */
28
+ #define PyArray_ByteDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[2])
29
+ #define PyArray_UByteDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[3])
30
+ #define PyArray_ShortDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[4])
31
+ #define PyArray_UShortDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[5])
32
+ #define PyArray_IntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[6])
33
+ #define PyArray_UIntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[7])
34
+ #define PyArray_LongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[8])
35
+ #define PyArray_ULongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[9])
36
+ #define PyArray_LongLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[10])
37
+ #define PyArray_ULongLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[11])
38
+ /* Integer aliases */
39
+ #define PyArray_Int8DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[12])
40
+ #define PyArray_UInt8DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[13])
41
+ #define PyArray_Int16DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[14])
42
+ #define PyArray_UInt16DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[15])
43
+ #define PyArray_Int32DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[16])
44
+ #define PyArray_UInt32DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[17])
45
+ #define PyArray_Int64DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[18])
46
+ #define PyArray_UInt64DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[19])
47
+ #define PyArray_IntpDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[20])
48
+ #define PyArray_UIntpDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[21])
49
+ /* Floats */
50
+ #define PyArray_HalfDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[22])
51
+ #define PyArray_FloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[23])
52
+ #define PyArray_DoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[24])
53
+ #define PyArray_LongDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[25])
54
+ /* Complex */
55
+ #define PyArray_CFloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[26])
56
+ #define PyArray_CDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[27])
57
+ #define PyArray_CLongDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[28])
58
+ /* String/Bytes */
59
+ #define PyArray_BytesDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[29])
60
+ #define PyArray_UnicodeDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[30])
61
+ /* Datetime/Timedelta */
62
+ #define PyArray_DatetimeDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[31])
63
+ #define PyArray_TimedeltaDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[32])
64
+ /* Object/Void */
65
+ #define PyArray_ObjectDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[33])
66
+ #define PyArray_VoidDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[34])
67
+ /* Python types (used as markers for scalars) */
68
+ #define PyArray_PyLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[35])
69
+ #define PyArray_PyFloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[36])
70
+ #define PyArray_PyComplexDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[37])
71
+ /* Default integer type */
72
+ #define PyArray_DefaultIntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[38])
73
+ /* New non-legacy DTypes follow in the order they were added */
74
+ #define PyArray_StringDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[39])
75
+
76
+ /* NOTE: offset 40 is free */
77
+
78
+ /* Need to start with a larger offset again for the abstract classes: */
79
+ #define PyArray_IntAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[366])
80
+ #define PyArray_FloatAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[367])
81
+ #define PyArray_ComplexAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[368])
82
+
83
+ #endif /* NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION */
84
+
85
+ #endif /* NPY_INTERNAL_BUILD */
86
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayobject.h ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_ARRAYOBJECT_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_ARRAYOBJECT_H_
3
+ #define Py_ARRAYOBJECT_H
4
+
5
+ #include "ndarrayobject.h"
6
+
7
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_ARRAYOBJECT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/arrayscalars.h ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_
3
+
4
+ #ifndef _MULTIARRAYMODULE
5
+ typedef struct {
6
+ PyObject_HEAD
7
+ npy_bool obval;
8
+ } PyBoolScalarObject;
9
+ #endif
10
+
11
+
12
+ typedef struct {
13
+ PyObject_HEAD
14
+ signed char obval;
15
+ } PyByteScalarObject;
16
+
17
+
18
+ typedef struct {
19
+ PyObject_HEAD
20
+ short obval;
21
+ } PyShortScalarObject;
22
+
23
+
24
+ typedef struct {
25
+ PyObject_HEAD
26
+ int obval;
27
+ } PyIntScalarObject;
28
+
29
+
30
+ typedef struct {
31
+ PyObject_HEAD
32
+ long obval;
33
+ } PyLongScalarObject;
34
+
35
+
36
+ typedef struct {
37
+ PyObject_HEAD
38
+ npy_longlong obval;
39
+ } PyLongLongScalarObject;
40
+
41
+
42
+ typedef struct {
43
+ PyObject_HEAD
44
+ unsigned char obval;
45
+ } PyUByteScalarObject;
46
+
47
+
48
+ typedef struct {
49
+ PyObject_HEAD
50
+ unsigned short obval;
51
+ } PyUShortScalarObject;
52
+
53
+
54
+ typedef struct {
55
+ PyObject_HEAD
56
+ unsigned int obval;
57
+ } PyUIntScalarObject;
58
+
59
+
60
+ typedef struct {
61
+ PyObject_HEAD
62
+ unsigned long obval;
63
+ } PyULongScalarObject;
64
+
65
+
66
+ typedef struct {
67
+ PyObject_HEAD
68
+ npy_ulonglong obval;
69
+ } PyULongLongScalarObject;
70
+
71
+
72
+ typedef struct {
73
+ PyObject_HEAD
74
+ npy_half obval;
75
+ } PyHalfScalarObject;
76
+
77
+
78
+ typedef struct {
79
+ PyObject_HEAD
80
+ float obval;
81
+ } PyFloatScalarObject;
82
+
83
+
84
+ typedef struct {
85
+ PyObject_HEAD
86
+ double obval;
87
+ } PyDoubleScalarObject;
88
+
89
+
90
+ typedef struct {
91
+ PyObject_HEAD
92
+ npy_longdouble obval;
93
+ } PyLongDoubleScalarObject;
94
+
95
+
96
+ typedef struct {
97
+ PyObject_HEAD
98
+ npy_cfloat obval;
99
+ } PyCFloatScalarObject;
100
+
101
+
102
+ typedef struct {
103
+ PyObject_HEAD
104
+ npy_cdouble obval;
105
+ } PyCDoubleScalarObject;
106
+
107
+
108
+ typedef struct {
109
+ PyObject_HEAD
110
+ npy_clongdouble obval;
111
+ } PyCLongDoubleScalarObject;
112
+
113
+
114
+ typedef struct {
115
+ PyObject_HEAD
116
+ PyObject * obval;
117
+ } PyObjectScalarObject;
118
+
119
+ typedef struct {
120
+ PyObject_HEAD
121
+ npy_datetime obval;
122
+ PyArray_DatetimeMetaData obmeta;
123
+ } PyDatetimeScalarObject;
124
+
125
+ typedef struct {
126
+ PyObject_HEAD
127
+ npy_timedelta obval;
128
+ PyArray_DatetimeMetaData obmeta;
129
+ } PyTimedeltaScalarObject;
130
+
131
+
132
+ typedef struct {
133
+ PyObject_HEAD
134
+ char obval;
135
+ } PyScalarObject;
136
+
137
+ #define PyStringScalarObject PyBytesObject
138
+ #ifndef Py_LIMITED_API
139
+ typedef struct {
140
+ /* note that the PyObject_HEAD macro lives right here */
141
+ PyUnicodeObject base;
142
+ Py_UCS4 *obval;
143
+ #if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
144
+ char *buffer_fmt;
145
+ #endif
146
+ } PyUnicodeScalarObject;
147
+ #endif
148
+
149
+
150
+ typedef struct {
151
+ PyObject_VAR_HEAD
152
+ char *obval;
153
+ #if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
154
+ /* Internally use the subclass to allow accessing names/fields */
155
+ _PyArray_LegacyDescr *descr;
156
+ #else
157
+ PyArray_Descr *descr;
158
+ #endif
159
+ int flags;
160
+ PyObject *base;
161
+ #if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
162
+ void *_buffer_info; /* private buffer info, tagged to allow warning */
163
+ #endif
164
+ } PyVoidScalarObject;
165
+
166
+ /* Macros
167
+ Py<Cls><bitsize>ScalarObject
168
+ Py<Cls><bitsize>ArrType_Type
169
+ are defined in ndarrayobject.h
170
+ */
171
+
172
+ #define PyArrayScalar_False ((PyObject *)(&(_PyArrayScalar_BoolValues[0])))
173
+ #define PyArrayScalar_True ((PyObject *)(&(_PyArrayScalar_BoolValues[1])))
174
+ #define PyArrayScalar_FromLong(i) \
175
+ ((PyObject *)(&(_PyArrayScalar_BoolValues[((i)!=0)])))
176
+ #define PyArrayScalar_RETURN_BOOL_FROM_LONG(i) \
177
+ return Py_INCREF(PyArrayScalar_FromLong(i)), \
178
+ PyArrayScalar_FromLong(i)
179
+ #define PyArrayScalar_RETURN_FALSE \
180
+ return Py_INCREF(PyArrayScalar_False), \
181
+ PyArrayScalar_False
182
+ #define PyArrayScalar_RETURN_TRUE \
183
+ return Py_INCREF(PyArrayScalar_True), \
184
+ PyArrayScalar_True
185
+
186
+ #define PyArrayScalar_New(cls) \
187
+ Py##cls##ArrType_Type.tp_alloc(&Py##cls##ArrType_Type, 0)
188
+ #ifndef Py_LIMITED_API
189
+ /* For the limited API, use PyArray_ScalarAsCtype instead */
190
+ #define PyArrayScalar_VAL(obj, cls) \
191
+ ((Py##cls##ScalarObject *)obj)->obval
192
+ #define PyArrayScalar_ASSIGN(obj, cls, val) \
193
+ PyArrayScalar_VAL(obj, cls) = val
194
+ #endif
195
+
196
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/dtype_api.h ADDED
@@ -0,0 +1,480 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * The public DType API
3
+ */
4
+
5
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_
6
+ #define NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_
7
+
8
+ struct PyArrayMethodObject_tag;
9
+
10
+ /*
11
+ * Largely opaque struct for DType classes (i.e. metaclass instances).
12
+ * The internal definition is currently in `ndarraytypes.h` (export is a bit
13
+ * more complex because `PyArray_Descr` is a DTypeMeta internally but not
14
+ * externally).
15
+ */
16
+ #if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
17
+
18
+ #ifndef Py_LIMITED_API
19
+
20
+ typedef struct PyArray_DTypeMeta_tag {
21
+ PyHeapTypeObject super;
22
+
23
+ /*
24
+ * Most DTypes will have a singleton default instance, for the
25
+ * parametric legacy DTypes (bytes, string, void, datetime) this
26
+ * may be a pointer to the *prototype* instance?
27
+ */
28
+ PyArray_Descr *singleton;
29
+ /* Copy of the legacy DTypes type number, usually invalid. */
30
+ int type_num;
31
+
32
+ /* The type object of the scalar instances (may be NULL?) */
33
+ PyTypeObject *scalar_type;
34
+ /*
35
+ * DType flags to signal legacy, parametric, or
36
+ * abstract. But plenty of space for additional information/flags.
37
+ */
38
+ npy_uint64 flags;
39
+
40
+ /*
41
+ * Use indirection in order to allow a fixed size for this struct.
42
+ * A stable ABI size makes creating a static DType less painful
43
+ * while also ensuring flexibility for all opaque API (with one
44
+ * indirection due the pointer lookup).
45
+ */
46
+ void *dt_slots;
47
+ /* Allow growing (at the moment also beyond this) */
48
+ void *reserved[3];
49
+ } PyArray_DTypeMeta;
50
+
51
+ #else
52
+
53
+ typedef PyTypeObject PyArray_DTypeMeta;
54
+
55
+ #endif /* Py_LIMITED_API */
56
+
57
+ #endif /* not internal build */
58
+
59
+ /*
60
+ * ******************************************************
61
+ * ArrayMethod API (Casting and UFuncs)
62
+ * ******************************************************
63
+ */
64
+
65
+
66
+ typedef enum {
67
+ /* Flag for whether the GIL is required */
68
+ NPY_METH_REQUIRES_PYAPI = 1 << 0,
69
+ /*
70
+ * Some functions cannot set floating point error flags, this flag
71
+ * gives us the option (not requirement) to skip floating point error
72
+ * setup/check. No function should set error flags and ignore them
73
+ * since it would interfere with chaining operations (e.g. casting).
74
+ */
75
+ NPY_METH_NO_FLOATINGPOINT_ERRORS = 1 << 1,
76
+ /* Whether the method supports unaligned access (not runtime) */
77
+ NPY_METH_SUPPORTS_UNALIGNED = 1 << 2,
78
+ /*
79
+ * Used for reductions to allow reordering the operation. At this point
80
+ * assume that if set, it also applies to normal operations though!
81
+ */
82
+ NPY_METH_IS_REORDERABLE = 1 << 3,
83
+ /*
84
+ * Private flag for now for *logic* functions. The logical functions
85
+ * `logical_or` and `logical_and` can always cast the inputs to booleans
86
+ * "safely" (because that is how the cast to bool is defined).
87
+ * @seberg: I am not sure this is the best way to handle this, so its
88
+ * private for now (also it is very limited anyway).
89
+ * There is one "exception". NA aware dtypes cannot cast to bool
90
+ * (hopefully), so the `??->?` loop should error even with this flag.
91
+ * But a second NA fallback loop will be necessary.
92
+ */
93
+ _NPY_METH_FORCE_CAST_INPUTS = 1 << 17,
94
+
95
+ /* All flags which can change at runtime */
96
+ NPY_METH_RUNTIME_FLAGS = (
97
+ NPY_METH_REQUIRES_PYAPI |
98
+ NPY_METH_NO_FLOATINGPOINT_ERRORS),
99
+ } NPY_ARRAYMETHOD_FLAGS;
100
+
101
+
102
+ typedef struct PyArrayMethod_Context_tag {
103
+ /* The caller, which is typically the original ufunc. May be NULL */
104
+ PyObject *caller;
105
+ /* The method "self". Currently an opaque object. */
106
+ struct PyArrayMethodObject_tag *method;
107
+
108
+ /* Operand descriptors, filled in by resolve_descriptors */
109
+ PyArray_Descr *const *descriptors;
110
+ /* Structure may grow (this is harmless for DType authors) */
111
+ } PyArrayMethod_Context;
112
+
113
+
114
+ /*
115
+ * The main object for creating a new ArrayMethod. We use the typical `slots`
116
+ * mechanism used by the Python limited API (see below for the slot defs).
117
+ */
118
+ typedef struct {
119
+ const char *name;
120
+ int nin, nout;
121
+ NPY_CASTING casting;
122
+ NPY_ARRAYMETHOD_FLAGS flags;
123
+ PyArray_DTypeMeta **dtypes;
124
+ PyType_Slot *slots;
125
+ } PyArrayMethod_Spec;
126
+
127
+
128
+ /*
129
+ * ArrayMethod slots
130
+ * -----------------
131
+ *
132
+ * SLOTS IDs For the ArrayMethod creation, once fully public, IDs are fixed
133
+ * but can be deprecated and arbitrarily extended.
134
+ */
135
+ #define _NPY_METH_resolve_descriptors_with_scalars 1
136
+ #define NPY_METH_resolve_descriptors 2
137
+ #define NPY_METH_get_loop 3
138
+ #define NPY_METH_get_reduction_initial 4
139
+ /* specific loops for constructions/default get_loop: */
140
+ #define NPY_METH_strided_loop 5
141
+ #define NPY_METH_contiguous_loop 6
142
+ #define NPY_METH_unaligned_strided_loop 7
143
+ #define NPY_METH_unaligned_contiguous_loop 8
144
+ #define NPY_METH_contiguous_indexed_loop 9
145
+ #define _NPY_METH_static_data 10
146
+
147
+
148
+ /*
149
+ * The resolve descriptors function, must be able to handle NULL values for
150
+ * all output (but not input) `given_descrs` and fill `loop_descrs`.
151
+ * Return -1 on error or 0 if the operation is not possible without an error
152
+ * set. (This may still be in flux.)
153
+ * Otherwise must return the "casting safety", for normal functions, this is
154
+ * almost always "safe" (or even "equivalent"?).
155
+ *
156
+ * `resolve_descriptors` is optional if all output DTypes are non-parametric.
157
+ */
158
+ typedef NPY_CASTING (PyArrayMethod_ResolveDescriptors)(
159
+ /* "method" is currently opaque (necessary e.g. to wrap Python) */
160
+ struct PyArrayMethodObject_tag *method,
161
+ /* DTypes the method was created for */
162
+ PyArray_DTypeMeta *const *dtypes,
163
+ /* Input descriptors (instances). Outputs may be NULL. */
164
+ PyArray_Descr *const *given_descrs,
165
+ /* Exact loop descriptors to use, must not hold references on error */
166
+ PyArray_Descr **loop_descrs,
167
+ npy_intp *view_offset);
168
+
169
+
170
+ /*
171
+ * Rarely needed, slightly more powerful version of `resolve_descriptors`.
172
+ * See also `PyArrayMethod_ResolveDescriptors` for details on shared arguments.
173
+ *
174
+ * NOTE: This function is private now as it is unclear how and what to pass
175
+ * exactly as additional information to allow dealing with the scalars.
176
+ * See also gh-24915.
177
+ */
178
+ typedef NPY_CASTING (PyArrayMethod_ResolveDescriptorsWithScalar)(
179
+ struct PyArrayMethodObject_tag *method,
180
+ PyArray_DTypeMeta *const *dtypes,
181
+ /* Unlike above, these can have any DType and we may allow NULL. */
182
+ PyArray_Descr *const *given_descrs,
183
+ /*
184
+ * Input scalars or NULL. Only ever passed for python scalars.
185
+ * WARNING: In some cases, a loop may be explicitly selected and the
186
+ * value passed is not available (NULL) or does not have the
187
+ * expected type.
188
+ */
189
+ PyObject *const *input_scalars,
190
+ PyArray_Descr **loop_descrs,
191
+ npy_intp *view_offset);
192
+
193
+
194
+
195
+ typedef int (PyArrayMethod_StridedLoop)(PyArrayMethod_Context *context,
196
+ char *const *data, const npy_intp *dimensions, const npy_intp *strides,
197
+ NpyAuxData *transferdata);
198
+
199
+
200
+ typedef int (PyArrayMethod_GetLoop)(
201
+ PyArrayMethod_Context *context,
202
+ int aligned, int move_references,
203
+ const npy_intp *strides,
204
+ PyArrayMethod_StridedLoop **out_loop,
205
+ NpyAuxData **out_transferdata,
206
+ NPY_ARRAYMETHOD_FLAGS *flags);
207
+
208
+ /**
209
+ * Query an ArrayMethod for the initial value for use in reduction.
210
+ *
211
+ * @param context The arraymethod context, mainly to access the descriptors.
212
+ * @param reduction_is_empty Whether the reduction is empty. When it is, the
213
+ * value returned may differ. In this case it is a "default" value that
214
+ * may differ from the "identity" value normally used. For example:
215
+ * - `0.0` is the default for `sum([])`. But `-0.0` is the correct
216
+ * identity otherwise as it preserves the sign for `sum([-0.0])`.
217
+ * - We use no identity for object, but return the default of `0` and `1`
218
+ * for the empty `sum([], dtype=object)` and `prod([], dtype=object)`.
219
+ * This allows `np.sum(np.array(["a", "b"], dtype=object))` to work.
220
+ * - `-inf` or `INT_MIN` for `max` is an identity, but at least `INT_MIN`
221
+ * not a good *default* when there are no items.
222
+ * @param initial Pointer to initial data to be filled (if possible)
223
+ *
224
+ * @returns -1, 0, or 1 indicating error, no initial value, and initial being
225
+ * successfully filled. Errors must not be given where 0 is correct, NumPy
226
+ * may call this even when not strictly necessary.
227
+ */
228
+ typedef int (PyArrayMethod_GetReductionInitial)(
229
+ PyArrayMethod_Context *context, npy_bool reduction_is_empty,
230
+ void *initial);
231
+
232
+ /*
233
+ * The following functions are only used by the wrapping array method defined
234
+ * in umath/wrapping_array_method.c
235
+ */
236
+
237
+
238
+ /*
239
+ * The function to convert the given descriptors (passed in to
240
+ * `resolve_descriptors`) and translates them for the wrapped loop.
241
+ * The new descriptors MUST be viewable with the old ones, `NULL` must be
242
+ * supported (for outputs) and should normally be forwarded.
243
+ *
244
+ * The function must clean up on error.
245
+ *
246
+ * NOTE: We currently assume that this translation gives "viewable" results.
247
+ * I.e. there is no additional casting related to the wrapping process.
248
+ * In principle that could be supported, but not sure it is useful.
249
+ * This currently also means that e.g. alignment must apply identically
250
+ * to the new dtypes.
251
+ *
252
+ * TODO: Due to the fact that `resolve_descriptors` is also used for `can_cast`
253
+ * there is no way to "pass out" the result of this function. This means
254
+ * it will be called twice for every ufunc call.
255
+ * (I am considering including `auxdata` as an "optional" parameter to
256
+ * `resolve_descriptors`, so that it can be filled there if not NULL.)
257
+ */
258
+ typedef int (PyArrayMethod_TranslateGivenDescriptors)(int nin, int nout,
259
+ PyArray_DTypeMeta *const wrapped_dtypes[],
260
+ PyArray_Descr *const given_descrs[], PyArray_Descr *new_descrs[]);
261
+
262
+ /**
263
+ * The function to convert the actual loop descriptors (as returned by the
264
+ * original `resolve_descriptors` function) to the ones the output array
265
+ * should use.
266
+ * This function must return "viewable" types, it must not mutate them in any
267
+ * form that would break the inner-loop logic. Does not need to support NULL.
268
+ *
269
+ * The function must clean up on error.
270
+ *
271
+ * @param nin Number of input arguments
272
+ * @param nout Number of output arguments
273
+ * @param new_dtypes The DTypes of the output (usually probably not needed)
274
+ * @param given_descrs Original given_descrs to the resolver, necessary to
275
+ * fetch any information related to the new dtypes from the original.
276
+ * @param original_descrs The `loop_descrs` returned by the wrapped loop.
277
+ * @param loop_descrs The output descriptors, compatible to `original_descrs`.
278
+ *
279
+ * @returns 0 on success, -1 on failure.
280
+ */
281
+ typedef int (PyArrayMethod_TranslateLoopDescriptors)(int nin, int nout,
282
+ PyArray_DTypeMeta *const new_dtypes[], PyArray_Descr *const given_descrs[],
283
+ PyArray_Descr *original_descrs[], PyArray_Descr *loop_descrs[]);
284
+
285
+
286
+
287
+ /*
288
+ * A traverse loop working on a single array. This is similar to the general
289
+ * strided-loop function. This is designed for loops that need to visit every
290
+ * element of a single array.
291
+ *
292
+ * Currently this is used for array clearing, via the NPY_DT_get_clear_loop
293
+ * API hook, and zero-filling, via the NPY_DT_get_fill_zero_loop API hook.
294
+ * These are most useful for handling arrays storing embedded references to
295
+ * python objects or heap-allocated data.
296
+ *
297
+ * The `void *traverse_context` is passed in because we may need to pass in
298
+ * Interpreter state or similar in the future, but we don't want to pass in
299
+ * a full context (with pointers to dtypes, method, caller which all make
300
+ * no sense for a traverse function).
301
+ *
302
+ * We assume for now that this context can be just passed through in the
303
+ * the future (for structured dtypes).
304
+ *
305
+ */
306
+ typedef int (PyArrayMethod_TraverseLoop)(
307
+ void *traverse_context, const PyArray_Descr *descr, char *data,
308
+ npy_intp size, npy_intp stride, NpyAuxData *auxdata);
309
+
310
+
311
+ /*
312
+ * Simplified get_loop function specific to dtype traversal
313
+ *
314
+ * It should set the flags needed for the traversal loop and set out_loop to the
315
+ * loop function, which must be a valid PyArrayMethod_TraverseLoop
316
+ * pointer. Currently this is used for zero-filling and clearing arrays storing
317
+ * embedded references.
318
+ *
319
+ */
320
+ typedef int (PyArrayMethod_GetTraverseLoop)(
321
+ void *traverse_context, const PyArray_Descr *descr,
322
+ int aligned, npy_intp fixed_stride,
323
+ PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **out_auxdata,
324
+ NPY_ARRAYMETHOD_FLAGS *flags);
325
+
326
+
327
+ /*
328
+ * Type of the C promoter function, which must be wrapped into a
329
+ * PyCapsule with name "numpy._ufunc_promoter".
330
+ *
331
+ * Note that currently the output dtypes are always NULL unless they are
332
+ * also part of the signature. This is an implementation detail and could
333
+ * change in the future. However, in general promoters should not have a
334
+ * need for output dtypes.
335
+ * (There are potential use-cases, these are currently unsupported.)
336
+ */
337
+ typedef int (PyArrayMethod_PromoterFunction)(PyObject *ufunc,
338
+ PyArray_DTypeMeta *const op_dtypes[], PyArray_DTypeMeta *const signature[],
339
+ PyArray_DTypeMeta *new_op_dtypes[]);
340
+
341
+ /*
342
+ * ****************************
343
+ * DTYPE API
344
+ * ****************************
345
+ */
346
+
347
+ #define NPY_DT_ABSTRACT 1 << 1
348
+ #define NPY_DT_PARAMETRIC 1 << 2
349
+ #define NPY_DT_NUMERIC 1 << 3
350
+
351
+ /*
352
+ * These correspond to slots in the NPY_DType_Slots struct and must
353
+ * be in the same order as the members of that struct. If new slots
354
+ * get added or old slots get removed NPY_NUM_DTYPE_SLOTS must also
355
+ * be updated
356
+ */
357
+
358
+ #define NPY_DT_discover_descr_from_pyobject 1
359
+ // this slot is considered private because its API hasn't been decided
360
+ #define _NPY_DT_is_known_scalar_type 2
361
+ #define NPY_DT_default_descr 3
362
+ #define NPY_DT_common_dtype 4
363
+ #define NPY_DT_common_instance 5
364
+ #define NPY_DT_ensure_canonical 6
365
+ #define NPY_DT_setitem 7
366
+ #define NPY_DT_getitem 8
367
+ #define NPY_DT_get_clear_loop 9
368
+ #define NPY_DT_get_fill_zero_loop 10
369
+ #define NPY_DT_finalize_descr 11
370
+
371
+ // These PyArray_ArrFunc slots will be deprecated and replaced eventually
372
+ // getitem and setitem can be defined as a performance optimization;
373
+ // by default the user dtypes call `legacy_getitem_using_DType` and
374
+ // `legacy_setitem_using_DType`, respectively. This functionality is
375
+ // only supported for basic NumPy DTypes.
376
+
377
+
378
+ // used to separate dtype slots from arrfuncs slots
379
+ // intended only for internal use but defined here for clarity
380
+ #define _NPY_DT_ARRFUNCS_OFFSET (1 << 10)
381
+
382
+ // Cast is disabled
383
+ // #define NPY_DT_PyArray_ArrFuncs_cast 0 + _NPY_DT_ARRFUNCS_OFFSET
384
+
385
+ #define NPY_DT_PyArray_ArrFuncs_getitem 1 + _NPY_DT_ARRFUNCS_OFFSET
386
+ #define NPY_DT_PyArray_ArrFuncs_setitem 2 + _NPY_DT_ARRFUNCS_OFFSET
387
+
388
+ // Copyswap is disabled
389
+ // #define NPY_DT_PyArray_ArrFuncs_copyswapn 3 + _NPY_DT_ARRFUNCS_OFFSET
390
+ // #define NPY_DT_PyArray_ArrFuncs_copyswap 4 + _NPY_DT_ARRFUNCS_OFFSET
391
+ #define NPY_DT_PyArray_ArrFuncs_compare 5 + _NPY_DT_ARRFUNCS_OFFSET
392
+ #define NPY_DT_PyArray_ArrFuncs_argmax 6 + _NPY_DT_ARRFUNCS_OFFSET
393
+ #define NPY_DT_PyArray_ArrFuncs_dotfunc 7 + _NPY_DT_ARRFUNCS_OFFSET
394
+ #define NPY_DT_PyArray_ArrFuncs_scanfunc 8 + _NPY_DT_ARRFUNCS_OFFSET
395
+ #define NPY_DT_PyArray_ArrFuncs_fromstr 9 + _NPY_DT_ARRFUNCS_OFFSET
396
+ #define NPY_DT_PyArray_ArrFuncs_nonzero 10 + _NPY_DT_ARRFUNCS_OFFSET
397
+ #define NPY_DT_PyArray_ArrFuncs_fill 11 + _NPY_DT_ARRFUNCS_OFFSET
398
+ #define NPY_DT_PyArray_ArrFuncs_fillwithscalar 12 + _NPY_DT_ARRFUNCS_OFFSET
399
+ #define NPY_DT_PyArray_ArrFuncs_sort 13 + _NPY_DT_ARRFUNCS_OFFSET
400
+ #define NPY_DT_PyArray_ArrFuncs_argsort 14 + _NPY_DT_ARRFUNCS_OFFSET
401
+
402
+ // Casting related slots are disabled. See
403
+ // https://github.com/numpy/numpy/pull/23173#discussion_r1101098163
404
+ // #define NPY_DT_PyArray_ArrFuncs_castdict 15 + _NPY_DT_ARRFUNCS_OFFSET
405
+ // #define NPY_DT_PyArray_ArrFuncs_scalarkind 16 + _NPY_DT_ARRFUNCS_OFFSET
406
+ // #define NPY_DT_PyArray_ArrFuncs_cancastscalarkindto 17 + _NPY_DT_ARRFUNCS_OFFSET
407
+ // #define NPY_DT_PyArray_ArrFuncs_cancastto 18 + _NPY_DT_ARRFUNCS_OFFSET
408
+
409
+ // These are deprecated in NumPy 1.19, so are disabled here.
410
+ // #define NPY_DT_PyArray_ArrFuncs_fastclip 19 + _NPY_DT_ARRFUNCS_OFFSET
411
+ // #define NPY_DT_PyArray_ArrFuncs_fastputmask 20 + _NPY_DT_ARRFUNCS_OFFSET
412
+ // #define NPY_DT_PyArray_ArrFuncs_fasttake 21 + _NPY_DT_ARRFUNCS_OFFSET
413
+ #define NPY_DT_PyArray_ArrFuncs_argmin 22 + _NPY_DT_ARRFUNCS_OFFSET
414
+
415
+
416
+ // TODO: These slots probably still need some thought, and/or a way to "grow"?
417
+ typedef struct {
418
+ PyTypeObject *typeobj; /* type of python scalar or NULL */
419
+ int flags; /* flags, including parametric and abstract */
420
+ /* NULL terminated cast definitions. Use NULL for the newly created DType */
421
+ PyArrayMethod_Spec **casts;
422
+ PyType_Slot *slots;
423
+ /* Baseclass or NULL (will always subclass `np.dtype`) */
424
+ PyTypeObject *baseclass;
425
+ } PyArrayDTypeMeta_Spec;
426
+
427
+
428
+ typedef PyArray_Descr *(PyArrayDTypeMeta_DiscoverDescrFromPyobject)(
429
+ PyArray_DTypeMeta *cls, PyObject *obj);
430
+
431
+ /*
432
+ * Before making this public, we should decide whether it should pass
433
+ * the type, or allow looking at the object. A possible use-case:
434
+ * `np.array(np.array([0]), dtype=np.ndarray)`
435
+ * Could consider arrays that are not `dtype=ndarray` "scalars".
436
+ */
437
+ typedef int (PyArrayDTypeMeta_IsKnownScalarType)(
438
+ PyArray_DTypeMeta *cls, PyTypeObject *obj);
439
+
440
+ typedef PyArray_Descr *(PyArrayDTypeMeta_DefaultDescriptor)(PyArray_DTypeMeta *cls);
441
+ typedef PyArray_DTypeMeta *(PyArrayDTypeMeta_CommonDType)(
442
+ PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtype2);
443
+
444
+
445
+ /*
446
+ * Convenience utility for getting a reference to the DType metaclass associated
447
+ * with a dtype instance.
448
+ */
449
+ #define NPY_DTYPE(descr) ((PyArray_DTypeMeta *)Py_TYPE(descr))
450
+
451
+ static inline PyArray_DTypeMeta *
452
+ NPY_DT_NewRef(PyArray_DTypeMeta *o) {
453
+ Py_INCREF((PyObject *)o);
454
+ return o;
455
+ }
456
+
457
+
458
+ typedef PyArray_Descr *(PyArrayDTypeMeta_CommonInstance)(
459
+ PyArray_Descr *dtype1, PyArray_Descr *dtype2);
460
+ typedef PyArray_Descr *(PyArrayDTypeMeta_EnsureCanonical)(PyArray_Descr *dtype);
461
+ /*
462
+ * Returns either a new reference to *dtype* or a new descriptor instance
463
+ * initialized with the same parameters as *dtype*. The caller cannot know
464
+ * which choice a dtype will make. This function is called just before the
465
+ * array buffer is created for a newly created array, it is not called for
466
+ * views and the descriptor returned by this function is attached to the array.
467
+ */
468
+ typedef PyArray_Descr *(PyArrayDTypeMeta_FinalizeDescriptor)(PyArray_Descr *dtype);
469
+
470
+ /*
471
+ * TODO: These two functions are currently only used for experimental DType
472
+ * API support. Their relation should be "reversed": NumPy should
473
+ * always use them internally.
474
+ * There are open points about "casting safety" though, e.g. setting
475
+ * elements is currently always unsafe.
476
+ */
477
+ typedef int(PyArrayDTypeMeta_SetItem)(PyArray_Descr *, PyObject *, char *);
478
+ typedef PyObject *(PyArrayDTypeMeta_GetItem)(PyArray_Descr *, char *);
479
+
480
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/halffloat.h ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_
3
+
4
+ #include <Python.h>
5
+ #include <numpy/npy_math.h>
6
+
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ /*
12
+ * Half-precision routines
13
+ */
14
+
15
+ /* Conversions */
16
+ float npy_half_to_float(npy_half h);
17
+ double npy_half_to_double(npy_half h);
18
+ npy_half npy_float_to_half(float f);
19
+ npy_half npy_double_to_half(double d);
20
+ /* Comparisons */
21
+ int npy_half_eq(npy_half h1, npy_half h2);
22
+ int npy_half_ne(npy_half h1, npy_half h2);
23
+ int npy_half_le(npy_half h1, npy_half h2);
24
+ int npy_half_lt(npy_half h1, npy_half h2);
25
+ int npy_half_ge(npy_half h1, npy_half h2);
26
+ int npy_half_gt(npy_half h1, npy_half h2);
27
+ /* faster *_nonan variants for when you know h1 and h2 are not NaN */
28
+ int npy_half_eq_nonan(npy_half h1, npy_half h2);
29
+ int npy_half_lt_nonan(npy_half h1, npy_half h2);
30
+ int npy_half_le_nonan(npy_half h1, npy_half h2);
31
+ /* Miscellaneous functions */
32
+ int npy_half_iszero(npy_half h);
33
+ int npy_half_isnan(npy_half h);
34
+ int npy_half_isinf(npy_half h);
35
+ int npy_half_isfinite(npy_half h);
36
+ int npy_half_signbit(npy_half h);
37
+ npy_half npy_half_copysign(npy_half x, npy_half y);
38
+ npy_half npy_half_spacing(npy_half h);
39
+ npy_half npy_half_nextafter(npy_half x, npy_half y);
40
+ npy_half npy_half_divmod(npy_half x, npy_half y, npy_half *modulus);
41
+
42
+ /*
43
+ * Half-precision constants
44
+ */
45
+
46
+ #define NPY_HALF_ZERO (0x0000u)
47
+ #define NPY_HALF_PZERO (0x0000u)
48
+ #define NPY_HALF_NZERO (0x8000u)
49
+ #define NPY_HALF_ONE (0x3c00u)
50
+ #define NPY_HALF_NEGONE (0xbc00u)
51
+ #define NPY_HALF_PINF (0x7c00u)
52
+ #define NPY_HALF_NINF (0xfc00u)
53
+ #define NPY_HALF_NAN (0x7e00u)
54
+
55
+ #define NPY_MAX_HALF (0x7bffu)
56
+
57
+ /*
58
+ * Bit-level conversions
59
+ */
60
+
61
+ npy_uint16 npy_floatbits_to_halfbits(npy_uint32 f);
62
+ npy_uint16 npy_doublebits_to_halfbits(npy_uint64 d);
63
+ npy_uint32 npy_halfbits_to_floatbits(npy_uint16 h);
64
+ npy_uint64 npy_halfbits_to_doublebits(npy_uint16 h);
65
+
66
+ #ifdef __cplusplus
67
+ }
68
+ #endif
69
+
70
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_HALFFLOAT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarrayobject.h ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * DON'T INCLUDE THIS DIRECTLY.
3
+ */
4
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NDARRAYOBJECT_H_
5
+ #define NUMPY_CORE_INCLUDE_NUMPY_NDARRAYOBJECT_H_
6
+
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ #include <Python.h>
12
+ #include "ndarraytypes.h"
13
+ #include "dtype_api.h"
14
+
15
+ /* Includes the "function" C-API -- these are all stored in a
16
+ list of pointers --- one for each file
17
+ The two lists are concatenated into one in multiarray.
18
+
19
+ They are available as import_array()
20
+ */
21
+
22
+ #include "__multiarray_api.h"
23
+
24
+ /*
25
+ * Include any definitions which are defined differently for 1.x and 2.x
26
+ * (Symbols only available on 2.x are not there, but rather guarded.)
27
+ */
28
+ #include "npy_2_compat.h"
29
+
30
+ /* C-API that requires previous API to be defined */
31
+
32
+ #define PyArray_DescrCheck(op) PyObject_TypeCheck(op, &PyArrayDescr_Type)
33
+
34
+ #define PyArray_Check(op) PyObject_TypeCheck(op, &PyArray_Type)
35
+ #define PyArray_CheckExact(op) (((PyObject*)(op))->ob_type == &PyArray_Type)
36
+
37
+ #define PyArray_HasArrayInterfaceType(op, type, context, out) \
38
+ ((((out)=PyArray_FromStructInterface(op)) != Py_NotImplemented) || \
39
+ (((out)=PyArray_FromInterface(op)) != Py_NotImplemented) || \
40
+ (((out)=PyArray_FromArrayAttr(op, type, context)) != \
41
+ Py_NotImplemented))
42
+
43
+ #define PyArray_HasArrayInterface(op, out) \
44
+ PyArray_HasArrayInterfaceType(op, NULL, NULL, out)
45
+
46
+ #define PyArray_IsZeroDim(op) (PyArray_Check(op) && \
47
+ (PyArray_NDIM((PyArrayObject *)op) == 0))
48
+
49
+ #define PyArray_IsScalar(obj, cls) \
50
+ (PyObject_TypeCheck(obj, &Py##cls##ArrType_Type))
51
+
52
+ #define PyArray_CheckScalar(m) (PyArray_IsScalar(m, Generic) || \
53
+ PyArray_IsZeroDim(m))
54
+ #define PyArray_IsPythonNumber(obj) \
55
+ (PyFloat_Check(obj) || PyComplex_Check(obj) || \
56
+ PyLong_Check(obj) || PyBool_Check(obj))
57
+ #define PyArray_IsIntegerScalar(obj) (PyLong_Check(obj) \
58
+ || PyArray_IsScalar((obj), Integer))
59
+ #define PyArray_IsPythonScalar(obj) \
60
+ (PyArray_IsPythonNumber(obj) || PyBytes_Check(obj) || \
61
+ PyUnicode_Check(obj))
62
+
63
+ #define PyArray_IsAnyScalar(obj) \
64
+ (PyArray_IsScalar(obj, Generic) || PyArray_IsPythonScalar(obj))
65
+
66
+ #define PyArray_CheckAnyScalar(obj) (PyArray_IsPythonScalar(obj) || \
67
+ PyArray_CheckScalar(obj))
68
+
69
+
70
+ #define PyArray_GETCONTIGUOUS(m) (PyArray_ISCONTIGUOUS(m) ? \
71
+ Py_INCREF(m), (m) : \
72
+ (PyArrayObject *)(PyArray_Copy(m)))
73
+
74
+ #define PyArray_SAMESHAPE(a1,a2) ((PyArray_NDIM(a1) == PyArray_NDIM(a2)) && \
75
+ PyArray_CompareLists(PyArray_DIMS(a1), \
76
+ PyArray_DIMS(a2), \
77
+ PyArray_NDIM(a1)))
78
+
79
+ #define PyArray_SIZE(m) PyArray_MultiplyList(PyArray_DIMS(m), PyArray_NDIM(m))
80
+ #define PyArray_NBYTES(m) (PyArray_ITEMSIZE(m) * PyArray_SIZE(m))
81
+ #define PyArray_FROM_O(m) PyArray_FromAny(m, NULL, 0, 0, 0, NULL)
82
+
83
+ #define PyArray_FROM_OF(m,flags) PyArray_CheckFromAny(m, NULL, 0, 0, flags, \
84
+ NULL)
85
+
86
+ #define PyArray_FROM_OT(m,type) PyArray_FromAny(m, \
87
+ PyArray_DescrFromType(type), 0, 0, 0, NULL)
88
+
89
+ #define PyArray_FROM_OTF(m, type, flags) \
90
+ PyArray_FromAny(m, PyArray_DescrFromType(type), 0, 0, \
91
+ (((flags) & NPY_ARRAY_ENSURECOPY) ? \
92
+ ((flags) | NPY_ARRAY_DEFAULT) : (flags)), NULL)
93
+
94
+ #define PyArray_FROMANY(m, type, min, max, flags) \
95
+ PyArray_FromAny(m, PyArray_DescrFromType(type), min, max, \
96
+ (((flags) & NPY_ARRAY_ENSURECOPY) ? \
97
+ (flags) | NPY_ARRAY_DEFAULT : (flags)), NULL)
98
+
99
+ #define PyArray_ZEROS(m, dims, type, is_f_order) \
100
+ PyArray_Zeros(m, dims, PyArray_DescrFromType(type), is_f_order)
101
+
102
+ #define PyArray_EMPTY(m, dims, type, is_f_order) \
103
+ PyArray_Empty(m, dims, PyArray_DescrFromType(type), is_f_order)
104
+
105
+ #define PyArray_FILLWBYTE(obj, val) memset(PyArray_DATA(obj), val, \
106
+ PyArray_NBYTES(obj))
107
+
108
+ #define PyArray_ContiguousFromAny(op, type, min_depth, max_depth) \
109
+ PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \
110
+ max_depth, NPY_ARRAY_DEFAULT, NULL)
111
+
112
+ #define PyArray_EquivArrTypes(a1, a2) \
113
+ PyArray_EquivTypes(PyArray_DESCR(a1), PyArray_DESCR(a2))
114
+
115
+ #define PyArray_EquivByteorders(b1, b2) \
116
+ (((b1) == (b2)) || (PyArray_ISNBO(b1) == PyArray_ISNBO(b2)))
117
+
118
+ #define PyArray_SimpleNew(nd, dims, typenum) \
119
+ PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)
120
+
121
+ #define PyArray_SimpleNewFromData(nd, dims, typenum, data) \
122
+ PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, \
123
+ data, 0, NPY_ARRAY_CARRAY, NULL)
124
+
125
+ #define PyArray_SimpleNewFromDescr(nd, dims, descr) \
126
+ PyArray_NewFromDescr(&PyArray_Type, descr, nd, dims, \
127
+ NULL, NULL, 0, NULL)
128
+
129
+ #define PyArray_ToScalar(data, arr) \
130
+ PyArray_Scalar(data, PyArray_DESCR(arr), (PyObject *)arr)
131
+
132
+
133
+ /* These might be faster without the dereferencing of obj
134
+ going on inside -- of course an optimizing compiler should
135
+ inline the constants inside a for loop making it a moot point
136
+ */
137
+
138
+ #define PyArray_GETPTR1(obj, i) ((void *)(PyArray_BYTES(obj) + \
139
+ (i)*PyArray_STRIDES(obj)[0]))
140
+
141
+ #define PyArray_GETPTR2(obj, i, j) ((void *)(PyArray_BYTES(obj) + \
142
+ (i)*PyArray_STRIDES(obj)[0] + \
143
+ (j)*PyArray_STRIDES(obj)[1]))
144
+
145
+ #define PyArray_GETPTR3(obj, i, j, k) ((void *)(PyArray_BYTES(obj) + \
146
+ (i)*PyArray_STRIDES(obj)[0] + \
147
+ (j)*PyArray_STRIDES(obj)[1] + \
148
+ (k)*PyArray_STRIDES(obj)[2]))
149
+
150
+ #define PyArray_GETPTR4(obj, i, j, k, l) ((void *)(PyArray_BYTES(obj) + \
151
+ (i)*PyArray_STRIDES(obj)[0] + \
152
+ (j)*PyArray_STRIDES(obj)[1] + \
153
+ (k)*PyArray_STRIDES(obj)[2] + \
154
+ (l)*PyArray_STRIDES(obj)[3]))
155
+
156
+ static inline void
157
+ PyArray_DiscardWritebackIfCopy(PyArrayObject *arr)
158
+ {
159
+ PyArrayObject_fields *fa = (PyArrayObject_fields *)arr;
160
+ if (fa && fa->base) {
161
+ if (fa->flags & NPY_ARRAY_WRITEBACKIFCOPY) {
162
+ PyArray_ENABLEFLAGS((PyArrayObject*)fa->base, NPY_ARRAY_WRITEABLE);
163
+ Py_DECREF(fa->base);
164
+ fa->base = NULL;
165
+ PyArray_CLEARFLAGS(arr, NPY_ARRAY_WRITEBACKIFCOPY);
166
+ }
167
+ }
168
+ }
169
+
170
+ #define PyArray_DESCR_REPLACE(descr) do { \
171
+ PyArray_Descr *_new_; \
172
+ _new_ = PyArray_DescrNew(descr); \
173
+ Py_XDECREF(descr); \
174
+ descr = _new_; \
175
+ } while(0)
176
+
177
+ /* Copy should always return contiguous array */
178
+ #define PyArray_Copy(obj) PyArray_NewCopy(obj, NPY_CORDER)
179
+
180
+ #define PyArray_FromObject(op, type, min_depth, max_depth) \
181
+ PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \
182
+ max_depth, NPY_ARRAY_BEHAVED | \
183
+ NPY_ARRAY_ENSUREARRAY, NULL)
184
+
185
+ #define PyArray_ContiguousFromObject(op, type, min_depth, max_depth) \
186
+ PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \
187
+ max_depth, NPY_ARRAY_DEFAULT | \
188
+ NPY_ARRAY_ENSUREARRAY, NULL)
189
+
190
+ #define PyArray_CopyFromObject(op, type, min_depth, max_depth) \
191
+ PyArray_FromAny(op, PyArray_DescrFromType(type), min_depth, \
192
+ max_depth, NPY_ARRAY_ENSURECOPY | \
193
+ NPY_ARRAY_DEFAULT | \
194
+ NPY_ARRAY_ENSUREARRAY, NULL)
195
+
196
+ #define PyArray_Cast(mp, type_num) \
197
+ PyArray_CastToType(mp, PyArray_DescrFromType(type_num), 0)
198
+
199
+ #define PyArray_Take(ap, items, axis) \
200
+ PyArray_TakeFrom(ap, items, axis, NULL, NPY_RAISE)
201
+
202
+ #define PyArray_Put(ap, items, values) \
203
+ PyArray_PutTo(ap, items, values, NPY_RAISE)
204
+
205
+
206
+ /*
207
+ Check to see if this key in the dictionary is the "title"
208
+ entry of the tuple (i.e. a duplicate dictionary entry in the fields
209
+ dict).
210
+ */
211
+
212
+ static inline int
213
+ NPY_TITLE_KEY_check(PyObject *key, PyObject *value)
214
+ {
215
+ PyObject *title;
216
+ if (PyTuple_Size(value) != 3) {
217
+ return 0;
218
+ }
219
+ title = PyTuple_GetItem(value, 2);
220
+ if (key == title) {
221
+ return 1;
222
+ }
223
+ #ifdef PYPY_VERSION
224
+ /*
225
+ * On PyPy, dictionary keys do not always preserve object identity.
226
+ * Fall back to comparison by value.
227
+ */
228
+ if (PyUnicode_Check(title) && PyUnicode_Check(key)) {
229
+ return PyUnicode_Compare(title, key) == 0 ? 1 : 0;
230
+ }
231
+ #endif
232
+ return 0;
233
+ }
234
+
235
+ /* Macro, for backward compat with "if NPY_TITLE_KEY(key, value) { ..." */
236
+ #define NPY_TITLE_KEY(key, value) (NPY_TITLE_KEY_check((key), (value)))
237
+
238
+ #define DEPRECATE(msg) PyErr_WarnEx(PyExc_DeprecationWarning,msg,1)
239
+ #define DEPRECATE_FUTUREWARNING(msg) PyErr_WarnEx(PyExc_FutureWarning,msg,1)
240
+
241
+
242
+ /*
243
+ * These macros and functions unfortunately require runtime version checks
244
+ * that are only defined in `npy_2_compat.h`. For that reasons they cannot be
245
+ * part of `ndarraytypes.h` which tries to be self contained.
246
+ */
247
+
248
+ static inline npy_intp
249
+ PyArray_ITEMSIZE(const PyArrayObject *arr)
250
+ {
251
+ return PyDataType_ELSIZE(((PyArrayObject_fields *)arr)->descr);
252
+ }
253
+
254
+ #define PyDataType_HASFIELDS(obj) (PyDataType_ISLEGACY((PyArray_Descr*)(obj)) && PyDataType_NAMES((PyArray_Descr*)(obj)) != NULL)
255
+ #define PyDataType_HASSUBARRAY(dtype) (PyDataType_ISLEGACY(dtype) && PyDataType_SUBARRAY(dtype) != NULL)
256
+ #define PyDataType_ISUNSIZED(dtype) ((dtype)->elsize == 0 && \
257
+ !PyDataType_HASFIELDS(dtype))
258
+
259
+ #define PyDataType_FLAGCHK(dtype, flag) \
260
+ ((PyDataType_FLAGS(dtype) & (flag)) == (flag))
261
+
262
+ #define PyDataType_REFCHK(dtype) \
263
+ PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)
264
+
265
+ #define NPY_BEGIN_THREADS_DESCR(dtype) \
266
+ do {if (!(PyDataType_FLAGCHK((dtype), NPY_NEEDS_PYAPI))) \
267
+ NPY_BEGIN_THREADS;} while (0);
268
+
269
+ #define NPY_END_THREADS_DESCR(dtype) \
270
+ do {if (!(PyDataType_FLAGCHK((dtype), NPY_NEEDS_PYAPI))) \
271
+ NPY_END_THREADS; } while (0);
272
+
273
+ #if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
274
+ /* The internal copy of this is now defined in `dtypemeta.h` */
275
+ /*
276
+ * `PyArray_Scalar` is the same as this function but converts will convert
277
+ * most NumPy types to Python scalars.
278
+ */
279
+ static inline PyObject *
280
+ PyArray_GETITEM(const PyArrayObject *arr, const char *itemptr)
281
+ {
282
+ return PyDataType_GetArrFuncs(((PyArrayObject_fields *)arr)->descr)->getitem(
283
+ (void *)itemptr, (PyArrayObject *)arr);
284
+ }
285
+
286
+ /*
287
+ * SETITEM should only be used if it is known that the value is a scalar
288
+ * and of a type understood by the arrays dtype.
289
+ * Use `PyArray_Pack` if the value may be of a different dtype.
290
+ */
291
+ static inline int
292
+ PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v)
293
+ {
294
+ return PyDataType_GetArrFuncs(((PyArrayObject_fields *)arr)->descr)->setitem(v, itemptr, arr);
295
+ }
296
+ #endif /* not internal */
297
+
298
+
299
+ #ifdef __cplusplus
300
+ }
301
+ #endif
302
+
303
+
304
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NDARRAYOBJECT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ndarraytypes.h ADDED
@@ -0,0 +1,1933 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_
3
+
4
+ #include "npy_common.h"
5
+ #include "npy_endian.h"
6
+ #include "npy_cpu.h"
7
+ #include "utils.h"
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ #define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
14
+
15
+ /* Always allow threading unless it was explicitly disabled at build time */
16
+ #if !NPY_NO_SMP
17
+ #define NPY_ALLOW_THREADS 1
18
+ #else
19
+ #define NPY_ALLOW_THREADS 0
20
+ #endif
21
+
22
+ #ifndef __has_extension
23
+ #define __has_extension(x) 0
24
+ #endif
25
+
26
+ /*
27
+ * There are several places in the code where an array of dimensions
28
+ * is allocated statically. This is the size of that static
29
+ * allocation.
30
+ *
31
+ * The array creation itself could have arbitrary dimensions but all
32
+ * the places where static allocation is used would need to be changed
33
+ * to dynamic (including inside of several structures)
34
+ *
35
+ * As of NumPy 2.0, we strongly discourage the downstream use of NPY_MAXDIMS,
36
+ * but since auditing everything seems a big ask, define it as 64.
37
+ * A future version could:
38
+ * - Increase or remove the limit and require recompilation (like 2.0 did)
39
+ * - Deprecate or remove the macro but keep the limit (at basically any time)
40
+ */
41
+ #define NPY_MAXDIMS 64
42
+ /* We cannot change this as it would break ABI: */
43
+ #define NPY_MAXDIMS_LEGACY_ITERS 32
44
+ /* NPY_MAXARGS is version dependent and defined in npy_2_compat.h */
45
+
46
+ /* Used for Converter Functions "O&" code in ParseTuple */
47
+ #define NPY_FAIL 0
48
+ #define NPY_SUCCEED 1
49
+
50
+
51
+ enum NPY_TYPES { NPY_BOOL=0,
52
+ NPY_BYTE, NPY_UBYTE,
53
+ NPY_SHORT, NPY_USHORT,
54
+ NPY_INT, NPY_UINT,
55
+ NPY_LONG, NPY_ULONG,
56
+ NPY_LONGLONG, NPY_ULONGLONG,
57
+ NPY_FLOAT, NPY_DOUBLE, NPY_LONGDOUBLE,
58
+ NPY_CFLOAT, NPY_CDOUBLE, NPY_CLONGDOUBLE,
59
+ NPY_OBJECT=17,
60
+ NPY_STRING, NPY_UNICODE,
61
+ NPY_VOID,
62
+ /*
63
+ * New 1.6 types appended, may be integrated
64
+ * into the above in 2.0.
65
+ */
66
+ NPY_DATETIME, NPY_TIMEDELTA, NPY_HALF,
67
+
68
+ NPY_CHAR, /* Deprecated, will raise if used */
69
+
70
+ /* The number of *legacy* dtypes */
71
+ NPY_NTYPES_LEGACY=24,
72
+
73
+ /* assign a high value to avoid changing this in the
74
+ future when new dtypes are added */
75
+ NPY_NOTYPE=25,
76
+
77
+ NPY_USERDEF=256, /* leave room for characters */
78
+
79
+ /* The number of types not including the new 1.6 types */
80
+ NPY_NTYPES_ABI_COMPATIBLE=21,
81
+
82
+ /*
83
+ * New DTypes which do not share the legacy layout
84
+ * (added after NumPy 2.0). VSTRING is the first of these
85
+ * we may open up a block for user-defined dtypes in the
86
+ * future.
87
+ */
88
+ NPY_VSTRING=2056,
89
+ };
90
+
91
+
92
+ /* basetype array priority */
93
+ #define NPY_PRIORITY 0.0
94
+
95
+ /* default subtype priority */
96
+ #define NPY_SUBTYPE_PRIORITY 1.0
97
+
98
+ /* default scalar priority */
99
+ #define NPY_SCALAR_PRIORITY -1000000.0
100
+
101
+ /* How many floating point types are there (excluding half) */
102
+ #define NPY_NUM_FLOATTYPE 3
103
+
104
+ /*
105
+ * These characters correspond to the array type and the struct
106
+ * module
107
+ */
108
+
109
+ enum NPY_TYPECHAR {
110
+ NPY_BOOLLTR = '?',
111
+ NPY_BYTELTR = 'b',
112
+ NPY_UBYTELTR = 'B',
113
+ NPY_SHORTLTR = 'h',
114
+ NPY_USHORTLTR = 'H',
115
+ NPY_INTLTR = 'i',
116
+ NPY_UINTLTR = 'I',
117
+ NPY_LONGLTR = 'l',
118
+ NPY_ULONGLTR = 'L',
119
+ NPY_LONGLONGLTR = 'q',
120
+ NPY_ULONGLONGLTR = 'Q',
121
+ NPY_HALFLTR = 'e',
122
+ NPY_FLOATLTR = 'f',
123
+ NPY_DOUBLELTR = 'd',
124
+ NPY_LONGDOUBLELTR = 'g',
125
+ NPY_CFLOATLTR = 'F',
126
+ NPY_CDOUBLELTR = 'D',
127
+ NPY_CLONGDOUBLELTR = 'G',
128
+ NPY_OBJECTLTR = 'O',
129
+ NPY_STRINGLTR = 'S',
130
+ NPY_DEPRECATED_STRINGLTR2 = 'a',
131
+ NPY_UNICODELTR = 'U',
132
+ NPY_VOIDLTR = 'V',
133
+ NPY_DATETIMELTR = 'M',
134
+ NPY_TIMEDELTALTR = 'm',
135
+ NPY_CHARLTR = 'c',
136
+
137
+ /*
138
+ * New non-legacy DTypes
139
+ */
140
+ NPY_VSTRINGLTR = 'T',
141
+
142
+ /*
143
+ * Note, we removed `NPY_INTPLTR` due to changing its definition
144
+ * to 'n', rather than 'p'. On any typical platform this is the
145
+ * same integer. 'n' should be used for the `np.intp` with the same
146
+ * size as `size_t` while 'p' remains pointer sized.
147
+ *
148
+ * 'p', 'P', 'n', and 'N' are valid and defined explicitly
149
+ * in `arraytypes.c.src`.
150
+ */
151
+
152
+ /*
153
+ * These are for dtype 'kinds', not dtype 'typecodes'
154
+ * as the above are for.
155
+ */
156
+ NPY_GENBOOLLTR ='b',
157
+ NPY_SIGNEDLTR = 'i',
158
+ NPY_UNSIGNEDLTR = 'u',
159
+ NPY_FLOATINGLTR = 'f',
160
+ NPY_COMPLEXLTR = 'c',
161
+
162
+ };
163
+
164
+ /*
165
+ * Changing this may break Numpy API compatibility
166
+ * due to changing offsets in PyArray_ArrFuncs, so be
167
+ * careful. Here we have reused the mergesort slot for
168
+ * any kind of stable sort, the actual implementation will
169
+ * depend on the data type.
170
+ */
171
+ typedef enum {
172
+ _NPY_SORT_UNDEFINED=-1,
173
+ NPY_QUICKSORT=0,
174
+ NPY_HEAPSORT=1,
175
+ NPY_MERGESORT=2,
176
+ NPY_STABLESORT=2,
177
+ } NPY_SORTKIND;
178
+ #define NPY_NSORTS (NPY_STABLESORT + 1)
179
+
180
+
181
+ typedef enum {
182
+ NPY_INTROSELECT=0
183
+ } NPY_SELECTKIND;
184
+ #define NPY_NSELECTS (NPY_INTROSELECT + 1)
185
+
186
+
187
+ typedef enum {
188
+ NPY_SEARCHLEFT=0,
189
+ NPY_SEARCHRIGHT=1
190
+ } NPY_SEARCHSIDE;
191
+ #define NPY_NSEARCHSIDES (NPY_SEARCHRIGHT + 1)
192
+
193
+
194
+ typedef enum {
195
+ NPY_NOSCALAR=-1,
196
+ NPY_BOOL_SCALAR,
197
+ NPY_INTPOS_SCALAR,
198
+ NPY_INTNEG_SCALAR,
199
+ NPY_FLOAT_SCALAR,
200
+ NPY_COMPLEX_SCALAR,
201
+ NPY_OBJECT_SCALAR
202
+ } NPY_SCALARKIND;
203
+ #define NPY_NSCALARKINDS (NPY_OBJECT_SCALAR + 1)
204
+
205
+ /* For specifying array memory layout or iteration order */
206
+ typedef enum {
207
+ /* Fortran order if inputs are all Fortran, C otherwise */
208
+ NPY_ANYORDER=-1,
209
+ /* C order */
210
+ NPY_CORDER=0,
211
+ /* Fortran order */
212
+ NPY_FORTRANORDER=1,
213
+ /* An order as close to the inputs as possible */
214
+ NPY_KEEPORDER=2
215
+ } NPY_ORDER;
216
+
217
+ /* For specifying allowed casting in operations which support it */
218
+ typedef enum {
219
+ _NPY_ERROR_OCCURRED_IN_CAST = -1,
220
+ /* Only allow identical types */
221
+ NPY_NO_CASTING=0,
222
+ /* Allow identical and byte swapped types */
223
+ NPY_EQUIV_CASTING=1,
224
+ /* Only allow safe casts */
225
+ NPY_SAFE_CASTING=2,
226
+ /* Allow safe casts or casts within the same kind */
227
+ NPY_SAME_KIND_CASTING=3,
228
+ /* Allow any casts */
229
+ NPY_UNSAFE_CASTING=4,
230
+ } NPY_CASTING;
231
+
232
+ typedef enum {
233
+ NPY_CLIP=0,
234
+ NPY_WRAP=1,
235
+ NPY_RAISE=2
236
+ } NPY_CLIPMODE;
237
+
238
+ typedef enum {
239
+ NPY_VALID=0,
240
+ NPY_SAME=1,
241
+ NPY_FULL=2
242
+ } NPY_CORRELATEMODE;
243
+
244
+ /* The special not-a-time (NaT) value */
245
+ #define NPY_DATETIME_NAT NPY_MIN_INT64
246
+
247
+ /*
248
+ * Upper bound on the length of a DATETIME ISO 8601 string
249
+ * YEAR: 21 (64-bit year)
250
+ * MONTH: 3
251
+ * DAY: 3
252
+ * HOURS: 3
253
+ * MINUTES: 3
254
+ * SECONDS: 3
255
+ * ATTOSECONDS: 1 + 3*6
256
+ * TIMEZONE: 5
257
+ * NULL TERMINATOR: 1
258
+ */
259
+ #define NPY_DATETIME_MAX_ISO8601_STRLEN (21 + 3*5 + 1 + 3*6 + 6 + 1)
260
+
261
+ /* The FR in the unit names stands for frequency */
262
+ typedef enum {
263
+ /* Force signed enum type, must be -1 for code compatibility */
264
+ NPY_FR_ERROR = -1, /* error or undetermined */
265
+
266
+ /* Start of valid units */
267
+ NPY_FR_Y = 0, /* Years */
268
+ NPY_FR_M = 1, /* Months */
269
+ NPY_FR_W = 2, /* Weeks */
270
+ /* Gap where 1.6 NPY_FR_B (value 3) was */
271
+ NPY_FR_D = 4, /* Days */
272
+ NPY_FR_h = 5, /* hours */
273
+ NPY_FR_m = 6, /* minutes */
274
+ NPY_FR_s = 7, /* seconds */
275
+ NPY_FR_ms = 8, /* milliseconds */
276
+ NPY_FR_us = 9, /* microseconds */
277
+ NPY_FR_ns = 10, /* nanoseconds */
278
+ NPY_FR_ps = 11, /* picoseconds */
279
+ NPY_FR_fs = 12, /* femtoseconds */
280
+ NPY_FR_as = 13, /* attoseconds */
281
+ NPY_FR_GENERIC = 14 /* unbound units, can convert to anything */
282
+ } NPY_DATETIMEUNIT;
283
+
284
+ /*
285
+ * NOTE: With the NPY_FR_B gap for 1.6 ABI compatibility, NPY_DATETIME_NUMUNITS
286
+ * is technically one more than the actual number of units.
287
+ */
288
+ #define NPY_DATETIME_NUMUNITS (NPY_FR_GENERIC + 1)
289
+ #define NPY_DATETIME_DEFAULTUNIT NPY_FR_GENERIC
290
+
291
+ /*
292
+ * Business day conventions for mapping invalid business
293
+ * days to valid business days.
294
+ */
295
+ typedef enum {
296
+ /* Go forward in time to the following business day. */
297
+ NPY_BUSDAY_FORWARD,
298
+ NPY_BUSDAY_FOLLOWING = NPY_BUSDAY_FORWARD,
299
+ /* Go backward in time to the preceding business day. */
300
+ NPY_BUSDAY_BACKWARD,
301
+ NPY_BUSDAY_PRECEDING = NPY_BUSDAY_BACKWARD,
302
+ /*
303
+ * Go forward in time to the following business day, unless it
304
+ * crosses a month boundary, in which case go backward
305
+ */
306
+ NPY_BUSDAY_MODIFIEDFOLLOWING,
307
+ /*
308
+ * Go backward in time to the preceding business day, unless it
309
+ * crosses a month boundary, in which case go forward.
310
+ */
311
+ NPY_BUSDAY_MODIFIEDPRECEDING,
312
+ /* Produce a NaT for non-business days. */
313
+ NPY_BUSDAY_NAT,
314
+ /* Raise an exception for non-business days. */
315
+ NPY_BUSDAY_RAISE
316
+ } NPY_BUSDAY_ROLL;
317
+
318
+
319
+ /************************************************************
320
+ * NumPy Auxiliary Data for inner loops, sort functions, etc.
321
+ ************************************************************/
322
+
323
+ /*
324
+ * When creating an auxiliary data struct, this should always appear
325
+ * as the first member, like this:
326
+ *
327
+ * typedef struct {
328
+ * NpyAuxData base;
329
+ * double constant;
330
+ * } constant_multiplier_aux_data;
331
+ */
332
+ typedef struct NpyAuxData_tag NpyAuxData;
333
+
334
+ /* Function pointers for freeing or cloning auxiliary data */
335
+ typedef void (NpyAuxData_FreeFunc) (NpyAuxData *);
336
+ typedef NpyAuxData *(NpyAuxData_CloneFunc) (NpyAuxData *);
337
+
338
+ struct NpyAuxData_tag {
339
+ NpyAuxData_FreeFunc *free;
340
+ NpyAuxData_CloneFunc *clone;
341
+ /* To allow for a bit of expansion without breaking the ABI */
342
+ void *reserved[2];
343
+ };
344
+
345
+ /* Macros to use for freeing and cloning auxiliary data */
346
+ #define NPY_AUXDATA_FREE(auxdata) \
347
+ do { \
348
+ if ((auxdata) != NULL) { \
349
+ (auxdata)->free(auxdata); \
350
+ } \
351
+ } while(0)
352
+ #define NPY_AUXDATA_CLONE(auxdata) \
353
+ ((auxdata)->clone(auxdata))
354
+
355
+ #define NPY_ERR(str) fprintf(stderr, #str); fflush(stderr);
356
+ #define NPY_ERR2(str) fprintf(stderr, str); fflush(stderr);
357
+
358
+ /*
359
+ * Macros to define how array, and dimension/strides data is
360
+ * allocated. These should be made private
361
+ */
362
+
363
+ #define NPY_USE_PYMEM 1
364
+
365
+
366
+ #if NPY_USE_PYMEM == 1
367
+ /* use the Raw versions which are safe to call with the GIL released */
368
+ #define PyArray_malloc PyMem_RawMalloc
369
+ #define PyArray_free PyMem_RawFree
370
+ #define PyArray_realloc PyMem_RawRealloc
371
+ #else
372
+ #define PyArray_malloc malloc
373
+ #define PyArray_free free
374
+ #define PyArray_realloc realloc
375
+ #endif
376
+
377
+ /* Dimensions and strides */
378
+ #define PyDimMem_NEW(size) \
379
+ ((npy_intp *)PyArray_malloc(size*sizeof(npy_intp)))
380
+
381
+ #define PyDimMem_FREE(ptr) PyArray_free(ptr)
382
+
383
+ #define PyDimMem_RENEW(ptr,size) \
384
+ ((npy_intp *)PyArray_realloc(ptr,size*sizeof(npy_intp)))
385
+
386
+ /* forward declaration */
387
+ struct _PyArray_Descr;
388
+
389
+ /* These must deal with unaligned and swapped data if necessary */
390
+ typedef PyObject * (PyArray_GetItemFunc) (void *, void *);
391
+ typedef int (PyArray_SetItemFunc)(PyObject *, void *, void *);
392
+
393
+ typedef void (PyArray_CopySwapNFunc)(void *, npy_intp, void *, npy_intp,
394
+ npy_intp, int, void *);
395
+
396
+ typedef void (PyArray_CopySwapFunc)(void *, void *, int, void *);
397
+ typedef npy_bool (PyArray_NonzeroFunc)(void *, void *);
398
+
399
+
400
+ /*
401
+ * These assume aligned and notswapped data -- a buffer will be used
402
+ * before or contiguous data will be obtained
403
+ */
404
+
405
+ typedef int (PyArray_CompareFunc)(const void *, const void *, void *);
406
+ typedef int (PyArray_ArgFunc)(void*, npy_intp, npy_intp*, void *);
407
+
408
+ typedef void (PyArray_DotFunc)(void *, npy_intp, void *, npy_intp, void *,
409
+ npy_intp, void *);
410
+
411
+ typedef void (PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *,
412
+ void *);
413
+
414
+ /*
415
+ * XXX the ignore argument should be removed next time the API version
416
+ * is bumped. It used to be the separator.
417
+ */
418
+ typedef int (PyArray_ScanFunc)(FILE *fp, void *dptr,
419
+ char *ignore, struct _PyArray_Descr *);
420
+ typedef int (PyArray_FromStrFunc)(char *s, void *dptr, char **endptr,
421
+ struct _PyArray_Descr *);
422
+
423
+ typedef int (PyArray_FillFunc)(void *, npy_intp, void *);
424
+
425
+ typedef int (PyArray_SortFunc)(void *, npy_intp, void *);
426
+ typedef int (PyArray_ArgSortFunc)(void *, npy_intp *, npy_intp, void *);
427
+
428
+ typedef int (PyArray_FillWithScalarFunc)(void *, npy_intp, void *, void *);
429
+
430
+ typedef int (PyArray_ScalarKindFunc)(void *);
431
+
432
+ typedef struct {
433
+ npy_intp *ptr;
434
+ int len;
435
+ } PyArray_Dims;
436
+
437
+ typedef struct {
438
+ /*
439
+ * Functions to cast to most other standard types
440
+ * Can have some NULL entries. The types
441
+ * DATETIME, TIMEDELTA, and HALF go into the castdict
442
+ * even though they are built-in.
443
+ */
444
+ PyArray_VectorUnaryFunc *cast[NPY_NTYPES_ABI_COMPATIBLE];
445
+
446
+ /* The next four functions *cannot* be NULL */
447
+
448
+ /*
449
+ * Functions to get and set items with standard Python types
450
+ * -- not array scalars
451
+ */
452
+ PyArray_GetItemFunc *getitem;
453
+ PyArray_SetItemFunc *setitem;
454
+
455
+ /*
456
+ * Copy and/or swap data. Memory areas may not overlap
457
+ * Use memmove first if they might
458
+ */
459
+ PyArray_CopySwapNFunc *copyswapn;
460
+ PyArray_CopySwapFunc *copyswap;
461
+
462
+ /*
463
+ * Function to compare items
464
+ * Can be NULL
465
+ */
466
+ PyArray_CompareFunc *compare;
467
+
468
+ /*
469
+ * Function to select largest
470
+ * Can be NULL
471
+ */
472
+ PyArray_ArgFunc *argmax;
473
+
474
+ /*
475
+ * Function to compute dot product
476
+ * Can be NULL
477
+ */
478
+ PyArray_DotFunc *dotfunc;
479
+
480
+ /*
481
+ * Function to scan an ASCII file and
482
+ * place a single value plus possible separator
483
+ * Can be NULL
484
+ */
485
+ PyArray_ScanFunc *scanfunc;
486
+
487
+ /*
488
+ * Function to read a single value from a string
489
+ * and adjust the pointer; Can be NULL
490
+ */
491
+ PyArray_FromStrFunc *fromstr;
492
+
493
+ /*
494
+ * Function to determine if data is zero or not
495
+ * If NULL a default version is
496
+ * used at Registration time.
497
+ */
498
+ PyArray_NonzeroFunc *nonzero;
499
+
500
+ /*
501
+ * Used for arange. Should return 0 on success
502
+ * and -1 on failure.
503
+ * Can be NULL.
504
+ */
505
+ PyArray_FillFunc *fill;
506
+
507
+ /*
508
+ * Function to fill arrays with scalar values
509
+ * Can be NULL
510
+ */
511
+ PyArray_FillWithScalarFunc *fillwithscalar;
512
+
513
+ /*
514
+ * Sorting functions
515
+ * Can be NULL
516
+ */
517
+ PyArray_SortFunc *sort[NPY_NSORTS];
518
+ PyArray_ArgSortFunc *argsort[NPY_NSORTS];
519
+
520
+ /*
521
+ * Dictionary of additional casting functions
522
+ * PyArray_VectorUnaryFuncs
523
+ * which can be populated to support casting
524
+ * to other registered types. Can be NULL
525
+ */
526
+ PyObject *castdict;
527
+
528
+ /*
529
+ * Functions useful for generalizing
530
+ * the casting rules.
531
+ * Can be NULL;
532
+ */
533
+ PyArray_ScalarKindFunc *scalarkind;
534
+ int **cancastscalarkindto;
535
+ int *cancastto;
536
+
537
+ void *_unused1;
538
+ void *_unused2;
539
+ void *_unused3;
540
+
541
+ /*
542
+ * Function to select smallest
543
+ * Can be NULL
544
+ */
545
+ PyArray_ArgFunc *argmin;
546
+
547
+ } PyArray_ArrFuncs;
548
+
549
+
550
+ /* The item must be reference counted when it is inserted or extracted. */
551
+ #define NPY_ITEM_REFCOUNT 0x01
552
+ /* Same as needing REFCOUNT */
553
+ #define NPY_ITEM_HASOBJECT 0x01
554
+ /* Convert to list for pickling */
555
+ #define NPY_LIST_PICKLE 0x02
556
+ /* The item is a POINTER */
557
+ #define NPY_ITEM_IS_POINTER 0x04
558
+ /* memory needs to be initialized for this data-type */
559
+ #define NPY_NEEDS_INIT 0x08
560
+ /* operations need Python C-API so don't give-up thread. */
561
+ #define NPY_NEEDS_PYAPI 0x10
562
+ /* Use f.getitem when extracting elements of this data-type */
563
+ #define NPY_USE_GETITEM 0x20
564
+ /* Use f.setitem when setting creating 0-d array from this data-type.*/
565
+ #define NPY_USE_SETITEM 0x40
566
+ /* A sticky flag specifically for structured arrays */
567
+ #define NPY_ALIGNED_STRUCT 0x80
568
+
569
+ /*
570
+ *These are inherited for global data-type if any data-types in the
571
+ * field have them
572
+ */
573
+ #define NPY_FROM_FIELDS (NPY_NEEDS_INIT | NPY_LIST_PICKLE | \
574
+ NPY_ITEM_REFCOUNT | NPY_NEEDS_PYAPI)
575
+
576
+ #define NPY_OBJECT_DTYPE_FLAGS (NPY_LIST_PICKLE | NPY_USE_GETITEM | \
577
+ NPY_ITEM_IS_POINTER | NPY_ITEM_REFCOUNT | \
578
+ NPY_NEEDS_INIT | NPY_NEEDS_PYAPI)
579
+
580
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
581
+ /*
582
+ * Public version of the Descriptor struct as of 2.x
583
+ */
584
+ typedef struct _PyArray_Descr {
585
+ PyObject_HEAD
586
+ /*
587
+ * the type object representing an
588
+ * instance of this type -- should not
589
+ * be two type_numbers with the same type
590
+ * object.
591
+ */
592
+ PyTypeObject *typeobj;
593
+ /* kind for this type */
594
+ char kind;
595
+ /* unique-character representing this type */
596
+ char type;
597
+ /*
598
+ * '>' (big), '<' (little), '|'
599
+ * (not-applicable), or '=' (native).
600
+ */
601
+ char byteorder;
602
+ /* Former flags flags space (unused) to ensure type_num is stable. */
603
+ char _former_flags;
604
+ /* number representing this type */
605
+ int type_num;
606
+ /* Space for dtype instance specific flags. */
607
+ npy_uint64 flags;
608
+ /* element size (itemsize) for this type */
609
+ npy_intp elsize;
610
+ /* alignment needed for this type */
611
+ npy_intp alignment;
612
+ /* metadata dict or NULL */
613
+ PyObject *metadata;
614
+ /* Cached hash value (-1 if not yet computed). */
615
+ npy_hash_t hash;
616
+ /* Unused slot (must be initialized to NULL) for future use */
617
+ void *reserved_null[2];
618
+ } PyArray_Descr;
619
+
620
+ #else /* 1.x and 2.x compatible version (only shared fields): */
621
+
622
+ typedef struct _PyArray_Descr {
623
+ PyObject_HEAD
624
+ PyTypeObject *typeobj;
625
+ char kind;
626
+ char type;
627
+ char byteorder;
628
+ char _former_flags;
629
+ int type_num;
630
+ } PyArray_Descr;
631
+
632
+ /* To access modified fields, define the full 2.0 struct: */
633
+ typedef struct {
634
+ PyObject_HEAD
635
+ PyTypeObject *typeobj;
636
+ char kind;
637
+ char type;
638
+ char byteorder;
639
+ char _former_flags;
640
+ int type_num;
641
+ npy_uint64 flags;
642
+ npy_intp elsize;
643
+ npy_intp alignment;
644
+ PyObject *metadata;
645
+ npy_hash_t hash;
646
+ void *reserved_null[2];
647
+ } _PyArray_DescrNumPy2;
648
+
649
+ #endif /* 1.x and 2.x compatible version */
650
+
651
+ /*
652
+ * Semi-private struct with additional field of legacy descriptors (must
653
+ * check NPY_DT_is_legacy before casting/accessing). The struct is also not
654
+ * valid when running on 1.x (i.e. in public API use).
655
+ */
656
+ typedef struct {
657
+ PyObject_HEAD
658
+ PyTypeObject *typeobj;
659
+ char kind;
660
+ char type;
661
+ char byteorder;
662
+ char _former_flags;
663
+ int type_num;
664
+ npy_uint64 flags;
665
+ npy_intp elsize;
666
+ npy_intp alignment;
667
+ PyObject *metadata;
668
+ npy_hash_t hash;
669
+ void *reserved_null[2];
670
+ struct _arr_descr *subarray;
671
+ PyObject *fields;
672
+ PyObject *names;
673
+ NpyAuxData *c_metadata;
674
+ } _PyArray_LegacyDescr;
675
+
676
+
677
+ /*
678
+ * Umodified PyArray_Descr struct identical to NumPy 1.x. This struct is
679
+ * used as a prototype for registering a new legacy DType.
680
+ * It is also used to access the fields in user code running on 1.x.
681
+ */
682
+ typedef struct {
683
+ PyObject_HEAD
684
+ PyTypeObject *typeobj;
685
+ char kind;
686
+ char type;
687
+ char byteorder;
688
+ char flags;
689
+ int type_num;
690
+ int elsize;
691
+ int alignment;
692
+ struct _arr_descr *subarray;
693
+ PyObject *fields;
694
+ PyObject *names;
695
+ PyArray_ArrFuncs *f;
696
+ PyObject *metadata;
697
+ NpyAuxData *c_metadata;
698
+ npy_hash_t hash;
699
+ } PyArray_DescrProto;
700
+
701
+
702
+ typedef struct _arr_descr {
703
+ PyArray_Descr *base;
704
+ PyObject *shape; /* a tuple */
705
+ } PyArray_ArrayDescr;
706
+
707
+ /*
708
+ * Memory handler structure for array data.
709
+ */
710
+ /* The declaration of free differs from PyMemAllocatorEx */
711
+ typedef struct {
712
+ void *ctx;
713
+ void* (*malloc) (void *ctx, size_t size);
714
+ void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
715
+ void* (*realloc) (void *ctx, void *ptr, size_t new_size);
716
+ void (*free) (void *ctx, void *ptr, size_t size);
717
+ /*
718
+ * This is the end of the version=1 struct. Only add new fields after
719
+ * this line
720
+ */
721
+ } PyDataMemAllocator;
722
+
723
+ typedef struct {
724
+ char name[127]; /* multiple of 64 to keep the struct aligned */
725
+ uint8_t version; /* currently 1 */
726
+ PyDataMemAllocator allocator;
727
+ } PyDataMem_Handler;
728
+
729
+
730
+ /*
731
+ * The main array object structure.
732
+ *
733
+ * It has been recommended to use the inline functions defined below
734
+ * (PyArray_DATA and friends) to access fields here for a number of
735
+ * releases. Direct access to the members themselves is deprecated.
736
+ * To ensure that your code does not use deprecated access,
737
+ * #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
738
+ * (or NPY_1_8_API_VERSION or higher as required).
739
+ */
740
+ /* This struct will be moved to a private header in a future release */
741
+ typedef struct tagPyArrayObject_fields {
742
+ PyObject_HEAD
743
+ /* Pointer to the raw data buffer */
744
+ char *data;
745
+ /* The number of dimensions, also called 'ndim' */
746
+ int nd;
747
+ /* The size in each dimension, also called 'shape' */
748
+ npy_intp *dimensions;
749
+ /*
750
+ * Number of bytes to jump to get to the
751
+ * next element in each dimension
752
+ */
753
+ npy_intp *strides;
754
+ /*
755
+ * This object is decref'd upon
756
+ * deletion of array. Except in the
757
+ * case of WRITEBACKIFCOPY which has
758
+ * special handling.
759
+ *
760
+ * For views it points to the original
761
+ * array, collapsed so no chains of
762
+ * views occur.
763
+ *
764
+ * For creation from buffer object it
765
+ * points to an object that should be
766
+ * decref'd on deletion
767
+ *
768
+ * For WRITEBACKIFCOPY flag this is an
769
+ * array to-be-updated upon calling
770
+ * PyArray_ResolveWritebackIfCopy
771
+ */
772
+ PyObject *base;
773
+ /* Pointer to type structure */
774
+ PyArray_Descr *descr;
775
+ /* Flags describing array -- see below */
776
+ int flags;
777
+ /* For weak references */
778
+ PyObject *weakreflist;
779
+ #if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
780
+ void *_buffer_info; /* private buffer info, tagged to allow warning */
781
+ #endif
782
+ /*
783
+ * For malloc/calloc/realloc/free per object
784
+ */
785
+ #if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
786
+ PyObject *mem_handler;
787
+ #endif
788
+ } PyArrayObject_fields;
789
+
790
+ /*
791
+ * To hide the implementation details, we only expose
792
+ * the Python struct HEAD.
793
+ */
794
+ #if !defined(NPY_NO_DEPRECATED_API) || \
795
+ (NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION)
796
+ /*
797
+ * Can't put this in npy_deprecated_api.h like the others.
798
+ * PyArrayObject field access is deprecated as of NumPy 1.7.
799
+ */
800
+ typedef PyArrayObject_fields PyArrayObject;
801
+ #else
802
+ typedef struct tagPyArrayObject {
803
+ PyObject_HEAD
804
+ } PyArrayObject;
805
+ #endif
806
+
807
+ /*
808
+ * Removed 2020-Nov-25, NumPy 1.20
809
+ * #define NPY_SIZEOF_PYARRAYOBJECT (sizeof(PyArrayObject_fields))
810
+ *
811
+ * The above macro was removed as it gave a false sense of a stable ABI
812
+ * with respect to the structures size. If you require a runtime constant,
813
+ * you can use `PyArray_Type.tp_basicsize` instead. Otherwise, please
814
+ * see the PyArrayObject documentation or ask the NumPy developers for
815
+ * information on how to correctly replace the macro in a way that is
816
+ * compatible with multiple NumPy versions.
817
+ */
818
+
819
+ /* Mirrors buffer object to ptr */
820
+
821
+ typedef struct {
822
+ PyObject_HEAD
823
+ PyObject *base;
824
+ void *ptr;
825
+ npy_intp len;
826
+ int flags;
827
+ } PyArray_Chunk;
828
+
829
+ typedef struct {
830
+ NPY_DATETIMEUNIT base;
831
+ int num;
832
+ } PyArray_DatetimeMetaData;
833
+
834
+ typedef struct {
835
+ NpyAuxData base;
836
+ PyArray_DatetimeMetaData meta;
837
+ } PyArray_DatetimeDTypeMetaData;
838
+
839
+ /*
840
+ * This structure contains an exploded view of a date-time value.
841
+ * NaT is represented by year == NPY_DATETIME_NAT.
842
+ */
843
+ typedef struct {
844
+ npy_int64 year;
845
+ npy_int32 month, day, hour, min, sec, us, ps, as;
846
+ } npy_datetimestruct;
847
+
848
+ /* This structure contains an exploded view of a timedelta value */
849
+ typedef struct {
850
+ npy_int64 day;
851
+ npy_int32 sec, us, ps, as;
852
+ } npy_timedeltastruct;
853
+
854
+ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
855
+
856
+ /*
857
+ * Means c-style contiguous (last index varies the fastest). The data
858
+ * elements right after each other.
859
+ *
860
+ * This flag may be requested in constructor functions.
861
+ * This flag may be tested for in PyArray_FLAGS(arr).
862
+ */
863
+ #define NPY_ARRAY_C_CONTIGUOUS 0x0001
864
+
865
+ /*
866
+ * Set if array is a contiguous Fortran array: the first index varies
867
+ * the fastest in memory (strides array is reverse of C-contiguous
868
+ * array)
869
+ *
870
+ * This flag may be requested in constructor functions.
871
+ * This flag may be tested for in PyArray_FLAGS(arr).
872
+ */
873
+ #define NPY_ARRAY_F_CONTIGUOUS 0x0002
874
+
875
+ /*
876
+ * Note: all 0-d arrays are C_CONTIGUOUS and F_CONTIGUOUS. If a
877
+ * 1-d array is C_CONTIGUOUS it is also F_CONTIGUOUS. Arrays with
878
+ * more then one dimension can be C_CONTIGUOUS and F_CONTIGUOUS
879
+ * at the same time if they have either zero or one element.
880
+ * A higher dimensional array always has the same contiguity flags as
881
+ * `array.squeeze()`; dimensions with `array.shape[dimension] == 1` are
882
+ * effectively ignored when checking for contiguity.
883
+ */
884
+
885
+ /*
886
+ * If set, the array owns the data: it will be free'd when the array
887
+ * is deleted.
888
+ *
889
+ * This flag may be tested for in PyArray_FLAGS(arr).
890
+ */
891
+ #define NPY_ARRAY_OWNDATA 0x0004
892
+
893
+ /*
894
+ * An array never has the next four set; they're only used as parameter
895
+ * flags to the various FromAny functions
896
+ *
897
+ * This flag may be requested in constructor functions.
898
+ */
899
+
900
+ /* Cause a cast to occur regardless of whether or not it is safe. */
901
+ #define NPY_ARRAY_FORCECAST 0x0010
902
+
903
+ /*
904
+ * Always copy the array. Returned arrays are always CONTIGUOUS,
905
+ * ALIGNED, and WRITEABLE. See also: NPY_ARRAY_ENSURENOCOPY = 0x4000.
906
+ *
907
+ * This flag may be requested in constructor functions.
908
+ */
909
+ #define NPY_ARRAY_ENSURECOPY 0x0020
910
+
911
+ /*
912
+ * Make sure the returned array is a base-class ndarray
913
+ *
914
+ * This flag may be requested in constructor functions.
915
+ */
916
+ #define NPY_ARRAY_ENSUREARRAY 0x0040
917
+
918
+ /*
919
+ * Make sure that the strides are in units of the element size Needed
920
+ * for some operations with record-arrays.
921
+ *
922
+ * This flag may be requested in constructor functions.
923
+ */
924
+ #define NPY_ARRAY_ELEMENTSTRIDES 0x0080
925
+
926
+ /*
927
+ * Array data is aligned on the appropriate memory address for the type
928
+ * stored according to how the compiler would align things (e.g., an
929
+ * array of integers (4 bytes each) starts on a memory address that's
930
+ * a multiple of 4)
931
+ *
932
+ * This flag may be requested in constructor functions.
933
+ * This flag may be tested for in PyArray_FLAGS(arr).
934
+ */
935
+ #define NPY_ARRAY_ALIGNED 0x0100
936
+
937
+ /*
938
+ * Array data has the native endianness
939
+ *
940
+ * This flag may be requested in constructor functions.
941
+ */
942
+ #define NPY_ARRAY_NOTSWAPPED 0x0200
943
+
944
+ /*
945
+ * Array data is writeable
946
+ *
947
+ * This flag may be requested in constructor functions.
948
+ * This flag may be tested for in PyArray_FLAGS(arr).
949
+ */
950
+ #define NPY_ARRAY_WRITEABLE 0x0400
951
+
952
+ /*
953
+ * If this flag is set, then base contains a pointer to an array of
954
+ * the same size that should be updated with the current contents of
955
+ * this array when PyArray_ResolveWritebackIfCopy is called.
956
+ *
957
+ * This flag may be requested in constructor functions.
958
+ * This flag may be tested for in PyArray_FLAGS(arr).
959
+ */
960
+ #define NPY_ARRAY_WRITEBACKIFCOPY 0x2000
961
+
962
+ /*
963
+ * No copy may be made while converting from an object/array (result is a view)
964
+ *
965
+ * This flag may be requested in constructor functions.
966
+ */
967
+ #define NPY_ARRAY_ENSURENOCOPY 0x4000
968
+
969
+ /*
970
+ * NOTE: there are also internal flags defined in multiarray/arrayobject.h,
971
+ * which start at bit 31 and work down.
972
+ */
973
+
974
+ #define NPY_ARRAY_BEHAVED (NPY_ARRAY_ALIGNED | \
975
+ NPY_ARRAY_WRITEABLE)
976
+ #define NPY_ARRAY_BEHAVED_NS (NPY_ARRAY_ALIGNED | \
977
+ NPY_ARRAY_WRITEABLE | \
978
+ NPY_ARRAY_NOTSWAPPED)
979
+ #define NPY_ARRAY_CARRAY (NPY_ARRAY_C_CONTIGUOUS | \
980
+ NPY_ARRAY_BEHAVED)
981
+ #define NPY_ARRAY_CARRAY_RO (NPY_ARRAY_C_CONTIGUOUS | \
982
+ NPY_ARRAY_ALIGNED)
983
+ #define NPY_ARRAY_FARRAY (NPY_ARRAY_F_CONTIGUOUS | \
984
+ NPY_ARRAY_BEHAVED)
985
+ #define NPY_ARRAY_FARRAY_RO (NPY_ARRAY_F_CONTIGUOUS | \
986
+ NPY_ARRAY_ALIGNED)
987
+ #define NPY_ARRAY_DEFAULT (NPY_ARRAY_CARRAY)
988
+ #define NPY_ARRAY_IN_ARRAY (NPY_ARRAY_CARRAY_RO)
989
+ #define NPY_ARRAY_OUT_ARRAY (NPY_ARRAY_CARRAY)
990
+ #define NPY_ARRAY_INOUT_ARRAY (NPY_ARRAY_CARRAY)
991
+ #define NPY_ARRAY_INOUT_ARRAY2 (NPY_ARRAY_CARRAY | \
992
+ NPY_ARRAY_WRITEBACKIFCOPY)
993
+ #define NPY_ARRAY_IN_FARRAY (NPY_ARRAY_FARRAY_RO)
994
+ #define NPY_ARRAY_OUT_FARRAY (NPY_ARRAY_FARRAY)
995
+ #define NPY_ARRAY_INOUT_FARRAY (NPY_ARRAY_FARRAY)
996
+ #define NPY_ARRAY_INOUT_FARRAY2 (NPY_ARRAY_FARRAY | \
997
+ NPY_ARRAY_WRITEBACKIFCOPY)
998
+
999
+ #define NPY_ARRAY_UPDATE_ALL (NPY_ARRAY_C_CONTIGUOUS | \
1000
+ NPY_ARRAY_F_CONTIGUOUS | \
1001
+ NPY_ARRAY_ALIGNED)
1002
+
1003
+ /* This flag is for the array interface, not PyArrayObject */
1004
+ #define NPY_ARR_HAS_DESCR 0x0800
1005
+
1006
+
1007
+
1008
+
1009
+ /*
1010
+ * Size of internal buffers used for alignment Make BUFSIZE a multiple
1011
+ * of sizeof(npy_cdouble) -- usually 16 so that ufunc buffers are aligned
1012
+ */
1013
+ #define NPY_MIN_BUFSIZE ((int)sizeof(npy_cdouble))
1014
+ #define NPY_MAX_BUFSIZE (((int)sizeof(npy_cdouble))*1000000)
1015
+ #define NPY_BUFSIZE 8192
1016
+ /* buffer stress test size: */
1017
+ /*#define NPY_BUFSIZE 17*/
1018
+
1019
+ /*
1020
+ * C API: consists of Macros and functions. The MACROS are defined
1021
+ * here.
1022
+ */
1023
+
1024
+
1025
+ #define PyArray_ISCONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
1026
+ #define PyArray_ISWRITEABLE(m) PyArray_CHKFLAGS((m), NPY_ARRAY_WRITEABLE)
1027
+ #define PyArray_ISALIGNED(m) PyArray_CHKFLAGS((m), NPY_ARRAY_ALIGNED)
1028
+
1029
+ #define PyArray_IS_C_CONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_C_CONTIGUOUS)
1030
+ #define PyArray_IS_F_CONTIGUOUS(m) PyArray_CHKFLAGS((m), NPY_ARRAY_F_CONTIGUOUS)
1031
+
1032
+ /* the variable is used in some places, so always define it */
1033
+ #define NPY_BEGIN_THREADS_DEF PyThreadState *_save=NULL;
1034
+ #if NPY_ALLOW_THREADS
1035
+ #define NPY_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
1036
+ #define NPY_END_ALLOW_THREADS Py_END_ALLOW_THREADS
1037
+ #define NPY_BEGIN_THREADS do {_save = PyEval_SaveThread();} while (0);
1038
+ #define NPY_END_THREADS do { if (_save) \
1039
+ { PyEval_RestoreThread(_save); _save = NULL;} } while (0);
1040
+ #define NPY_BEGIN_THREADS_THRESHOLDED(loop_size) do { if ((loop_size) > 500) \
1041
+ { _save = PyEval_SaveThread();} } while (0);
1042
+
1043
+
1044
+ #define NPY_ALLOW_C_API_DEF PyGILState_STATE __save__;
1045
+ #define NPY_ALLOW_C_API do {__save__ = PyGILState_Ensure();} while (0);
1046
+ #define NPY_DISABLE_C_API do {PyGILState_Release(__save__);} while (0);
1047
+ #else
1048
+ #define NPY_BEGIN_ALLOW_THREADS
1049
+ #define NPY_END_ALLOW_THREADS
1050
+ #define NPY_BEGIN_THREADS
1051
+ #define NPY_END_THREADS
1052
+ #define NPY_BEGIN_THREADS_THRESHOLDED(loop_size)
1053
+ #define NPY_BEGIN_THREADS_DESCR(dtype)
1054
+ #define NPY_END_THREADS_DESCR(dtype)
1055
+ #define NPY_ALLOW_C_API_DEF
1056
+ #define NPY_ALLOW_C_API
1057
+ #define NPY_DISABLE_C_API
1058
+ #endif
1059
+
1060
+ /**********************************
1061
+ * The nditer object, added in 1.6
1062
+ **********************************/
1063
+
1064
+ /* The actual structure of the iterator is an internal detail */
1065
+ typedef struct NpyIter_InternalOnly NpyIter;
1066
+
1067
+ /* Iterator function pointers that may be specialized */
1068
+ typedef int (NpyIter_IterNextFunc)(NpyIter *iter);
1069
+ typedef void (NpyIter_GetMultiIndexFunc)(NpyIter *iter,
1070
+ npy_intp *outcoords);
1071
+
1072
+ /*** Global flags that may be passed to the iterator constructors ***/
1073
+
1074
+ /* Track an index representing C order */
1075
+ #define NPY_ITER_C_INDEX 0x00000001
1076
+ /* Track an index representing Fortran order */
1077
+ #define NPY_ITER_F_INDEX 0x00000002
1078
+ /* Track a multi-index */
1079
+ #define NPY_ITER_MULTI_INDEX 0x00000004
1080
+ /* User code external to the iterator does the 1-dimensional innermost loop */
1081
+ #define NPY_ITER_EXTERNAL_LOOP 0x00000008
1082
+ /* Convert all the operands to a common data type */
1083
+ #define NPY_ITER_COMMON_DTYPE 0x00000010
1084
+ /* Operands may hold references, requiring API access during iteration */
1085
+ #define NPY_ITER_REFS_OK 0x00000020
1086
+ /* Zero-sized operands should be permitted, iteration checks IterSize for 0 */
1087
+ #define NPY_ITER_ZEROSIZE_OK 0x00000040
1088
+ /* Permits reductions (size-0 stride with dimension size > 1) */
1089
+ #define NPY_ITER_REDUCE_OK 0x00000080
1090
+ /* Enables sub-range iteration */
1091
+ #define NPY_ITER_RANGED 0x00000100
1092
+ /* Enables buffering */
1093
+ #define NPY_ITER_BUFFERED 0x00000200
1094
+ /* When buffering is enabled, grows the inner loop if possible */
1095
+ #define NPY_ITER_GROWINNER 0x00000400
1096
+ /* Delay allocation of buffers until first Reset* call */
1097
+ #define NPY_ITER_DELAY_BUFALLOC 0x00000800
1098
+ /* When NPY_KEEPORDER is specified, disable reversing negative-stride axes */
1099
+ #define NPY_ITER_DONT_NEGATE_STRIDES 0x00001000
1100
+ /*
1101
+ * If output operands overlap with other operands (based on heuristics that
1102
+ * has false positives but no false negatives), make temporary copies to
1103
+ * eliminate overlap.
1104
+ */
1105
+ #define NPY_ITER_COPY_IF_OVERLAP 0x00002000
1106
+
1107
+ /*** Per-operand flags that may be passed to the iterator constructors ***/
1108
+
1109
+ /* The operand will be read from and written to */
1110
+ #define NPY_ITER_READWRITE 0x00010000
1111
+ /* The operand will only be read from */
1112
+ #define NPY_ITER_READONLY 0x00020000
1113
+ /* The operand will only be written to */
1114
+ #define NPY_ITER_WRITEONLY 0x00040000
1115
+ /* The operand's data must be in native byte order */
1116
+ #define NPY_ITER_NBO 0x00080000
1117
+ /* The operand's data must be aligned */
1118
+ #define NPY_ITER_ALIGNED 0x00100000
1119
+ /* The operand's data must be contiguous (within the inner loop) */
1120
+ #define NPY_ITER_CONTIG 0x00200000
1121
+ /* The operand may be copied to satisfy requirements */
1122
+ #define NPY_ITER_COPY 0x00400000
1123
+ /* The operand may be copied with WRITEBACKIFCOPY to satisfy requirements */
1124
+ #define NPY_ITER_UPDATEIFCOPY 0x00800000
1125
+ /* Allocate the operand if it is NULL */
1126
+ #define NPY_ITER_ALLOCATE 0x01000000
1127
+ /* If an operand is allocated, don't use any subtype */
1128
+ #define NPY_ITER_NO_SUBTYPE 0x02000000
1129
+ /* This is a virtual array slot, operand is NULL but temporary data is there */
1130
+ #define NPY_ITER_VIRTUAL 0x04000000
1131
+ /* Require that the dimension match the iterator dimensions exactly */
1132
+ #define NPY_ITER_NO_BROADCAST 0x08000000
1133
+ /* A mask is being used on this array, affects buffer -> array copy */
1134
+ #define NPY_ITER_WRITEMASKED 0x10000000
1135
+ /* This array is the mask for all WRITEMASKED operands */
1136
+ #define NPY_ITER_ARRAYMASK 0x20000000
1137
+ /* Assume iterator order data access for COPY_IF_OVERLAP */
1138
+ #define NPY_ITER_OVERLAP_ASSUME_ELEMENTWISE 0x40000000
1139
+
1140
+ #define NPY_ITER_GLOBAL_FLAGS 0x0000ffff
1141
+ #define NPY_ITER_PER_OP_FLAGS 0xffff0000
1142
+
1143
+
1144
+ /*****************************
1145
+ * Basic iterator object
1146
+ *****************************/
1147
+
1148
+ /* FWD declaration */
1149
+ typedef struct PyArrayIterObject_tag PyArrayIterObject;
1150
+
1151
+ /*
1152
+ * type of the function which translates a set of coordinates to a
1153
+ * pointer to the data
1154
+ */
1155
+ typedef char* (*npy_iter_get_dataptr_t)(
1156
+ PyArrayIterObject* iter, const npy_intp*);
1157
+
1158
+ struct PyArrayIterObject_tag {
1159
+ PyObject_HEAD
1160
+ int nd_m1; /* number of dimensions - 1 */
1161
+ npy_intp index, size;
1162
+ npy_intp coordinates[NPY_MAXDIMS_LEGACY_ITERS];/* N-dimensional loop */
1163
+ npy_intp dims_m1[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->dimensions - 1 */
1164
+ npy_intp strides[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->strides or fake */
1165
+ npy_intp backstrides[NPY_MAXDIMS_LEGACY_ITERS];/* how far to jump back */
1166
+ npy_intp factors[NPY_MAXDIMS_LEGACY_ITERS]; /* shape factors */
1167
+ PyArrayObject *ao;
1168
+ char *dataptr; /* pointer to current item*/
1169
+ npy_bool contiguous;
1170
+
1171
+ npy_intp bounds[NPY_MAXDIMS_LEGACY_ITERS][2];
1172
+ npy_intp limits[NPY_MAXDIMS_LEGACY_ITERS][2];
1173
+ npy_intp limits_sizes[NPY_MAXDIMS_LEGACY_ITERS];
1174
+ npy_iter_get_dataptr_t translate;
1175
+ } ;
1176
+
1177
+
1178
+ /* Iterator API */
1179
+ #define PyArrayIter_Check(op) PyObject_TypeCheck((op), &PyArrayIter_Type)
1180
+
1181
+ #define _PyAIT(it) ((PyArrayIterObject *)(it))
1182
+ #define PyArray_ITER_RESET(it) do { \
1183
+ _PyAIT(it)->index = 0; \
1184
+ _PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
1185
+ memset(_PyAIT(it)->coordinates, 0, \
1186
+ (_PyAIT(it)->nd_m1+1)*sizeof(npy_intp)); \
1187
+ } while (0)
1188
+
1189
+ #define _PyArray_ITER_NEXT1(it) do { \
1190
+ (it)->dataptr += _PyAIT(it)->strides[0]; \
1191
+ (it)->coordinates[0]++; \
1192
+ } while (0)
1193
+
1194
+ #define _PyArray_ITER_NEXT2(it) do { \
1195
+ if ((it)->coordinates[1] < (it)->dims_m1[1]) { \
1196
+ (it)->coordinates[1]++; \
1197
+ (it)->dataptr += (it)->strides[1]; \
1198
+ } \
1199
+ else { \
1200
+ (it)->coordinates[1] = 0; \
1201
+ (it)->coordinates[0]++; \
1202
+ (it)->dataptr += (it)->strides[0] - \
1203
+ (it)->backstrides[1]; \
1204
+ } \
1205
+ } while (0)
1206
+
1207
+ #define PyArray_ITER_NEXT(it) do { \
1208
+ _PyAIT(it)->index++; \
1209
+ if (_PyAIT(it)->nd_m1 == 0) { \
1210
+ _PyArray_ITER_NEXT1(_PyAIT(it)); \
1211
+ } \
1212
+ else if (_PyAIT(it)->contiguous) \
1213
+ _PyAIT(it)->dataptr += PyArray_ITEMSIZE(_PyAIT(it)->ao); \
1214
+ else if (_PyAIT(it)->nd_m1 == 1) { \
1215
+ _PyArray_ITER_NEXT2(_PyAIT(it)); \
1216
+ } \
1217
+ else { \
1218
+ int __npy_i; \
1219
+ for (__npy_i=_PyAIT(it)->nd_m1; __npy_i >= 0; __npy_i--) { \
1220
+ if (_PyAIT(it)->coordinates[__npy_i] < \
1221
+ _PyAIT(it)->dims_m1[__npy_i]) { \
1222
+ _PyAIT(it)->coordinates[__npy_i]++; \
1223
+ _PyAIT(it)->dataptr += \
1224
+ _PyAIT(it)->strides[__npy_i]; \
1225
+ break; \
1226
+ } \
1227
+ else { \
1228
+ _PyAIT(it)->coordinates[__npy_i] = 0; \
1229
+ _PyAIT(it)->dataptr -= \
1230
+ _PyAIT(it)->backstrides[__npy_i]; \
1231
+ } \
1232
+ } \
1233
+ } \
1234
+ } while (0)
1235
+
1236
+ #define PyArray_ITER_GOTO(it, destination) do { \
1237
+ int __npy_i; \
1238
+ _PyAIT(it)->index = 0; \
1239
+ _PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
1240
+ for (__npy_i = _PyAIT(it)->nd_m1; __npy_i>=0; __npy_i--) { \
1241
+ if (destination[__npy_i] < 0) { \
1242
+ destination[__npy_i] += \
1243
+ _PyAIT(it)->dims_m1[__npy_i]+1; \
1244
+ } \
1245
+ _PyAIT(it)->dataptr += destination[__npy_i] * \
1246
+ _PyAIT(it)->strides[__npy_i]; \
1247
+ _PyAIT(it)->coordinates[__npy_i] = \
1248
+ destination[__npy_i]; \
1249
+ _PyAIT(it)->index += destination[__npy_i] * \
1250
+ ( __npy_i==_PyAIT(it)->nd_m1 ? 1 : \
1251
+ _PyAIT(it)->dims_m1[__npy_i+1]+1) ; \
1252
+ } \
1253
+ } while (0)
1254
+
1255
+ #define PyArray_ITER_GOTO1D(it, ind) do { \
1256
+ int __npy_i; \
1257
+ npy_intp __npy_ind = (npy_intp)(ind); \
1258
+ if (__npy_ind < 0) __npy_ind += _PyAIT(it)->size; \
1259
+ _PyAIT(it)->index = __npy_ind; \
1260
+ if (_PyAIT(it)->nd_m1 == 0) { \
1261
+ _PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao) + \
1262
+ __npy_ind * _PyAIT(it)->strides[0]; \
1263
+ } \
1264
+ else if (_PyAIT(it)->contiguous) \
1265
+ _PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao) + \
1266
+ __npy_ind * PyArray_ITEMSIZE(_PyAIT(it)->ao); \
1267
+ else { \
1268
+ _PyAIT(it)->dataptr = PyArray_BYTES(_PyAIT(it)->ao); \
1269
+ for (__npy_i = 0; __npy_i<=_PyAIT(it)->nd_m1; \
1270
+ __npy_i++) { \
1271
+ _PyAIT(it)->coordinates[__npy_i] = \
1272
+ (__npy_ind / _PyAIT(it)->factors[__npy_i]); \
1273
+ _PyAIT(it)->dataptr += \
1274
+ (__npy_ind / _PyAIT(it)->factors[__npy_i]) \
1275
+ * _PyAIT(it)->strides[__npy_i]; \
1276
+ __npy_ind %= _PyAIT(it)->factors[__npy_i]; \
1277
+ } \
1278
+ } \
1279
+ } while (0)
1280
+
1281
+ #define PyArray_ITER_DATA(it) ((void *)(_PyAIT(it)->dataptr))
1282
+
1283
+ #define PyArray_ITER_NOTDONE(it) (_PyAIT(it)->index < _PyAIT(it)->size)
1284
+
1285
+
1286
+ /*
1287
+ * Any object passed to PyArray_Broadcast must be binary compatible
1288
+ * with this structure.
1289
+ */
1290
+
1291
+ typedef struct {
1292
+ PyObject_HEAD
1293
+ int numiter; /* number of iters */
1294
+ npy_intp size; /* broadcasted size */
1295
+ npy_intp index; /* current index */
1296
+ int nd; /* number of dims */
1297
+ npy_intp dimensions[NPY_MAXDIMS_LEGACY_ITERS]; /* dimensions */
1298
+ /*
1299
+ * Space for the individual iterators, do not specify size publicly
1300
+ * to allow changing it more easily.
1301
+ * One reason is that Cython uses this for checks and only allows
1302
+ * growing structs (as of Cython 3.0.6). It also allows NPY_MAXARGS
1303
+ * to be runtime dependent.
1304
+ */
1305
+ #if (defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
1306
+ PyArrayIterObject *iters[64];
1307
+ #elif defined(__cplusplus)
1308
+ /*
1309
+ * C++ doesn't strictly support flexible members and gives compilers
1310
+ * warnings (pedantic only), so we lie. We can't make it 64 because
1311
+ * then Cython is unhappy (larger struct at runtime is OK smaller not).
1312
+ */
1313
+ PyArrayIterObject *iters[32];
1314
+ #else
1315
+ PyArrayIterObject *iters[];
1316
+ #endif
1317
+ } PyArrayMultiIterObject;
1318
+
1319
+ #define _PyMIT(m) ((PyArrayMultiIterObject *)(m))
1320
+ #define PyArray_MultiIter_RESET(multi) do { \
1321
+ int __npy_mi; \
1322
+ _PyMIT(multi)->index = 0; \
1323
+ for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
1324
+ PyArray_ITER_RESET(_PyMIT(multi)->iters[__npy_mi]); \
1325
+ } \
1326
+ } while (0)
1327
+
1328
+ #define PyArray_MultiIter_NEXT(multi) do { \
1329
+ int __npy_mi; \
1330
+ _PyMIT(multi)->index++; \
1331
+ for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
1332
+ PyArray_ITER_NEXT(_PyMIT(multi)->iters[__npy_mi]); \
1333
+ } \
1334
+ } while (0)
1335
+
1336
+ #define PyArray_MultiIter_GOTO(multi, dest) do { \
1337
+ int __npy_mi; \
1338
+ for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
1339
+ PyArray_ITER_GOTO(_PyMIT(multi)->iters[__npy_mi], dest); \
1340
+ } \
1341
+ _PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \
1342
+ } while (0)
1343
+
1344
+ #define PyArray_MultiIter_GOTO1D(multi, ind) do { \
1345
+ int __npy_mi; \
1346
+ for (__npy_mi=0; __npy_mi < _PyMIT(multi)->numiter; __npy_mi++) { \
1347
+ PyArray_ITER_GOTO1D(_PyMIT(multi)->iters[__npy_mi], ind); \
1348
+ } \
1349
+ _PyMIT(multi)->index = _PyMIT(multi)->iters[0]->index; \
1350
+ } while (0)
1351
+
1352
+ #define PyArray_MultiIter_DATA(multi, i) \
1353
+ ((void *)(_PyMIT(multi)->iters[i]->dataptr))
1354
+
1355
+ #define PyArray_MultiIter_NEXTi(multi, i) \
1356
+ PyArray_ITER_NEXT(_PyMIT(multi)->iters[i])
1357
+
1358
+ #define PyArray_MultiIter_NOTDONE(multi) \
1359
+ (_PyMIT(multi)->index < _PyMIT(multi)->size)
1360
+
1361
+
1362
+ static NPY_INLINE int
1363
+ PyArray_MultiIter_NUMITER(PyArrayMultiIterObject *multi)
1364
+ {
1365
+ return multi->numiter;
1366
+ }
1367
+
1368
+
1369
+ static NPY_INLINE npy_intp
1370
+ PyArray_MultiIter_SIZE(PyArrayMultiIterObject *multi)
1371
+ {
1372
+ return multi->size;
1373
+ }
1374
+
1375
+
1376
+ static NPY_INLINE npy_intp
1377
+ PyArray_MultiIter_INDEX(PyArrayMultiIterObject *multi)
1378
+ {
1379
+ return multi->index;
1380
+ }
1381
+
1382
+
1383
+ static NPY_INLINE int
1384
+ PyArray_MultiIter_NDIM(PyArrayMultiIterObject *multi)
1385
+ {
1386
+ return multi->nd;
1387
+ }
1388
+
1389
+
1390
+ static NPY_INLINE npy_intp *
1391
+ PyArray_MultiIter_DIMS(PyArrayMultiIterObject *multi)
1392
+ {
1393
+ return multi->dimensions;
1394
+ }
1395
+
1396
+
1397
+ static NPY_INLINE void **
1398
+ PyArray_MultiIter_ITERS(PyArrayMultiIterObject *multi)
1399
+ {
1400
+ return (void**)multi->iters;
1401
+ }
1402
+
1403
+
1404
+ enum {
1405
+ NPY_NEIGHBORHOOD_ITER_ZERO_PADDING,
1406
+ NPY_NEIGHBORHOOD_ITER_ONE_PADDING,
1407
+ NPY_NEIGHBORHOOD_ITER_CONSTANT_PADDING,
1408
+ NPY_NEIGHBORHOOD_ITER_CIRCULAR_PADDING,
1409
+ NPY_NEIGHBORHOOD_ITER_MIRROR_PADDING
1410
+ };
1411
+
1412
+ typedef struct {
1413
+ PyObject_HEAD
1414
+
1415
+ /*
1416
+ * PyArrayIterObject part: keep this in this exact order
1417
+ */
1418
+ int nd_m1; /* number of dimensions - 1 */
1419
+ npy_intp index, size;
1420
+ npy_intp coordinates[NPY_MAXDIMS_LEGACY_ITERS];/* N-dimensional loop */
1421
+ npy_intp dims_m1[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->dimensions - 1 */
1422
+ npy_intp strides[NPY_MAXDIMS_LEGACY_ITERS]; /* ao->strides or fake */
1423
+ npy_intp backstrides[NPY_MAXDIMS_LEGACY_ITERS];/* how far to jump back */
1424
+ npy_intp factors[NPY_MAXDIMS_LEGACY_ITERS]; /* shape factors */
1425
+ PyArrayObject *ao;
1426
+ char *dataptr; /* pointer to current item*/
1427
+ npy_bool contiguous;
1428
+
1429
+ npy_intp bounds[NPY_MAXDIMS_LEGACY_ITERS][2];
1430
+ npy_intp limits[NPY_MAXDIMS_LEGACY_ITERS][2];
1431
+ npy_intp limits_sizes[NPY_MAXDIMS_LEGACY_ITERS];
1432
+ npy_iter_get_dataptr_t translate;
1433
+
1434
+ /*
1435
+ * New members
1436
+ */
1437
+ npy_intp nd;
1438
+
1439
+ /* Dimensions is the dimension of the array */
1440
+ npy_intp dimensions[NPY_MAXDIMS_LEGACY_ITERS];
1441
+
1442
+ /*
1443
+ * Neighborhood points coordinates are computed relatively to the
1444
+ * point pointed by _internal_iter
1445
+ */
1446
+ PyArrayIterObject* _internal_iter;
1447
+ /*
1448
+ * To keep a reference to the representation of the constant value
1449
+ * for constant padding
1450
+ */
1451
+ char* constant;
1452
+
1453
+ int mode;
1454
+ } PyArrayNeighborhoodIterObject;
1455
+
1456
+ /*
1457
+ * Neighborhood iterator API
1458
+ */
1459
+
1460
+ /* General: those work for any mode */
1461
+ static inline int
1462
+ PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter);
1463
+ static inline int
1464
+ PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter);
1465
+ #if 0
1466
+ static inline int
1467
+ PyArrayNeighborhoodIter_Next2D(PyArrayNeighborhoodIterObject* iter);
1468
+ #endif
1469
+
1470
+ /*
1471
+ * Include inline implementations - functions defined there are not
1472
+ * considered public API
1473
+ */
1474
+ #define NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
1475
+ #include "_neighborhood_iterator_imp.h"
1476
+ #undef NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
1477
+
1478
+
1479
+
1480
+ /* The default array type */
1481
+ #define NPY_DEFAULT_TYPE NPY_DOUBLE
1482
+ /* default integer type defined in npy_2_compat header */
1483
+
1484
+ /*
1485
+ * All sorts of useful ways to look into a PyArrayObject. It is recommended
1486
+ * to use PyArrayObject * objects instead of always casting from PyObject *,
1487
+ * for improved type checking.
1488
+ *
1489
+ * In many cases here the macro versions of the accessors are deprecated,
1490
+ * but can't be immediately changed to inline functions because the
1491
+ * preexisting macros accept PyObject * and do automatic casts. Inline
1492
+ * functions accepting PyArrayObject * provides for some compile-time
1493
+ * checking of correctness when working with these objects in C.
1494
+ */
1495
+
1496
+ #define PyArray_ISONESEGMENT(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS) || \
1497
+ PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS))
1498
+
1499
+ #define PyArray_ISFORTRAN(m) (PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) && \
1500
+ (!PyArray_CHKFLAGS(m, NPY_ARRAY_C_CONTIGUOUS)))
1501
+
1502
+ #define PyArray_FORTRAN_IF(m) ((PyArray_CHKFLAGS(m, NPY_ARRAY_F_CONTIGUOUS) ? \
1503
+ NPY_ARRAY_F_CONTIGUOUS : 0))
1504
+
1505
+ static inline int
1506
+ PyArray_NDIM(const PyArrayObject *arr)
1507
+ {
1508
+ return ((PyArrayObject_fields *)arr)->nd;
1509
+ }
1510
+
1511
+ static inline void *
1512
+ PyArray_DATA(const PyArrayObject *arr)
1513
+ {
1514
+ return ((PyArrayObject_fields *)arr)->data;
1515
+ }
1516
+
1517
+ static inline char *
1518
+ PyArray_BYTES(const PyArrayObject *arr)
1519
+ {
1520
+ return ((PyArrayObject_fields *)arr)->data;
1521
+ }
1522
+
1523
+ static inline npy_intp *
1524
+ PyArray_DIMS(const PyArrayObject *arr)
1525
+ {
1526
+ return ((PyArrayObject_fields *)arr)->dimensions;
1527
+ }
1528
+
1529
+ static inline npy_intp *
1530
+ PyArray_STRIDES(const PyArrayObject *arr)
1531
+ {
1532
+ return ((PyArrayObject_fields *)arr)->strides;
1533
+ }
1534
+
1535
+ static inline npy_intp
1536
+ PyArray_DIM(const PyArrayObject *arr, int idim)
1537
+ {
1538
+ return ((PyArrayObject_fields *)arr)->dimensions[idim];
1539
+ }
1540
+
1541
+ static inline npy_intp
1542
+ PyArray_STRIDE(const PyArrayObject *arr, int istride)
1543
+ {
1544
+ return ((PyArrayObject_fields *)arr)->strides[istride];
1545
+ }
1546
+
1547
+ static inline NPY_RETURNS_BORROWED_REF PyObject *
1548
+ PyArray_BASE(const PyArrayObject *arr)
1549
+ {
1550
+ return ((PyArrayObject_fields *)arr)->base;
1551
+ }
1552
+
1553
+ static inline NPY_RETURNS_BORROWED_REF PyArray_Descr *
1554
+ PyArray_DESCR(const PyArrayObject *arr)
1555
+ {
1556
+ return ((PyArrayObject_fields *)arr)->descr;
1557
+ }
1558
+
1559
+ static inline int
1560
+ PyArray_FLAGS(const PyArrayObject *arr)
1561
+ {
1562
+ return ((PyArrayObject_fields *)arr)->flags;
1563
+ }
1564
+
1565
+
1566
+ static inline int
1567
+ PyArray_TYPE(const PyArrayObject *arr)
1568
+ {
1569
+ return ((PyArrayObject_fields *)arr)->descr->type_num;
1570
+ }
1571
+
1572
+ static inline int
1573
+ PyArray_CHKFLAGS(const PyArrayObject *arr, int flags)
1574
+ {
1575
+ return (PyArray_FLAGS(arr) & flags) == flags;
1576
+ }
1577
+
1578
+ static inline PyArray_Descr *
1579
+ PyArray_DTYPE(const PyArrayObject *arr)
1580
+ {
1581
+ return ((PyArrayObject_fields *)arr)->descr;
1582
+ }
1583
+
1584
+ static inline npy_intp *
1585
+ PyArray_SHAPE(const PyArrayObject *arr)
1586
+ {
1587
+ return ((PyArrayObject_fields *)arr)->dimensions;
1588
+ }
1589
+
1590
+ /*
1591
+ * Enables the specified array flags. Does no checking,
1592
+ * assumes you know what you're doing.
1593
+ */
1594
+ static inline void
1595
+ PyArray_ENABLEFLAGS(PyArrayObject *arr, int flags)
1596
+ {
1597
+ ((PyArrayObject_fields *)arr)->flags |= flags;
1598
+ }
1599
+
1600
+ /*
1601
+ * Clears the specified array flags. Does no checking,
1602
+ * assumes you know what you're doing.
1603
+ */
1604
+ static inline void
1605
+ PyArray_CLEARFLAGS(PyArrayObject *arr, int flags)
1606
+ {
1607
+ ((PyArrayObject_fields *)arr)->flags &= ~flags;
1608
+ }
1609
+
1610
+ #if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
1611
+ static inline NPY_RETURNS_BORROWED_REF PyObject *
1612
+ PyArray_HANDLER(PyArrayObject *arr)
1613
+ {
1614
+ return ((PyArrayObject_fields *)arr)->mem_handler;
1615
+ }
1616
+ #endif
1617
+
1618
+ #define PyTypeNum_ISBOOL(type) ((type) == NPY_BOOL)
1619
+
1620
+ #define PyTypeNum_ISUNSIGNED(type) (((type) == NPY_UBYTE) || \
1621
+ ((type) == NPY_USHORT) || \
1622
+ ((type) == NPY_UINT) || \
1623
+ ((type) == NPY_ULONG) || \
1624
+ ((type) == NPY_ULONGLONG))
1625
+
1626
+ #define PyTypeNum_ISSIGNED(type) (((type) == NPY_BYTE) || \
1627
+ ((type) == NPY_SHORT) || \
1628
+ ((type) == NPY_INT) || \
1629
+ ((type) == NPY_LONG) || \
1630
+ ((type) == NPY_LONGLONG))
1631
+
1632
+ #define PyTypeNum_ISINTEGER(type) (((type) >= NPY_BYTE) && \
1633
+ ((type) <= NPY_ULONGLONG))
1634
+
1635
+ #define PyTypeNum_ISFLOAT(type) ((((type) >= NPY_FLOAT) && \
1636
+ ((type) <= NPY_LONGDOUBLE)) || \
1637
+ ((type) == NPY_HALF))
1638
+
1639
+ #define PyTypeNum_ISNUMBER(type) (((type) <= NPY_CLONGDOUBLE) || \
1640
+ ((type) == NPY_HALF))
1641
+
1642
+ #define PyTypeNum_ISSTRING(type) (((type) == NPY_STRING) || \
1643
+ ((type) == NPY_UNICODE))
1644
+
1645
+ #define PyTypeNum_ISCOMPLEX(type) (((type) >= NPY_CFLOAT) && \
1646
+ ((type) <= NPY_CLONGDOUBLE))
1647
+
1648
+ #define PyTypeNum_ISFLEXIBLE(type) (((type) >=NPY_STRING) && \
1649
+ ((type) <=NPY_VOID))
1650
+
1651
+ #define PyTypeNum_ISDATETIME(type) (((type) >=NPY_DATETIME) && \
1652
+ ((type) <=NPY_TIMEDELTA))
1653
+
1654
+ #define PyTypeNum_ISUSERDEF(type) (((type) >= NPY_USERDEF) && \
1655
+ ((type) < NPY_USERDEF+ \
1656
+ NPY_NUMUSERTYPES))
1657
+
1658
+ #define PyTypeNum_ISEXTENDED(type) (PyTypeNum_ISFLEXIBLE(type) || \
1659
+ PyTypeNum_ISUSERDEF(type))
1660
+
1661
+ #define PyTypeNum_ISOBJECT(type) ((type) == NPY_OBJECT)
1662
+
1663
+
1664
+ #define PyDataType_ISLEGACY(dtype) ((dtype)->type_num < NPY_VSTRING && ((dtype)->type_num >= 0))
1665
+ #define PyDataType_ISBOOL(obj) PyTypeNum_ISBOOL(((PyArray_Descr*)(obj))->type_num)
1666
+ #define PyDataType_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(((PyArray_Descr*)(obj))->type_num)
1667
+ #define PyDataType_ISSIGNED(obj) PyTypeNum_ISSIGNED(((PyArray_Descr*)(obj))->type_num)
1668
+ #define PyDataType_ISINTEGER(obj) PyTypeNum_ISINTEGER(((PyArray_Descr*)(obj))->type_num )
1669
+ #define PyDataType_ISFLOAT(obj) PyTypeNum_ISFLOAT(((PyArray_Descr*)(obj))->type_num)
1670
+ #define PyDataType_ISNUMBER(obj) PyTypeNum_ISNUMBER(((PyArray_Descr*)(obj))->type_num)
1671
+ #define PyDataType_ISSTRING(obj) PyTypeNum_ISSTRING(((PyArray_Descr*)(obj))->type_num)
1672
+ #define PyDataType_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(((PyArray_Descr*)(obj))->type_num)
1673
+ #define PyDataType_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(((PyArray_Descr*)(obj))->type_num)
1674
+ #define PyDataType_ISDATETIME(obj) PyTypeNum_ISDATETIME(((PyArray_Descr*)(obj))->type_num)
1675
+ #define PyDataType_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(((PyArray_Descr*)(obj))->type_num)
1676
+ #define PyDataType_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(((PyArray_Descr*)(obj))->type_num)
1677
+ #define PyDataType_ISOBJECT(obj) PyTypeNum_ISOBJECT(((PyArray_Descr*)(obj))->type_num)
1678
+ #define PyDataType_MAKEUNSIZED(dtype) ((dtype)->elsize = 0)
1679
+ /*
1680
+ * PyDataType_* FLAGS, FLACHK, REFCHK, HASFIELDS, HASSUBARRAY, UNSIZED,
1681
+ * SUBARRAY, NAMES, FIELDS, C_METADATA, and METADATA require version specific
1682
+ * lookup and are defined in npy_2_compat.h.
1683
+ */
1684
+
1685
+
1686
+ #define PyArray_ISBOOL(obj) PyTypeNum_ISBOOL(PyArray_TYPE(obj))
1687
+ #define PyArray_ISUNSIGNED(obj) PyTypeNum_ISUNSIGNED(PyArray_TYPE(obj))
1688
+ #define PyArray_ISSIGNED(obj) PyTypeNum_ISSIGNED(PyArray_TYPE(obj))
1689
+ #define PyArray_ISINTEGER(obj) PyTypeNum_ISINTEGER(PyArray_TYPE(obj))
1690
+ #define PyArray_ISFLOAT(obj) PyTypeNum_ISFLOAT(PyArray_TYPE(obj))
1691
+ #define PyArray_ISNUMBER(obj) PyTypeNum_ISNUMBER(PyArray_TYPE(obj))
1692
+ #define PyArray_ISSTRING(obj) PyTypeNum_ISSTRING(PyArray_TYPE(obj))
1693
+ #define PyArray_ISCOMPLEX(obj) PyTypeNum_ISCOMPLEX(PyArray_TYPE(obj))
1694
+ #define PyArray_ISFLEXIBLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
1695
+ #define PyArray_ISDATETIME(obj) PyTypeNum_ISDATETIME(PyArray_TYPE(obj))
1696
+ #define PyArray_ISUSERDEF(obj) PyTypeNum_ISUSERDEF(PyArray_TYPE(obj))
1697
+ #define PyArray_ISEXTENDED(obj) PyTypeNum_ISEXTENDED(PyArray_TYPE(obj))
1698
+ #define PyArray_ISOBJECT(obj) PyTypeNum_ISOBJECT(PyArray_TYPE(obj))
1699
+ #define PyArray_HASFIELDS(obj) PyDataType_HASFIELDS(PyArray_DESCR(obj))
1700
+
1701
+ /*
1702
+ * FIXME: This should check for a flag on the data-type that
1703
+ * states whether or not it is variable length. Because the
1704
+ * ISFLEXIBLE check is hard-coded to the built-in data-types.
1705
+ */
1706
+ #define PyArray_ISVARIABLE(obj) PyTypeNum_ISFLEXIBLE(PyArray_TYPE(obj))
1707
+
1708
+ #define PyArray_SAFEALIGNEDCOPY(obj) (PyArray_ISALIGNED(obj) && !PyArray_ISVARIABLE(obj))
1709
+
1710
+
1711
+ #define NPY_LITTLE '<'
1712
+ #define NPY_BIG '>'
1713
+ #define NPY_NATIVE '='
1714
+ #define NPY_SWAP 's'
1715
+ #define NPY_IGNORE '|'
1716
+
1717
+ #if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
1718
+ #define NPY_NATBYTE NPY_BIG
1719
+ #define NPY_OPPBYTE NPY_LITTLE
1720
+ #else
1721
+ #define NPY_NATBYTE NPY_LITTLE
1722
+ #define NPY_OPPBYTE NPY_BIG
1723
+ #endif
1724
+
1725
+ #define PyArray_ISNBO(arg) ((arg) != NPY_OPPBYTE)
1726
+ #define PyArray_IsNativeByteOrder PyArray_ISNBO
1727
+ #define PyArray_ISNOTSWAPPED(m) PyArray_ISNBO(PyArray_DESCR(m)->byteorder)
1728
+ #define PyArray_ISBYTESWAPPED(m) (!PyArray_ISNOTSWAPPED(m))
1729
+
1730
+ #define PyArray_FLAGSWAP(m, flags) (PyArray_CHKFLAGS(m, flags) && \
1731
+ PyArray_ISNOTSWAPPED(m))
1732
+
1733
+ #define PyArray_ISCARRAY(m) PyArray_FLAGSWAP(m, NPY_ARRAY_CARRAY)
1734
+ #define PyArray_ISCARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_CARRAY_RO)
1735
+ #define PyArray_ISFARRAY(m) PyArray_FLAGSWAP(m, NPY_ARRAY_FARRAY)
1736
+ #define PyArray_ISFARRAY_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_FARRAY_RO)
1737
+ #define PyArray_ISBEHAVED(m) PyArray_FLAGSWAP(m, NPY_ARRAY_BEHAVED)
1738
+ #define PyArray_ISBEHAVED_RO(m) PyArray_FLAGSWAP(m, NPY_ARRAY_ALIGNED)
1739
+
1740
+
1741
+ #define PyDataType_ISNOTSWAPPED(d) PyArray_ISNBO(((PyArray_Descr *)(d))->byteorder)
1742
+ #define PyDataType_ISBYTESWAPPED(d) (!PyDataType_ISNOTSWAPPED(d))
1743
+
1744
+ /************************************************************
1745
+ * A struct used by PyArray_CreateSortedStridePerm, new in 1.7.
1746
+ ************************************************************/
1747
+
1748
+ typedef struct {
1749
+ npy_intp perm, stride;
1750
+ } npy_stride_sort_item;
1751
+
1752
+ /************************************************************
1753
+ * This is the form of the struct that's stored in the
1754
+ * PyCapsule returned by an array's __array_struct__ attribute. See
1755
+ * https://docs.scipy.org/doc/numpy/reference/arrays.interface.html for the full
1756
+ * documentation.
1757
+ ************************************************************/
1758
+ typedef struct {
1759
+ int two; /*
1760
+ * contains the integer 2 as a sanity
1761
+ * check
1762
+ */
1763
+
1764
+ int nd; /* number of dimensions */
1765
+
1766
+ char typekind; /*
1767
+ * kind in array --- character code of
1768
+ * typestr
1769
+ */
1770
+
1771
+ int itemsize; /* size of each element */
1772
+
1773
+ int flags; /*
1774
+ * how should be data interpreted. Valid
1775
+ * flags are CONTIGUOUS (1), F_CONTIGUOUS (2),
1776
+ * ALIGNED (0x100), NOTSWAPPED (0x200), and
1777
+ * WRITEABLE (0x400). ARR_HAS_DESCR (0x800)
1778
+ * states that arrdescr field is present in
1779
+ * structure
1780
+ */
1781
+
1782
+ npy_intp *shape; /*
1783
+ * A length-nd array of shape
1784
+ * information
1785
+ */
1786
+
1787
+ npy_intp *strides; /* A length-nd array of stride information */
1788
+
1789
+ void *data; /* A pointer to the first element of the array */
1790
+
1791
+ PyObject *descr; /*
1792
+ * A list of fields or NULL (ignored if flags
1793
+ * does not have ARR_HAS_DESCR flag set)
1794
+ */
1795
+ } PyArrayInterface;
1796
+
1797
+
1798
+ /****************************************
1799
+ * NpyString
1800
+ *
1801
+ * Types used by the NpyString API.
1802
+ ****************************************/
1803
+
1804
+ /*
1805
+ * A "packed" encoded string. The string data must be accessed by first unpacking the string.
1806
+ */
1807
+ typedef struct npy_packed_static_string npy_packed_static_string;
1808
+
1809
+ /*
1810
+ * An unpacked read-only view onto the data in a packed string
1811
+ */
1812
+ typedef struct npy_unpacked_static_string {
1813
+ size_t size;
1814
+ const char *buf;
1815
+ } npy_static_string;
1816
+
1817
+ /*
1818
+ * Handles heap allocations for static strings.
1819
+ */
1820
+ typedef struct npy_string_allocator npy_string_allocator;
1821
+
1822
+ typedef struct {
1823
+ PyArray_Descr base;
1824
+ // The object representing a null value
1825
+ PyObject *na_object;
1826
+ // Flag indicating whether or not to coerce arbitrary objects to strings
1827
+ char coerce;
1828
+ // Flag indicating the na object is NaN-like
1829
+ char has_nan_na;
1830
+ // Flag indicating the na object is a string
1831
+ char has_string_na;
1832
+ // If nonzero, indicates that this instance is owned by an array already
1833
+ char array_owned;
1834
+ // The string data to use when a default string is needed
1835
+ npy_static_string default_string;
1836
+ // The name of the missing data object, if any
1837
+ npy_static_string na_name;
1838
+ // the allocator should only be directly accessed after
1839
+ // acquiring the allocator_lock and the lock should
1840
+ // be released immediately after the allocator is
1841
+ // no longer needed
1842
+ npy_string_allocator *allocator;
1843
+ } PyArray_StringDTypeObject;
1844
+
1845
+ /*
1846
+ * PyArray_DTypeMeta related definitions.
1847
+ *
1848
+ * As of now, this API is preliminary and will be extended as necessary.
1849
+ */
1850
+ #if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
1851
+ /*
1852
+ * The Structures defined in this block are currently considered
1853
+ * private API and may change without warning!
1854
+ * Part of this (at least the size) is expected to be public API without
1855
+ * further modifications.
1856
+ */
1857
+ /* TODO: Make this definition public in the API, as soon as its settled */
1858
+ NPY_NO_EXPORT extern PyTypeObject PyArrayDTypeMeta_Type;
1859
+
1860
+ /*
1861
+ * While NumPy DTypes would not need to be heap types the plan is to
1862
+ * make DTypes available in Python at which point they will be heap types.
1863
+ * Since we also wish to add fields to the DType class, this looks like
1864
+ * a typical instance definition, but with PyHeapTypeObject instead of
1865
+ * only the PyObject_HEAD.
1866
+ * This must only be exposed very extremely careful consideration, since
1867
+ * it is a fairly complex construct which may be better to allow
1868
+ * refactoring of.
1869
+ */
1870
+ typedef struct {
1871
+ PyHeapTypeObject super;
1872
+
1873
+ /*
1874
+ * Most DTypes will have a singleton default instance, for the
1875
+ * parametric legacy DTypes (bytes, string, void, datetime) this
1876
+ * may be a pointer to the *prototype* instance?
1877
+ */
1878
+ PyArray_Descr *singleton;
1879
+ /* Copy of the legacy DTypes type number, usually invalid. */
1880
+ int type_num;
1881
+
1882
+ /* The type object of the scalar instances (may be NULL?) */
1883
+ PyTypeObject *scalar_type;
1884
+ /*
1885
+ * DType flags to signal legacy, parametric, or
1886
+ * abstract. But plenty of space for additional information/flags.
1887
+ */
1888
+ npy_uint64 flags;
1889
+
1890
+ /*
1891
+ * Use indirection in order to allow a fixed size for this struct.
1892
+ * A stable ABI size makes creating a static DType less painful
1893
+ * while also ensuring flexibility for all opaque API (with one
1894
+ * indirection due the pointer lookup).
1895
+ */
1896
+ void *dt_slots;
1897
+ void *reserved[3];
1898
+ } PyArray_DTypeMeta;
1899
+
1900
+ #endif /* NPY_INTERNAL_BUILD */
1901
+
1902
+
1903
+ /*
1904
+ * Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files
1905
+ * npy_*_*_deprecated_api.h are only included from here and nowhere else.
1906
+ */
1907
+ #ifdef NPY_DEPRECATED_INCLUDES
1908
+ #error "Do not use the reserved keyword NPY_DEPRECATED_INCLUDES."
1909
+ #endif
1910
+ #define NPY_DEPRECATED_INCLUDES
1911
+ #if !defined(NPY_NO_DEPRECATED_API) || \
1912
+ (NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION)
1913
+ #include "npy_1_7_deprecated_api.h"
1914
+ #endif
1915
+ /*
1916
+ * There is no file npy_1_8_deprecated_api.h since there are no additional
1917
+ * deprecated API features in NumPy 1.8.
1918
+ *
1919
+ * Note to maintainers: insert code like the following in future NumPy
1920
+ * versions.
1921
+ *
1922
+ * #if !defined(NPY_NO_DEPRECATED_API) || \
1923
+ * (NPY_NO_DEPRECATED_API < NPY_1_9_API_VERSION)
1924
+ * #include "npy_1_9_deprecated_api.h"
1925
+ * #endif
1926
+ */
1927
+ #undef NPY_DEPRECATED_INCLUDES
1928
+
1929
+ #ifdef __cplusplus
1930
+ }
1931
+ #endif
1932
+
1933
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_1_7_deprecated_api.h ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NPY_DEPRECATED_INCLUDES
2
+ #error "Should never include npy_*_*_deprecated_api directly."
3
+ #endif
4
+
5
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
6
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_
7
+
8
+ /* Emit a warning if the user did not specifically request the old API */
9
+ #ifndef NPY_NO_DEPRECATED_API
10
+ #if defined(_WIN32)
11
+ #define _WARN___STR2__(x) #x
12
+ #define _WARN___STR1__(x) _WARN___STR2__(x)
13
+ #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
14
+ #pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it with " \
15
+ "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION")
16
+ #else
17
+ #warning "Using deprecated NumPy API, disable it with " \
18
+ "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
19
+ #endif
20
+ #endif
21
+
22
+ /*
23
+ * This header exists to collect all dangerous/deprecated NumPy API
24
+ * as of NumPy 1.7.
25
+ *
26
+ * This is an attempt to remove bad API, the proliferation of macros,
27
+ * and namespace pollution currently produced by the NumPy headers.
28
+ */
29
+
30
+ /* These array flags are deprecated as of NumPy 1.7 */
31
+ #define NPY_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS
32
+ #define NPY_FORTRAN NPY_ARRAY_F_CONTIGUOUS
33
+
34
+ /*
35
+ * The consistent NPY_ARRAY_* names which don't pollute the NPY_*
36
+ * namespace were added in NumPy 1.7.
37
+ *
38
+ * These versions of the carray flags are deprecated, but
39
+ * probably should only be removed after two releases instead of one.
40
+ */
41
+ #define NPY_C_CONTIGUOUS NPY_ARRAY_C_CONTIGUOUS
42
+ #define NPY_F_CONTIGUOUS NPY_ARRAY_F_CONTIGUOUS
43
+ #define NPY_OWNDATA NPY_ARRAY_OWNDATA
44
+ #define NPY_FORCECAST NPY_ARRAY_FORCECAST
45
+ #define NPY_ENSURECOPY NPY_ARRAY_ENSURECOPY
46
+ #define NPY_ENSUREARRAY NPY_ARRAY_ENSUREARRAY
47
+ #define NPY_ELEMENTSTRIDES NPY_ARRAY_ELEMENTSTRIDES
48
+ #define NPY_ALIGNED NPY_ARRAY_ALIGNED
49
+ #define NPY_NOTSWAPPED NPY_ARRAY_NOTSWAPPED
50
+ #define NPY_WRITEABLE NPY_ARRAY_WRITEABLE
51
+ #define NPY_BEHAVED NPY_ARRAY_BEHAVED
52
+ #define NPY_BEHAVED_NS NPY_ARRAY_BEHAVED_NS
53
+ #define NPY_CARRAY NPY_ARRAY_CARRAY
54
+ #define NPY_CARRAY_RO NPY_ARRAY_CARRAY_RO
55
+ #define NPY_FARRAY NPY_ARRAY_FARRAY
56
+ #define NPY_FARRAY_RO NPY_ARRAY_FARRAY_RO
57
+ #define NPY_DEFAULT NPY_ARRAY_DEFAULT
58
+ #define NPY_IN_ARRAY NPY_ARRAY_IN_ARRAY
59
+ #define NPY_OUT_ARRAY NPY_ARRAY_OUT_ARRAY
60
+ #define NPY_INOUT_ARRAY NPY_ARRAY_INOUT_ARRAY
61
+ #define NPY_IN_FARRAY NPY_ARRAY_IN_FARRAY
62
+ #define NPY_OUT_FARRAY NPY_ARRAY_OUT_FARRAY
63
+ #define NPY_INOUT_FARRAY NPY_ARRAY_INOUT_FARRAY
64
+ #define NPY_UPDATE_ALL NPY_ARRAY_UPDATE_ALL
65
+
66
+ /* This way of accessing the default type is deprecated as of NumPy 1.7 */
67
+ #define PyArray_DEFAULT NPY_DEFAULT_TYPE
68
+
69
+ /*
70
+ * Deprecated as of NumPy 1.7, this kind of shortcut doesn't
71
+ * belong in the public API.
72
+ */
73
+ #define NPY_AO PyArrayObject
74
+
75
+ /*
76
+ * Deprecated as of NumPy 1.7, an all-lowercase macro doesn't
77
+ * belong in the public API.
78
+ */
79
+ #define fortran fortran_
80
+
81
+ /*
82
+ * Deprecated as of NumPy 1.7, as it is a namespace-polluting
83
+ * macro.
84
+ */
85
+ #define FORTRAN_IF PyArray_FORTRAN_IF
86
+
87
+ /* Deprecated as of NumPy 1.7, datetime64 uses c_metadata instead */
88
+ #define NPY_METADATA_DTSTR "__timeunit__"
89
+
90
+ /*
91
+ * Deprecated as of NumPy 1.7.
92
+ * The reasoning:
93
+ * - These are for datetime, but there's no datetime "namespace".
94
+ * - They just turn NPY_STR_<x> into "<x>", which is just
95
+ * making something simple be indirected.
96
+ */
97
+ #define NPY_STR_Y "Y"
98
+ #define NPY_STR_M "M"
99
+ #define NPY_STR_W "W"
100
+ #define NPY_STR_D "D"
101
+ #define NPY_STR_h "h"
102
+ #define NPY_STR_m "m"
103
+ #define NPY_STR_s "s"
104
+ #define NPY_STR_ms "ms"
105
+ #define NPY_STR_us "us"
106
+ #define NPY_STR_ns "ns"
107
+ #define NPY_STR_ps "ps"
108
+ #define NPY_STR_fs "fs"
109
+ #define NPY_STR_as "as"
110
+
111
+
112
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_1_7_DEPRECATED_API_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_2_compat.h ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This header file defines relevant features which:
3
+ * - Require runtime inspection depending on the NumPy version.
4
+ * - May be needed when compiling with an older version of NumPy to allow
5
+ * a smooth transition.
6
+ *
7
+ * As such, it is shipped with NumPy 2.0, but designed to be vendored in full
8
+ * or parts by downstream projects.
9
+ *
10
+ * It must be included after any other includes. `import_array()` must have
11
+ * been called in the scope or version dependency will misbehave, even when
12
+ * only `PyUFunc_` API is used.
13
+ *
14
+ * If required complicated defs (with inline functions) should be written as:
15
+ *
16
+ * #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
17
+ * Simple definition when NumPy 2.0 API is guaranteed.
18
+ * #else
19
+ * static inline definition of a 1.x compatibility shim
20
+ * #if NPY_ABI_VERSION < 0x02000000
21
+ * Make 1.x compatibility shim the public API (1.x only branch)
22
+ * #else
23
+ * Runtime dispatched version (1.x or 2.x)
24
+ * #endif
25
+ * #endif
26
+ *
27
+ * An internal build always passes NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
28
+ */
29
+
30
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPAT_H_
31
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPAT_H_
32
+
33
+ /*
34
+ * New macros for accessing real and complex part of a complex number can be
35
+ * found in "npy_2_complexcompat.h".
36
+ */
37
+
38
+
39
+ /*
40
+ * This header is meant to be included by downstream directly for 1.x compat.
41
+ * In that case we need to ensure that users first included the full headers
42
+ * and not just `ndarraytypes.h`.
43
+ */
44
+
45
+ #ifndef NPY_FEATURE_VERSION
46
+ #error "The NumPy 2 compat header requires `import_array()` for which " \
47
+ "the `ndarraytypes.h` header include is not sufficient. Please " \
48
+ "include it after `numpy/ndarrayobject.h` or similar.\n" \
49
+ "To simplify inclusion, you may use `PyArray_ImportNumPy()` " \
50
+ "which is defined in the compat header and is lightweight (can be)."
51
+ #endif
52
+
53
+ #if NPY_ABI_VERSION < 0x02000000
54
+ /*
55
+ * Define 2.0 feature version as it is needed below to decide whether we
56
+ * compile for both 1.x and 2.x (defining it guarantees 1.x only).
57
+ */
58
+ #define NPY_2_0_API_VERSION 0x00000012
59
+ /*
60
+ * If we are compiling with NumPy 1.x, PyArray_RUNTIME_VERSION so we
61
+ * pretend the `PyArray_RUNTIME_VERSION` is `NPY_FEATURE_VERSION`.
62
+ * This allows downstream to use `PyArray_RUNTIME_VERSION` if they need to.
63
+ */
64
+ #define PyArray_RUNTIME_VERSION NPY_FEATURE_VERSION
65
+ /* Compiling on NumPy 1.x where these are the same: */
66
+ #define PyArray_DescrProto PyArray_Descr
67
+ #endif
68
+
69
+
70
+ /*
71
+ * Define a better way to call `_import_array()` to simplify backporting as
72
+ * we now require imports more often (necessary to make ABI flexible).
73
+ */
74
+ #ifdef import_array1
75
+
76
+ static inline int
77
+ PyArray_ImportNumPyAPI(void)
78
+ {
79
+ if (NPY_UNLIKELY(PyArray_API == NULL)) {
80
+ import_array1(-1);
81
+ }
82
+ return 0;
83
+ }
84
+
85
+ #endif /* import_array1 */
86
+
87
+
88
+ /*
89
+ * NPY_DEFAULT_INT
90
+ *
91
+ * The default integer has changed, `NPY_DEFAULT_INT` is available at runtime
92
+ * for use as type number, e.g. `PyArray_DescrFromType(NPY_DEFAULT_INT)`.
93
+ *
94
+ * NPY_RAVEL_AXIS
95
+ *
96
+ * This was introduced in NumPy 2.0 to allow indicating that an axis should be
97
+ * raveled in an operation. Before NumPy 2.0, NPY_MAXDIMS was used for this purpose.
98
+ *
99
+ * NPY_MAXDIMS
100
+ *
101
+ * A constant indicating the maximum number dimensions allowed when creating
102
+ * an ndarray.
103
+ *
104
+ * NPY_NTYPES_LEGACY
105
+ *
106
+ * The number of built-in NumPy dtypes.
107
+ */
108
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
109
+ #define NPY_DEFAULT_INT NPY_INTP
110
+ #define NPY_RAVEL_AXIS NPY_MIN_INT
111
+ #define NPY_MAXARGS 64
112
+
113
+ #elif NPY_ABI_VERSION < 0x02000000
114
+ #define NPY_DEFAULT_INT NPY_LONG
115
+ #define NPY_RAVEL_AXIS 32
116
+ #define NPY_MAXARGS 32
117
+
118
+ /* Aliases of 2.x names to 1.x only equivalent names */
119
+ #define NPY_NTYPES NPY_NTYPES_LEGACY
120
+ #define PyArray_DescrProto PyArray_Descr
121
+ #define _PyArray_LegacyDescr PyArray_Descr
122
+ /* NumPy 2 definition always works, but add it for 1.x only */
123
+ #define PyDataType_ISLEGACY(dtype) (1)
124
+ #else
125
+ #define NPY_DEFAULT_INT \
126
+ (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? NPY_INTP : NPY_LONG)
127
+ #define NPY_RAVEL_AXIS \
128
+ (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? NPY_MIN_INT : 32)
129
+ #define NPY_MAXARGS \
130
+ (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION ? 64 : 32)
131
+ #endif
132
+
133
+
134
+ /*
135
+ * Access inline functions for descriptor fields. Except for the first
136
+ * few fields, these needed to be moved (elsize, alignment) for
137
+ * additional space. Or they are descriptor specific and are not generally
138
+ * available anymore (metadata, c_metadata, subarray, names, fields).
139
+ *
140
+ * Most of these are defined via the `DESCR_ACCESSOR` macro helper.
141
+ */
142
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION || NPY_ABI_VERSION < 0x02000000
143
+ /* Compiling for 1.x or 2.x only, direct field access is OK: */
144
+
145
+ static inline void
146
+ PyDataType_SET_ELSIZE(PyArray_Descr *dtype, npy_intp size)
147
+ {
148
+ dtype->elsize = size;
149
+ }
150
+
151
+ static inline npy_uint64
152
+ PyDataType_FLAGS(const PyArray_Descr *dtype)
153
+ {
154
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
155
+ return dtype->flags;
156
+ #else
157
+ return (unsigned char)dtype->flags; /* Need unsigned cast on 1.x */
158
+ #endif
159
+ }
160
+
161
+ #define DESCR_ACCESSOR(FIELD, field, type, legacy_only) \
162
+ static inline type \
163
+ PyDataType_##FIELD(const PyArray_Descr *dtype) { \
164
+ if (legacy_only && !PyDataType_ISLEGACY(dtype)) { \
165
+ return (type)0; \
166
+ } \
167
+ return ((_PyArray_LegacyDescr *)dtype)->field; \
168
+ }
169
+ #else /* compiling for both 1.x and 2.x */
170
+
171
+ static inline void
172
+ PyDataType_SET_ELSIZE(PyArray_Descr *dtype, npy_intp size)
173
+ {
174
+ if (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION) {
175
+ ((_PyArray_DescrNumPy2 *)dtype)->elsize = size;
176
+ }
177
+ else {
178
+ ((PyArray_DescrProto *)dtype)->elsize = (int)size;
179
+ }
180
+ }
181
+
182
+ static inline npy_uint64
183
+ PyDataType_FLAGS(const PyArray_Descr *dtype)
184
+ {
185
+ if (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION) {
186
+ return ((_PyArray_DescrNumPy2 *)dtype)->flags;
187
+ }
188
+ else {
189
+ return (unsigned char)((PyArray_DescrProto *)dtype)->flags;
190
+ }
191
+ }
192
+
193
+ /* Cast to LegacyDescr always fine but needed when `legacy_only` */
194
+ #define DESCR_ACCESSOR(FIELD, field, type, legacy_only) \
195
+ static inline type \
196
+ PyDataType_##FIELD(const PyArray_Descr *dtype) { \
197
+ if (legacy_only && !PyDataType_ISLEGACY(dtype)) { \
198
+ return (type)0; \
199
+ } \
200
+ if (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION) { \
201
+ return ((_PyArray_LegacyDescr *)dtype)->field; \
202
+ } \
203
+ else { \
204
+ return ((PyArray_DescrProto *)dtype)->field; \
205
+ } \
206
+ }
207
+ #endif
208
+
209
+ DESCR_ACCESSOR(ELSIZE, elsize, npy_intp, 0)
210
+ DESCR_ACCESSOR(ALIGNMENT, alignment, npy_intp, 0)
211
+ DESCR_ACCESSOR(METADATA, metadata, PyObject *, 1)
212
+ DESCR_ACCESSOR(SUBARRAY, subarray, PyArray_ArrayDescr *, 1)
213
+ DESCR_ACCESSOR(NAMES, names, PyObject *, 1)
214
+ DESCR_ACCESSOR(FIELDS, fields, PyObject *, 1)
215
+ DESCR_ACCESSOR(C_METADATA, c_metadata, NpyAuxData *, 1)
216
+
217
+ #undef DESCR_ACCESSOR
218
+
219
+
220
+ #if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
221
+ #if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
222
+ static inline PyArray_ArrFuncs *
223
+ PyDataType_GetArrFuncs(const PyArray_Descr *descr)
224
+ {
225
+ return _PyDataType_GetArrFuncs(descr);
226
+ }
227
+ #elif NPY_ABI_VERSION < 0x02000000
228
+ static inline PyArray_ArrFuncs *
229
+ PyDataType_GetArrFuncs(const PyArray_Descr *descr)
230
+ {
231
+ return descr->f;
232
+ }
233
+ #else
234
+ static inline PyArray_ArrFuncs *
235
+ PyDataType_GetArrFuncs(const PyArray_Descr *descr)
236
+ {
237
+ if (PyArray_RUNTIME_VERSION >= NPY_2_0_API_VERSION) {
238
+ return _PyDataType_GetArrFuncs(descr);
239
+ }
240
+ else {
241
+ return ((PyArray_DescrProto *)descr)->f;
242
+ }
243
+ }
244
+ #endif
245
+
246
+
247
+ #endif /* not internal build */
248
+
249
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPAT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_2_complexcompat.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* This header is designed to be copy-pasted into downstream packages, since it provides
2
+ a compatibility layer between the old C struct complex types and the new native C99
3
+ complex types. The new macros are in numpy/npy_math.h, which is why it is included here. */
4
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPLEXCOMPAT_H_
5
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_2_COMPLEXCOMPAT_H_
6
+
7
+ #include <numpy/npy_math.h>
8
+
9
+ #ifndef NPY_CSETREALF
10
+ #define NPY_CSETREALF(c, r) (c)->real = (r)
11
+ #endif
12
+ #ifndef NPY_CSETIMAGF
13
+ #define NPY_CSETIMAGF(c, i) (c)->imag = (i)
14
+ #endif
15
+ #ifndef NPY_CSETREAL
16
+ #define NPY_CSETREAL(c, r) (c)->real = (r)
17
+ #endif
18
+ #ifndef NPY_CSETIMAG
19
+ #define NPY_CSETIMAG(c, i) (c)->imag = (i)
20
+ #endif
21
+ #ifndef NPY_CSETREALL
22
+ #define NPY_CSETREALL(c, r) (c)->real = (r)
23
+ #endif
24
+ #ifndef NPY_CSETIMAGL
25
+ #define NPY_CSETIMAGL(c, i) (c)->imag = (i)
26
+ #endif
27
+
28
+ #endif
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_3kcompat.h ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This is a convenience header file providing compatibility utilities
3
+ * for supporting different minor versions of Python 3.
4
+ * It was originally used to support the transition from Python 2,
5
+ * hence the "3k" naming.
6
+ *
7
+ * If you want to use this for your own projects, it's recommended to make a
8
+ * copy of it. We don't provide backwards compatibility guarantees.
9
+ */
10
+
11
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_
12
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_
13
+
14
+ #include <Python.h>
15
+ #include <stdio.h>
16
+
17
+ #include "npy_common.h"
18
+
19
+ #ifdef __cplusplus
20
+ extern "C" {
21
+ #endif
22
+
23
+ /* Python13 removes _PyLong_AsInt */
24
+ static inline int
25
+ Npy__PyLong_AsInt(PyObject *obj)
26
+ {
27
+ int overflow;
28
+ long result = PyLong_AsLongAndOverflow(obj, &overflow);
29
+
30
+ /* INT_MAX and INT_MIN are defined in Python.h */
31
+ if (overflow || result > INT_MAX || result < INT_MIN) {
32
+ /* XXX: could be cute and give a different
33
+ message for overflow == -1 */
34
+ PyErr_SetString(PyExc_OverflowError,
35
+ "Python int too large to convert to C int");
36
+ return -1;
37
+ }
38
+ return (int)result;
39
+ }
40
+
41
+ #if defined _MSC_VER && _MSC_VER >= 1900
42
+
43
+ #include <stdlib.h>
44
+
45
+ /*
46
+ * Macros to protect CRT calls against instant termination when passed an
47
+ * invalid parameter (https://bugs.python.org/issue23524).
48
+ */
49
+ extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler;
50
+ #define NPY_BEGIN_SUPPRESS_IPH { _invalid_parameter_handler _Py_old_handler = \
51
+ _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler);
52
+ #define NPY_END_SUPPRESS_IPH _set_thread_local_invalid_parameter_handler(_Py_old_handler); }
53
+
54
+ #else
55
+
56
+ #define NPY_BEGIN_SUPPRESS_IPH
57
+ #define NPY_END_SUPPRESS_IPH
58
+
59
+ #endif /* _MSC_VER >= 1900 */
60
+
61
+ /*
62
+ * PyFile_* compatibility
63
+ */
64
+
65
+ /*
66
+ * Get a FILE* handle to the file represented by the Python object
67
+ */
68
+ static inline FILE*
69
+ npy_PyFile_Dup2(PyObject *file, char *mode, npy_off_t *orig_pos)
70
+ {
71
+ int fd, fd2, unbuf;
72
+ Py_ssize_t fd2_tmp;
73
+ PyObject *ret, *os, *io, *io_raw;
74
+ npy_off_t pos;
75
+ FILE *handle;
76
+
77
+ /* Flush first to ensure things end up in the file in the correct order */
78
+ ret = PyObject_CallMethod(file, "flush", "");
79
+ if (ret == NULL) {
80
+ return NULL;
81
+ }
82
+ Py_DECREF(ret);
83
+ fd = PyObject_AsFileDescriptor(file);
84
+ if (fd == -1) {
85
+ return NULL;
86
+ }
87
+
88
+ /*
89
+ * The handle needs to be dup'd because we have to call fclose
90
+ * at the end
91
+ */
92
+ os = PyImport_ImportModule("os");
93
+ if (os == NULL) {
94
+ return NULL;
95
+ }
96
+ ret = PyObject_CallMethod(os, "dup", "i", fd);
97
+ Py_DECREF(os);
98
+ if (ret == NULL) {
99
+ return NULL;
100
+ }
101
+ fd2_tmp = PyNumber_AsSsize_t(ret, PyExc_IOError);
102
+ Py_DECREF(ret);
103
+ if (fd2_tmp == -1 && PyErr_Occurred()) {
104
+ return NULL;
105
+ }
106
+ if (fd2_tmp < INT_MIN || fd2_tmp > INT_MAX) {
107
+ PyErr_SetString(PyExc_IOError,
108
+ "Getting an 'int' from os.dup() failed");
109
+ return NULL;
110
+ }
111
+ fd2 = (int)fd2_tmp;
112
+
113
+ /* Convert to FILE* handle */
114
+ #ifdef _WIN32
115
+ NPY_BEGIN_SUPPRESS_IPH
116
+ handle = _fdopen(fd2, mode);
117
+ NPY_END_SUPPRESS_IPH
118
+ #else
119
+ handle = fdopen(fd2, mode);
120
+ #endif
121
+ if (handle == NULL) {
122
+ PyErr_SetString(PyExc_IOError,
123
+ "Getting a FILE* from a Python file object via "
124
+ "_fdopen failed. If you built NumPy, you probably "
125
+ "linked with the wrong debug/release runtime");
126
+ return NULL;
127
+ }
128
+
129
+ /* Record the original raw file handle position */
130
+ *orig_pos = npy_ftell(handle);
131
+ if (*orig_pos == -1) {
132
+ /* The io module is needed to determine if buffering is used */
133
+ io = PyImport_ImportModule("io");
134
+ if (io == NULL) {
135
+ fclose(handle);
136
+ return NULL;
137
+ }
138
+ /* File object instances of RawIOBase are unbuffered */
139
+ io_raw = PyObject_GetAttrString(io, "RawIOBase");
140
+ Py_DECREF(io);
141
+ if (io_raw == NULL) {
142
+ fclose(handle);
143
+ return NULL;
144
+ }
145
+ unbuf = PyObject_IsInstance(file, io_raw);
146
+ Py_DECREF(io_raw);
147
+ if (unbuf == 1) {
148
+ /* Succeed if the IO is unbuffered */
149
+ return handle;
150
+ }
151
+ else {
152
+ PyErr_SetString(PyExc_IOError, "obtaining file position failed");
153
+ fclose(handle);
154
+ return NULL;
155
+ }
156
+ }
157
+
158
+ /* Seek raw handle to the Python-side position */
159
+ ret = PyObject_CallMethod(file, "tell", "");
160
+ if (ret == NULL) {
161
+ fclose(handle);
162
+ return NULL;
163
+ }
164
+ pos = PyLong_AsLongLong(ret);
165
+ Py_DECREF(ret);
166
+ if (PyErr_Occurred()) {
167
+ fclose(handle);
168
+ return NULL;
169
+ }
170
+ if (npy_fseek(handle, pos, SEEK_SET) == -1) {
171
+ PyErr_SetString(PyExc_IOError, "seeking file failed");
172
+ fclose(handle);
173
+ return NULL;
174
+ }
175
+ return handle;
176
+ }
177
+
178
+ /*
179
+ * Close the dup-ed file handle, and seek the Python one to the current position
180
+ */
181
+ static inline int
182
+ npy_PyFile_DupClose2(PyObject *file, FILE* handle, npy_off_t orig_pos)
183
+ {
184
+ int fd, unbuf;
185
+ PyObject *ret, *io, *io_raw;
186
+ npy_off_t position;
187
+
188
+ position = npy_ftell(handle);
189
+
190
+ /* Close the FILE* handle */
191
+ fclose(handle);
192
+
193
+ /*
194
+ * Restore original file handle position, in order to not confuse
195
+ * Python-side data structures
196
+ */
197
+ fd = PyObject_AsFileDescriptor(file);
198
+ if (fd == -1) {
199
+ return -1;
200
+ }
201
+
202
+ if (npy_lseek(fd, orig_pos, SEEK_SET) == -1) {
203
+
204
+ /* The io module is needed to determine if buffering is used */
205
+ io = PyImport_ImportModule("io");
206
+ if (io == NULL) {
207
+ return -1;
208
+ }
209
+ /* File object instances of RawIOBase are unbuffered */
210
+ io_raw = PyObject_GetAttrString(io, "RawIOBase");
211
+ Py_DECREF(io);
212
+ if (io_raw == NULL) {
213
+ return -1;
214
+ }
215
+ unbuf = PyObject_IsInstance(file, io_raw);
216
+ Py_DECREF(io_raw);
217
+ if (unbuf == 1) {
218
+ /* Succeed if the IO is unbuffered */
219
+ return 0;
220
+ }
221
+ else {
222
+ PyErr_SetString(PyExc_IOError, "seeking file failed");
223
+ return -1;
224
+ }
225
+ }
226
+
227
+ if (position == -1) {
228
+ PyErr_SetString(PyExc_IOError, "obtaining file position failed");
229
+ return -1;
230
+ }
231
+
232
+ /* Seek Python-side handle to the FILE* handle position */
233
+ ret = PyObject_CallMethod(file, "seek", NPY_OFF_T_PYFMT "i", position, 0);
234
+ if (ret == NULL) {
235
+ return -1;
236
+ }
237
+ Py_DECREF(ret);
238
+ return 0;
239
+ }
240
+
241
+ static inline PyObject*
242
+ npy_PyFile_OpenFile(PyObject *filename, const char *mode)
243
+ {
244
+ PyObject *open;
245
+ open = PyDict_GetItemString(PyEval_GetBuiltins(), "open");
246
+ if (open == NULL) {
247
+ return NULL;
248
+ }
249
+ return PyObject_CallFunction(open, "Os", filename, mode);
250
+ }
251
+
252
+ static inline int
253
+ npy_PyFile_CloseFile(PyObject *file)
254
+ {
255
+ PyObject *ret;
256
+
257
+ ret = PyObject_CallMethod(file, "close", NULL);
258
+ if (ret == NULL) {
259
+ return -1;
260
+ }
261
+ Py_DECREF(ret);
262
+ return 0;
263
+ }
264
+
265
+ /* This is a copy of _PyErr_ChainExceptions, which
266
+ * is no longer exported from Python3.12
267
+ */
268
+ static inline void
269
+ npy_PyErr_ChainExceptions(PyObject *exc, PyObject *val, PyObject *tb)
270
+ {
271
+ if (exc == NULL)
272
+ return;
273
+
274
+ if (PyErr_Occurred()) {
275
+ PyObject *exc2, *val2, *tb2;
276
+ PyErr_Fetch(&exc2, &val2, &tb2);
277
+ PyErr_NormalizeException(&exc, &val, &tb);
278
+ if (tb != NULL) {
279
+ PyException_SetTraceback(val, tb);
280
+ Py_DECREF(tb);
281
+ }
282
+ Py_DECREF(exc);
283
+ PyErr_NormalizeException(&exc2, &val2, &tb2);
284
+ PyException_SetContext(val2, val);
285
+ PyErr_Restore(exc2, val2, tb2);
286
+ }
287
+ else {
288
+ PyErr_Restore(exc, val, tb);
289
+ }
290
+ }
291
+
292
+ /* This is a copy of _PyErr_ChainExceptions, with:
293
+ * __cause__ used instead of __context__
294
+ */
295
+ static inline void
296
+ npy_PyErr_ChainExceptionsCause(PyObject *exc, PyObject *val, PyObject *tb)
297
+ {
298
+ if (exc == NULL)
299
+ return;
300
+
301
+ if (PyErr_Occurred()) {
302
+ PyObject *exc2, *val2, *tb2;
303
+ PyErr_Fetch(&exc2, &val2, &tb2);
304
+ PyErr_NormalizeException(&exc, &val, &tb);
305
+ if (tb != NULL) {
306
+ PyException_SetTraceback(val, tb);
307
+ Py_DECREF(tb);
308
+ }
309
+ Py_DECREF(exc);
310
+ PyErr_NormalizeException(&exc2, &val2, &tb2);
311
+ PyException_SetCause(val2, val);
312
+ PyErr_Restore(exc2, val2, tb2);
313
+ }
314
+ else {
315
+ PyErr_Restore(exc, val, tb);
316
+ }
317
+ }
318
+
319
+ /*
320
+ * PyCObject functions adapted to PyCapsules.
321
+ *
322
+ * The main job here is to get rid of the improved error handling
323
+ * of PyCapsules. It's a shame...
324
+ */
325
+ static inline PyObject *
326
+ NpyCapsule_FromVoidPtr(void *ptr, void (*dtor)(PyObject *))
327
+ {
328
+ PyObject *ret = PyCapsule_New(ptr, NULL, dtor);
329
+ if (ret == NULL) {
330
+ PyErr_Clear();
331
+ }
332
+ return ret;
333
+ }
334
+
335
+ static inline PyObject *
336
+ NpyCapsule_FromVoidPtrAndDesc(void *ptr, void* context, void (*dtor)(PyObject *))
337
+ {
338
+ PyObject *ret = NpyCapsule_FromVoidPtr(ptr, dtor);
339
+ if (ret != NULL && PyCapsule_SetContext(ret, context) != 0) {
340
+ PyErr_Clear();
341
+ Py_DECREF(ret);
342
+ ret = NULL;
343
+ }
344
+ return ret;
345
+ }
346
+
347
+ static inline void *
348
+ NpyCapsule_AsVoidPtr(PyObject *obj)
349
+ {
350
+ void *ret = PyCapsule_GetPointer(obj, NULL);
351
+ if (ret == NULL) {
352
+ PyErr_Clear();
353
+ }
354
+ return ret;
355
+ }
356
+
357
+ static inline void *
358
+ NpyCapsule_GetDesc(PyObject *obj)
359
+ {
360
+ return PyCapsule_GetContext(obj);
361
+ }
362
+
363
+ static inline int
364
+ NpyCapsule_Check(PyObject *ptr)
365
+ {
366
+ return PyCapsule_CheckExact(ptr);
367
+ }
368
+
369
+ #ifdef __cplusplus
370
+ }
371
+ #endif
372
+
373
+
374
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_3KCOMPAT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_common.h ADDED
@@ -0,0 +1,1070 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_
3
+
4
+ /* need Python.h for npy_intp, npy_uintp */
5
+ #include <Python.h>
6
+
7
+ /* numpconfig.h is auto-generated */
8
+ #include "numpyconfig.h"
9
+ #ifdef HAVE_NPY_CONFIG_H
10
+ #include <npy_config.h>
11
+ #endif
12
+
13
+ /*
14
+ * using static inline modifiers when defining npy_math functions
15
+ * allows the compiler to make optimizations when possible
16
+ */
17
+ #ifndef NPY_INLINE_MATH
18
+ #if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
19
+ #define NPY_INLINE_MATH 1
20
+ #else
21
+ #define NPY_INLINE_MATH 0
22
+ #endif
23
+ #endif
24
+
25
+ /*
26
+ * gcc does not unroll even with -O3
27
+ * use with care, unrolling on modern cpus rarely speeds things up
28
+ */
29
+ #ifdef HAVE_ATTRIBUTE_OPTIMIZE_UNROLL_LOOPS
30
+ #define NPY_GCC_UNROLL_LOOPS \
31
+ __attribute__((optimize("unroll-loops")))
32
+ #else
33
+ #define NPY_GCC_UNROLL_LOOPS
34
+ #endif
35
+
36
+ /* highest gcc optimization level, enabled autovectorizer */
37
+ #ifdef HAVE_ATTRIBUTE_OPTIMIZE_OPT_3
38
+ #define NPY_GCC_OPT_3 __attribute__((optimize("O3")))
39
+ #else
40
+ #define NPY_GCC_OPT_3
41
+ #endif
42
+
43
+ /*
44
+ * mark an argument (starting from 1) that must not be NULL and is not checked
45
+ * DO NOT USE IF FUNCTION CHECKS FOR NULL!! the compiler will remove the check
46
+ */
47
+ #ifdef HAVE_ATTRIBUTE_NONNULL
48
+ #define NPY_GCC_NONNULL(n) __attribute__((nonnull(n)))
49
+ #else
50
+ #define NPY_GCC_NONNULL(n)
51
+ #endif
52
+
53
+ /*
54
+ * give a hint to the compiler which branch is more likely or unlikely
55
+ * to occur, e.g. rare error cases:
56
+ *
57
+ * if (NPY_UNLIKELY(failure == 0))
58
+ * return NULL;
59
+ *
60
+ * the double !! is to cast the expression (e.g. NULL) to a boolean required by
61
+ * the intrinsic
62
+ */
63
+ #ifdef HAVE___BUILTIN_EXPECT
64
+ #define NPY_LIKELY(x) __builtin_expect(!!(x), 1)
65
+ #define NPY_UNLIKELY(x) __builtin_expect(!!(x), 0)
66
+ #else
67
+ #define NPY_LIKELY(x) (x)
68
+ #define NPY_UNLIKELY(x) (x)
69
+ #endif
70
+
71
+ #ifdef HAVE___BUILTIN_PREFETCH
72
+ /* unlike _mm_prefetch also works on non-x86 */
73
+ #define NPY_PREFETCH(x, rw, loc) __builtin_prefetch((x), (rw), (loc))
74
+ #else
75
+ #ifdef NPY_HAVE_SSE
76
+ /* _MM_HINT_ET[01] (rw = 1) unsupported, only available in gcc >= 4.9 */
77
+ #define NPY_PREFETCH(x, rw, loc) _mm_prefetch((x), loc == 0 ? _MM_HINT_NTA : \
78
+ (loc == 1 ? _MM_HINT_T2 : \
79
+ (loc == 2 ? _MM_HINT_T1 : \
80
+ (loc == 3 ? _MM_HINT_T0 : -1))))
81
+ #else
82
+ #define NPY_PREFETCH(x, rw,loc)
83
+ #endif
84
+ #endif
85
+
86
+ /* `NPY_INLINE` kept for backwards compatibility; use `inline` instead */
87
+ #if defined(_MSC_VER) && !defined(__clang__)
88
+ #define NPY_INLINE __inline
89
+ /* clang included here to handle clang-cl on Windows */
90
+ #elif defined(__GNUC__) || defined(__clang__)
91
+ #if defined(__STRICT_ANSI__)
92
+ #define NPY_INLINE __inline__
93
+ #else
94
+ #define NPY_INLINE inline
95
+ #endif
96
+ #else
97
+ #define NPY_INLINE
98
+ #endif
99
+
100
+ #ifdef _MSC_VER
101
+ #define NPY_FINLINE static __forceinline
102
+ #elif defined(__GNUC__)
103
+ #define NPY_FINLINE static inline __attribute__((always_inline))
104
+ #else
105
+ #define NPY_FINLINE static
106
+ #endif
107
+
108
+ #if defined(_MSC_VER)
109
+ #define NPY_NOINLINE static __declspec(noinline)
110
+ #elif defined(__GNUC__) || defined(__clang__)
111
+ #define NPY_NOINLINE static __attribute__((noinline))
112
+ #else
113
+ #define NPY_NOINLINE static
114
+ #endif
115
+
116
+ #ifdef __cplusplus
117
+ #define NPY_TLS thread_local
118
+ #elif defined(HAVE_THREAD_LOCAL)
119
+ #define NPY_TLS thread_local
120
+ #elif defined(HAVE__THREAD_LOCAL)
121
+ #define NPY_TLS _Thread_local
122
+ #elif defined(HAVE___THREAD)
123
+ #define NPY_TLS __thread
124
+ #elif defined(HAVE___DECLSPEC_THREAD_)
125
+ #define NPY_TLS __declspec(thread)
126
+ #else
127
+ #define NPY_TLS
128
+ #endif
129
+
130
+ #ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE
131
+ #define NPY_RETURNS_BORROWED_REF \
132
+ __attribute__((cpychecker_returns_borrowed_ref))
133
+ #else
134
+ #define NPY_RETURNS_BORROWED_REF
135
+ #endif
136
+
137
+ #ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE
138
+ #define NPY_STEALS_REF_TO_ARG(n) \
139
+ __attribute__((cpychecker_steals_reference_to_arg(n)))
140
+ #else
141
+ #define NPY_STEALS_REF_TO_ARG(n)
142
+ #endif
143
+
144
+ /* 64 bit file position support, also on win-amd64. Issue gh-2256 */
145
+ #if defined(_MSC_VER) && defined(_WIN64) && (_MSC_VER > 1400) || \
146
+ defined(__MINGW32__) || defined(__MINGW64__)
147
+ #include <io.h>
148
+
149
+ #define npy_fseek _fseeki64
150
+ #define npy_ftell _ftelli64
151
+ #define npy_lseek _lseeki64
152
+ #define npy_off_t npy_int64
153
+
154
+ #if NPY_SIZEOF_INT == 8
155
+ #define NPY_OFF_T_PYFMT "i"
156
+ #elif NPY_SIZEOF_LONG == 8
157
+ #define NPY_OFF_T_PYFMT "l"
158
+ #elif NPY_SIZEOF_LONGLONG == 8
159
+ #define NPY_OFF_T_PYFMT "L"
160
+ #else
161
+ #error Unsupported size for type off_t
162
+ #endif
163
+ #else
164
+ #ifdef HAVE_FSEEKO
165
+ #define npy_fseek fseeko
166
+ #else
167
+ #define npy_fseek fseek
168
+ #endif
169
+ #ifdef HAVE_FTELLO
170
+ #define npy_ftell ftello
171
+ #else
172
+ #define npy_ftell ftell
173
+ #endif
174
+ #include <sys/types.h>
175
+ #ifndef _WIN32
176
+ #include <unistd.h>
177
+ #endif
178
+ #define npy_lseek lseek
179
+ #define npy_off_t off_t
180
+
181
+ #if NPY_SIZEOF_OFF_T == NPY_SIZEOF_SHORT
182
+ #define NPY_OFF_T_PYFMT "h"
183
+ #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_INT
184
+ #define NPY_OFF_T_PYFMT "i"
185
+ #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONG
186
+ #define NPY_OFF_T_PYFMT "l"
187
+ #elif NPY_SIZEOF_OFF_T == NPY_SIZEOF_LONGLONG
188
+ #define NPY_OFF_T_PYFMT "L"
189
+ #else
190
+ #error Unsupported size for type off_t
191
+ #endif
192
+ #endif
193
+
194
+ /* enums for detected endianness */
195
+ enum {
196
+ NPY_CPU_UNKNOWN_ENDIAN,
197
+ NPY_CPU_LITTLE,
198
+ NPY_CPU_BIG
199
+ };
200
+
201
+ /*
202
+ * This is to typedef npy_intp to the appropriate size for Py_ssize_t.
203
+ * (Before NumPy 2.0 we used Py_intptr_t and Py_uintptr_t from `pyport.h`.)
204
+ */
205
+ typedef Py_ssize_t npy_intp;
206
+ typedef size_t npy_uintp;
207
+
208
+ /*
209
+ * Define sizes that were not defined in numpyconfig.h.
210
+ */
211
+ #define NPY_SIZEOF_CHAR 1
212
+ #define NPY_SIZEOF_BYTE 1
213
+ #define NPY_SIZEOF_DATETIME 8
214
+ #define NPY_SIZEOF_TIMEDELTA 8
215
+ #define NPY_SIZEOF_HALF 2
216
+ #define NPY_SIZEOF_CFLOAT NPY_SIZEOF_COMPLEX_FLOAT
217
+ #define NPY_SIZEOF_CDOUBLE NPY_SIZEOF_COMPLEX_DOUBLE
218
+ #define NPY_SIZEOF_CLONGDOUBLE NPY_SIZEOF_COMPLEX_LONGDOUBLE
219
+
220
+ #ifdef constchar
221
+ #undef constchar
222
+ #endif
223
+
224
+ #define NPY_SSIZE_T_PYFMT "n"
225
+ #define constchar char
226
+
227
+ /* NPY_INTP_FMT Note:
228
+ * Unlike the other NPY_*_FMT macros, which are used with PyOS_snprintf,
229
+ * NPY_INTP_FMT is used with PyErr_Format and PyUnicode_FromFormat. Those
230
+ * functions use different formatting codes that are portably specified
231
+ * according to the Python documentation. See issue gh-2388.
232
+ */
233
+ #if NPY_SIZEOF_INTP == NPY_SIZEOF_LONG
234
+ #define NPY_INTP NPY_LONG
235
+ #define NPY_UINTP NPY_ULONG
236
+ #define PyIntpArrType_Type PyLongArrType_Type
237
+ #define PyUIntpArrType_Type PyULongArrType_Type
238
+ #define NPY_MAX_INTP NPY_MAX_LONG
239
+ #define NPY_MIN_INTP NPY_MIN_LONG
240
+ #define NPY_MAX_UINTP NPY_MAX_ULONG
241
+ #define NPY_INTP_FMT "ld"
242
+ #elif NPY_SIZEOF_INTP == NPY_SIZEOF_INT
243
+ #define NPY_INTP NPY_INT
244
+ #define NPY_UINTP NPY_UINT
245
+ #define PyIntpArrType_Type PyIntArrType_Type
246
+ #define PyUIntpArrType_Type PyUIntArrType_Type
247
+ #define NPY_MAX_INTP NPY_MAX_INT
248
+ #define NPY_MIN_INTP NPY_MIN_INT
249
+ #define NPY_MAX_UINTP NPY_MAX_UINT
250
+ #define NPY_INTP_FMT "d"
251
+ #elif defined(PY_LONG_LONG) && (NPY_SIZEOF_INTP == NPY_SIZEOF_LONGLONG)
252
+ #define NPY_INTP NPY_LONGLONG
253
+ #define NPY_UINTP NPY_ULONGLONG
254
+ #define PyIntpArrType_Type PyLongLongArrType_Type
255
+ #define PyUIntpArrType_Type PyULongLongArrType_Type
256
+ #define NPY_MAX_INTP NPY_MAX_LONGLONG
257
+ #define NPY_MIN_INTP NPY_MIN_LONGLONG
258
+ #define NPY_MAX_UINTP NPY_MAX_ULONGLONG
259
+ #define NPY_INTP_FMT "lld"
260
+ #else
261
+ #error "Failed to correctly define NPY_INTP and NPY_UINTP"
262
+ #endif
263
+
264
+
265
+ /*
266
+ * Some platforms don't define bool, long long, or long double.
267
+ * Handle that here.
268
+ */
269
+ #define NPY_BYTE_FMT "hhd"
270
+ #define NPY_UBYTE_FMT "hhu"
271
+ #define NPY_SHORT_FMT "hd"
272
+ #define NPY_USHORT_FMT "hu"
273
+ #define NPY_INT_FMT "d"
274
+ #define NPY_UINT_FMT "u"
275
+ #define NPY_LONG_FMT "ld"
276
+ #define NPY_ULONG_FMT "lu"
277
+ #define NPY_HALF_FMT "g"
278
+ #define NPY_FLOAT_FMT "g"
279
+ #define NPY_DOUBLE_FMT "g"
280
+
281
+
282
+ #ifdef PY_LONG_LONG
283
+ typedef PY_LONG_LONG npy_longlong;
284
+ typedef unsigned PY_LONG_LONG npy_ulonglong;
285
+ # ifdef _MSC_VER
286
+ # define NPY_LONGLONG_FMT "I64d"
287
+ # define NPY_ULONGLONG_FMT "I64u"
288
+ # else
289
+ # define NPY_LONGLONG_FMT "lld"
290
+ # define NPY_ULONGLONG_FMT "llu"
291
+ # endif
292
+ # ifdef _MSC_VER
293
+ # define NPY_LONGLONG_SUFFIX(x) (x##i64)
294
+ # define NPY_ULONGLONG_SUFFIX(x) (x##Ui64)
295
+ # else
296
+ # define NPY_LONGLONG_SUFFIX(x) (x##LL)
297
+ # define NPY_ULONGLONG_SUFFIX(x) (x##ULL)
298
+ # endif
299
+ #else
300
+ typedef long npy_longlong;
301
+ typedef unsigned long npy_ulonglong;
302
+ # define NPY_LONGLONG_SUFFIX(x) (x##L)
303
+ # define NPY_ULONGLONG_SUFFIX(x) (x##UL)
304
+ #endif
305
+
306
+
307
+ typedef unsigned char npy_bool;
308
+ #define NPY_FALSE 0
309
+ #define NPY_TRUE 1
310
+ /*
311
+ * `NPY_SIZEOF_LONGDOUBLE` isn't usually equal to sizeof(long double).
312
+ * In some certain cases, it may forced to be equal to sizeof(double)
313
+ * even against the compiler implementation and the same goes for
314
+ * `complex long double`.
315
+ *
316
+ * Therefore, avoid `long double`, use `npy_longdouble` instead,
317
+ * and when it comes to standard math functions make sure of using
318
+ * the double version when `NPY_SIZEOF_LONGDOUBLE` == `NPY_SIZEOF_DOUBLE`.
319
+ * For example:
320
+ * npy_longdouble *ptr, x;
321
+ * #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
322
+ * npy_longdouble r = modf(x, ptr);
323
+ * #else
324
+ * npy_longdouble r = modfl(x, ptr);
325
+ * #endif
326
+ *
327
+ * See https://github.com/numpy/numpy/issues/20348
328
+ */
329
+ #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE
330
+ #define NPY_LONGDOUBLE_FMT "g"
331
+ #define longdouble_t double
332
+ typedef double npy_longdouble;
333
+ #else
334
+ #define NPY_LONGDOUBLE_FMT "Lg"
335
+ #define longdouble_t long double
336
+ typedef long double npy_longdouble;
337
+ #endif
338
+
339
+ #ifndef Py_USING_UNICODE
340
+ #error Must use Python with unicode enabled.
341
+ #endif
342
+
343
+
344
+ typedef signed char npy_byte;
345
+ typedef unsigned char npy_ubyte;
346
+ typedef unsigned short npy_ushort;
347
+ typedef unsigned int npy_uint;
348
+ typedef unsigned long npy_ulong;
349
+
350
+ /* These are for completeness */
351
+ typedef char npy_char;
352
+ typedef short npy_short;
353
+ typedef int npy_int;
354
+ typedef long npy_long;
355
+ typedef float npy_float;
356
+ typedef double npy_double;
357
+
358
+ typedef Py_hash_t npy_hash_t;
359
+ #define NPY_SIZEOF_HASH_T NPY_SIZEOF_INTP
360
+
361
+ #if defined(__cplusplus)
362
+
363
+ typedef struct
364
+ {
365
+ double _Val[2];
366
+ } npy_cdouble;
367
+
368
+ typedef struct
369
+ {
370
+ float _Val[2];
371
+ } npy_cfloat;
372
+
373
+ typedef struct
374
+ {
375
+ long double _Val[2];
376
+ } npy_clongdouble;
377
+
378
+ #else
379
+
380
+ #include <complex.h>
381
+
382
+
383
+ #if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
384
+ typedef _Dcomplex npy_cdouble;
385
+ typedef _Fcomplex npy_cfloat;
386
+ typedef _Lcomplex npy_clongdouble;
387
+ #else /* !defined(_MSC_VER) || defined(__INTEL_COMPILER) */
388
+ typedef double _Complex npy_cdouble;
389
+ typedef float _Complex npy_cfloat;
390
+ typedef longdouble_t _Complex npy_clongdouble;
391
+ #endif
392
+
393
+ #endif
394
+
395
+ /*
396
+ * numarray-style bit-width typedefs
397
+ */
398
+ #define NPY_MAX_INT8 127
399
+ #define NPY_MIN_INT8 -128
400
+ #define NPY_MAX_UINT8 255
401
+ #define NPY_MAX_INT16 32767
402
+ #define NPY_MIN_INT16 -32768
403
+ #define NPY_MAX_UINT16 65535
404
+ #define NPY_MAX_INT32 2147483647
405
+ #define NPY_MIN_INT32 (-NPY_MAX_INT32 - 1)
406
+ #define NPY_MAX_UINT32 4294967295U
407
+ #define NPY_MAX_INT64 NPY_LONGLONG_SUFFIX(9223372036854775807)
408
+ #define NPY_MIN_INT64 (-NPY_MAX_INT64 - NPY_LONGLONG_SUFFIX(1))
409
+ #define NPY_MAX_UINT64 NPY_ULONGLONG_SUFFIX(18446744073709551615)
410
+ #define NPY_MAX_INT128 NPY_LONGLONG_SUFFIX(85070591730234615865843651857942052864)
411
+ #define NPY_MIN_INT128 (-NPY_MAX_INT128 - NPY_LONGLONG_SUFFIX(1))
412
+ #define NPY_MAX_UINT128 NPY_ULONGLONG_SUFFIX(170141183460469231731687303715884105728)
413
+ #define NPY_MAX_INT256 NPY_LONGLONG_SUFFIX(57896044618658097711785492504343953926634992332820282019728792003956564819967)
414
+ #define NPY_MIN_INT256 (-NPY_MAX_INT256 - NPY_LONGLONG_SUFFIX(1))
415
+ #define NPY_MAX_UINT256 NPY_ULONGLONG_SUFFIX(115792089237316195423570985008687907853269984665640564039457584007913129639935)
416
+ #define NPY_MIN_DATETIME NPY_MIN_INT64
417
+ #define NPY_MAX_DATETIME NPY_MAX_INT64
418
+ #define NPY_MIN_TIMEDELTA NPY_MIN_INT64
419
+ #define NPY_MAX_TIMEDELTA NPY_MAX_INT64
420
+
421
+ /* Need to find the number of bits for each type and
422
+ make definitions accordingly.
423
+
424
+ C states that sizeof(char) == 1 by definition
425
+
426
+ So, just using the sizeof keyword won't help.
427
+
428
+ It also looks like Python itself uses sizeof(char) quite a
429
+ bit, which by definition should be 1 all the time.
430
+
431
+ Idea: Make Use of CHAR_BIT which should tell us how many
432
+ BITS per CHARACTER
433
+ */
434
+
435
+ /* Include platform definitions -- These are in the C89/90 standard */
436
+ #include <limits.h>
437
+ #define NPY_MAX_BYTE SCHAR_MAX
438
+ #define NPY_MIN_BYTE SCHAR_MIN
439
+ #define NPY_MAX_UBYTE UCHAR_MAX
440
+ #define NPY_MAX_SHORT SHRT_MAX
441
+ #define NPY_MIN_SHORT SHRT_MIN
442
+ #define NPY_MAX_USHORT USHRT_MAX
443
+ #define NPY_MAX_INT INT_MAX
444
+ #ifndef INT_MIN
445
+ #define INT_MIN (-INT_MAX - 1)
446
+ #endif
447
+ #define NPY_MIN_INT INT_MIN
448
+ #define NPY_MAX_UINT UINT_MAX
449
+ #define NPY_MAX_LONG LONG_MAX
450
+ #define NPY_MIN_LONG LONG_MIN
451
+ #define NPY_MAX_ULONG ULONG_MAX
452
+
453
+ #define NPY_BITSOF_BOOL (sizeof(npy_bool) * CHAR_BIT)
454
+ #define NPY_BITSOF_CHAR CHAR_BIT
455
+ #define NPY_BITSOF_BYTE (NPY_SIZEOF_BYTE * CHAR_BIT)
456
+ #define NPY_BITSOF_SHORT (NPY_SIZEOF_SHORT * CHAR_BIT)
457
+ #define NPY_BITSOF_INT (NPY_SIZEOF_INT * CHAR_BIT)
458
+ #define NPY_BITSOF_LONG (NPY_SIZEOF_LONG * CHAR_BIT)
459
+ #define NPY_BITSOF_LONGLONG (NPY_SIZEOF_LONGLONG * CHAR_BIT)
460
+ #define NPY_BITSOF_INTP (NPY_SIZEOF_INTP * CHAR_BIT)
461
+ #define NPY_BITSOF_HALF (NPY_SIZEOF_HALF * CHAR_BIT)
462
+ #define NPY_BITSOF_FLOAT (NPY_SIZEOF_FLOAT * CHAR_BIT)
463
+ #define NPY_BITSOF_DOUBLE (NPY_SIZEOF_DOUBLE * CHAR_BIT)
464
+ #define NPY_BITSOF_LONGDOUBLE (NPY_SIZEOF_LONGDOUBLE * CHAR_BIT)
465
+ #define NPY_BITSOF_CFLOAT (NPY_SIZEOF_CFLOAT * CHAR_BIT)
466
+ #define NPY_BITSOF_CDOUBLE (NPY_SIZEOF_CDOUBLE * CHAR_BIT)
467
+ #define NPY_BITSOF_CLONGDOUBLE (NPY_SIZEOF_CLONGDOUBLE * CHAR_BIT)
468
+ #define NPY_BITSOF_DATETIME (NPY_SIZEOF_DATETIME * CHAR_BIT)
469
+ #define NPY_BITSOF_TIMEDELTA (NPY_SIZEOF_TIMEDELTA * CHAR_BIT)
470
+
471
+ #if NPY_BITSOF_LONG == 8
472
+ #define NPY_INT8 NPY_LONG
473
+ #define NPY_UINT8 NPY_ULONG
474
+ typedef long npy_int8;
475
+ typedef unsigned long npy_uint8;
476
+ #define PyInt8ScalarObject PyLongScalarObject
477
+ #define PyInt8ArrType_Type PyLongArrType_Type
478
+ #define PyUInt8ScalarObject PyULongScalarObject
479
+ #define PyUInt8ArrType_Type PyULongArrType_Type
480
+ #define NPY_INT8_FMT NPY_LONG_FMT
481
+ #define NPY_UINT8_FMT NPY_ULONG_FMT
482
+ #elif NPY_BITSOF_LONG == 16
483
+ #define NPY_INT16 NPY_LONG
484
+ #define NPY_UINT16 NPY_ULONG
485
+ typedef long npy_int16;
486
+ typedef unsigned long npy_uint16;
487
+ #define PyInt16ScalarObject PyLongScalarObject
488
+ #define PyInt16ArrType_Type PyLongArrType_Type
489
+ #define PyUInt16ScalarObject PyULongScalarObject
490
+ #define PyUInt16ArrType_Type PyULongArrType_Type
491
+ #define NPY_INT16_FMT NPY_LONG_FMT
492
+ #define NPY_UINT16_FMT NPY_ULONG_FMT
493
+ #elif NPY_BITSOF_LONG == 32
494
+ #define NPY_INT32 NPY_LONG
495
+ #define NPY_UINT32 NPY_ULONG
496
+ typedef long npy_int32;
497
+ typedef unsigned long npy_uint32;
498
+ typedef unsigned long npy_ucs4;
499
+ #define PyInt32ScalarObject PyLongScalarObject
500
+ #define PyInt32ArrType_Type PyLongArrType_Type
501
+ #define PyUInt32ScalarObject PyULongScalarObject
502
+ #define PyUInt32ArrType_Type PyULongArrType_Type
503
+ #define NPY_INT32_FMT NPY_LONG_FMT
504
+ #define NPY_UINT32_FMT NPY_ULONG_FMT
505
+ #elif NPY_BITSOF_LONG == 64
506
+ #define NPY_INT64 NPY_LONG
507
+ #define NPY_UINT64 NPY_ULONG
508
+ typedef long npy_int64;
509
+ typedef unsigned long npy_uint64;
510
+ #define PyInt64ScalarObject PyLongScalarObject
511
+ #define PyInt64ArrType_Type PyLongArrType_Type
512
+ #define PyUInt64ScalarObject PyULongScalarObject
513
+ #define PyUInt64ArrType_Type PyULongArrType_Type
514
+ #define NPY_INT64_FMT NPY_LONG_FMT
515
+ #define NPY_UINT64_FMT NPY_ULONG_FMT
516
+ #define MyPyLong_FromInt64 PyLong_FromLong
517
+ #define MyPyLong_AsInt64 PyLong_AsLong
518
+ #elif NPY_BITSOF_LONG == 128
519
+ #define NPY_INT128 NPY_LONG
520
+ #define NPY_UINT128 NPY_ULONG
521
+ typedef long npy_int128;
522
+ typedef unsigned long npy_uint128;
523
+ #define PyInt128ScalarObject PyLongScalarObject
524
+ #define PyInt128ArrType_Type PyLongArrType_Type
525
+ #define PyUInt128ScalarObject PyULongScalarObject
526
+ #define PyUInt128ArrType_Type PyULongArrType_Type
527
+ #define NPY_INT128_FMT NPY_LONG_FMT
528
+ #define NPY_UINT128_FMT NPY_ULONG_FMT
529
+ #endif
530
+
531
+ #if NPY_BITSOF_LONGLONG == 8
532
+ # ifndef NPY_INT8
533
+ # define NPY_INT8 NPY_LONGLONG
534
+ # define NPY_UINT8 NPY_ULONGLONG
535
+ typedef npy_longlong npy_int8;
536
+ typedef npy_ulonglong npy_uint8;
537
+ # define PyInt8ScalarObject PyLongLongScalarObject
538
+ # define PyInt8ArrType_Type PyLongLongArrType_Type
539
+ # define PyUInt8ScalarObject PyULongLongScalarObject
540
+ # define PyUInt8ArrType_Type PyULongLongArrType_Type
541
+ #define NPY_INT8_FMT NPY_LONGLONG_FMT
542
+ #define NPY_UINT8_FMT NPY_ULONGLONG_FMT
543
+ # endif
544
+ # define NPY_MAX_LONGLONG NPY_MAX_INT8
545
+ # define NPY_MIN_LONGLONG NPY_MIN_INT8
546
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT8
547
+ #elif NPY_BITSOF_LONGLONG == 16
548
+ # ifndef NPY_INT16
549
+ # define NPY_INT16 NPY_LONGLONG
550
+ # define NPY_UINT16 NPY_ULONGLONG
551
+ typedef npy_longlong npy_int16;
552
+ typedef npy_ulonglong npy_uint16;
553
+ # define PyInt16ScalarObject PyLongLongScalarObject
554
+ # define PyInt16ArrType_Type PyLongLongArrType_Type
555
+ # define PyUInt16ScalarObject PyULongLongScalarObject
556
+ # define PyUInt16ArrType_Type PyULongLongArrType_Type
557
+ #define NPY_INT16_FMT NPY_LONGLONG_FMT
558
+ #define NPY_UINT16_FMT NPY_ULONGLONG_FMT
559
+ # endif
560
+ # define NPY_MAX_LONGLONG NPY_MAX_INT16
561
+ # define NPY_MIN_LONGLONG NPY_MIN_INT16
562
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT16
563
+ #elif NPY_BITSOF_LONGLONG == 32
564
+ # ifndef NPY_INT32
565
+ # define NPY_INT32 NPY_LONGLONG
566
+ # define NPY_UINT32 NPY_ULONGLONG
567
+ typedef npy_longlong npy_int32;
568
+ typedef npy_ulonglong npy_uint32;
569
+ typedef npy_ulonglong npy_ucs4;
570
+ # define PyInt32ScalarObject PyLongLongScalarObject
571
+ # define PyInt32ArrType_Type PyLongLongArrType_Type
572
+ # define PyUInt32ScalarObject PyULongLongScalarObject
573
+ # define PyUInt32ArrType_Type PyULongLongArrType_Type
574
+ #define NPY_INT32_FMT NPY_LONGLONG_FMT
575
+ #define NPY_UINT32_FMT NPY_ULONGLONG_FMT
576
+ # endif
577
+ # define NPY_MAX_LONGLONG NPY_MAX_INT32
578
+ # define NPY_MIN_LONGLONG NPY_MIN_INT32
579
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT32
580
+ #elif NPY_BITSOF_LONGLONG == 64
581
+ # ifndef NPY_INT64
582
+ # define NPY_INT64 NPY_LONGLONG
583
+ # define NPY_UINT64 NPY_ULONGLONG
584
+ typedef npy_longlong npy_int64;
585
+ typedef npy_ulonglong npy_uint64;
586
+ # define PyInt64ScalarObject PyLongLongScalarObject
587
+ # define PyInt64ArrType_Type PyLongLongArrType_Type
588
+ # define PyUInt64ScalarObject PyULongLongScalarObject
589
+ # define PyUInt64ArrType_Type PyULongLongArrType_Type
590
+ #define NPY_INT64_FMT NPY_LONGLONG_FMT
591
+ #define NPY_UINT64_FMT NPY_ULONGLONG_FMT
592
+ # define MyPyLong_FromInt64 PyLong_FromLongLong
593
+ # define MyPyLong_AsInt64 PyLong_AsLongLong
594
+ # endif
595
+ # define NPY_MAX_LONGLONG NPY_MAX_INT64
596
+ # define NPY_MIN_LONGLONG NPY_MIN_INT64
597
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT64
598
+ #elif NPY_BITSOF_LONGLONG == 128
599
+ # ifndef NPY_INT128
600
+ # define NPY_INT128 NPY_LONGLONG
601
+ # define NPY_UINT128 NPY_ULONGLONG
602
+ typedef npy_longlong npy_int128;
603
+ typedef npy_ulonglong npy_uint128;
604
+ # define PyInt128ScalarObject PyLongLongScalarObject
605
+ # define PyInt128ArrType_Type PyLongLongArrType_Type
606
+ # define PyUInt128ScalarObject PyULongLongScalarObject
607
+ # define PyUInt128ArrType_Type PyULongLongArrType_Type
608
+ #define NPY_INT128_FMT NPY_LONGLONG_FMT
609
+ #define NPY_UINT128_FMT NPY_ULONGLONG_FMT
610
+ # endif
611
+ # define NPY_MAX_LONGLONG NPY_MAX_INT128
612
+ # define NPY_MIN_LONGLONG NPY_MIN_INT128
613
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT128
614
+ #elif NPY_BITSOF_LONGLONG == 256
615
+ # define NPY_INT256 NPY_LONGLONG
616
+ # define NPY_UINT256 NPY_ULONGLONG
617
+ typedef npy_longlong npy_int256;
618
+ typedef npy_ulonglong npy_uint256;
619
+ # define PyInt256ScalarObject PyLongLongScalarObject
620
+ # define PyInt256ArrType_Type PyLongLongArrType_Type
621
+ # define PyUInt256ScalarObject PyULongLongScalarObject
622
+ # define PyUInt256ArrType_Type PyULongLongArrType_Type
623
+ #define NPY_INT256_FMT NPY_LONGLONG_FMT
624
+ #define NPY_UINT256_FMT NPY_ULONGLONG_FMT
625
+ # define NPY_MAX_LONGLONG NPY_MAX_INT256
626
+ # define NPY_MIN_LONGLONG NPY_MIN_INT256
627
+ # define NPY_MAX_ULONGLONG NPY_MAX_UINT256
628
+ #endif
629
+
630
+ #if NPY_BITSOF_INT == 8
631
+ #ifndef NPY_INT8
632
+ #define NPY_INT8 NPY_INT
633
+ #define NPY_UINT8 NPY_UINT
634
+ typedef int npy_int8;
635
+ typedef unsigned int npy_uint8;
636
+ # define PyInt8ScalarObject PyIntScalarObject
637
+ # define PyInt8ArrType_Type PyIntArrType_Type
638
+ # define PyUInt8ScalarObject PyUIntScalarObject
639
+ # define PyUInt8ArrType_Type PyUIntArrType_Type
640
+ #define NPY_INT8_FMT NPY_INT_FMT
641
+ #define NPY_UINT8_FMT NPY_UINT_FMT
642
+ #endif
643
+ #elif NPY_BITSOF_INT == 16
644
+ #ifndef NPY_INT16
645
+ #define NPY_INT16 NPY_INT
646
+ #define NPY_UINT16 NPY_UINT
647
+ typedef int npy_int16;
648
+ typedef unsigned int npy_uint16;
649
+ # define PyInt16ScalarObject PyIntScalarObject
650
+ # define PyInt16ArrType_Type PyIntArrType_Type
651
+ # define PyUInt16ScalarObject PyIntUScalarObject
652
+ # define PyUInt16ArrType_Type PyIntUArrType_Type
653
+ #define NPY_INT16_FMT NPY_INT_FMT
654
+ #define NPY_UINT16_FMT NPY_UINT_FMT
655
+ #endif
656
+ #elif NPY_BITSOF_INT == 32
657
+ #ifndef NPY_INT32
658
+ #define NPY_INT32 NPY_INT
659
+ #define NPY_UINT32 NPY_UINT
660
+ typedef int npy_int32;
661
+ typedef unsigned int npy_uint32;
662
+ typedef unsigned int npy_ucs4;
663
+ # define PyInt32ScalarObject PyIntScalarObject
664
+ # define PyInt32ArrType_Type PyIntArrType_Type
665
+ # define PyUInt32ScalarObject PyUIntScalarObject
666
+ # define PyUInt32ArrType_Type PyUIntArrType_Type
667
+ #define NPY_INT32_FMT NPY_INT_FMT
668
+ #define NPY_UINT32_FMT NPY_UINT_FMT
669
+ #endif
670
+ #elif NPY_BITSOF_INT == 64
671
+ #ifndef NPY_INT64
672
+ #define NPY_INT64 NPY_INT
673
+ #define NPY_UINT64 NPY_UINT
674
+ typedef int npy_int64;
675
+ typedef unsigned int npy_uint64;
676
+ # define PyInt64ScalarObject PyIntScalarObject
677
+ # define PyInt64ArrType_Type PyIntArrType_Type
678
+ # define PyUInt64ScalarObject PyUIntScalarObject
679
+ # define PyUInt64ArrType_Type PyUIntArrType_Type
680
+ #define NPY_INT64_FMT NPY_INT_FMT
681
+ #define NPY_UINT64_FMT NPY_UINT_FMT
682
+ # define MyPyLong_FromInt64 PyLong_FromLong
683
+ # define MyPyLong_AsInt64 PyLong_AsLong
684
+ #endif
685
+ #elif NPY_BITSOF_INT == 128
686
+ #ifndef NPY_INT128
687
+ #define NPY_INT128 NPY_INT
688
+ #define NPY_UINT128 NPY_UINT
689
+ typedef int npy_int128;
690
+ typedef unsigned int npy_uint128;
691
+ # define PyInt128ScalarObject PyIntScalarObject
692
+ # define PyInt128ArrType_Type PyIntArrType_Type
693
+ # define PyUInt128ScalarObject PyUIntScalarObject
694
+ # define PyUInt128ArrType_Type PyUIntArrType_Type
695
+ #define NPY_INT128_FMT NPY_INT_FMT
696
+ #define NPY_UINT128_FMT NPY_UINT_FMT
697
+ #endif
698
+ #endif
699
+
700
+ #if NPY_BITSOF_SHORT == 8
701
+ #ifndef NPY_INT8
702
+ #define NPY_INT8 NPY_SHORT
703
+ #define NPY_UINT8 NPY_USHORT
704
+ typedef short npy_int8;
705
+ typedef unsigned short npy_uint8;
706
+ # define PyInt8ScalarObject PyShortScalarObject
707
+ # define PyInt8ArrType_Type PyShortArrType_Type
708
+ # define PyUInt8ScalarObject PyUShortScalarObject
709
+ # define PyUInt8ArrType_Type PyUShortArrType_Type
710
+ #define NPY_INT8_FMT NPY_SHORT_FMT
711
+ #define NPY_UINT8_FMT NPY_USHORT_FMT
712
+ #endif
713
+ #elif NPY_BITSOF_SHORT == 16
714
+ #ifndef NPY_INT16
715
+ #define NPY_INT16 NPY_SHORT
716
+ #define NPY_UINT16 NPY_USHORT
717
+ typedef short npy_int16;
718
+ typedef unsigned short npy_uint16;
719
+ # define PyInt16ScalarObject PyShortScalarObject
720
+ # define PyInt16ArrType_Type PyShortArrType_Type
721
+ # define PyUInt16ScalarObject PyUShortScalarObject
722
+ # define PyUInt16ArrType_Type PyUShortArrType_Type
723
+ #define NPY_INT16_FMT NPY_SHORT_FMT
724
+ #define NPY_UINT16_FMT NPY_USHORT_FMT
725
+ #endif
726
+ #elif NPY_BITSOF_SHORT == 32
727
+ #ifndef NPY_INT32
728
+ #define NPY_INT32 NPY_SHORT
729
+ #define NPY_UINT32 NPY_USHORT
730
+ typedef short npy_int32;
731
+ typedef unsigned short npy_uint32;
732
+ typedef unsigned short npy_ucs4;
733
+ # define PyInt32ScalarObject PyShortScalarObject
734
+ # define PyInt32ArrType_Type PyShortArrType_Type
735
+ # define PyUInt32ScalarObject PyUShortScalarObject
736
+ # define PyUInt32ArrType_Type PyUShortArrType_Type
737
+ #define NPY_INT32_FMT NPY_SHORT_FMT
738
+ #define NPY_UINT32_FMT NPY_USHORT_FMT
739
+ #endif
740
+ #elif NPY_BITSOF_SHORT == 64
741
+ #ifndef NPY_INT64
742
+ #define NPY_INT64 NPY_SHORT
743
+ #define NPY_UINT64 NPY_USHORT
744
+ typedef short npy_int64;
745
+ typedef unsigned short npy_uint64;
746
+ # define PyInt64ScalarObject PyShortScalarObject
747
+ # define PyInt64ArrType_Type PyShortArrType_Type
748
+ # define PyUInt64ScalarObject PyUShortScalarObject
749
+ # define PyUInt64ArrType_Type PyUShortArrType_Type
750
+ #define NPY_INT64_FMT NPY_SHORT_FMT
751
+ #define NPY_UINT64_FMT NPY_USHORT_FMT
752
+ # define MyPyLong_FromInt64 PyLong_FromLong
753
+ # define MyPyLong_AsInt64 PyLong_AsLong
754
+ #endif
755
+ #elif NPY_BITSOF_SHORT == 128
756
+ #ifndef NPY_INT128
757
+ #define NPY_INT128 NPY_SHORT
758
+ #define NPY_UINT128 NPY_USHORT
759
+ typedef short npy_int128;
760
+ typedef unsigned short npy_uint128;
761
+ # define PyInt128ScalarObject PyShortScalarObject
762
+ # define PyInt128ArrType_Type PyShortArrType_Type
763
+ # define PyUInt128ScalarObject PyUShortScalarObject
764
+ # define PyUInt128ArrType_Type PyUShortArrType_Type
765
+ #define NPY_INT128_FMT NPY_SHORT_FMT
766
+ #define NPY_UINT128_FMT NPY_USHORT_FMT
767
+ #endif
768
+ #endif
769
+
770
+
771
+ #if NPY_BITSOF_CHAR == 8
772
+ #ifndef NPY_INT8
773
+ #define NPY_INT8 NPY_BYTE
774
+ #define NPY_UINT8 NPY_UBYTE
775
+ typedef signed char npy_int8;
776
+ typedef unsigned char npy_uint8;
777
+ # define PyInt8ScalarObject PyByteScalarObject
778
+ # define PyInt8ArrType_Type PyByteArrType_Type
779
+ # define PyUInt8ScalarObject PyUByteScalarObject
780
+ # define PyUInt8ArrType_Type PyUByteArrType_Type
781
+ #define NPY_INT8_FMT NPY_BYTE_FMT
782
+ #define NPY_UINT8_FMT NPY_UBYTE_FMT
783
+ #endif
784
+ #elif NPY_BITSOF_CHAR == 16
785
+ #ifndef NPY_INT16
786
+ #define NPY_INT16 NPY_BYTE
787
+ #define NPY_UINT16 NPY_UBYTE
788
+ typedef signed char npy_int16;
789
+ typedef unsigned char npy_uint16;
790
+ # define PyInt16ScalarObject PyByteScalarObject
791
+ # define PyInt16ArrType_Type PyByteArrType_Type
792
+ # define PyUInt16ScalarObject PyUByteScalarObject
793
+ # define PyUInt16ArrType_Type PyUByteArrType_Type
794
+ #define NPY_INT16_FMT NPY_BYTE_FMT
795
+ #define NPY_UINT16_FMT NPY_UBYTE_FMT
796
+ #endif
797
+ #elif NPY_BITSOF_CHAR == 32
798
+ #ifndef NPY_INT32
799
+ #define NPY_INT32 NPY_BYTE
800
+ #define NPY_UINT32 NPY_UBYTE
801
+ typedef signed char npy_int32;
802
+ typedef unsigned char npy_uint32;
803
+ typedef unsigned char npy_ucs4;
804
+ # define PyInt32ScalarObject PyByteScalarObject
805
+ # define PyInt32ArrType_Type PyByteArrType_Type
806
+ # define PyUInt32ScalarObject PyUByteScalarObject
807
+ # define PyUInt32ArrType_Type PyUByteArrType_Type
808
+ #define NPY_INT32_FMT NPY_BYTE_FMT
809
+ #define NPY_UINT32_FMT NPY_UBYTE_FMT
810
+ #endif
811
+ #elif NPY_BITSOF_CHAR == 64
812
+ #ifndef NPY_INT64
813
+ #define NPY_INT64 NPY_BYTE
814
+ #define NPY_UINT64 NPY_UBYTE
815
+ typedef signed char npy_int64;
816
+ typedef unsigned char npy_uint64;
817
+ # define PyInt64ScalarObject PyByteScalarObject
818
+ # define PyInt64ArrType_Type PyByteArrType_Type
819
+ # define PyUInt64ScalarObject PyUByteScalarObject
820
+ # define PyUInt64ArrType_Type PyUByteArrType_Type
821
+ #define NPY_INT64_FMT NPY_BYTE_FMT
822
+ #define NPY_UINT64_FMT NPY_UBYTE_FMT
823
+ # define MyPyLong_FromInt64 PyLong_FromLong
824
+ # define MyPyLong_AsInt64 PyLong_AsLong
825
+ #endif
826
+ #elif NPY_BITSOF_CHAR == 128
827
+ #ifndef NPY_INT128
828
+ #define NPY_INT128 NPY_BYTE
829
+ #define NPY_UINT128 NPY_UBYTE
830
+ typedef signed char npy_int128;
831
+ typedef unsigned char npy_uint128;
832
+ # define PyInt128ScalarObject PyByteScalarObject
833
+ # define PyInt128ArrType_Type PyByteArrType_Type
834
+ # define PyUInt128ScalarObject PyUByteScalarObject
835
+ # define PyUInt128ArrType_Type PyUByteArrType_Type
836
+ #define NPY_INT128_FMT NPY_BYTE_FMT
837
+ #define NPY_UINT128_FMT NPY_UBYTE_FMT
838
+ #endif
839
+ #endif
840
+
841
+
842
+
843
+ #if NPY_BITSOF_DOUBLE == 32
844
+ #ifndef NPY_FLOAT32
845
+ #define NPY_FLOAT32 NPY_DOUBLE
846
+ #define NPY_COMPLEX64 NPY_CDOUBLE
847
+ typedef double npy_float32;
848
+ typedef npy_cdouble npy_complex64;
849
+ # define PyFloat32ScalarObject PyDoubleScalarObject
850
+ # define PyComplex64ScalarObject PyCDoubleScalarObject
851
+ # define PyFloat32ArrType_Type PyDoubleArrType_Type
852
+ # define PyComplex64ArrType_Type PyCDoubleArrType_Type
853
+ #define NPY_FLOAT32_FMT NPY_DOUBLE_FMT
854
+ #define NPY_COMPLEX64_FMT NPY_CDOUBLE_FMT
855
+ #endif
856
+ #elif NPY_BITSOF_DOUBLE == 64
857
+ #ifndef NPY_FLOAT64
858
+ #define NPY_FLOAT64 NPY_DOUBLE
859
+ #define NPY_COMPLEX128 NPY_CDOUBLE
860
+ typedef double npy_float64;
861
+ typedef npy_cdouble npy_complex128;
862
+ # define PyFloat64ScalarObject PyDoubleScalarObject
863
+ # define PyComplex128ScalarObject PyCDoubleScalarObject
864
+ # define PyFloat64ArrType_Type PyDoubleArrType_Type
865
+ # define PyComplex128ArrType_Type PyCDoubleArrType_Type
866
+ #define NPY_FLOAT64_FMT NPY_DOUBLE_FMT
867
+ #define NPY_COMPLEX128_FMT NPY_CDOUBLE_FMT
868
+ #endif
869
+ #elif NPY_BITSOF_DOUBLE == 80
870
+ #ifndef NPY_FLOAT80
871
+ #define NPY_FLOAT80 NPY_DOUBLE
872
+ #define NPY_COMPLEX160 NPY_CDOUBLE
873
+ typedef double npy_float80;
874
+ typedef npy_cdouble npy_complex160;
875
+ # define PyFloat80ScalarObject PyDoubleScalarObject
876
+ # define PyComplex160ScalarObject PyCDoubleScalarObject
877
+ # define PyFloat80ArrType_Type PyDoubleArrType_Type
878
+ # define PyComplex160ArrType_Type PyCDoubleArrType_Type
879
+ #define NPY_FLOAT80_FMT NPY_DOUBLE_FMT
880
+ #define NPY_COMPLEX160_FMT NPY_CDOUBLE_FMT
881
+ #endif
882
+ #elif NPY_BITSOF_DOUBLE == 96
883
+ #ifndef NPY_FLOAT96
884
+ #define NPY_FLOAT96 NPY_DOUBLE
885
+ #define NPY_COMPLEX192 NPY_CDOUBLE
886
+ typedef double npy_float96;
887
+ typedef npy_cdouble npy_complex192;
888
+ # define PyFloat96ScalarObject PyDoubleScalarObject
889
+ # define PyComplex192ScalarObject PyCDoubleScalarObject
890
+ # define PyFloat96ArrType_Type PyDoubleArrType_Type
891
+ # define PyComplex192ArrType_Type PyCDoubleArrType_Type
892
+ #define NPY_FLOAT96_FMT NPY_DOUBLE_FMT
893
+ #define NPY_COMPLEX192_FMT NPY_CDOUBLE_FMT
894
+ #endif
895
+ #elif NPY_BITSOF_DOUBLE == 128
896
+ #ifndef NPY_FLOAT128
897
+ #define NPY_FLOAT128 NPY_DOUBLE
898
+ #define NPY_COMPLEX256 NPY_CDOUBLE
899
+ typedef double npy_float128;
900
+ typedef npy_cdouble npy_complex256;
901
+ # define PyFloat128ScalarObject PyDoubleScalarObject
902
+ # define PyComplex256ScalarObject PyCDoubleScalarObject
903
+ # define PyFloat128ArrType_Type PyDoubleArrType_Type
904
+ # define PyComplex256ArrType_Type PyCDoubleArrType_Type
905
+ #define NPY_FLOAT128_FMT NPY_DOUBLE_FMT
906
+ #define NPY_COMPLEX256_FMT NPY_CDOUBLE_FMT
907
+ #endif
908
+ #endif
909
+
910
+
911
+
912
+ #if NPY_BITSOF_FLOAT == 32
913
+ #ifndef NPY_FLOAT32
914
+ #define NPY_FLOAT32 NPY_FLOAT
915
+ #define NPY_COMPLEX64 NPY_CFLOAT
916
+ typedef float npy_float32;
917
+ typedef npy_cfloat npy_complex64;
918
+ # define PyFloat32ScalarObject PyFloatScalarObject
919
+ # define PyComplex64ScalarObject PyCFloatScalarObject
920
+ # define PyFloat32ArrType_Type PyFloatArrType_Type
921
+ # define PyComplex64ArrType_Type PyCFloatArrType_Type
922
+ #define NPY_FLOAT32_FMT NPY_FLOAT_FMT
923
+ #define NPY_COMPLEX64_FMT NPY_CFLOAT_FMT
924
+ #endif
925
+ #elif NPY_BITSOF_FLOAT == 64
926
+ #ifndef NPY_FLOAT64
927
+ #define NPY_FLOAT64 NPY_FLOAT
928
+ #define NPY_COMPLEX128 NPY_CFLOAT
929
+ typedef float npy_float64;
930
+ typedef npy_cfloat npy_complex128;
931
+ # define PyFloat64ScalarObject PyFloatScalarObject
932
+ # define PyComplex128ScalarObject PyCFloatScalarObject
933
+ # define PyFloat64ArrType_Type PyFloatArrType_Type
934
+ # define PyComplex128ArrType_Type PyCFloatArrType_Type
935
+ #define NPY_FLOAT64_FMT NPY_FLOAT_FMT
936
+ #define NPY_COMPLEX128_FMT NPY_CFLOAT_FMT
937
+ #endif
938
+ #elif NPY_BITSOF_FLOAT == 80
939
+ #ifndef NPY_FLOAT80
940
+ #define NPY_FLOAT80 NPY_FLOAT
941
+ #define NPY_COMPLEX160 NPY_CFLOAT
942
+ typedef float npy_float80;
943
+ typedef npy_cfloat npy_complex160;
944
+ # define PyFloat80ScalarObject PyFloatScalarObject
945
+ # define PyComplex160ScalarObject PyCFloatScalarObject
946
+ # define PyFloat80ArrType_Type PyFloatArrType_Type
947
+ # define PyComplex160ArrType_Type PyCFloatArrType_Type
948
+ #define NPY_FLOAT80_FMT NPY_FLOAT_FMT
949
+ #define NPY_COMPLEX160_FMT NPY_CFLOAT_FMT
950
+ #endif
951
+ #elif NPY_BITSOF_FLOAT == 96
952
+ #ifndef NPY_FLOAT96
953
+ #define NPY_FLOAT96 NPY_FLOAT
954
+ #define NPY_COMPLEX192 NPY_CFLOAT
955
+ typedef float npy_float96;
956
+ typedef npy_cfloat npy_complex192;
957
+ # define PyFloat96ScalarObject PyFloatScalarObject
958
+ # define PyComplex192ScalarObject PyCFloatScalarObject
959
+ # define PyFloat96ArrType_Type PyFloatArrType_Type
960
+ # define PyComplex192ArrType_Type PyCFloatArrType_Type
961
+ #define NPY_FLOAT96_FMT NPY_FLOAT_FMT
962
+ #define NPY_COMPLEX192_FMT NPY_CFLOAT_FMT
963
+ #endif
964
+ #elif NPY_BITSOF_FLOAT == 128
965
+ #ifndef NPY_FLOAT128
966
+ #define NPY_FLOAT128 NPY_FLOAT
967
+ #define NPY_COMPLEX256 NPY_CFLOAT
968
+ typedef float npy_float128;
969
+ typedef npy_cfloat npy_complex256;
970
+ # define PyFloat128ScalarObject PyFloatScalarObject
971
+ # define PyComplex256ScalarObject PyCFloatScalarObject
972
+ # define PyFloat128ArrType_Type PyFloatArrType_Type
973
+ # define PyComplex256ArrType_Type PyCFloatArrType_Type
974
+ #define NPY_FLOAT128_FMT NPY_FLOAT_FMT
975
+ #define NPY_COMPLEX256_FMT NPY_CFLOAT_FMT
976
+ #endif
977
+ #endif
978
+
979
+ /* half/float16 isn't a floating-point type in C */
980
+ #define NPY_FLOAT16 NPY_HALF
981
+ typedef npy_uint16 npy_half;
982
+ typedef npy_half npy_float16;
983
+
984
+ #if NPY_BITSOF_LONGDOUBLE == 32
985
+ #ifndef NPY_FLOAT32
986
+ #define NPY_FLOAT32 NPY_LONGDOUBLE
987
+ #define NPY_COMPLEX64 NPY_CLONGDOUBLE
988
+ typedef npy_longdouble npy_float32;
989
+ typedef npy_clongdouble npy_complex64;
990
+ # define PyFloat32ScalarObject PyLongDoubleScalarObject
991
+ # define PyComplex64ScalarObject PyCLongDoubleScalarObject
992
+ # define PyFloat32ArrType_Type PyLongDoubleArrType_Type
993
+ # define PyComplex64ArrType_Type PyCLongDoubleArrType_Type
994
+ #define NPY_FLOAT32_FMT NPY_LONGDOUBLE_FMT
995
+ #define NPY_COMPLEX64_FMT NPY_CLONGDOUBLE_FMT
996
+ #endif
997
+ #elif NPY_BITSOF_LONGDOUBLE == 64
998
+ #ifndef NPY_FLOAT64
999
+ #define NPY_FLOAT64 NPY_LONGDOUBLE
1000
+ #define NPY_COMPLEX128 NPY_CLONGDOUBLE
1001
+ typedef npy_longdouble npy_float64;
1002
+ typedef npy_clongdouble npy_complex128;
1003
+ # define PyFloat64ScalarObject PyLongDoubleScalarObject
1004
+ # define PyComplex128ScalarObject PyCLongDoubleScalarObject
1005
+ # define PyFloat64ArrType_Type PyLongDoubleArrType_Type
1006
+ # define PyComplex128ArrType_Type PyCLongDoubleArrType_Type
1007
+ #define NPY_FLOAT64_FMT NPY_LONGDOUBLE_FMT
1008
+ #define NPY_COMPLEX128_FMT NPY_CLONGDOUBLE_FMT
1009
+ #endif
1010
+ #elif NPY_BITSOF_LONGDOUBLE == 80
1011
+ #ifndef NPY_FLOAT80
1012
+ #define NPY_FLOAT80 NPY_LONGDOUBLE
1013
+ #define NPY_COMPLEX160 NPY_CLONGDOUBLE
1014
+ typedef npy_longdouble npy_float80;
1015
+ typedef npy_clongdouble npy_complex160;
1016
+ # define PyFloat80ScalarObject PyLongDoubleScalarObject
1017
+ # define PyComplex160ScalarObject PyCLongDoubleScalarObject
1018
+ # define PyFloat80ArrType_Type PyLongDoubleArrType_Type
1019
+ # define PyComplex160ArrType_Type PyCLongDoubleArrType_Type
1020
+ #define NPY_FLOAT80_FMT NPY_LONGDOUBLE_FMT
1021
+ #define NPY_COMPLEX160_FMT NPY_CLONGDOUBLE_FMT
1022
+ #endif
1023
+ #elif NPY_BITSOF_LONGDOUBLE == 96
1024
+ #ifndef NPY_FLOAT96
1025
+ #define NPY_FLOAT96 NPY_LONGDOUBLE
1026
+ #define NPY_COMPLEX192 NPY_CLONGDOUBLE
1027
+ typedef npy_longdouble npy_float96;
1028
+ typedef npy_clongdouble npy_complex192;
1029
+ # define PyFloat96ScalarObject PyLongDoubleScalarObject
1030
+ # define PyComplex192ScalarObject PyCLongDoubleScalarObject
1031
+ # define PyFloat96ArrType_Type PyLongDoubleArrType_Type
1032
+ # define PyComplex192ArrType_Type PyCLongDoubleArrType_Type
1033
+ #define NPY_FLOAT96_FMT NPY_LONGDOUBLE_FMT
1034
+ #define NPY_COMPLEX192_FMT NPY_CLONGDOUBLE_FMT
1035
+ #endif
1036
+ #elif NPY_BITSOF_LONGDOUBLE == 128
1037
+ #ifndef NPY_FLOAT128
1038
+ #define NPY_FLOAT128 NPY_LONGDOUBLE
1039
+ #define NPY_COMPLEX256 NPY_CLONGDOUBLE
1040
+ typedef npy_longdouble npy_float128;
1041
+ typedef npy_clongdouble npy_complex256;
1042
+ # define PyFloat128ScalarObject PyLongDoubleScalarObject
1043
+ # define PyComplex256ScalarObject PyCLongDoubleScalarObject
1044
+ # define PyFloat128ArrType_Type PyLongDoubleArrType_Type
1045
+ # define PyComplex256ArrType_Type PyCLongDoubleArrType_Type
1046
+ #define NPY_FLOAT128_FMT NPY_LONGDOUBLE_FMT
1047
+ #define NPY_COMPLEX256_FMT NPY_CLONGDOUBLE_FMT
1048
+ #endif
1049
+ #elif NPY_BITSOF_LONGDOUBLE == 256
1050
+ #define NPY_FLOAT256 NPY_LONGDOUBLE
1051
+ #define NPY_COMPLEX512 NPY_CLONGDOUBLE
1052
+ typedef npy_longdouble npy_float256;
1053
+ typedef npy_clongdouble npy_complex512;
1054
+ # define PyFloat256ScalarObject PyLongDoubleScalarObject
1055
+ # define PyComplex512ScalarObject PyCLongDoubleScalarObject
1056
+ # define PyFloat256ArrType_Type PyLongDoubleArrType_Type
1057
+ # define PyComplex512ArrType_Type PyCLongDoubleArrType_Type
1058
+ #define NPY_FLOAT256_FMT NPY_LONGDOUBLE_FMT
1059
+ #define NPY_COMPLEX512_FMT NPY_CLONGDOUBLE_FMT
1060
+ #endif
1061
+
1062
+ /* datetime typedefs */
1063
+ typedef npy_int64 npy_timedelta;
1064
+ typedef npy_int64 npy_datetime;
1065
+ #define NPY_DATETIME_FMT NPY_INT64_FMT
1066
+ #define NPY_TIMEDELTA_FMT NPY_INT64_FMT
1067
+
1068
+ /* End of typedefs for numarray style bit-width names */
1069
+
1070
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_COMMON_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_cpu.h ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This set (target) cpu specific macros:
3
+ * - Possible values:
4
+ * NPY_CPU_X86
5
+ * NPY_CPU_AMD64
6
+ * NPY_CPU_PPC
7
+ * NPY_CPU_PPC64
8
+ * NPY_CPU_PPC64LE
9
+ * NPY_CPU_SPARC
10
+ * NPY_CPU_S390
11
+ * NPY_CPU_IA64
12
+ * NPY_CPU_HPPA
13
+ * NPY_CPU_ALPHA
14
+ * NPY_CPU_ARMEL
15
+ * NPY_CPU_ARMEB
16
+ * NPY_CPU_SH_LE
17
+ * NPY_CPU_SH_BE
18
+ * NPY_CPU_ARCEL
19
+ * NPY_CPU_ARCEB
20
+ * NPY_CPU_RISCV64
21
+ * NPY_CPU_RISCV32
22
+ * NPY_CPU_LOONGARCH
23
+ * NPY_CPU_WASM
24
+ */
25
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_CPU_H_
26
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_CPU_H_
27
+
28
+ #include "numpyconfig.h"
29
+
30
+ #if defined( __i386__ ) || defined(i386) || defined(_M_IX86)
31
+ /*
32
+ * __i386__ is defined by gcc and Intel compiler on Linux,
33
+ * _M_IX86 by VS compiler,
34
+ * i386 by Sun compilers on opensolaris at least
35
+ */
36
+ #define NPY_CPU_X86
37
+ #elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64)
38
+ /*
39
+ * both __x86_64__ and __amd64__ are defined by gcc
40
+ * __x86_64 defined by sun compiler on opensolaris at least
41
+ * _M_AMD64 defined by MS compiler
42
+ */
43
+ #define NPY_CPU_AMD64
44
+ #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__)
45
+ #define NPY_CPU_PPC64LE
46
+ #elif defined(__powerpc64__) && defined(__BIG_ENDIAN__)
47
+ #define NPY_CPU_PPC64
48
+ #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC)
49
+ /*
50
+ * __ppc__ is defined by gcc, I remember having seen __powerpc__ once,
51
+ * but can't find it ATM
52
+ * _ARCH_PPC is used by at least gcc on AIX
53
+ * As __powerpc__ and _ARCH_PPC are also defined by PPC64 check
54
+ * for those specifically first before defaulting to ppc
55
+ */
56
+ #define NPY_CPU_PPC
57
+ #elif defined(__sparc__) || defined(__sparc)
58
+ /* __sparc__ is defined by gcc and Forte (e.g. Sun) compilers */
59
+ #define NPY_CPU_SPARC
60
+ #elif defined(__s390__)
61
+ #define NPY_CPU_S390
62
+ #elif defined(__ia64)
63
+ #define NPY_CPU_IA64
64
+ #elif defined(__hppa)
65
+ #define NPY_CPU_HPPA
66
+ #elif defined(__alpha__)
67
+ #define NPY_CPU_ALPHA
68
+ #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
69
+ /* _M_ARM64 is defined in MSVC for ARM64 compilation on Windows */
70
+ #if defined(__ARMEB__) || defined(__AARCH64EB__)
71
+ #if defined(__ARM_32BIT_STATE)
72
+ #define NPY_CPU_ARMEB_AARCH32
73
+ #elif defined(__ARM_64BIT_STATE)
74
+ #define NPY_CPU_ARMEB_AARCH64
75
+ #else
76
+ #define NPY_CPU_ARMEB
77
+ #endif
78
+ #elif defined(__ARMEL__) || defined(__AARCH64EL__) || defined(_M_ARM64)
79
+ #if defined(__ARM_32BIT_STATE)
80
+ #define NPY_CPU_ARMEL_AARCH32
81
+ #elif defined(__ARM_64BIT_STATE) || defined(_M_ARM64) || defined(__AARCH64EL__)
82
+ #define NPY_CPU_ARMEL_AARCH64
83
+ #else
84
+ #define NPY_CPU_ARMEL
85
+ #endif
86
+ #else
87
+ # error Unknown ARM CPU, please report this to numpy maintainers with \
88
+ information about your platform (OS, CPU and compiler)
89
+ #endif
90
+ #elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
91
+ #define NPY_CPU_SH_LE
92
+ #elif defined(__sh__) && defined(__BIG_ENDIAN__)
93
+ #define NPY_CPU_SH_BE
94
+ #elif defined(__MIPSEL__)
95
+ #define NPY_CPU_MIPSEL
96
+ #elif defined(__MIPSEB__)
97
+ #define NPY_CPU_MIPSEB
98
+ #elif defined(__or1k__)
99
+ #define NPY_CPU_OR1K
100
+ #elif defined(__mc68000__)
101
+ #define NPY_CPU_M68K
102
+ #elif defined(__arc__) && defined(__LITTLE_ENDIAN__)
103
+ #define NPY_CPU_ARCEL
104
+ #elif defined(__arc__) && defined(__BIG_ENDIAN__)
105
+ #define NPY_CPU_ARCEB
106
+ #elif defined(__riscv)
107
+ #if __riscv_xlen == 64
108
+ #define NPY_CPU_RISCV64
109
+ #elif __riscv_xlen == 32
110
+ #define NPY_CPU_RISCV32
111
+ #endif
112
+ #elif defined(__loongarch__)
113
+ #define NPY_CPU_LOONGARCH
114
+ #elif defined(__EMSCRIPTEN__)
115
+ /* __EMSCRIPTEN__ is defined by emscripten: an LLVM-to-Web compiler */
116
+ #define NPY_CPU_WASM
117
+ #else
118
+ #error Unknown CPU, please report this to numpy maintainers with \
119
+ information about your platform (OS, CPU and compiler)
120
+ #endif
121
+
122
+ /*
123
+ * Except for the following architectures, memory access is limited to the natural
124
+ * alignment of data types otherwise it may lead to bus error or performance regression.
125
+ * For more details about unaligned access, see https://www.kernel.org/doc/Documentation/unaligned-memory-access.txt.
126
+ */
127
+ #if defined(NPY_CPU_X86) || defined(NPY_CPU_AMD64) || defined(__aarch64__) || defined(__powerpc64__)
128
+ #define NPY_ALIGNMENT_REQUIRED 0
129
+ #endif
130
+ #ifndef NPY_ALIGNMENT_REQUIRED
131
+ #define NPY_ALIGNMENT_REQUIRED 1
132
+ #endif
133
+
134
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_CPU_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_endian.h ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_
3
+
4
+ /*
5
+ * NPY_BYTE_ORDER is set to the same value as BYTE_ORDER set by glibc in
6
+ * endian.h
7
+ */
8
+
9
+ #if defined(NPY_HAVE_ENDIAN_H) || defined(NPY_HAVE_SYS_ENDIAN_H)
10
+ /* Use endian.h if available */
11
+
12
+ #if defined(NPY_HAVE_ENDIAN_H)
13
+ #include <endian.h>
14
+ #elif defined(NPY_HAVE_SYS_ENDIAN_H)
15
+ #include <sys/endian.h>
16
+ #endif
17
+
18
+ #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
19
+ #define NPY_BYTE_ORDER BYTE_ORDER
20
+ #define NPY_LITTLE_ENDIAN LITTLE_ENDIAN
21
+ #define NPY_BIG_ENDIAN BIG_ENDIAN
22
+ #elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
23
+ #define NPY_BYTE_ORDER _BYTE_ORDER
24
+ #define NPY_LITTLE_ENDIAN _LITTLE_ENDIAN
25
+ #define NPY_BIG_ENDIAN _BIG_ENDIAN
26
+ #elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
27
+ #define NPY_BYTE_ORDER __BYTE_ORDER
28
+ #define NPY_LITTLE_ENDIAN __LITTLE_ENDIAN
29
+ #define NPY_BIG_ENDIAN __BIG_ENDIAN
30
+ #endif
31
+ #endif
32
+
33
+ #ifndef NPY_BYTE_ORDER
34
+ /* Set endianness info using target CPU */
35
+ #include "npy_cpu.h"
36
+
37
+ #define NPY_LITTLE_ENDIAN 1234
38
+ #define NPY_BIG_ENDIAN 4321
39
+
40
+ #if defined(NPY_CPU_X86) \
41
+ || defined(NPY_CPU_AMD64) \
42
+ || defined(NPY_CPU_IA64) \
43
+ || defined(NPY_CPU_ALPHA) \
44
+ || defined(NPY_CPU_ARMEL) \
45
+ || defined(NPY_CPU_ARMEL_AARCH32) \
46
+ || defined(NPY_CPU_ARMEL_AARCH64) \
47
+ || defined(NPY_CPU_SH_LE) \
48
+ || defined(NPY_CPU_MIPSEL) \
49
+ || defined(NPY_CPU_PPC64LE) \
50
+ || defined(NPY_CPU_ARCEL) \
51
+ || defined(NPY_CPU_RISCV64) \
52
+ || defined(NPY_CPU_RISCV32) \
53
+ || defined(NPY_CPU_LOONGARCH) \
54
+ || defined(NPY_CPU_WASM)
55
+ #define NPY_BYTE_ORDER NPY_LITTLE_ENDIAN
56
+
57
+ #elif defined(NPY_CPU_PPC) \
58
+ || defined(NPY_CPU_SPARC) \
59
+ || defined(NPY_CPU_S390) \
60
+ || defined(NPY_CPU_HPPA) \
61
+ || defined(NPY_CPU_PPC64) \
62
+ || defined(NPY_CPU_ARMEB) \
63
+ || defined(NPY_CPU_ARMEB_AARCH32) \
64
+ || defined(NPY_CPU_ARMEB_AARCH64) \
65
+ || defined(NPY_CPU_SH_BE) \
66
+ || defined(NPY_CPU_MIPSEB) \
67
+ || defined(NPY_CPU_OR1K) \
68
+ || defined(NPY_CPU_M68K) \
69
+ || defined(NPY_CPU_ARCEB)
70
+ #define NPY_BYTE_ORDER NPY_BIG_ENDIAN
71
+
72
+ #else
73
+ #error Unknown CPU: can not set endianness
74
+ #endif
75
+
76
+ #endif
77
+
78
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_ENDIAN_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_math.h ADDED
@@ -0,0 +1,602 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_MATH_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_MATH_H_
3
+
4
+ #include <numpy/npy_common.h>
5
+
6
+ #include <math.h>
7
+
8
+ /* By adding static inline specifiers to npy_math function definitions when
9
+ appropriate, compiler is given the opportunity to optimize */
10
+ #if NPY_INLINE_MATH
11
+ #define NPY_INPLACE static inline
12
+ #else
13
+ #define NPY_INPLACE
14
+ #endif
15
+
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ #define PyArray_MAX(a,b) (((a)>(b))?(a):(b))
22
+ #define PyArray_MIN(a,b) (((a)<(b))?(a):(b))
23
+
24
+ /*
25
+ * NAN and INFINITY like macros (same behavior as glibc for NAN, same as C99
26
+ * for INFINITY)
27
+ *
28
+ * XXX: I should test whether INFINITY and NAN are available on the platform
29
+ */
30
+ static inline float __npy_inff(void)
31
+ {
32
+ const union { npy_uint32 __i; float __f;} __bint = {0x7f800000UL};
33
+ return __bint.__f;
34
+ }
35
+
36
+ static inline float __npy_nanf(void)
37
+ {
38
+ const union { npy_uint32 __i; float __f;} __bint = {0x7fc00000UL};
39
+ return __bint.__f;
40
+ }
41
+
42
+ static inline float __npy_pzerof(void)
43
+ {
44
+ const union { npy_uint32 __i; float __f;} __bint = {0x00000000UL};
45
+ return __bint.__f;
46
+ }
47
+
48
+ static inline float __npy_nzerof(void)
49
+ {
50
+ const union { npy_uint32 __i; float __f;} __bint = {0x80000000UL};
51
+ return __bint.__f;
52
+ }
53
+
54
+ #define NPY_INFINITYF __npy_inff()
55
+ #define NPY_NANF __npy_nanf()
56
+ #define NPY_PZEROF __npy_pzerof()
57
+ #define NPY_NZEROF __npy_nzerof()
58
+
59
+ #define NPY_INFINITY ((npy_double)NPY_INFINITYF)
60
+ #define NPY_NAN ((npy_double)NPY_NANF)
61
+ #define NPY_PZERO ((npy_double)NPY_PZEROF)
62
+ #define NPY_NZERO ((npy_double)NPY_NZEROF)
63
+
64
+ #define NPY_INFINITYL ((npy_longdouble)NPY_INFINITYF)
65
+ #define NPY_NANL ((npy_longdouble)NPY_NANF)
66
+ #define NPY_PZEROL ((npy_longdouble)NPY_PZEROF)
67
+ #define NPY_NZEROL ((npy_longdouble)NPY_NZEROF)
68
+
69
+ /*
70
+ * Useful constants
71
+ */
72
+ #define NPY_E 2.718281828459045235360287471352662498 /* e */
73
+ #define NPY_LOG2E 1.442695040888963407359924681001892137 /* log_2 e */
74
+ #define NPY_LOG10E 0.434294481903251827651128918916605082 /* log_10 e */
75
+ #define NPY_LOGE2 0.693147180559945309417232121458176568 /* log_e 2 */
76
+ #define NPY_LOGE10 2.302585092994045684017991454684364208 /* log_e 10 */
77
+ #define NPY_PI 3.141592653589793238462643383279502884 /* pi */
78
+ #define NPY_PI_2 1.570796326794896619231321691639751442 /* pi/2 */
79
+ #define NPY_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
80
+ #define NPY_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
81
+ #define NPY_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
82
+ #define NPY_EULER 0.577215664901532860606512090082402431 /* Euler constant */
83
+ #define NPY_SQRT2 1.414213562373095048801688724209698079 /* sqrt(2) */
84
+ #define NPY_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
85
+
86
+ #define NPY_Ef 2.718281828459045235360287471352662498F /* e */
87
+ #define NPY_LOG2Ef 1.442695040888963407359924681001892137F /* log_2 e */
88
+ #define NPY_LOG10Ef 0.434294481903251827651128918916605082F /* log_10 e */
89
+ #define NPY_LOGE2f 0.693147180559945309417232121458176568F /* log_e 2 */
90
+ #define NPY_LOGE10f 2.302585092994045684017991454684364208F /* log_e 10 */
91
+ #define NPY_PIf 3.141592653589793238462643383279502884F /* pi */
92
+ #define NPY_PI_2f 1.570796326794896619231321691639751442F /* pi/2 */
93
+ #define NPY_PI_4f 0.785398163397448309615660845819875721F /* pi/4 */
94
+ #define NPY_1_PIf 0.318309886183790671537767526745028724F /* 1/pi */
95
+ #define NPY_2_PIf 0.636619772367581343075535053490057448F /* 2/pi */
96
+ #define NPY_EULERf 0.577215664901532860606512090082402431F /* Euler constant */
97
+ #define NPY_SQRT2f 1.414213562373095048801688724209698079F /* sqrt(2) */
98
+ #define NPY_SQRT1_2f 0.707106781186547524400844362104849039F /* 1/sqrt(2) */
99
+
100
+ #define NPY_El 2.718281828459045235360287471352662498L /* e */
101
+ #define NPY_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */
102
+ #define NPY_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */
103
+ #define NPY_LOGE2l 0.693147180559945309417232121458176568L /* log_e 2 */
104
+ #define NPY_LOGE10l 2.302585092994045684017991454684364208L /* log_e 10 */
105
+ #define NPY_PIl 3.141592653589793238462643383279502884L /* pi */
106
+ #define NPY_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
107
+ #define NPY_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
108
+ #define NPY_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
109
+ #define NPY_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
110
+ #define NPY_EULERl 0.577215664901532860606512090082402431L /* Euler constant */
111
+ #define NPY_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
112
+ #define NPY_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
113
+
114
+ /*
115
+ * Integer functions.
116
+ */
117
+ NPY_INPLACE npy_uint npy_gcdu(npy_uint a, npy_uint b);
118
+ NPY_INPLACE npy_uint npy_lcmu(npy_uint a, npy_uint b);
119
+ NPY_INPLACE npy_ulong npy_gcdul(npy_ulong a, npy_ulong b);
120
+ NPY_INPLACE npy_ulong npy_lcmul(npy_ulong a, npy_ulong b);
121
+ NPY_INPLACE npy_ulonglong npy_gcdull(npy_ulonglong a, npy_ulonglong b);
122
+ NPY_INPLACE npy_ulonglong npy_lcmull(npy_ulonglong a, npy_ulonglong b);
123
+
124
+ NPY_INPLACE npy_int npy_gcd(npy_int a, npy_int b);
125
+ NPY_INPLACE npy_int npy_lcm(npy_int a, npy_int b);
126
+ NPY_INPLACE npy_long npy_gcdl(npy_long a, npy_long b);
127
+ NPY_INPLACE npy_long npy_lcml(npy_long a, npy_long b);
128
+ NPY_INPLACE npy_longlong npy_gcdll(npy_longlong a, npy_longlong b);
129
+ NPY_INPLACE npy_longlong npy_lcmll(npy_longlong a, npy_longlong b);
130
+
131
+ NPY_INPLACE npy_ubyte npy_rshiftuhh(npy_ubyte a, npy_ubyte b);
132
+ NPY_INPLACE npy_ubyte npy_lshiftuhh(npy_ubyte a, npy_ubyte b);
133
+ NPY_INPLACE npy_ushort npy_rshiftuh(npy_ushort a, npy_ushort b);
134
+ NPY_INPLACE npy_ushort npy_lshiftuh(npy_ushort a, npy_ushort b);
135
+ NPY_INPLACE npy_uint npy_rshiftu(npy_uint a, npy_uint b);
136
+ NPY_INPLACE npy_uint npy_lshiftu(npy_uint a, npy_uint b);
137
+ NPY_INPLACE npy_ulong npy_rshiftul(npy_ulong a, npy_ulong b);
138
+ NPY_INPLACE npy_ulong npy_lshiftul(npy_ulong a, npy_ulong b);
139
+ NPY_INPLACE npy_ulonglong npy_rshiftull(npy_ulonglong a, npy_ulonglong b);
140
+ NPY_INPLACE npy_ulonglong npy_lshiftull(npy_ulonglong a, npy_ulonglong b);
141
+
142
+ NPY_INPLACE npy_byte npy_rshifthh(npy_byte a, npy_byte b);
143
+ NPY_INPLACE npy_byte npy_lshifthh(npy_byte a, npy_byte b);
144
+ NPY_INPLACE npy_short npy_rshifth(npy_short a, npy_short b);
145
+ NPY_INPLACE npy_short npy_lshifth(npy_short a, npy_short b);
146
+ NPY_INPLACE npy_int npy_rshift(npy_int a, npy_int b);
147
+ NPY_INPLACE npy_int npy_lshift(npy_int a, npy_int b);
148
+ NPY_INPLACE npy_long npy_rshiftl(npy_long a, npy_long b);
149
+ NPY_INPLACE npy_long npy_lshiftl(npy_long a, npy_long b);
150
+ NPY_INPLACE npy_longlong npy_rshiftll(npy_longlong a, npy_longlong b);
151
+ NPY_INPLACE npy_longlong npy_lshiftll(npy_longlong a, npy_longlong b);
152
+
153
+ NPY_INPLACE uint8_t npy_popcountuhh(npy_ubyte a);
154
+ NPY_INPLACE uint8_t npy_popcountuh(npy_ushort a);
155
+ NPY_INPLACE uint8_t npy_popcountu(npy_uint a);
156
+ NPY_INPLACE uint8_t npy_popcountul(npy_ulong a);
157
+ NPY_INPLACE uint8_t npy_popcountull(npy_ulonglong a);
158
+ NPY_INPLACE uint8_t npy_popcounthh(npy_byte a);
159
+ NPY_INPLACE uint8_t npy_popcounth(npy_short a);
160
+ NPY_INPLACE uint8_t npy_popcount(npy_int a);
161
+ NPY_INPLACE uint8_t npy_popcountl(npy_long a);
162
+ NPY_INPLACE uint8_t npy_popcountll(npy_longlong a);
163
+
164
+ /*
165
+ * C99 double math funcs that need fixups or are blocklist-able
166
+ */
167
+ NPY_INPLACE double npy_sin(double x);
168
+ NPY_INPLACE double npy_cos(double x);
169
+ NPY_INPLACE double npy_tan(double x);
170
+ NPY_INPLACE double npy_hypot(double x, double y);
171
+ NPY_INPLACE double npy_log2(double x);
172
+ NPY_INPLACE double npy_atan2(double x, double y);
173
+
174
+ /* Mandatory C99 double math funcs, no blocklisting or fixups */
175
+ /* defined for legacy reasons, should be deprecated at some point */
176
+ #define npy_sinh sinh
177
+ #define npy_cosh cosh
178
+ #define npy_tanh tanh
179
+ #define npy_asin asin
180
+ #define npy_acos acos
181
+ #define npy_atan atan
182
+ #define npy_log log
183
+ #define npy_log10 log10
184
+ #define npy_cbrt cbrt
185
+ #define npy_fabs fabs
186
+ #define npy_ceil ceil
187
+ #define npy_fmod fmod
188
+ #define npy_floor floor
189
+ #define npy_expm1 expm1
190
+ #define npy_log1p log1p
191
+ #define npy_acosh acosh
192
+ #define npy_asinh asinh
193
+ #define npy_atanh atanh
194
+ #define npy_rint rint
195
+ #define npy_trunc trunc
196
+ #define npy_exp2 exp2
197
+ #define npy_frexp frexp
198
+ #define npy_ldexp ldexp
199
+ #define npy_copysign copysign
200
+ #define npy_exp exp
201
+ #define npy_sqrt sqrt
202
+ #define npy_pow pow
203
+ #define npy_modf modf
204
+ #define npy_nextafter nextafter
205
+
206
+ double npy_spacing(double x);
207
+
208
+ /*
209
+ * IEEE 754 fpu handling
210
+ */
211
+
212
+ /* use builtins to avoid function calls in tight loops
213
+ * only available if npy_config.h is available (= numpys own build) */
214
+ #ifdef HAVE___BUILTIN_ISNAN
215
+ #define npy_isnan(x) __builtin_isnan(x)
216
+ #else
217
+ #define npy_isnan(x) isnan(x)
218
+ #endif
219
+
220
+
221
+ /* only available if npy_config.h is available (= numpys own build) */
222
+ #ifdef HAVE___BUILTIN_ISFINITE
223
+ #define npy_isfinite(x) __builtin_isfinite(x)
224
+ #else
225
+ #define npy_isfinite(x) isfinite((x))
226
+ #endif
227
+
228
+ /* only available if npy_config.h is available (= numpys own build) */
229
+ #ifdef HAVE___BUILTIN_ISINF
230
+ #define npy_isinf(x) __builtin_isinf(x)
231
+ #else
232
+ #define npy_isinf(x) isinf((x))
233
+ #endif
234
+
235
+ #define npy_signbit(x) signbit((x))
236
+
237
+ /*
238
+ * float C99 math funcs that need fixups or are blocklist-able
239
+ */
240
+ NPY_INPLACE float npy_sinf(float x);
241
+ NPY_INPLACE float npy_cosf(float x);
242
+ NPY_INPLACE float npy_tanf(float x);
243
+ NPY_INPLACE float npy_expf(float x);
244
+ NPY_INPLACE float npy_sqrtf(float x);
245
+ NPY_INPLACE float npy_hypotf(float x, float y);
246
+ NPY_INPLACE float npy_log2f(float x);
247
+ NPY_INPLACE float npy_atan2f(float x, float y);
248
+ NPY_INPLACE float npy_powf(float x, float y);
249
+ NPY_INPLACE float npy_modff(float x, float* y);
250
+
251
+ /* Mandatory C99 float math funcs, no blocklisting or fixups */
252
+ /* defined for legacy reasons, should be deprecated at some point */
253
+
254
+ #define npy_sinhf sinhf
255
+ #define npy_coshf coshf
256
+ #define npy_tanhf tanhf
257
+ #define npy_asinf asinf
258
+ #define npy_acosf acosf
259
+ #define npy_atanf atanf
260
+ #define npy_logf logf
261
+ #define npy_log10f log10f
262
+ #define npy_cbrtf cbrtf
263
+ #define npy_fabsf fabsf
264
+ #define npy_ceilf ceilf
265
+ #define npy_fmodf fmodf
266
+ #define npy_floorf floorf
267
+ #define npy_expm1f expm1f
268
+ #define npy_log1pf log1pf
269
+ #define npy_asinhf asinhf
270
+ #define npy_acoshf acoshf
271
+ #define npy_atanhf atanhf
272
+ #define npy_rintf rintf
273
+ #define npy_truncf truncf
274
+ #define npy_exp2f exp2f
275
+ #define npy_frexpf frexpf
276
+ #define npy_ldexpf ldexpf
277
+ #define npy_copysignf copysignf
278
+ #define npy_nextafterf nextafterf
279
+
280
+ float npy_spacingf(float x);
281
+
282
+ /*
283
+ * long double C99 double math funcs that need fixups or are blocklist-able
284
+ */
285
+ NPY_INPLACE npy_longdouble npy_sinl(npy_longdouble x);
286
+ NPY_INPLACE npy_longdouble npy_cosl(npy_longdouble x);
287
+ NPY_INPLACE npy_longdouble npy_tanl(npy_longdouble x);
288
+ NPY_INPLACE npy_longdouble npy_expl(npy_longdouble x);
289
+ NPY_INPLACE npy_longdouble npy_sqrtl(npy_longdouble x);
290
+ NPY_INPLACE npy_longdouble npy_hypotl(npy_longdouble x, npy_longdouble y);
291
+ NPY_INPLACE npy_longdouble npy_log2l(npy_longdouble x);
292
+ NPY_INPLACE npy_longdouble npy_atan2l(npy_longdouble x, npy_longdouble y);
293
+ NPY_INPLACE npy_longdouble npy_powl(npy_longdouble x, npy_longdouble y);
294
+ NPY_INPLACE npy_longdouble npy_modfl(npy_longdouble x, npy_longdouble* y);
295
+
296
+ /* Mandatory C99 double math funcs, no blocklisting or fixups */
297
+ /* defined for legacy reasons, should be deprecated at some point */
298
+ #define npy_sinhl sinhl
299
+ #define npy_coshl coshl
300
+ #define npy_tanhl tanhl
301
+ #define npy_fabsl fabsl
302
+ #define npy_floorl floorl
303
+ #define npy_ceill ceill
304
+ #define npy_rintl rintl
305
+ #define npy_truncl truncl
306
+ #define npy_cbrtl cbrtl
307
+ #define npy_log10l log10l
308
+ #define npy_logl logl
309
+ #define npy_expm1l expm1l
310
+ #define npy_asinl asinl
311
+ #define npy_acosl acosl
312
+ #define npy_atanl atanl
313
+ #define npy_asinhl asinhl
314
+ #define npy_acoshl acoshl
315
+ #define npy_atanhl atanhl
316
+ #define npy_log1pl log1pl
317
+ #define npy_exp2l exp2l
318
+ #define npy_fmodl fmodl
319
+ #define npy_frexpl frexpl
320
+ #define npy_ldexpl ldexpl
321
+ #define npy_copysignl copysignl
322
+ #define npy_nextafterl nextafterl
323
+
324
+ npy_longdouble npy_spacingl(npy_longdouble x);
325
+
326
+ /*
327
+ * Non standard functions
328
+ */
329
+ NPY_INPLACE double npy_deg2rad(double x);
330
+ NPY_INPLACE double npy_rad2deg(double x);
331
+ NPY_INPLACE double npy_logaddexp(double x, double y);
332
+ NPY_INPLACE double npy_logaddexp2(double x, double y);
333
+ NPY_INPLACE double npy_divmod(double x, double y, double *modulus);
334
+ NPY_INPLACE double npy_heaviside(double x, double h0);
335
+
336
+ NPY_INPLACE float npy_deg2radf(float x);
337
+ NPY_INPLACE float npy_rad2degf(float x);
338
+ NPY_INPLACE float npy_logaddexpf(float x, float y);
339
+ NPY_INPLACE float npy_logaddexp2f(float x, float y);
340
+ NPY_INPLACE float npy_divmodf(float x, float y, float *modulus);
341
+ NPY_INPLACE float npy_heavisidef(float x, float h0);
342
+
343
+ NPY_INPLACE npy_longdouble npy_deg2radl(npy_longdouble x);
344
+ NPY_INPLACE npy_longdouble npy_rad2degl(npy_longdouble x);
345
+ NPY_INPLACE npy_longdouble npy_logaddexpl(npy_longdouble x, npy_longdouble y);
346
+ NPY_INPLACE npy_longdouble npy_logaddexp2l(npy_longdouble x, npy_longdouble y);
347
+ NPY_INPLACE npy_longdouble npy_divmodl(npy_longdouble x, npy_longdouble y,
348
+ npy_longdouble *modulus);
349
+ NPY_INPLACE npy_longdouble npy_heavisidel(npy_longdouble x, npy_longdouble h0);
350
+
351
+ #define npy_degrees npy_rad2deg
352
+ #define npy_degreesf npy_rad2degf
353
+ #define npy_degreesl npy_rad2degl
354
+
355
+ #define npy_radians npy_deg2rad
356
+ #define npy_radiansf npy_deg2radf
357
+ #define npy_radiansl npy_deg2radl
358
+
359
+ /*
360
+ * Complex declarations
361
+ */
362
+
363
+ static inline double npy_creal(const npy_cdouble z)
364
+ {
365
+ #if defined(__cplusplus)
366
+ return z._Val[0];
367
+ #else
368
+ return creal(z);
369
+ #endif
370
+ }
371
+
372
+ static inline void npy_csetreal(npy_cdouble *z, const double r)
373
+ {
374
+ ((double *) z)[0] = r;
375
+ }
376
+
377
+ static inline double npy_cimag(const npy_cdouble z)
378
+ {
379
+ #if defined(__cplusplus)
380
+ return z._Val[1];
381
+ #else
382
+ return cimag(z);
383
+ #endif
384
+ }
385
+
386
+ static inline void npy_csetimag(npy_cdouble *z, const double i)
387
+ {
388
+ ((double *) z)[1] = i;
389
+ }
390
+
391
+ static inline float npy_crealf(const npy_cfloat z)
392
+ {
393
+ #if defined(__cplusplus)
394
+ return z._Val[0];
395
+ #else
396
+ return crealf(z);
397
+ #endif
398
+ }
399
+
400
+ static inline void npy_csetrealf(npy_cfloat *z, const float r)
401
+ {
402
+ ((float *) z)[0] = r;
403
+ }
404
+
405
+ static inline float npy_cimagf(const npy_cfloat z)
406
+ {
407
+ #if defined(__cplusplus)
408
+ return z._Val[1];
409
+ #else
410
+ return cimagf(z);
411
+ #endif
412
+ }
413
+
414
+ static inline void npy_csetimagf(npy_cfloat *z, const float i)
415
+ {
416
+ ((float *) z)[1] = i;
417
+ }
418
+
419
+ static inline npy_longdouble npy_creall(const npy_clongdouble z)
420
+ {
421
+ #if defined(__cplusplus)
422
+ return (npy_longdouble)z._Val[0];
423
+ #else
424
+ return creall(z);
425
+ #endif
426
+ }
427
+
428
+ static inline void npy_csetreall(npy_clongdouble *z, const longdouble_t r)
429
+ {
430
+ ((longdouble_t *) z)[0] = r;
431
+ }
432
+
433
+ static inline npy_longdouble npy_cimagl(const npy_clongdouble z)
434
+ {
435
+ #if defined(__cplusplus)
436
+ return (npy_longdouble)z._Val[1];
437
+ #else
438
+ return cimagl(z);
439
+ #endif
440
+ }
441
+
442
+ static inline void npy_csetimagl(npy_clongdouble *z, const longdouble_t i)
443
+ {
444
+ ((longdouble_t *) z)[1] = i;
445
+ }
446
+
447
+ #define NPY_CSETREAL(z, r) npy_csetreal(z, r)
448
+ #define NPY_CSETIMAG(z, i) npy_csetimag(z, i)
449
+ #define NPY_CSETREALF(z, r) npy_csetrealf(z, r)
450
+ #define NPY_CSETIMAGF(z, i) npy_csetimagf(z, i)
451
+ #define NPY_CSETREALL(z, r) npy_csetreall(z, r)
452
+ #define NPY_CSETIMAGL(z, i) npy_csetimagl(z, i)
453
+
454
+ static inline npy_cdouble npy_cpack(double x, double y)
455
+ {
456
+ npy_cdouble z;
457
+ npy_csetreal(&z, x);
458
+ npy_csetimag(&z, y);
459
+ return z;
460
+ }
461
+
462
+ static inline npy_cfloat npy_cpackf(float x, float y)
463
+ {
464
+ npy_cfloat z;
465
+ npy_csetrealf(&z, x);
466
+ npy_csetimagf(&z, y);
467
+ return z;
468
+ }
469
+
470
+ static inline npy_clongdouble npy_cpackl(npy_longdouble x, npy_longdouble y)
471
+ {
472
+ npy_clongdouble z;
473
+ npy_csetreall(&z, x);
474
+ npy_csetimagl(&z, y);
475
+ return z;
476
+ }
477
+
478
+ /*
479
+ * Double precision complex functions
480
+ */
481
+ double npy_cabs(npy_cdouble z);
482
+ double npy_carg(npy_cdouble z);
483
+
484
+ npy_cdouble npy_cexp(npy_cdouble z);
485
+ npy_cdouble npy_clog(npy_cdouble z);
486
+ npy_cdouble npy_cpow(npy_cdouble x, npy_cdouble y);
487
+
488
+ npy_cdouble npy_csqrt(npy_cdouble z);
489
+
490
+ npy_cdouble npy_ccos(npy_cdouble z);
491
+ npy_cdouble npy_csin(npy_cdouble z);
492
+ npy_cdouble npy_ctan(npy_cdouble z);
493
+
494
+ npy_cdouble npy_ccosh(npy_cdouble z);
495
+ npy_cdouble npy_csinh(npy_cdouble z);
496
+ npy_cdouble npy_ctanh(npy_cdouble z);
497
+
498
+ npy_cdouble npy_cacos(npy_cdouble z);
499
+ npy_cdouble npy_casin(npy_cdouble z);
500
+ npy_cdouble npy_catan(npy_cdouble z);
501
+
502
+ npy_cdouble npy_cacosh(npy_cdouble z);
503
+ npy_cdouble npy_casinh(npy_cdouble z);
504
+ npy_cdouble npy_catanh(npy_cdouble z);
505
+
506
+ /*
507
+ * Single precision complex functions
508
+ */
509
+ float npy_cabsf(npy_cfloat z);
510
+ float npy_cargf(npy_cfloat z);
511
+
512
+ npy_cfloat npy_cexpf(npy_cfloat z);
513
+ npy_cfloat npy_clogf(npy_cfloat z);
514
+ npy_cfloat npy_cpowf(npy_cfloat x, npy_cfloat y);
515
+
516
+ npy_cfloat npy_csqrtf(npy_cfloat z);
517
+
518
+ npy_cfloat npy_ccosf(npy_cfloat z);
519
+ npy_cfloat npy_csinf(npy_cfloat z);
520
+ npy_cfloat npy_ctanf(npy_cfloat z);
521
+
522
+ npy_cfloat npy_ccoshf(npy_cfloat z);
523
+ npy_cfloat npy_csinhf(npy_cfloat z);
524
+ npy_cfloat npy_ctanhf(npy_cfloat z);
525
+
526
+ npy_cfloat npy_cacosf(npy_cfloat z);
527
+ npy_cfloat npy_casinf(npy_cfloat z);
528
+ npy_cfloat npy_catanf(npy_cfloat z);
529
+
530
+ npy_cfloat npy_cacoshf(npy_cfloat z);
531
+ npy_cfloat npy_casinhf(npy_cfloat z);
532
+ npy_cfloat npy_catanhf(npy_cfloat z);
533
+
534
+
535
+ /*
536
+ * Extended precision complex functions
537
+ */
538
+ npy_longdouble npy_cabsl(npy_clongdouble z);
539
+ npy_longdouble npy_cargl(npy_clongdouble z);
540
+
541
+ npy_clongdouble npy_cexpl(npy_clongdouble z);
542
+ npy_clongdouble npy_clogl(npy_clongdouble z);
543
+ npy_clongdouble npy_cpowl(npy_clongdouble x, npy_clongdouble y);
544
+
545
+ npy_clongdouble npy_csqrtl(npy_clongdouble z);
546
+
547
+ npy_clongdouble npy_ccosl(npy_clongdouble z);
548
+ npy_clongdouble npy_csinl(npy_clongdouble z);
549
+ npy_clongdouble npy_ctanl(npy_clongdouble z);
550
+
551
+ npy_clongdouble npy_ccoshl(npy_clongdouble z);
552
+ npy_clongdouble npy_csinhl(npy_clongdouble z);
553
+ npy_clongdouble npy_ctanhl(npy_clongdouble z);
554
+
555
+ npy_clongdouble npy_cacosl(npy_clongdouble z);
556
+ npy_clongdouble npy_casinl(npy_clongdouble z);
557
+ npy_clongdouble npy_catanl(npy_clongdouble z);
558
+
559
+ npy_clongdouble npy_cacoshl(npy_clongdouble z);
560
+ npy_clongdouble npy_casinhl(npy_clongdouble z);
561
+ npy_clongdouble npy_catanhl(npy_clongdouble z);
562
+
563
+
564
+ /*
565
+ * Functions that set the floating point error
566
+ * status word.
567
+ */
568
+
569
+ /*
570
+ * platform-dependent code translates floating point
571
+ * status to an integer sum of these values
572
+ */
573
+ #define NPY_FPE_DIVIDEBYZERO 1
574
+ #define NPY_FPE_OVERFLOW 2
575
+ #define NPY_FPE_UNDERFLOW 4
576
+ #define NPY_FPE_INVALID 8
577
+
578
+ int npy_clear_floatstatus_barrier(char*);
579
+ int npy_get_floatstatus_barrier(char*);
580
+ /*
581
+ * use caution with these - clang and gcc8.1 are known to reorder calls
582
+ * to this form of the function which can defeat the check. The _barrier
583
+ * form of the call is preferable, where the argument is
584
+ * (char*)&local_variable
585
+ */
586
+ int npy_clear_floatstatus(void);
587
+ int npy_get_floatstatus(void);
588
+
589
+ void npy_set_floatstatus_divbyzero(void);
590
+ void npy_set_floatstatus_overflow(void);
591
+ void npy_set_floatstatus_underflow(void);
592
+ void npy_set_floatstatus_invalid(void);
593
+
594
+ #ifdef __cplusplus
595
+ }
596
+ #endif
597
+
598
+ #if NPY_INLINE_MATH
599
+ #include "npy_math_internal.h"
600
+ #endif
601
+
602
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_MATH_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_no_deprecated_api.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This include file is provided for inclusion in Cython *.pyd files where
3
+ * one would like to define the NPY_NO_DEPRECATED_API macro. It can be
4
+ * included by
5
+ *
6
+ * cdef extern from "npy_no_deprecated_api.h": pass
7
+ *
8
+ */
9
+ #ifndef NPY_NO_DEPRECATED_API
10
+
11
+ /* put this check here since there may be multiple includes in C extensions. */
12
+ #if defined(NUMPY_CORE_INCLUDE_NUMPY_NDARRAYTYPES_H_) || \
13
+ defined(NUMPY_CORE_INCLUDE_NUMPY_NPY_DEPRECATED_API_H) || \
14
+ defined(NUMPY_CORE_INCLUDE_NUMPY_OLD_DEFINES_H_)
15
+ #error "npy_no_deprecated_api.h" must be first among numpy includes.
16
+ #else
17
+ #define NPY_NO_DEPRECATED_API NPY_API_VERSION
18
+ #endif
19
+
20
+ #endif /* NPY_NO_DEPRECATED_API */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/npy_os.h ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_OS_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_OS_H_
3
+
4
+ #if defined(linux) || defined(__linux) || defined(__linux__)
5
+ #define NPY_OS_LINUX
6
+ #elif defined(__FreeBSD__) || defined(__NetBSD__) || \
7
+ defined(__OpenBSD__) || defined(__DragonFly__)
8
+ #define NPY_OS_BSD
9
+ #ifdef __FreeBSD__
10
+ #define NPY_OS_FREEBSD
11
+ #elif defined(__NetBSD__)
12
+ #define NPY_OS_NETBSD
13
+ #elif defined(__OpenBSD__)
14
+ #define NPY_OS_OPENBSD
15
+ #elif defined(__DragonFly__)
16
+ #define NPY_OS_DRAGONFLY
17
+ #endif
18
+ #elif defined(sun) || defined(__sun)
19
+ #define NPY_OS_SOLARIS
20
+ #elif defined(__CYGWIN__)
21
+ #define NPY_OS_CYGWIN
22
+ /* We are on Windows.*/
23
+ #elif defined(_WIN32)
24
+ /* We are using MinGW (64-bit or 32-bit)*/
25
+ #if defined(__MINGW32__) || defined(__MINGW64__)
26
+ #define NPY_OS_MINGW
27
+ /* Otherwise, if _WIN64 is defined, we are targeting 64-bit Windows*/
28
+ #elif defined(_WIN64)
29
+ #define NPY_OS_WIN64
30
+ /* Otherwise assume we are targeting 32-bit Windows*/
31
+ #else
32
+ #define NPY_OS_WIN32
33
+ #endif
34
+ #elif defined(__APPLE__)
35
+ #define NPY_OS_DARWIN
36
+ #elif defined(__HAIKU__)
37
+ #define NPY_OS_HAIKU
38
+ #else
39
+ #define NPY_OS_UNKNOWN
40
+ #endif
41
+
42
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_OS_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/numpyconfig.h ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_NPY_NUMPYCONFIG_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_NPY_NUMPYCONFIG_H_
3
+
4
+ #include "_numpyconfig.h"
5
+
6
+ /*
7
+ * On Mac OS X, because there is only one configuration stage for all the archs
8
+ * in universal builds, any macro which depends on the arch needs to be
9
+ * hardcoded.
10
+ *
11
+ * Note that distutils/pip will attempt a universal2 build when Python itself
12
+ * is built as universal2, hence this hardcoding is needed even if we do not
13
+ * support universal2 wheels anymore (see gh-22796).
14
+ * This code block can be removed after we have dropped the setup.py based
15
+ * build completely.
16
+ */
17
+ #ifdef __APPLE__
18
+ #undef NPY_SIZEOF_LONG
19
+
20
+ #ifdef __LP64__
21
+ #define NPY_SIZEOF_LONG 8
22
+ #else
23
+ #define NPY_SIZEOF_LONG 4
24
+ #endif
25
+
26
+ #undef NPY_SIZEOF_LONGDOUBLE
27
+ #undef NPY_SIZEOF_COMPLEX_LONGDOUBLE
28
+ #ifdef HAVE_LDOUBLE_IEEE_DOUBLE_LE
29
+ #undef HAVE_LDOUBLE_IEEE_DOUBLE_LE
30
+ #endif
31
+ #ifdef HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE
32
+ #undef HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE
33
+ #endif
34
+
35
+ #if defined(__arm64__)
36
+ #define NPY_SIZEOF_LONGDOUBLE 8
37
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 16
38
+ #define HAVE_LDOUBLE_IEEE_DOUBLE_LE 1
39
+ #elif defined(__x86_64)
40
+ #define NPY_SIZEOF_LONGDOUBLE 16
41
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
42
+ #define HAVE_LDOUBLE_INTEL_EXTENDED_16_BYTES_LE 1
43
+ #elif defined (__i386)
44
+ #define NPY_SIZEOF_LONGDOUBLE 12
45
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 24
46
+ #elif defined(__ppc__) || defined (__ppc64__)
47
+ #define NPY_SIZEOF_LONGDOUBLE 16
48
+ #define NPY_SIZEOF_COMPLEX_LONGDOUBLE 32
49
+ #else
50
+ #error "unknown architecture"
51
+ #endif
52
+ #endif
53
+
54
+
55
+ /**
56
+ * To help with both NPY_TARGET_VERSION and the NPY_NO_DEPRECATED_API macro,
57
+ * we include API version numbers for specific versions of NumPy.
58
+ * To exclude all API that was deprecated as of 1.7, add the following before
59
+ * #including any NumPy headers:
60
+ * #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
61
+ * The same is true for NPY_TARGET_VERSION, although NumPy will default to
62
+ * a backwards compatible build anyway.
63
+ */
64
+ #define NPY_1_7_API_VERSION 0x00000007
65
+ #define NPY_1_8_API_VERSION 0x00000008
66
+ #define NPY_1_9_API_VERSION 0x00000009
67
+ #define NPY_1_10_API_VERSION 0x0000000a
68
+ #define NPY_1_11_API_VERSION 0x0000000a
69
+ #define NPY_1_12_API_VERSION 0x0000000a
70
+ #define NPY_1_13_API_VERSION 0x0000000b
71
+ #define NPY_1_14_API_VERSION 0x0000000c
72
+ #define NPY_1_15_API_VERSION 0x0000000c
73
+ #define NPY_1_16_API_VERSION 0x0000000d
74
+ #define NPY_1_17_API_VERSION 0x0000000d
75
+ #define NPY_1_18_API_VERSION 0x0000000d
76
+ #define NPY_1_19_API_VERSION 0x0000000d
77
+ #define NPY_1_20_API_VERSION 0x0000000e
78
+ #define NPY_1_21_API_VERSION 0x0000000e
79
+ #define NPY_1_22_API_VERSION 0x0000000f
80
+ #define NPY_1_23_API_VERSION 0x00000010
81
+ #define NPY_1_24_API_VERSION 0x00000010
82
+ #define NPY_1_25_API_VERSION 0x00000011
83
+ #define NPY_2_0_API_VERSION 0x00000012
84
+ #define NPY_2_1_API_VERSION 0x00000013
85
+
86
+
87
+ /*
88
+ * Binary compatibility version number. This number is increased
89
+ * whenever the C-API is changed such that binary compatibility is
90
+ * broken, i.e. whenever a recompile of extension modules is needed.
91
+ */
92
+ #define NPY_VERSION NPY_ABI_VERSION
93
+
94
+ /*
95
+ * Minor API version we are compiling to be compatible with. The version
96
+ * Number is always increased when the API changes via: `NPY_API_VERSION`
97
+ * (and should maybe just track the NumPy version).
98
+ *
99
+ * If we have an internal build, we always target the current version of
100
+ * course.
101
+ *
102
+ * For downstream users, we default to an older version to provide them with
103
+ * maximum compatibility by default. Downstream can choose to extend that
104
+ * default, or narrow it down if they wish to use newer API. If you adjust
105
+ * this, consider the Python version support (example for 1.25.x):
106
+ *
107
+ * NumPy 1.25.x supports Python: 3.9 3.10 3.11 (3.12)
108
+ * NumPy 1.19.x supports Python: 3.6 3.7 3.8 3.9
109
+ * NumPy 1.17.x supports Python: 3.5 3.6 3.7 3.8
110
+ * NumPy 1.15.x supports Python: ... 3.6 3.7
111
+ *
112
+ * Users of the stable ABI may wish to target the last Python that is not
113
+ * end of life. This would be 3.8 at NumPy 1.25 release time.
114
+ * 1.17 as default was the choice of oldest-support-numpy at the time and
115
+ * has in practice no limit (compared to 1.19). Even earlier becomes legacy.
116
+ */
117
+ #if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
118
+ /* NumPy internal build, always use current version. */
119
+ #define NPY_FEATURE_VERSION NPY_API_VERSION
120
+ #elif defined(NPY_TARGET_VERSION) && NPY_TARGET_VERSION
121
+ /* user provided a target version, use it */
122
+ #define NPY_FEATURE_VERSION NPY_TARGET_VERSION
123
+ #else
124
+ /* Use the default (increase when dropping Python 3.10 support) */
125
+ #define NPY_FEATURE_VERSION NPY_1_21_API_VERSION
126
+ #endif
127
+
128
+ /* Sanity check the (requested) feature version */
129
+ #if NPY_FEATURE_VERSION > NPY_API_VERSION
130
+ #error "NPY_TARGET_VERSION higher than NumPy headers!"
131
+ #elif NPY_FEATURE_VERSION < NPY_1_15_API_VERSION
132
+ /* No support for irrelevant old targets, no need for error, but warn. */
133
+ #ifndef _MSC_VER
134
+ #warning "Requested NumPy target lower than supported NumPy 1.15."
135
+ #else
136
+ #define _WARN___STR2__(x) #x
137
+ #define _WARN___STR1__(x) _WARN___STR2__(x)
138
+ #define _WARN___LOC__ __FILE__ "(" _WARN___STR1__(__LINE__) ") : Warning Msg: "
139
+ #pragma message(_WARN___LOC__"Requested NumPy target lower than supported NumPy 1.15.")
140
+ #endif
141
+ #endif
142
+
143
+ /*
144
+ * We define a human readable translation to the Python version of NumPy
145
+ * for error messages (and also to allow grepping the binaries for conda).
146
+ */
147
+ #if NPY_FEATURE_VERSION == NPY_1_7_API_VERSION
148
+ #define NPY_FEATURE_VERSION_STRING "1.7"
149
+ #elif NPY_FEATURE_VERSION == NPY_1_8_API_VERSION
150
+ #define NPY_FEATURE_VERSION_STRING "1.8"
151
+ #elif NPY_FEATURE_VERSION == NPY_1_9_API_VERSION
152
+ #define NPY_FEATURE_VERSION_STRING "1.9"
153
+ #elif NPY_FEATURE_VERSION == NPY_1_10_API_VERSION /* also 1.11, 1.12 */
154
+ #define NPY_FEATURE_VERSION_STRING "1.10"
155
+ #elif NPY_FEATURE_VERSION == NPY_1_13_API_VERSION
156
+ #define NPY_FEATURE_VERSION_STRING "1.13"
157
+ #elif NPY_FEATURE_VERSION == NPY_1_14_API_VERSION /* also 1.15 */
158
+ #define NPY_FEATURE_VERSION_STRING "1.14"
159
+ #elif NPY_FEATURE_VERSION == NPY_1_16_API_VERSION /* also 1.17, 1.18, 1.19 */
160
+ #define NPY_FEATURE_VERSION_STRING "1.16"
161
+ #elif NPY_FEATURE_VERSION == NPY_1_20_API_VERSION /* also 1.21 */
162
+ #define NPY_FEATURE_VERSION_STRING "1.20"
163
+ #elif NPY_FEATURE_VERSION == NPY_1_22_API_VERSION
164
+ #define NPY_FEATURE_VERSION_STRING "1.22"
165
+ #elif NPY_FEATURE_VERSION == NPY_1_23_API_VERSION /* also 1.24 */
166
+ #define NPY_FEATURE_VERSION_STRING "1.23"
167
+ #elif NPY_FEATURE_VERSION == NPY_1_25_API_VERSION
168
+ #define NPY_FEATURE_VERSION_STRING "1.25"
169
+ #elif NPY_FEATURE_VERSION == NPY_2_0_API_VERSION
170
+ #define NPY_FEATURE_VERSION_STRING "2.0"
171
+ #elif NPY_FEATURE_VERSION == NPY_2_1_API_VERSION
172
+ #define NPY_FEATURE_VERSION_STRING "2.1"
173
+ #else
174
+ #error "Missing version string define for new NumPy version."
175
+ #endif
176
+
177
+
178
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_NPY_NUMPYCONFIG_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ zlib License
2
+ ------------
3
+
4
+ Copyright (C) 2010 - 2019 ridiculous_fish, <libdivide@ridiculousfish.com>
5
+ Copyright (C) 2016 - 2019 Kim Walisch, <kim.walisch@gmail.com>
6
+
7
+ This software is provided 'as-is', without any express or implied
8
+ warranty. In no event will the authors be held liable for any damages
9
+ arising from the use of this software.
10
+
11
+ Permission is granted to anyone to use this software for any purpose,
12
+ including commercial applications, and to alter it and redistribute it
13
+ freely, subject to the following restrictions:
14
+
15
+ 1. The origin of this software must not be misrepresented; you must not
16
+ claim that you wrote the original software. If you use this software
17
+ in a product, an acknowledgment in the product documentation would be
18
+ appreciated but is not required.
19
+ 2. Altered source versions must be plainly marked as such, and must not be
20
+ misrepresented as being the original software.
21
+ 3. This notice may not be removed or altered from any source distribution.
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/bitgen.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_RANDOM_BITGEN_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_RANDOM_BITGEN_H_
3
+
4
+ #pragma once
5
+ #include <stddef.h>
6
+ #include <stdbool.h>
7
+ #include <stdint.h>
8
+
9
+ /* Must match the declaration in numpy/random/<any>.pxd */
10
+
11
+ typedef struct bitgen {
12
+ void *state;
13
+ uint64_t (*next_uint64)(void *st);
14
+ uint32_t (*next_uint32)(void *st);
15
+ double (*next_double)(void *st);
16
+ uint64_t (*next_raw)(void *st);
17
+ } bitgen_t;
18
+
19
+
20
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_RANDOM_BITGEN_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/distributions.h ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_RANDOM_DISTRIBUTIONS_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_RANDOM_DISTRIBUTIONS_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include <Python.h>
9
+ #include "numpy/npy_common.h"
10
+ #include <stddef.h>
11
+ #include <stdbool.h>
12
+ #include <stdint.h>
13
+
14
+ #include "numpy/npy_math.h"
15
+ #include "numpy/random/bitgen.h"
16
+
17
+ /*
18
+ * RAND_INT_TYPE is used to share integer generators with RandomState which
19
+ * used long in place of int64_t. If changing a distribution that uses
20
+ * RAND_INT_TYPE, then the original unmodified copy must be retained for
21
+ * use in RandomState by copying to the legacy distributions source file.
22
+ */
23
+ #ifdef NP_RANDOM_LEGACY
24
+ #define RAND_INT_TYPE long
25
+ #define RAND_INT_MAX LONG_MAX
26
+ #else
27
+ #define RAND_INT_TYPE int64_t
28
+ #define RAND_INT_MAX INT64_MAX
29
+ #endif
30
+
31
+ #ifdef _MSC_VER
32
+ #define DECLDIR __declspec(dllexport)
33
+ #else
34
+ #define DECLDIR extern
35
+ #endif
36
+
37
+ #ifndef MIN
38
+ #define MIN(x, y) (((x) < (y)) ? x : y)
39
+ #define MAX(x, y) (((x) > (y)) ? x : y)
40
+ #endif
41
+
42
+ #ifndef M_PI
43
+ #define M_PI 3.14159265358979323846264338328
44
+ #endif
45
+
46
+ typedef struct s_binomial_t {
47
+ int has_binomial; /* !=0: following parameters initialized for binomial */
48
+ double psave;
49
+ RAND_INT_TYPE nsave;
50
+ double r;
51
+ double q;
52
+ double fm;
53
+ RAND_INT_TYPE m;
54
+ double p1;
55
+ double xm;
56
+ double xl;
57
+ double xr;
58
+ double c;
59
+ double laml;
60
+ double lamr;
61
+ double p2;
62
+ double p3;
63
+ double p4;
64
+ } binomial_t;
65
+
66
+ DECLDIR float random_standard_uniform_f(bitgen_t *bitgen_state);
67
+ DECLDIR double random_standard_uniform(bitgen_t *bitgen_state);
68
+ DECLDIR void random_standard_uniform_fill(bitgen_t *, npy_intp, double *);
69
+ DECLDIR void random_standard_uniform_fill_f(bitgen_t *, npy_intp, float *);
70
+
71
+ DECLDIR int64_t random_positive_int64(bitgen_t *bitgen_state);
72
+ DECLDIR int32_t random_positive_int32(bitgen_t *bitgen_state);
73
+ DECLDIR int64_t random_positive_int(bitgen_t *bitgen_state);
74
+ DECLDIR uint64_t random_uint(bitgen_t *bitgen_state);
75
+
76
+ DECLDIR double random_standard_exponential(bitgen_t *bitgen_state);
77
+ DECLDIR float random_standard_exponential_f(bitgen_t *bitgen_state);
78
+ DECLDIR void random_standard_exponential_fill(bitgen_t *, npy_intp, double *);
79
+ DECLDIR void random_standard_exponential_fill_f(bitgen_t *, npy_intp, float *);
80
+ DECLDIR void random_standard_exponential_inv_fill(bitgen_t *, npy_intp, double *);
81
+ DECLDIR void random_standard_exponential_inv_fill_f(bitgen_t *, npy_intp, float *);
82
+
83
+ DECLDIR double random_standard_normal(bitgen_t *bitgen_state);
84
+ DECLDIR float random_standard_normal_f(bitgen_t *bitgen_state);
85
+ DECLDIR void random_standard_normal_fill(bitgen_t *, npy_intp, double *);
86
+ DECLDIR void random_standard_normal_fill_f(bitgen_t *, npy_intp, float *);
87
+ DECLDIR double random_standard_gamma(bitgen_t *bitgen_state, double shape);
88
+ DECLDIR float random_standard_gamma_f(bitgen_t *bitgen_state, float shape);
89
+
90
+ DECLDIR double random_normal(bitgen_t *bitgen_state, double loc, double scale);
91
+
92
+ DECLDIR double random_gamma(bitgen_t *bitgen_state, double shape, double scale);
93
+ DECLDIR float random_gamma_f(bitgen_t *bitgen_state, float shape, float scale);
94
+
95
+ DECLDIR double random_exponential(bitgen_t *bitgen_state, double scale);
96
+ DECLDIR double random_uniform(bitgen_t *bitgen_state, double lower, double range);
97
+ DECLDIR double random_beta(bitgen_t *bitgen_state, double a, double b);
98
+ DECLDIR double random_chisquare(bitgen_t *bitgen_state, double df);
99
+ DECLDIR double random_f(bitgen_t *bitgen_state, double dfnum, double dfden);
100
+ DECLDIR double random_standard_cauchy(bitgen_t *bitgen_state);
101
+ DECLDIR double random_pareto(bitgen_t *bitgen_state, double a);
102
+ DECLDIR double random_weibull(bitgen_t *bitgen_state, double a);
103
+ DECLDIR double random_power(bitgen_t *bitgen_state, double a);
104
+ DECLDIR double random_laplace(bitgen_t *bitgen_state, double loc, double scale);
105
+ DECLDIR double random_gumbel(bitgen_t *bitgen_state, double loc, double scale);
106
+ DECLDIR double random_logistic(bitgen_t *bitgen_state, double loc, double scale);
107
+ DECLDIR double random_lognormal(bitgen_t *bitgen_state, double mean, double sigma);
108
+ DECLDIR double random_rayleigh(bitgen_t *bitgen_state, double mode);
109
+ DECLDIR double random_standard_t(bitgen_t *bitgen_state, double df);
110
+ DECLDIR double random_noncentral_chisquare(bitgen_t *bitgen_state, double df,
111
+ double nonc);
112
+ DECLDIR double random_noncentral_f(bitgen_t *bitgen_state, double dfnum,
113
+ double dfden, double nonc);
114
+ DECLDIR double random_wald(bitgen_t *bitgen_state, double mean, double scale);
115
+ DECLDIR double random_vonmises(bitgen_t *bitgen_state, double mu, double kappa);
116
+ DECLDIR double random_triangular(bitgen_t *bitgen_state, double left, double mode,
117
+ double right);
118
+
119
+ DECLDIR RAND_INT_TYPE random_poisson(bitgen_t *bitgen_state, double lam);
120
+ DECLDIR RAND_INT_TYPE random_negative_binomial(bitgen_t *bitgen_state, double n,
121
+ double p);
122
+
123
+ DECLDIR int64_t random_binomial(bitgen_t *bitgen_state, double p,
124
+ int64_t n, binomial_t *binomial);
125
+
126
+ DECLDIR int64_t random_logseries(bitgen_t *bitgen_state, double p);
127
+ DECLDIR int64_t random_geometric(bitgen_t *bitgen_state, double p);
128
+ DECLDIR RAND_INT_TYPE random_geometric_search(bitgen_t *bitgen_state, double p);
129
+ DECLDIR RAND_INT_TYPE random_zipf(bitgen_t *bitgen_state, double a);
130
+ DECLDIR int64_t random_hypergeometric(bitgen_t *bitgen_state,
131
+ int64_t good, int64_t bad, int64_t sample);
132
+ DECLDIR uint64_t random_interval(bitgen_t *bitgen_state, uint64_t max);
133
+
134
+ /* Generate random uint64 numbers in closed interval [off, off + rng]. */
135
+ DECLDIR uint64_t random_bounded_uint64(bitgen_t *bitgen_state, uint64_t off,
136
+ uint64_t rng, uint64_t mask,
137
+ bool use_masked);
138
+
139
+ /* Generate random uint32 numbers in closed interval [off, off + rng]. */
140
+ DECLDIR uint32_t random_buffered_bounded_uint32(bitgen_t *bitgen_state,
141
+ uint32_t off, uint32_t rng,
142
+ uint32_t mask, bool use_masked,
143
+ int *bcnt, uint32_t *buf);
144
+ DECLDIR uint16_t random_buffered_bounded_uint16(bitgen_t *bitgen_state,
145
+ uint16_t off, uint16_t rng,
146
+ uint16_t mask, bool use_masked,
147
+ int *bcnt, uint32_t *buf);
148
+ DECLDIR uint8_t random_buffered_bounded_uint8(bitgen_t *bitgen_state, uint8_t off,
149
+ uint8_t rng, uint8_t mask,
150
+ bool use_masked, int *bcnt,
151
+ uint32_t *buf);
152
+ DECLDIR npy_bool random_buffered_bounded_bool(bitgen_t *bitgen_state, npy_bool off,
153
+ npy_bool rng, npy_bool mask,
154
+ bool use_masked, int *bcnt,
155
+ uint32_t *buf);
156
+
157
+ DECLDIR void random_bounded_uint64_fill(bitgen_t *bitgen_state, uint64_t off,
158
+ uint64_t rng, npy_intp cnt,
159
+ bool use_masked, uint64_t *out);
160
+ DECLDIR void random_bounded_uint32_fill(bitgen_t *bitgen_state, uint32_t off,
161
+ uint32_t rng, npy_intp cnt,
162
+ bool use_masked, uint32_t *out);
163
+ DECLDIR void random_bounded_uint16_fill(bitgen_t *bitgen_state, uint16_t off,
164
+ uint16_t rng, npy_intp cnt,
165
+ bool use_masked, uint16_t *out);
166
+ DECLDIR void random_bounded_uint8_fill(bitgen_t *bitgen_state, uint8_t off,
167
+ uint8_t rng, npy_intp cnt,
168
+ bool use_masked, uint8_t *out);
169
+ DECLDIR void random_bounded_bool_fill(bitgen_t *bitgen_state, npy_bool off,
170
+ npy_bool rng, npy_intp cnt,
171
+ bool use_masked, npy_bool *out);
172
+
173
+ DECLDIR void random_multinomial(bitgen_t *bitgen_state, RAND_INT_TYPE n, RAND_INT_TYPE *mnix,
174
+ double *pix, npy_intp d, binomial_t *binomial);
175
+
176
+ /* multivariate hypergeometric, "count" method */
177
+ DECLDIR int random_multivariate_hypergeometric_count(bitgen_t *bitgen_state,
178
+ int64_t total,
179
+ size_t num_colors, int64_t *colors,
180
+ int64_t nsample,
181
+ size_t num_variates, int64_t *variates);
182
+
183
+ /* multivariate hypergeometric, "marginals" method */
184
+ DECLDIR void random_multivariate_hypergeometric_marginals(bitgen_t *bitgen_state,
185
+ int64_t total,
186
+ size_t num_colors, int64_t *colors,
187
+ int64_t nsample,
188
+ size_t num_variates, int64_t *variates);
189
+
190
+ /* Common to legacy-distributions.c and distributions.c but not exported */
191
+
192
+ RAND_INT_TYPE random_binomial_btpe(bitgen_t *bitgen_state,
193
+ RAND_INT_TYPE n,
194
+ double p,
195
+ binomial_t *binomial);
196
+ RAND_INT_TYPE random_binomial_inversion(bitgen_t *bitgen_state,
197
+ RAND_INT_TYPE n,
198
+ double p,
199
+ binomial_t *binomial);
200
+ double random_loggam(double x);
201
+ static inline double next_double(bitgen_t *bitgen_state) {
202
+ return bitgen_state->next_double(bitgen_state->state);
203
+ }
204
+
205
+ #ifdef __cplusplus
206
+ }
207
+ #endif
208
+
209
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_RANDOM_DISTRIBUTIONS_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/random/libdivide.h ADDED
@@ -0,0 +1,2079 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // libdivide.h - Optimized integer division
2
+ // https://libdivide.com
3
+ //
4
+ // Copyright (C) 2010 - 2019 ridiculous_fish, <libdivide@ridiculousfish.com>
5
+ // Copyright (C) 2016 - 2019 Kim Walisch, <kim.walisch@gmail.com>
6
+ //
7
+ // libdivide is dual-licensed under the Boost or zlib licenses.
8
+ // You may use libdivide under the terms of either of these.
9
+ // See LICENSE.txt for more details.
10
+
11
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_LIBDIVIDE_LIBDIVIDE_H_
12
+ #define NUMPY_CORE_INCLUDE_NUMPY_LIBDIVIDE_LIBDIVIDE_H_
13
+
14
+ #define LIBDIVIDE_VERSION "3.0"
15
+ #define LIBDIVIDE_VERSION_MAJOR 3
16
+ #define LIBDIVIDE_VERSION_MINOR 0
17
+
18
+ #include <stdint.h>
19
+
20
+ #if defined(__cplusplus)
21
+ #include <cstdlib>
22
+ #include <cstdio>
23
+ #include <type_traits>
24
+ #else
25
+ #include <stdlib.h>
26
+ #include <stdio.h>
27
+ #endif
28
+
29
+ #if defined(LIBDIVIDE_AVX512)
30
+ #include <immintrin.h>
31
+ #elif defined(LIBDIVIDE_AVX2)
32
+ #include <immintrin.h>
33
+ #elif defined(LIBDIVIDE_SSE2)
34
+ #include <emmintrin.h>
35
+ #endif
36
+
37
+ #if defined(_MSC_VER)
38
+ #include <intrin.h>
39
+ // disable warning C4146: unary minus operator applied
40
+ // to unsigned type, result still unsigned
41
+ #pragma warning(disable: 4146)
42
+ #define LIBDIVIDE_VC
43
+ #endif
44
+
45
+ #if !defined(__has_builtin)
46
+ #define __has_builtin(x) 0
47
+ #endif
48
+
49
+ #if defined(__SIZEOF_INT128__)
50
+ #define HAS_INT128_T
51
+ // clang-cl on Windows does not yet support 128-bit division
52
+ #if !(defined(__clang__) && defined(LIBDIVIDE_VC))
53
+ #define HAS_INT128_DIV
54
+ #endif
55
+ #endif
56
+
57
+ #if defined(__x86_64__) || defined(_M_X64)
58
+ #define LIBDIVIDE_X86_64
59
+ #endif
60
+
61
+ #if defined(__i386__)
62
+ #define LIBDIVIDE_i386
63
+ #endif
64
+
65
+ #if defined(__GNUC__) || defined(__clang__)
66
+ #define LIBDIVIDE_GCC_STYLE_ASM
67
+ #endif
68
+
69
+ #if defined(__cplusplus) || defined(LIBDIVIDE_VC)
70
+ #define LIBDIVIDE_FUNCTION __FUNCTION__
71
+ #else
72
+ #define LIBDIVIDE_FUNCTION __func__
73
+ #endif
74
+
75
+ #define LIBDIVIDE_ERROR(msg) \
76
+ do { \
77
+ fprintf(stderr, "libdivide.h:%d: %s(): Error: %s\n", \
78
+ __LINE__, LIBDIVIDE_FUNCTION, msg); \
79
+ abort(); \
80
+ } while (0)
81
+
82
+ #if defined(LIBDIVIDE_ASSERTIONS_ON)
83
+ #define LIBDIVIDE_ASSERT(x) \
84
+ do { \
85
+ if (!(x)) { \
86
+ fprintf(stderr, "libdivide.h:%d: %s(): Assertion failed: %s\n", \
87
+ __LINE__, LIBDIVIDE_FUNCTION, #x); \
88
+ abort(); \
89
+ } \
90
+ } while (0)
91
+ #else
92
+ #define LIBDIVIDE_ASSERT(x)
93
+ #endif
94
+
95
+ #ifdef __cplusplus
96
+ namespace libdivide {
97
+ #endif
98
+
99
+ // pack divider structs to prevent compilers from padding.
100
+ // This reduces memory usage by up to 43% when using a large
101
+ // array of libdivide dividers and improves performance
102
+ // by up to 10% because of reduced memory bandwidth.
103
+ #pragma pack(push, 1)
104
+
105
+ struct libdivide_u32_t {
106
+ uint32_t magic;
107
+ uint8_t more;
108
+ };
109
+
110
+ struct libdivide_s32_t {
111
+ int32_t magic;
112
+ uint8_t more;
113
+ };
114
+
115
+ struct libdivide_u64_t {
116
+ uint64_t magic;
117
+ uint8_t more;
118
+ };
119
+
120
+ struct libdivide_s64_t {
121
+ int64_t magic;
122
+ uint8_t more;
123
+ };
124
+
125
+ struct libdivide_u32_branchfree_t {
126
+ uint32_t magic;
127
+ uint8_t more;
128
+ };
129
+
130
+ struct libdivide_s32_branchfree_t {
131
+ int32_t magic;
132
+ uint8_t more;
133
+ };
134
+
135
+ struct libdivide_u64_branchfree_t {
136
+ uint64_t magic;
137
+ uint8_t more;
138
+ };
139
+
140
+ struct libdivide_s64_branchfree_t {
141
+ int64_t magic;
142
+ uint8_t more;
143
+ };
144
+
145
+ #pragma pack(pop)
146
+
147
+ // Explanation of the "more" field:
148
+ //
149
+ // * Bits 0-5 is the shift value (for shift path or mult path).
150
+ // * Bit 6 is the add indicator for mult path.
151
+ // * Bit 7 is set if the divisor is negative. We use bit 7 as the negative
152
+ // divisor indicator so that we can efficiently use sign extension to
153
+ // create a bitmask with all bits set to 1 (if the divisor is negative)
154
+ // or 0 (if the divisor is positive).
155
+ //
156
+ // u32: [0-4] shift value
157
+ // [5] ignored
158
+ // [6] add indicator
159
+ // magic number of 0 indicates shift path
160
+ //
161
+ // s32: [0-4] shift value
162
+ // [5] ignored
163
+ // [6] add indicator
164
+ // [7] indicates negative divisor
165
+ // magic number of 0 indicates shift path
166
+ //
167
+ // u64: [0-5] shift value
168
+ // [6] add indicator
169
+ // magic number of 0 indicates shift path
170
+ //
171
+ // s64: [0-5] shift value
172
+ // [6] add indicator
173
+ // [7] indicates negative divisor
174
+ // magic number of 0 indicates shift path
175
+ //
176
+ // In s32 and s64 branchfree modes, the magic number is negated according to
177
+ // whether the divisor is negated. In branchfree strategy, it is not negated.
178
+
179
+ enum {
180
+ LIBDIVIDE_32_SHIFT_MASK = 0x1F,
181
+ LIBDIVIDE_64_SHIFT_MASK = 0x3F,
182
+ LIBDIVIDE_ADD_MARKER = 0x40,
183
+ LIBDIVIDE_NEGATIVE_DIVISOR = 0x80
184
+ };
185
+
186
+ static inline struct libdivide_s32_t libdivide_s32_gen(int32_t d);
187
+ static inline struct libdivide_u32_t libdivide_u32_gen(uint32_t d);
188
+ static inline struct libdivide_s64_t libdivide_s64_gen(int64_t d);
189
+ static inline struct libdivide_u64_t libdivide_u64_gen(uint64_t d);
190
+
191
+ static inline struct libdivide_s32_branchfree_t libdivide_s32_branchfree_gen(int32_t d);
192
+ static inline struct libdivide_u32_branchfree_t libdivide_u32_branchfree_gen(uint32_t d);
193
+ static inline struct libdivide_s64_branchfree_t libdivide_s64_branchfree_gen(int64_t d);
194
+ static inline struct libdivide_u64_branchfree_t libdivide_u64_branchfree_gen(uint64_t d);
195
+
196
+ static inline int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom);
197
+ static inline uint32_t libdivide_u32_do(uint32_t numer, const struct libdivide_u32_t *denom);
198
+ static inline int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom);
199
+ static inline uint64_t libdivide_u64_do(uint64_t numer, const struct libdivide_u64_t *denom);
200
+
201
+ static inline int32_t libdivide_s32_branchfree_do(int32_t numer, const struct libdivide_s32_branchfree_t *denom);
202
+ static inline uint32_t libdivide_u32_branchfree_do(uint32_t numer, const struct libdivide_u32_branchfree_t *denom);
203
+ static inline int64_t libdivide_s64_branchfree_do(int64_t numer, const struct libdivide_s64_branchfree_t *denom);
204
+ static inline uint64_t libdivide_u64_branchfree_do(uint64_t numer, const struct libdivide_u64_branchfree_t *denom);
205
+
206
+ static inline int32_t libdivide_s32_recover(const struct libdivide_s32_t *denom);
207
+ static inline uint32_t libdivide_u32_recover(const struct libdivide_u32_t *denom);
208
+ static inline int64_t libdivide_s64_recover(const struct libdivide_s64_t *denom);
209
+ static inline uint64_t libdivide_u64_recover(const struct libdivide_u64_t *denom);
210
+
211
+ static inline int32_t libdivide_s32_branchfree_recover(const struct libdivide_s32_branchfree_t *denom);
212
+ static inline uint32_t libdivide_u32_branchfree_recover(const struct libdivide_u32_branchfree_t *denom);
213
+ static inline int64_t libdivide_s64_branchfree_recover(const struct libdivide_s64_branchfree_t *denom);
214
+ static inline uint64_t libdivide_u64_branchfree_recover(const struct libdivide_u64_branchfree_t *denom);
215
+
216
+ //////// Internal Utility Functions
217
+
218
+ static inline uint32_t libdivide_mullhi_u32(uint32_t x, uint32_t y) {
219
+ uint64_t xl = x, yl = y;
220
+ uint64_t rl = xl * yl;
221
+ return (uint32_t)(rl >> 32);
222
+ }
223
+
224
+ static inline int32_t libdivide_mullhi_s32(int32_t x, int32_t y) {
225
+ int64_t xl = x, yl = y;
226
+ int64_t rl = xl * yl;
227
+ // needs to be arithmetic shift
228
+ return (int32_t)(rl >> 32);
229
+ }
230
+
231
+ static inline uint64_t libdivide_mullhi_u64(uint64_t x, uint64_t y) {
232
+ #if defined(LIBDIVIDE_VC) && \
233
+ defined(LIBDIVIDE_X86_64)
234
+ return __umulh(x, y);
235
+ #elif defined(HAS_INT128_T)
236
+ __uint128_t xl = x, yl = y;
237
+ __uint128_t rl = xl * yl;
238
+ return (uint64_t)(rl >> 64);
239
+ #else
240
+ // full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64)
241
+ uint32_t mask = 0xFFFFFFFF;
242
+ uint32_t x0 = (uint32_t)(x & mask);
243
+ uint32_t x1 = (uint32_t)(x >> 32);
244
+ uint32_t y0 = (uint32_t)(y & mask);
245
+ uint32_t y1 = (uint32_t)(y >> 32);
246
+ uint32_t x0y0_hi = libdivide_mullhi_u32(x0, y0);
247
+ uint64_t x0y1 = x0 * (uint64_t)y1;
248
+ uint64_t x1y0 = x1 * (uint64_t)y0;
249
+ uint64_t x1y1 = x1 * (uint64_t)y1;
250
+ uint64_t temp = x1y0 + x0y0_hi;
251
+ uint64_t temp_lo = temp & mask;
252
+ uint64_t temp_hi = temp >> 32;
253
+
254
+ return x1y1 + temp_hi + ((temp_lo + x0y1) >> 32);
255
+ #endif
256
+ }
257
+
258
+ static inline int64_t libdivide_mullhi_s64(int64_t x, int64_t y) {
259
+ #if defined(LIBDIVIDE_VC) && \
260
+ defined(LIBDIVIDE_X86_64)
261
+ return __mulh(x, y);
262
+ #elif defined(HAS_INT128_T)
263
+ __int128_t xl = x, yl = y;
264
+ __int128_t rl = xl * yl;
265
+ return (int64_t)(rl >> 64);
266
+ #else
267
+ // full 128 bits are x0 * y0 + (x0 * y1 << 32) + (x1 * y0 << 32) + (x1 * y1 << 64)
268
+ uint32_t mask = 0xFFFFFFFF;
269
+ uint32_t x0 = (uint32_t)(x & mask);
270
+ uint32_t y0 = (uint32_t)(y & mask);
271
+ int32_t x1 = (int32_t)(x >> 32);
272
+ int32_t y1 = (int32_t)(y >> 32);
273
+ uint32_t x0y0_hi = libdivide_mullhi_u32(x0, y0);
274
+ int64_t t = x1 * (int64_t)y0 + x0y0_hi;
275
+ int64_t w1 = x0 * (int64_t)y1 + (t & mask);
276
+
277
+ return x1 * (int64_t)y1 + (t >> 32) + (w1 >> 32);
278
+ #endif
279
+ }
280
+
281
+ static inline int32_t libdivide_count_leading_zeros32(uint32_t val) {
282
+ #if defined(__GNUC__) || \
283
+ __has_builtin(__builtin_clz)
284
+ // Fast way to count leading zeros
285
+ return __builtin_clz(val);
286
+ #elif defined(LIBDIVIDE_VC)
287
+ unsigned long result;
288
+ if (_BitScanReverse(&result, val)) {
289
+ return 31 - result;
290
+ }
291
+ return 0;
292
+ #else
293
+ if (val == 0)
294
+ return 32;
295
+ int32_t result = 8;
296
+ uint32_t hi = 0xFFU << 24;
297
+ while ((val & hi) == 0) {
298
+ hi >>= 8;
299
+ result += 8;
300
+ }
301
+ while (val & hi) {
302
+ result -= 1;
303
+ hi <<= 1;
304
+ }
305
+ return result;
306
+ #endif
307
+ }
308
+
309
+ static inline int32_t libdivide_count_leading_zeros64(uint64_t val) {
310
+ #if defined(__GNUC__) || \
311
+ __has_builtin(__builtin_clzll)
312
+ // Fast way to count leading zeros
313
+ return __builtin_clzll(val);
314
+ #elif defined(LIBDIVIDE_VC) && defined(_WIN64)
315
+ unsigned long result;
316
+ if (_BitScanReverse64(&result, val)) {
317
+ return 63 - result;
318
+ }
319
+ return 0;
320
+ #else
321
+ uint32_t hi = val >> 32;
322
+ uint32_t lo = val & 0xFFFFFFFF;
323
+ if (hi != 0) return libdivide_count_leading_zeros32(hi);
324
+ return 32 + libdivide_count_leading_zeros32(lo);
325
+ #endif
326
+ }
327
+
328
+ // libdivide_64_div_32_to_32: divides a 64-bit uint {u1, u0} by a 32-bit
329
+ // uint {v}. The result must fit in 32 bits.
330
+ // Returns the quotient directly and the remainder in *r
331
+ static inline uint32_t libdivide_64_div_32_to_32(uint32_t u1, uint32_t u0, uint32_t v, uint32_t *r) {
332
+ #if (defined(LIBDIVIDE_i386) || defined(LIBDIVIDE_X86_64)) && \
333
+ defined(LIBDIVIDE_GCC_STYLE_ASM)
334
+ uint32_t result;
335
+ __asm__("divl %[v]"
336
+ : "=a"(result), "=d"(*r)
337
+ : [v] "r"(v), "a"(u0), "d"(u1)
338
+ );
339
+ return result;
340
+ #else
341
+ uint64_t n = ((uint64_t)u1 << 32) | u0;
342
+ uint32_t result = (uint32_t)(n / v);
343
+ *r = (uint32_t)(n - result * (uint64_t)v);
344
+ return result;
345
+ #endif
346
+ }
347
+
348
+ // libdivide_128_div_64_to_64: divides a 128-bit uint {u1, u0} by a 64-bit
349
+ // uint {v}. The result must fit in 64 bits.
350
+ // Returns the quotient directly and the remainder in *r
351
+ static uint64_t libdivide_128_div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, uint64_t *r) {
352
+ #if defined(LIBDIVIDE_X86_64) && \
353
+ defined(LIBDIVIDE_GCC_STYLE_ASM)
354
+ uint64_t result;
355
+ __asm__("divq %[v]"
356
+ : "=a"(result), "=d"(*r)
357
+ : [v] "r"(v), "a"(u0), "d"(u1)
358
+ );
359
+ return result;
360
+ #elif defined(HAS_INT128_T) && \
361
+ defined(HAS_INT128_DIV)
362
+ __uint128_t n = ((__uint128_t)u1 << 64) | u0;
363
+ uint64_t result = (uint64_t)(n / v);
364
+ *r = (uint64_t)(n - result * (__uint128_t)v);
365
+ return result;
366
+ #else
367
+ // Code taken from Hacker's Delight:
368
+ // http://www.hackersdelight.org/HDcode/divlu.c.
369
+ // License permits inclusion here per:
370
+ // http://www.hackersdelight.org/permissions.htm
371
+
372
+ const uint64_t b = (1ULL << 32); // Number base (32 bits)
373
+ uint64_t un1, un0; // Norm. dividend LSD's
374
+ uint64_t vn1, vn0; // Norm. divisor digits
375
+ uint64_t q1, q0; // Quotient digits
376
+ uint64_t un64, un21, un10; // Dividend digit pairs
377
+ uint64_t rhat; // A remainder
378
+ int32_t s; // Shift amount for norm
379
+
380
+ // If overflow, set rem. to an impossible value,
381
+ // and return the largest possible quotient
382
+ if (u1 >= v) {
383
+ *r = (uint64_t) -1;
384
+ return (uint64_t) -1;
385
+ }
386
+
387
+ // count leading zeros
388
+ s = libdivide_count_leading_zeros64(v);
389
+ if (s > 0) {
390
+ // Normalize divisor
391
+ v = v << s;
392
+ un64 = (u1 << s) | (u0 >> (64 - s));
393
+ un10 = u0 << s; // Shift dividend left
394
+ } else {
395
+ // Avoid undefined behavior of (u0 >> 64).
396
+ // The behavior is undefined if the right operand is
397
+ // negative, or greater than or equal to the length
398
+ // in bits of the promoted left operand.
399
+ un64 = u1;
400
+ un10 = u0;
401
+ }
402
+
403
+ // Break divisor up into two 32-bit digits
404
+ vn1 = v >> 32;
405
+ vn0 = v & 0xFFFFFFFF;
406
+
407
+ // Break right half of dividend into two digits
408
+ un1 = un10 >> 32;
409
+ un0 = un10 & 0xFFFFFFFF;
410
+
411
+ // Compute the first quotient digit, q1
412
+ q1 = un64 / vn1;
413
+ rhat = un64 - q1 * vn1;
414
+
415
+ while (q1 >= b || q1 * vn0 > b * rhat + un1) {
416
+ q1 = q1 - 1;
417
+ rhat = rhat + vn1;
418
+ if (rhat >= b)
419
+ break;
420
+ }
421
+
422
+ // Multiply and subtract
423
+ un21 = un64 * b + un1 - q1 * v;
424
+
425
+ // Compute the second quotient digit
426
+ q0 = un21 / vn1;
427
+ rhat = un21 - q0 * vn1;
428
+
429
+ while (q0 >= b || q0 * vn0 > b * rhat + un0) {
430
+ q0 = q0 - 1;
431
+ rhat = rhat + vn1;
432
+ if (rhat >= b)
433
+ break;
434
+ }
435
+
436
+ *r = (un21 * b + un0 - q0 * v) >> s;
437
+ return q1 * b + q0;
438
+ #endif
439
+ }
440
+
441
+ // Bitshift a u128 in place, left (signed_shift > 0) or right (signed_shift < 0)
442
+ static inline void libdivide_u128_shift(uint64_t *u1, uint64_t *u0, int32_t signed_shift) {
443
+ if (signed_shift > 0) {
444
+ uint32_t shift = signed_shift;
445
+ *u1 <<= shift;
446
+ *u1 |= *u0 >> (64 - shift);
447
+ *u0 <<= shift;
448
+ }
449
+ else if (signed_shift < 0) {
450
+ uint32_t shift = -signed_shift;
451
+ *u0 >>= shift;
452
+ *u0 |= *u1 << (64 - shift);
453
+ *u1 >>= shift;
454
+ }
455
+ }
456
+
457
+ // Computes a 128 / 128 -> 64 bit division, with a 128 bit remainder.
458
+ static uint64_t libdivide_128_div_128_to_64(uint64_t u_hi, uint64_t u_lo, uint64_t v_hi, uint64_t v_lo, uint64_t *r_hi, uint64_t *r_lo) {
459
+ #if defined(HAS_INT128_T) && \
460
+ defined(HAS_INT128_DIV)
461
+ __uint128_t ufull = u_hi;
462
+ __uint128_t vfull = v_hi;
463
+ ufull = (ufull << 64) | u_lo;
464
+ vfull = (vfull << 64) | v_lo;
465
+ uint64_t res = (uint64_t)(ufull / vfull);
466
+ __uint128_t remainder = ufull - (vfull * res);
467
+ *r_lo = (uint64_t)remainder;
468
+ *r_hi = (uint64_t)(remainder >> 64);
469
+ return res;
470
+ #else
471
+ // Adapted from "Unsigned Doubleword Division" in Hacker's Delight
472
+ // We want to compute u / v
473
+ typedef struct { uint64_t hi; uint64_t lo; } u128_t;
474
+ u128_t u = {u_hi, u_lo};
475
+ u128_t v = {v_hi, v_lo};
476
+
477
+ if (v.hi == 0) {
478
+ // divisor v is a 64 bit value, so we just need one 128/64 division
479
+ // Note that we are simpler than Hacker's Delight here, because we know
480
+ // the quotient fits in 64 bits whereas Hacker's Delight demands a full
481
+ // 128 bit quotient
482
+ *r_hi = 0;
483
+ return libdivide_128_div_64_to_64(u.hi, u.lo, v.lo, r_lo);
484
+ }
485
+ // Here v >= 2**64
486
+ // We know that v.hi != 0, so count leading zeros is OK
487
+ // We have 0 <= n <= 63
488
+ uint32_t n = libdivide_count_leading_zeros64(v.hi);
489
+
490
+ // Normalize the divisor so its MSB is 1
491
+ u128_t v1t = v;
492
+ libdivide_u128_shift(&v1t.hi, &v1t.lo, n);
493
+ uint64_t v1 = v1t.hi; // i.e. v1 = v1t >> 64
494
+
495
+ // To ensure no overflow
496
+ u128_t u1 = u;
497
+ libdivide_u128_shift(&u1.hi, &u1.lo, -1);
498
+
499
+ // Get quotient from divide unsigned insn.
500
+ uint64_t rem_ignored;
501
+ uint64_t q1 = libdivide_128_div_64_to_64(u1.hi, u1.lo, v1, &rem_ignored);
502
+
503
+ // Undo normalization and division of u by 2.
504
+ u128_t q0 = {0, q1};
505
+ libdivide_u128_shift(&q0.hi, &q0.lo, n);
506
+ libdivide_u128_shift(&q0.hi, &q0.lo, -63);
507
+
508
+ // Make q0 correct or too small by 1
509
+ // Equivalent to `if (q0 != 0) q0 = q0 - 1;`
510
+ if (q0.hi != 0 || q0.lo != 0) {
511
+ q0.hi -= (q0.lo == 0); // borrow
512
+ q0.lo -= 1;
513
+ }
514
+
515
+ // Now q0 is correct.
516
+ // Compute q0 * v as q0v
517
+ // = (q0.hi << 64 + q0.lo) * (v.hi << 64 + v.lo)
518
+ // = (q0.hi * v.hi << 128) + (q0.hi * v.lo << 64) +
519
+ // (q0.lo * v.hi << 64) + q0.lo * v.lo)
520
+ // Each term is 128 bit
521
+ // High half of full product (upper 128 bits!) are dropped
522
+ u128_t q0v = {0, 0};
523
+ q0v.hi = q0.hi*v.lo + q0.lo*v.hi + libdivide_mullhi_u64(q0.lo, v.lo);
524
+ q0v.lo = q0.lo*v.lo;
525
+
526
+ // Compute u - q0v as u_q0v
527
+ // This is the remainder
528
+ u128_t u_q0v = u;
529
+ u_q0v.hi -= q0v.hi + (u.lo < q0v.lo); // second term is borrow
530
+ u_q0v.lo -= q0v.lo;
531
+
532
+ // Check if u_q0v >= v
533
+ // This checks if our remainder is larger than the divisor
534
+ if ((u_q0v.hi > v.hi) ||
535
+ (u_q0v.hi == v.hi && u_q0v.lo >= v.lo)) {
536
+ // Increment q0
537
+ q0.lo += 1;
538
+ q0.hi += (q0.lo == 0); // carry
539
+
540
+ // Subtract v from remainder
541
+ u_q0v.hi -= v.hi + (u_q0v.lo < v.lo);
542
+ u_q0v.lo -= v.lo;
543
+ }
544
+
545
+ *r_hi = u_q0v.hi;
546
+ *r_lo = u_q0v.lo;
547
+
548
+ LIBDIVIDE_ASSERT(q0.hi == 0);
549
+ return q0.lo;
550
+ #endif
551
+ }
552
+
553
+ ////////// UINT32
554
+
555
+ static inline struct libdivide_u32_t libdivide_internal_u32_gen(uint32_t d, int branchfree) {
556
+ if (d == 0) {
557
+ LIBDIVIDE_ERROR("divider must be != 0");
558
+ }
559
+
560
+ struct libdivide_u32_t result;
561
+ uint32_t floor_log_2_d = 31 - libdivide_count_leading_zeros32(d);
562
+
563
+ // Power of 2
564
+ if ((d & (d - 1)) == 0) {
565
+ // We need to subtract 1 from the shift value in case of an unsigned
566
+ // branchfree divider because there is a hardcoded right shift by 1
567
+ // in its division algorithm. Because of this we also need to add back
568
+ // 1 in its recovery algorithm.
569
+ result.magic = 0;
570
+ result.more = (uint8_t)(floor_log_2_d - (branchfree != 0));
571
+ } else {
572
+ uint8_t more;
573
+ uint32_t rem, proposed_m;
574
+ proposed_m = libdivide_64_div_32_to_32(1U << floor_log_2_d, 0, d, &rem);
575
+
576
+ LIBDIVIDE_ASSERT(rem > 0 && rem < d);
577
+ const uint32_t e = d - rem;
578
+
579
+ // This power works if e < 2**floor_log_2_d.
580
+ if (!branchfree && (e < (1U << floor_log_2_d))) {
581
+ // This power works
582
+ more = floor_log_2_d;
583
+ } else {
584
+ // We have to use the general 33-bit algorithm. We need to compute
585
+ // (2**power) / d. However, we already have (2**(power-1))/d and
586
+ // its remainder. By doubling both, and then correcting the
587
+ // remainder, we can compute the larger division.
588
+ // don't care about overflow here - in fact, we expect it
589
+ proposed_m += proposed_m;
590
+ const uint32_t twice_rem = rem + rem;
591
+ if (twice_rem >= d || twice_rem < rem) proposed_m += 1;
592
+ more = floor_log_2_d | LIBDIVIDE_ADD_MARKER;
593
+ }
594
+ result.magic = 1 + proposed_m;
595
+ result.more = more;
596
+ // result.more's shift should in general be ceil_log_2_d. But if we
597
+ // used the smaller power, we subtract one from the shift because we're
598
+ // using the smaller power. If we're using the larger power, we
599
+ // subtract one from the shift because it's taken care of by the add
600
+ // indicator. So floor_log_2_d happens to be correct in both cases.
601
+ }
602
+ return result;
603
+ }
604
+
605
+ struct libdivide_u32_t libdivide_u32_gen(uint32_t d) {
606
+ return libdivide_internal_u32_gen(d, 0);
607
+ }
608
+
609
+ struct libdivide_u32_branchfree_t libdivide_u32_branchfree_gen(uint32_t d) {
610
+ if (d == 1) {
611
+ LIBDIVIDE_ERROR("branchfree divider must be != 1");
612
+ }
613
+ struct libdivide_u32_t tmp = libdivide_internal_u32_gen(d, 1);
614
+ struct libdivide_u32_branchfree_t ret = {tmp.magic, (uint8_t)(tmp.more & LIBDIVIDE_32_SHIFT_MASK)};
615
+ return ret;
616
+ }
617
+
618
+ uint32_t libdivide_u32_do(uint32_t numer, const struct libdivide_u32_t *denom) {
619
+ uint8_t more = denom->more;
620
+ if (!denom->magic) {
621
+ return numer >> more;
622
+ }
623
+ else {
624
+ uint32_t q = libdivide_mullhi_u32(denom->magic, numer);
625
+ if (more & LIBDIVIDE_ADD_MARKER) {
626
+ uint32_t t = ((numer - q) >> 1) + q;
627
+ return t >> (more & LIBDIVIDE_32_SHIFT_MASK);
628
+ }
629
+ else {
630
+ // All upper bits are 0,
631
+ // don't need to mask them off.
632
+ return q >> more;
633
+ }
634
+ }
635
+ }
636
+
637
+ uint32_t libdivide_u32_branchfree_do(uint32_t numer, const struct libdivide_u32_branchfree_t *denom) {
638
+ uint32_t q = libdivide_mullhi_u32(denom->magic, numer);
639
+ uint32_t t = ((numer - q) >> 1) + q;
640
+ return t >> denom->more;
641
+ }
642
+
643
+ uint32_t libdivide_u32_recover(const struct libdivide_u32_t *denom) {
644
+ uint8_t more = denom->more;
645
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
646
+
647
+ if (!denom->magic) {
648
+ return 1U << shift;
649
+ } else if (!(more & LIBDIVIDE_ADD_MARKER)) {
650
+ // We compute q = n/d = n*m / 2^(32 + shift)
651
+ // Therefore we have d = 2^(32 + shift) / m
652
+ // We need to ceil it.
653
+ // We know d is not a power of 2, so m is not a power of 2,
654
+ // so we can just add 1 to the floor
655
+ uint32_t hi_dividend = 1U << shift;
656
+ uint32_t rem_ignored;
657
+ return 1 + libdivide_64_div_32_to_32(hi_dividend, 0, denom->magic, &rem_ignored);
658
+ } else {
659
+ // Here we wish to compute d = 2^(32+shift+1)/(m+2^32).
660
+ // Notice (m + 2^32) is a 33 bit number. Use 64 bit division for now
661
+ // Also note that shift may be as high as 31, so shift + 1 will
662
+ // overflow. So we have to compute it as 2^(32+shift)/(m+2^32), and
663
+ // then double the quotient and remainder.
664
+ uint64_t half_n = 1ULL << (32 + shift);
665
+ uint64_t d = (1ULL << 32) | denom->magic;
666
+ // Note that the quotient is guaranteed <= 32 bits, but the remainder
667
+ // may need 33!
668
+ uint32_t half_q = (uint32_t)(half_n / d);
669
+ uint64_t rem = half_n % d;
670
+ // We computed 2^(32+shift)/(m+2^32)
671
+ // Need to double it, and then add 1 to the quotient if doubling th
672
+ // remainder would increase the quotient.
673
+ // Note that rem<<1 cannot overflow, since rem < d and d is 33 bits
674
+ uint32_t full_q = half_q + half_q + ((rem<<1) >= d);
675
+
676
+ // We rounded down in gen (hence +1)
677
+ return full_q + 1;
678
+ }
679
+ }
680
+
681
+ uint32_t libdivide_u32_branchfree_recover(const struct libdivide_u32_branchfree_t *denom) {
682
+ uint8_t more = denom->more;
683
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
684
+
685
+ if (!denom->magic) {
686
+ return 1U << (shift + 1);
687
+ } else {
688
+ // Here we wish to compute d = 2^(32+shift+1)/(m+2^32).
689
+ // Notice (m + 2^32) is a 33 bit number. Use 64 bit division for now
690
+ // Also note that shift may be as high as 31, so shift + 1 will
691
+ // overflow. So we have to compute it as 2^(32+shift)/(m+2^32), and
692
+ // then double the quotient and remainder.
693
+ uint64_t half_n = 1ULL << (32 + shift);
694
+ uint64_t d = (1ULL << 32) | denom->magic;
695
+ // Note that the quotient is guaranteed <= 32 bits, but the remainder
696
+ // may need 33!
697
+ uint32_t half_q = (uint32_t)(half_n / d);
698
+ uint64_t rem = half_n % d;
699
+ // We computed 2^(32+shift)/(m+2^32)
700
+ // Need to double it, and then add 1 to the quotient if doubling th
701
+ // remainder would increase the quotient.
702
+ // Note that rem<<1 cannot overflow, since rem < d and d is 33 bits
703
+ uint32_t full_q = half_q + half_q + ((rem<<1) >= d);
704
+
705
+ // We rounded down in gen (hence +1)
706
+ return full_q + 1;
707
+ }
708
+ }
709
+
710
+ /////////// UINT64
711
+
712
+ static inline struct libdivide_u64_t libdivide_internal_u64_gen(uint64_t d, int branchfree) {
713
+ if (d == 0) {
714
+ LIBDIVIDE_ERROR("divider must be != 0");
715
+ }
716
+
717
+ struct libdivide_u64_t result;
718
+ uint32_t floor_log_2_d = 63 - libdivide_count_leading_zeros64(d);
719
+
720
+ // Power of 2
721
+ if ((d & (d - 1)) == 0) {
722
+ // We need to subtract 1 from the shift value in case of an unsigned
723
+ // branchfree divider because there is a hardcoded right shift by 1
724
+ // in its division algorithm. Because of this we also need to add back
725
+ // 1 in its recovery algorithm.
726
+ result.magic = 0;
727
+ result.more = (uint8_t)(floor_log_2_d - (branchfree != 0));
728
+ } else {
729
+ uint64_t proposed_m, rem;
730
+ uint8_t more;
731
+ // (1 << (64 + floor_log_2_d)) / d
732
+ proposed_m = libdivide_128_div_64_to_64(1ULL << floor_log_2_d, 0, d, &rem);
733
+
734
+ LIBDIVIDE_ASSERT(rem > 0 && rem < d);
735
+ const uint64_t e = d - rem;
736
+
737
+ // This power works if e < 2**floor_log_2_d.
738
+ if (!branchfree && e < (1ULL << floor_log_2_d)) {
739
+ // This power works
740
+ more = floor_log_2_d;
741
+ } else {
742
+ // We have to use the general 65-bit algorithm. We need to compute
743
+ // (2**power) / d. However, we already have (2**(power-1))/d and
744
+ // its remainder. By doubling both, and then correcting the
745
+ // remainder, we can compute the larger division.
746
+ // don't care about overflow here - in fact, we expect it
747
+ proposed_m += proposed_m;
748
+ const uint64_t twice_rem = rem + rem;
749
+ if (twice_rem >= d || twice_rem < rem) proposed_m += 1;
750
+ more = floor_log_2_d | LIBDIVIDE_ADD_MARKER;
751
+ }
752
+ result.magic = 1 + proposed_m;
753
+ result.more = more;
754
+ // result.more's shift should in general be ceil_log_2_d. But if we
755
+ // used the smaller power, we subtract one from the shift because we're
756
+ // using the smaller power. If we're using the larger power, we
757
+ // subtract one from the shift because it's taken care of by the add
758
+ // indicator. So floor_log_2_d happens to be correct in both cases,
759
+ // which is why we do it outside of the if statement.
760
+ }
761
+ return result;
762
+ }
763
+
764
+ struct libdivide_u64_t libdivide_u64_gen(uint64_t d) {
765
+ return libdivide_internal_u64_gen(d, 0);
766
+ }
767
+
768
+ struct libdivide_u64_branchfree_t libdivide_u64_branchfree_gen(uint64_t d) {
769
+ if (d == 1) {
770
+ LIBDIVIDE_ERROR("branchfree divider must be != 1");
771
+ }
772
+ struct libdivide_u64_t tmp = libdivide_internal_u64_gen(d, 1);
773
+ struct libdivide_u64_branchfree_t ret = {tmp.magic, (uint8_t)(tmp.more & LIBDIVIDE_64_SHIFT_MASK)};
774
+ return ret;
775
+ }
776
+
777
+ uint64_t libdivide_u64_do(uint64_t numer, const struct libdivide_u64_t *denom) {
778
+ uint8_t more = denom->more;
779
+ if (!denom->magic) {
780
+ return numer >> more;
781
+ }
782
+ else {
783
+ uint64_t q = libdivide_mullhi_u64(denom->magic, numer);
784
+ if (more & LIBDIVIDE_ADD_MARKER) {
785
+ uint64_t t = ((numer - q) >> 1) + q;
786
+ return t >> (more & LIBDIVIDE_64_SHIFT_MASK);
787
+ }
788
+ else {
789
+ // All upper bits are 0,
790
+ // don't need to mask them off.
791
+ return q >> more;
792
+ }
793
+ }
794
+ }
795
+
796
+ uint64_t libdivide_u64_branchfree_do(uint64_t numer, const struct libdivide_u64_branchfree_t *denom) {
797
+ uint64_t q = libdivide_mullhi_u64(denom->magic, numer);
798
+ uint64_t t = ((numer - q) >> 1) + q;
799
+ return t >> denom->more;
800
+ }
801
+
802
+ uint64_t libdivide_u64_recover(const struct libdivide_u64_t *denom) {
803
+ uint8_t more = denom->more;
804
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
805
+
806
+ if (!denom->magic) {
807
+ return 1ULL << shift;
808
+ } else if (!(more & LIBDIVIDE_ADD_MARKER)) {
809
+ // We compute q = n/d = n*m / 2^(64 + shift)
810
+ // Therefore we have d = 2^(64 + shift) / m
811
+ // We need to ceil it.
812
+ // We know d is not a power of 2, so m is not a power of 2,
813
+ // so we can just add 1 to the floor
814
+ uint64_t hi_dividend = 1ULL << shift;
815
+ uint64_t rem_ignored;
816
+ return 1 + libdivide_128_div_64_to_64(hi_dividend, 0, denom->magic, &rem_ignored);
817
+ } else {
818
+ // Here we wish to compute d = 2^(64+shift+1)/(m+2^64).
819
+ // Notice (m + 2^64) is a 65 bit number. This gets hairy. See
820
+ // libdivide_u32_recover for more on what we do here.
821
+ // TODO: do something better than 128 bit math
822
+
823
+ // Full n is a (potentially) 129 bit value
824
+ // half_n is a 128 bit value
825
+ // Compute the hi half of half_n. Low half is 0.
826
+ uint64_t half_n_hi = 1ULL << shift, half_n_lo = 0;
827
+ // d is a 65 bit value. The high bit is always set to 1.
828
+ const uint64_t d_hi = 1, d_lo = denom->magic;
829
+ // Note that the quotient is guaranteed <= 64 bits,
830
+ // but the remainder may need 65!
831
+ uint64_t r_hi, r_lo;
832
+ uint64_t half_q = libdivide_128_div_128_to_64(half_n_hi, half_n_lo, d_hi, d_lo, &r_hi, &r_lo);
833
+ // We computed 2^(64+shift)/(m+2^64)
834
+ // Double the remainder ('dr') and check if that is larger than d
835
+ // Note that d is a 65 bit value, so r1 is small and so r1 + r1
836
+ // cannot overflow
837
+ uint64_t dr_lo = r_lo + r_lo;
838
+ uint64_t dr_hi = r_hi + r_hi + (dr_lo < r_lo); // last term is carry
839
+ int dr_exceeds_d = (dr_hi > d_hi) || (dr_hi == d_hi && dr_lo >= d_lo);
840
+ uint64_t full_q = half_q + half_q + (dr_exceeds_d ? 1 : 0);
841
+ return full_q + 1;
842
+ }
843
+ }
844
+
845
+ uint64_t libdivide_u64_branchfree_recover(const struct libdivide_u64_branchfree_t *denom) {
846
+ uint8_t more = denom->more;
847
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
848
+
849
+ if (!denom->magic) {
850
+ return 1ULL << (shift + 1);
851
+ } else {
852
+ // Here we wish to compute d = 2^(64+shift+1)/(m+2^64).
853
+ // Notice (m + 2^64) is a 65 bit number. This gets hairy. See
854
+ // libdivide_u32_recover for more on what we do here.
855
+ // TODO: do something better than 128 bit math
856
+
857
+ // Full n is a (potentially) 129 bit value
858
+ // half_n is a 128 bit value
859
+ // Compute the hi half of half_n. Low half is 0.
860
+ uint64_t half_n_hi = 1ULL << shift, half_n_lo = 0;
861
+ // d is a 65 bit value. The high bit is always set to 1.
862
+ const uint64_t d_hi = 1, d_lo = denom->magic;
863
+ // Note that the quotient is guaranteed <= 64 bits,
864
+ // but the remainder may need 65!
865
+ uint64_t r_hi, r_lo;
866
+ uint64_t half_q = libdivide_128_div_128_to_64(half_n_hi, half_n_lo, d_hi, d_lo, &r_hi, &r_lo);
867
+ // We computed 2^(64+shift)/(m+2^64)
868
+ // Double the remainder ('dr') and check if that is larger than d
869
+ // Note that d is a 65 bit value, so r1 is small and so r1 + r1
870
+ // cannot overflow
871
+ uint64_t dr_lo = r_lo + r_lo;
872
+ uint64_t dr_hi = r_hi + r_hi + (dr_lo < r_lo); // last term is carry
873
+ int dr_exceeds_d = (dr_hi > d_hi) || (dr_hi == d_hi && dr_lo >= d_lo);
874
+ uint64_t full_q = half_q + half_q + (dr_exceeds_d ? 1 : 0);
875
+ return full_q + 1;
876
+ }
877
+ }
878
+
879
+ /////////// SINT32
880
+
881
+ static inline struct libdivide_s32_t libdivide_internal_s32_gen(int32_t d, int branchfree) {
882
+ if (d == 0) {
883
+ LIBDIVIDE_ERROR("divider must be != 0");
884
+ }
885
+
886
+ struct libdivide_s32_t result;
887
+
888
+ // If d is a power of 2, or negative a power of 2, we have to use a shift.
889
+ // This is especially important because the magic algorithm fails for -1.
890
+ // To check if d is a power of 2 or its inverse, it suffices to check
891
+ // whether its absolute value has exactly one bit set. This works even for
892
+ // INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set
893
+ // and is a power of 2.
894
+ uint32_t ud = (uint32_t)d;
895
+ uint32_t absD = (d < 0) ? -ud : ud;
896
+ uint32_t floor_log_2_d = 31 - libdivide_count_leading_zeros32(absD);
897
+ // check if exactly one bit is set,
898
+ // don't care if absD is 0 since that's divide by zero
899
+ if ((absD & (absD - 1)) == 0) {
900
+ // Branchfree and normal paths are exactly the same
901
+ result.magic = 0;
902
+ result.more = floor_log_2_d | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0);
903
+ } else {
904
+ LIBDIVIDE_ASSERT(floor_log_2_d >= 1);
905
+
906
+ uint8_t more;
907
+ // the dividend here is 2**(floor_log_2_d + 31), so the low 32 bit word
908
+ // is 0 and the high word is floor_log_2_d - 1
909
+ uint32_t rem, proposed_m;
910
+ proposed_m = libdivide_64_div_32_to_32(1U << (floor_log_2_d - 1), 0, absD, &rem);
911
+ const uint32_t e = absD - rem;
912
+
913
+ // We are going to start with a power of floor_log_2_d - 1.
914
+ // This works if works if e < 2**floor_log_2_d.
915
+ if (!branchfree && e < (1U << floor_log_2_d)) {
916
+ // This power works
917
+ more = floor_log_2_d - 1;
918
+ } else {
919
+ // We need to go one higher. This should not make proposed_m
920
+ // overflow, but it will make it negative when interpreted as an
921
+ // int32_t.
922
+ proposed_m += proposed_m;
923
+ const uint32_t twice_rem = rem + rem;
924
+ if (twice_rem >= absD || twice_rem < rem) proposed_m += 1;
925
+ more = floor_log_2_d | LIBDIVIDE_ADD_MARKER;
926
+ }
927
+
928
+ proposed_m += 1;
929
+ int32_t magic = (int32_t)proposed_m;
930
+
931
+ // Mark if we are negative. Note we only negate the magic number in the
932
+ // branchfull case.
933
+ if (d < 0) {
934
+ more |= LIBDIVIDE_NEGATIVE_DIVISOR;
935
+ if (!branchfree) {
936
+ magic = -magic;
937
+ }
938
+ }
939
+
940
+ result.more = more;
941
+ result.magic = magic;
942
+ }
943
+ return result;
944
+ }
945
+
946
+ struct libdivide_s32_t libdivide_s32_gen(int32_t d) {
947
+ return libdivide_internal_s32_gen(d, 0);
948
+ }
949
+
950
+ struct libdivide_s32_branchfree_t libdivide_s32_branchfree_gen(int32_t d) {
951
+ struct libdivide_s32_t tmp = libdivide_internal_s32_gen(d, 1);
952
+ struct libdivide_s32_branchfree_t result = {tmp.magic, tmp.more};
953
+ return result;
954
+ }
955
+
956
+ int32_t libdivide_s32_do(int32_t numer, const struct libdivide_s32_t *denom) {
957
+ uint8_t more = denom->more;
958
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
959
+
960
+ if (!denom->magic) {
961
+ uint32_t sign = (int8_t)more >> 7;
962
+ uint32_t mask = (1U << shift) - 1;
963
+ uint32_t uq = numer + ((numer >> 31) & mask);
964
+ int32_t q = (int32_t)uq;
965
+ q >>= shift;
966
+ q = (q ^ sign) - sign;
967
+ return q;
968
+ } else {
969
+ uint32_t uq = (uint32_t)libdivide_mullhi_s32(denom->magic, numer);
970
+ if (more & LIBDIVIDE_ADD_MARKER) {
971
+ // must be arithmetic shift and then sign extend
972
+ int32_t sign = (int8_t)more >> 7;
973
+ // q += (more < 0 ? -numer : numer)
974
+ // cast required to avoid UB
975
+ uq += ((uint32_t)numer ^ sign) - sign;
976
+ }
977
+ int32_t q = (int32_t)uq;
978
+ q >>= shift;
979
+ q += (q < 0);
980
+ return q;
981
+ }
982
+ }
983
+
984
+ int32_t libdivide_s32_branchfree_do(int32_t numer, const struct libdivide_s32_branchfree_t *denom) {
985
+ uint8_t more = denom->more;
986
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
987
+ // must be arithmetic shift and then sign extend
988
+ int32_t sign = (int8_t)more >> 7;
989
+ int32_t magic = denom->magic;
990
+ int32_t q = libdivide_mullhi_s32(magic, numer);
991
+ q += numer;
992
+
993
+ // If q is non-negative, we have nothing to do
994
+ // If q is negative, we want to add either (2**shift)-1 if d is a power of
995
+ // 2, or (2**shift) if it is not a power of 2
996
+ uint32_t is_power_of_2 = (magic == 0);
997
+ uint32_t q_sign = (uint32_t)(q >> 31);
998
+ q += q_sign & ((1U << shift) - is_power_of_2);
999
+
1000
+ // Now arithmetic right shift
1001
+ q >>= shift;
1002
+ // Negate if needed
1003
+ q = (q ^ sign) - sign;
1004
+
1005
+ return q;
1006
+ }
1007
+
1008
+ int32_t libdivide_s32_recover(const struct libdivide_s32_t *denom) {
1009
+ uint8_t more = denom->more;
1010
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1011
+ if (!denom->magic) {
1012
+ uint32_t absD = 1U << shift;
1013
+ if (more & LIBDIVIDE_NEGATIVE_DIVISOR) {
1014
+ absD = -absD;
1015
+ }
1016
+ return (int32_t)absD;
1017
+ } else {
1018
+ // Unsigned math is much easier
1019
+ // We negate the magic number only in the branchfull case, and we don't
1020
+ // know which case we're in. However we have enough information to
1021
+ // determine the correct sign of the magic number. The divisor was
1022
+ // negative if LIBDIVIDE_NEGATIVE_DIVISOR is set. If ADD_MARKER is set,
1023
+ // the magic number's sign is opposite that of the divisor.
1024
+ // We want to compute the positive magic number.
1025
+ int negative_divisor = (more & LIBDIVIDE_NEGATIVE_DIVISOR);
1026
+ int magic_was_negated = (more & LIBDIVIDE_ADD_MARKER)
1027
+ ? denom->magic > 0 : denom->magic < 0;
1028
+
1029
+ // Handle the power of 2 case (including branchfree)
1030
+ if (denom->magic == 0) {
1031
+ int32_t result = 1U << shift;
1032
+ return negative_divisor ? -result : result;
1033
+ }
1034
+
1035
+ uint32_t d = (uint32_t)(magic_was_negated ? -denom->magic : denom->magic);
1036
+ uint64_t n = 1ULL << (32 + shift); // this shift cannot exceed 30
1037
+ uint32_t q = (uint32_t)(n / d);
1038
+ int32_t result = (int32_t)q;
1039
+ result += 1;
1040
+ return negative_divisor ? -result : result;
1041
+ }
1042
+ }
1043
+
1044
+ int32_t libdivide_s32_branchfree_recover(const struct libdivide_s32_branchfree_t *denom) {
1045
+ return libdivide_s32_recover((const struct libdivide_s32_t *)denom);
1046
+ }
1047
+
1048
+ ///////////// SINT64
1049
+
1050
+ static inline struct libdivide_s64_t libdivide_internal_s64_gen(int64_t d, int branchfree) {
1051
+ if (d == 0) {
1052
+ LIBDIVIDE_ERROR("divider must be != 0");
1053
+ }
1054
+
1055
+ struct libdivide_s64_t result;
1056
+
1057
+ // If d is a power of 2, or negative a power of 2, we have to use a shift.
1058
+ // This is especially important because the magic algorithm fails for -1.
1059
+ // To check if d is a power of 2 or its inverse, it suffices to check
1060
+ // whether its absolute value has exactly one bit set. This works even for
1061
+ // INT_MIN, because abs(INT_MIN) == INT_MIN, and INT_MIN has one bit set
1062
+ // and is a power of 2.
1063
+ uint64_t ud = (uint64_t)d;
1064
+ uint64_t absD = (d < 0) ? -ud : ud;
1065
+ uint32_t floor_log_2_d = 63 - libdivide_count_leading_zeros64(absD);
1066
+ // check if exactly one bit is set,
1067
+ // don't care if absD is 0 since that's divide by zero
1068
+ if ((absD & (absD - 1)) == 0) {
1069
+ // Branchfree and non-branchfree cases are the same
1070
+ result.magic = 0;
1071
+ result.more = floor_log_2_d | (d < 0 ? LIBDIVIDE_NEGATIVE_DIVISOR : 0);
1072
+ } else {
1073
+ // the dividend here is 2**(floor_log_2_d + 63), so the low 64 bit word
1074
+ // is 0 and the high word is floor_log_2_d - 1
1075
+ uint8_t more;
1076
+ uint64_t rem, proposed_m;
1077
+ proposed_m = libdivide_128_div_64_to_64(1ULL << (floor_log_2_d - 1), 0, absD, &rem);
1078
+ const uint64_t e = absD - rem;
1079
+
1080
+ // We are going to start with a power of floor_log_2_d - 1.
1081
+ // This works if works if e < 2**floor_log_2_d.
1082
+ if (!branchfree && e < (1ULL << floor_log_2_d)) {
1083
+ // This power works
1084
+ more = floor_log_2_d - 1;
1085
+ } else {
1086
+ // We need to go one higher. This should not make proposed_m
1087
+ // overflow, but it will make it negative when interpreted as an
1088
+ // int32_t.
1089
+ proposed_m += proposed_m;
1090
+ const uint64_t twice_rem = rem + rem;
1091
+ if (twice_rem >= absD || twice_rem < rem) proposed_m += 1;
1092
+ // note that we only set the LIBDIVIDE_NEGATIVE_DIVISOR bit if we
1093
+ // also set ADD_MARKER this is an annoying optimization that
1094
+ // enables algorithm #4 to avoid the mask. However we always set it
1095
+ // in the branchfree case
1096
+ more = floor_log_2_d | LIBDIVIDE_ADD_MARKER;
1097
+ }
1098
+ proposed_m += 1;
1099
+ int64_t magic = (int64_t)proposed_m;
1100
+
1101
+ // Mark if we are negative
1102
+ if (d < 0) {
1103
+ more |= LIBDIVIDE_NEGATIVE_DIVISOR;
1104
+ if (!branchfree) {
1105
+ magic = -magic;
1106
+ }
1107
+ }
1108
+
1109
+ result.more = more;
1110
+ result.magic = magic;
1111
+ }
1112
+ return result;
1113
+ }
1114
+
1115
+ struct libdivide_s64_t libdivide_s64_gen(int64_t d) {
1116
+ return libdivide_internal_s64_gen(d, 0);
1117
+ }
1118
+
1119
+ struct libdivide_s64_branchfree_t libdivide_s64_branchfree_gen(int64_t d) {
1120
+ struct libdivide_s64_t tmp = libdivide_internal_s64_gen(d, 1);
1121
+ struct libdivide_s64_branchfree_t ret = {tmp.magic, tmp.more};
1122
+ return ret;
1123
+ }
1124
+
1125
+ int64_t libdivide_s64_do(int64_t numer, const struct libdivide_s64_t *denom) {
1126
+ uint8_t more = denom->more;
1127
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1128
+
1129
+ if (!denom->magic) { // shift path
1130
+ uint64_t mask = (1ULL << shift) - 1;
1131
+ uint64_t uq = numer + ((numer >> 63) & mask);
1132
+ int64_t q = (int64_t)uq;
1133
+ q >>= shift;
1134
+ // must be arithmetic shift and then sign-extend
1135
+ int64_t sign = (int8_t)more >> 7;
1136
+ q = (q ^ sign) - sign;
1137
+ return q;
1138
+ } else {
1139
+ uint64_t uq = (uint64_t)libdivide_mullhi_s64(denom->magic, numer);
1140
+ if (more & LIBDIVIDE_ADD_MARKER) {
1141
+ // must be arithmetic shift and then sign extend
1142
+ int64_t sign = (int8_t)more >> 7;
1143
+ // q += (more < 0 ? -numer : numer)
1144
+ // cast required to avoid UB
1145
+ uq += ((uint64_t)numer ^ sign) - sign;
1146
+ }
1147
+ int64_t q = (int64_t)uq;
1148
+ q >>= shift;
1149
+ q += (q < 0);
1150
+ return q;
1151
+ }
1152
+ }
1153
+
1154
+ int64_t libdivide_s64_branchfree_do(int64_t numer, const struct libdivide_s64_branchfree_t *denom) {
1155
+ uint8_t more = denom->more;
1156
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1157
+ // must be arithmetic shift and then sign extend
1158
+ int64_t sign = (int8_t)more >> 7;
1159
+ int64_t magic = denom->magic;
1160
+ int64_t q = libdivide_mullhi_s64(magic, numer);
1161
+ q += numer;
1162
+
1163
+ // If q is non-negative, we have nothing to do.
1164
+ // If q is negative, we want to add either (2**shift)-1 if d is a power of
1165
+ // 2, or (2**shift) if it is not a power of 2.
1166
+ uint64_t is_power_of_2 = (magic == 0);
1167
+ uint64_t q_sign = (uint64_t)(q >> 63);
1168
+ q += q_sign & ((1ULL << shift) - is_power_of_2);
1169
+
1170
+ // Arithmetic right shift
1171
+ q >>= shift;
1172
+ // Negate if needed
1173
+ q = (q ^ sign) - sign;
1174
+
1175
+ return q;
1176
+ }
1177
+
1178
+ int64_t libdivide_s64_recover(const struct libdivide_s64_t *denom) {
1179
+ uint8_t more = denom->more;
1180
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1181
+ if (denom->magic == 0) { // shift path
1182
+ uint64_t absD = 1ULL << shift;
1183
+ if (more & LIBDIVIDE_NEGATIVE_DIVISOR) {
1184
+ absD = -absD;
1185
+ }
1186
+ return (int64_t)absD;
1187
+ } else {
1188
+ // Unsigned math is much easier
1189
+ int negative_divisor = (more & LIBDIVIDE_NEGATIVE_DIVISOR);
1190
+ int magic_was_negated = (more & LIBDIVIDE_ADD_MARKER)
1191
+ ? denom->magic > 0 : denom->magic < 0;
1192
+
1193
+ uint64_t d = (uint64_t)(magic_was_negated ? -denom->magic : denom->magic);
1194
+ uint64_t n_hi = 1ULL << shift, n_lo = 0;
1195
+ uint64_t rem_ignored;
1196
+ uint64_t q = libdivide_128_div_64_to_64(n_hi, n_lo, d, &rem_ignored);
1197
+ int64_t result = (int64_t)(q + 1);
1198
+ if (negative_divisor) {
1199
+ result = -result;
1200
+ }
1201
+ return result;
1202
+ }
1203
+ }
1204
+
1205
+ int64_t libdivide_s64_branchfree_recover(const struct libdivide_s64_branchfree_t *denom) {
1206
+ return libdivide_s64_recover((const struct libdivide_s64_t *)denom);
1207
+ }
1208
+
1209
+ #if defined(LIBDIVIDE_AVX512)
1210
+
1211
+ static inline __m512i libdivide_u32_do_vector(__m512i numers, const struct libdivide_u32_t *denom);
1212
+ static inline __m512i libdivide_s32_do_vector(__m512i numers, const struct libdivide_s32_t *denom);
1213
+ static inline __m512i libdivide_u64_do_vector(__m512i numers, const struct libdivide_u64_t *denom);
1214
+ static inline __m512i libdivide_s64_do_vector(__m512i numers, const struct libdivide_s64_t *denom);
1215
+
1216
+ static inline __m512i libdivide_u32_branchfree_do_vector(__m512i numers, const struct libdivide_u32_branchfree_t *denom);
1217
+ static inline __m512i libdivide_s32_branchfree_do_vector(__m512i numers, const struct libdivide_s32_branchfree_t *denom);
1218
+ static inline __m512i libdivide_u64_branchfree_do_vector(__m512i numers, const struct libdivide_u64_branchfree_t *denom);
1219
+ static inline __m512i libdivide_s64_branchfree_do_vector(__m512i numers, const struct libdivide_s64_branchfree_t *denom);
1220
+
1221
+ //////// Internal Utility Functions
1222
+
1223
+ static inline __m512i libdivide_s64_signbits(__m512i v) {;
1224
+ return _mm512_srai_epi64(v, 63);
1225
+ }
1226
+
1227
+ static inline __m512i libdivide_s64_shift_right_vector(__m512i v, int amt) {
1228
+ return _mm512_srai_epi64(v, amt);
1229
+ }
1230
+
1231
+ // Here, b is assumed to contain one 32-bit value repeated.
1232
+ static inline __m512i libdivide_mullhi_u32_vector(__m512i a, __m512i b) {
1233
+ __m512i hi_product_0Z2Z = _mm512_srli_epi64(_mm512_mul_epu32(a, b), 32);
1234
+ __m512i a1X3X = _mm512_srli_epi64(a, 32);
1235
+ __m512i mask = _mm512_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0);
1236
+ __m512i hi_product_Z1Z3 = _mm512_and_si512(_mm512_mul_epu32(a1X3X, b), mask);
1237
+ return _mm512_or_si512(hi_product_0Z2Z, hi_product_Z1Z3);
1238
+ }
1239
+
1240
+ // b is one 32-bit value repeated.
1241
+ static inline __m512i libdivide_mullhi_s32_vector(__m512i a, __m512i b) {
1242
+ __m512i hi_product_0Z2Z = _mm512_srli_epi64(_mm512_mul_epi32(a, b), 32);
1243
+ __m512i a1X3X = _mm512_srli_epi64(a, 32);
1244
+ __m512i mask = _mm512_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0);
1245
+ __m512i hi_product_Z1Z3 = _mm512_and_si512(_mm512_mul_epi32(a1X3X, b), mask);
1246
+ return _mm512_or_si512(hi_product_0Z2Z, hi_product_Z1Z3);
1247
+ }
1248
+
1249
+ // Here, y is assumed to contain one 64-bit value repeated.
1250
+ // https://stackoverflow.com/a/28827013
1251
+ static inline __m512i libdivide_mullhi_u64_vector(__m512i x, __m512i y) {
1252
+ __m512i lomask = _mm512_set1_epi64(0xffffffff);
1253
+ __m512i xh = _mm512_shuffle_epi32(x, (_MM_PERM_ENUM) 0xB1);
1254
+ __m512i yh = _mm512_shuffle_epi32(y, (_MM_PERM_ENUM) 0xB1);
1255
+ __m512i w0 = _mm512_mul_epu32(x, y);
1256
+ __m512i w1 = _mm512_mul_epu32(x, yh);
1257
+ __m512i w2 = _mm512_mul_epu32(xh, y);
1258
+ __m512i w3 = _mm512_mul_epu32(xh, yh);
1259
+ __m512i w0h = _mm512_srli_epi64(w0, 32);
1260
+ __m512i s1 = _mm512_add_epi64(w1, w0h);
1261
+ __m512i s1l = _mm512_and_si512(s1, lomask);
1262
+ __m512i s1h = _mm512_srli_epi64(s1, 32);
1263
+ __m512i s2 = _mm512_add_epi64(w2, s1l);
1264
+ __m512i s2h = _mm512_srli_epi64(s2, 32);
1265
+ __m512i hi = _mm512_add_epi64(w3, s1h);
1266
+ hi = _mm512_add_epi64(hi, s2h);
1267
+
1268
+ return hi;
1269
+ }
1270
+
1271
+ // y is one 64-bit value repeated.
1272
+ static inline __m512i libdivide_mullhi_s64_vector(__m512i x, __m512i y) {
1273
+ __m512i p = libdivide_mullhi_u64_vector(x, y);
1274
+ __m512i t1 = _mm512_and_si512(libdivide_s64_signbits(x), y);
1275
+ __m512i t2 = _mm512_and_si512(libdivide_s64_signbits(y), x);
1276
+ p = _mm512_sub_epi64(p, t1);
1277
+ p = _mm512_sub_epi64(p, t2);
1278
+ return p;
1279
+ }
1280
+
1281
+ ////////// UINT32
1282
+
1283
+ __m512i libdivide_u32_do_vector(__m512i numers, const struct libdivide_u32_t *denom) {
1284
+ uint8_t more = denom->more;
1285
+ if (!denom->magic) {
1286
+ return _mm512_srli_epi32(numers, more);
1287
+ }
1288
+ else {
1289
+ __m512i q = libdivide_mullhi_u32_vector(numers, _mm512_set1_epi32(denom->magic));
1290
+ if (more & LIBDIVIDE_ADD_MARKER) {
1291
+ // uint32_t t = ((numer - q) >> 1) + q;
1292
+ // return t >> denom->shift;
1293
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1294
+ __m512i t = _mm512_add_epi32(_mm512_srli_epi32(_mm512_sub_epi32(numers, q), 1), q);
1295
+ return _mm512_srli_epi32(t, shift);
1296
+ }
1297
+ else {
1298
+ return _mm512_srli_epi32(q, more);
1299
+ }
1300
+ }
1301
+ }
1302
+
1303
+ __m512i libdivide_u32_branchfree_do_vector(__m512i numers, const struct libdivide_u32_branchfree_t *denom) {
1304
+ __m512i q = libdivide_mullhi_u32_vector(numers, _mm512_set1_epi32(denom->magic));
1305
+ __m512i t = _mm512_add_epi32(_mm512_srli_epi32(_mm512_sub_epi32(numers, q), 1), q);
1306
+ return _mm512_srli_epi32(t, denom->more);
1307
+ }
1308
+
1309
+ ////////// UINT64
1310
+
1311
+ __m512i libdivide_u64_do_vector(__m512i numers, const struct libdivide_u64_t *denom) {
1312
+ uint8_t more = denom->more;
1313
+ if (!denom->magic) {
1314
+ return _mm512_srli_epi64(numers, more);
1315
+ }
1316
+ else {
1317
+ __m512i q = libdivide_mullhi_u64_vector(numers, _mm512_set1_epi64(denom->magic));
1318
+ if (more & LIBDIVIDE_ADD_MARKER) {
1319
+ // uint32_t t = ((numer - q) >> 1) + q;
1320
+ // return t >> denom->shift;
1321
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1322
+ __m512i t = _mm512_add_epi64(_mm512_srli_epi64(_mm512_sub_epi64(numers, q), 1), q);
1323
+ return _mm512_srli_epi64(t, shift);
1324
+ }
1325
+ else {
1326
+ return _mm512_srli_epi64(q, more);
1327
+ }
1328
+ }
1329
+ }
1330
+
1331
+ __m512i libdivide_u64_branchfree_do_vector(__m512i numers, const struct libdivide_u64_branchfree_t *denom) {
1332
+ __m512i q = libdivide_mullhi_u64_vector(numers, _mm512_set1_epi64(denom->magic));
1333
+ __m512i t = _mm512_add_epi64(_mm512_srli_epi64(_mm512_sub_epi64(numers, q), 1), q);
1334
+ return _mm512_srli_epi64(t, denom->more);
1335
+ }
1336
+
1337
+ ////////// SINT32
1338
+
1339
+ __m512i libdivide_s32_do_vector(__m512i numers, const struct libdivide_s32_t *denom) {
1340
+ uint8_t more = denom->more;
1341
+ if (!denom->magic) {
1342
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1343
+ uint32_t mask = (1U << shift) - 1;
1344
+ __m512i roundToZeroTweak = _mm512_set1_epi32(mask);
1345
+ // q = numer + ((numer >> 31) & roundToZeroTweak);
1346
+ __m512i q = _mm512_add_epi32(numers, _mm512_and_si512(_mm512_srai_epi32(numers, 31), roundToZeroTweak));
1347
+ q = _mm512_srai_epi32(q, shift);
1348
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1349
+ // q = (q ^ sign) - sign;
1350
+ q = _mm512_sub_epi32(_mm512_xor_si512(q, sign), sign);
1351
+ return q;
1352
+ }
1353
+ else {
1354
+ __m512i q = libdivide_mullhi_s32_vector(numers, _mm512_set1_epi32(denom->magic));
1355
+ if (more & LIBDIVIDE_ADD_MARKER) {
1356
+ // must be arithmetic shift
1357
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1358
+ // q += ((numer ^ sign) - sign);
1359
+ q = _mm512_add_epi32(q, _mm512_sub_epi32(_mm512_xor_si512(numers, sign), sign));
1360
+ }
1361
+ // q >>= shift
1362
+ q = _mm512_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK);
1363
+ q = _mm512_add_epi32(q, _mm512_srli_epi32(q, 31)); // q += (q < 0)
1364
+ return q;
1365
+ }
1366
+ }
1367
+
1368
+ __m512i libdivide_s32_branchfree_do_vector(__m512i numers, const struct libdivide_s32_branchfree_t *denom) {
1369
+ int32_t magic = denom->magic;
1370
+ uint8_t more = denom->more;
1371
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1372
+ // must be arithmetic shift
1373
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1374
+ __m512i q = libdivide_mullhi_s32_vector(numers, _mm512_set1_epi32(magic));
1375
+ q = _mm512_add_epi32(q, numers); // q += numers
1376
+
1377
+ // If q is non-negative, we have nothing to do
1378
+ // If q is negative, we want to add either (2**shift)-1 if d is
1379
+ // a power of 2, or (2**shift) if it is not a power of 2
1380
+ uint32_t is_power_of_2 = (magic == 0);
1381
+ __m512i q_sign = _mm512_srai_epi32(q, 31); // q_sign = q >> 31
1382
+ __m512i mask = _mm512_set1_epi32((1U << shift) - is_power_of_2);
1383
+ q = _mm512_add_epi32(q, _mm512_and_si512(q_sign, mask)); // q = q + (q_sign & mask)
1384
+ q = _mm512_srai_epi32(q, shift); // q >>= shift
1385
+ q = _mm512_sub_epi32(_mm512_xor_si512(q, sign), sign); // q = (q ^ sign) - sign
1386
+ return q;
1387
+ }
1388
+
1389
+ ////////// SINT64
1390
+
1391
+ __m512i libdivide_s64_do_vector(__m512i numers, const struct libdivide_s64_t *denom) {
1392
+ uint8_t more = denom->more;
1393
+ int64_t magic = denom->magic;
1394
+ if (magic == 0) { // shift path
1395
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1396
+ uint64_t mask = (1ULL << shift) - 1;
1397
+ __m512i roundToZeroTweak = _mm512_set1_epi64(mask);
1398
+ // q = numer + ((numer >> 63) & roundToZeroTweak);
1399
+ __m512i q = _mm512_add_epi64(numers, _mm512_and_si512(libdivide_s64_signbits(numers), roundToZeroTweak));
1400
+ q = libdivide_s64_shift_right_vector(q, shift);
1401
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1402
+ // q = (q ^ sign) - sign;
1403
+ q = _mm512_sub_epi64(_mm512_xor_si512(q, sign), sign);
1404
+ return q;
1405
+ }
1406
+ else {
1407
+ __m512i q = libdivide_mullhi_s64_vector(numers, _mm512_set1_epi64(magic));
1408
+ if (more & LIBDIVIDE_ADD_MARKER) {
1409
+ // must be arithmetic shift
1410
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1411
+ // q += ((numer ^ sign) - sign);
1412
+ q = _mm512_add_epi64(q, _mm512_sub_epi64(_mm512_xor_si512(numers, sign), sign));
1413
+ }
1414
+ // q >>= denom->mult_path.shift
1415
+ q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK);
1416
+ q = _mm512_add_epi64(q, _mm512_srli_epi64(q, 63)); // q += (q < 0)
1417
+ return q;
1418
+ }
1419
+ }
1420
+
1421
+ __m512i libdivide_s64_branchfree_do_vector(__m512i numers, const struct libdivide_s64_branchfree_t *denom) {
1422
+ int64_t magic = denom->magic;
1423
+ uint8_t more = denom->more;
1424
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1425
+ // must be arithmetic shift
1426
+ __m512i sign = _mm512_set1_epi32((int8_t)more >> 7);
1427
+
1428
+ // libdivide_mullhi_s64(numers, magic);
1429
+ __m512i q = libdivide_mullhi_s64_vector(numers, _mm512_set1_epi64(magic));
1430
+ q = _mm512_add_epi64(q, numers); // q += numers
1431
+
1432
+ // If q is non-negative, we have nothing to do.
1433
+ // If q is negative, we want to add either (2**shift)-1 if d is
1434
+ // a power of 2, or (2**shift) if it is not a power of 2.
1435
+ uint32_t is_power_of_2 = (magic == 0);
1436
+ __m512i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63
1437
+ __m512i mask = _mm512_set1_epi64((1ULL << shift) - is_power_of_2);
1438
+ q = _mm512_add_epi64(q, _mm512_and_si512(q_sign, mask)); // q = q + (q_sign & mask)
1439
+ q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift
1440
+ q = _mm512_sub_epi64(_mm512_xor_si512(q, sign), sign); // q = (q ^ sign) - sign
1441
+ return q;
1442
+ }
1443
+
1444
+ #elif defined(LIBDIVIDE_AVX2)
1445
+
1446
+ static inline __m256i libdivide_u32_do_vector(__m256i numers, const struct libdivide_u32_t *denom);
1447
+ static inline __m256i libdivide_s32_do_vector(__m256i numers, const struct libdivide_s32_t *denom);
1448
+ static inline __m256i libdivide_u64_do_vector(__m256i numers, const struct libdivide_u64_t *denom);
1449
+ static inline __m256i libdivide_s64_do_vector(__m256i numers, const struct libdivide_s64_t *denom);
1450
+
1451
+ static inline __m256i libdivide_u32_branchfree_do_vector(__m256i numers, const struct libdivide_u32_branchfree_t *denom);
1452
+ static inline __m256i libdivide_s32_branchfree_do_vector(__m256i numers, const struct libdivide_s32_branchfree_t *denom);
1453
+ static inline __m256i libdivide_u64_branchfree_do_vector(__m256i numers, const struct libdivide_u64_branchfree_t *denom);
1454
+ static inline __m256i libdivide_s64_branchfree_do_vector(__m256i numers, const struct libdivide_s64_branchfree_t *denom);
1455
+
1456
+ //////// Internal Utility Functions
1457
+
1458
+ // Implementation of _mm256_srai_epi64(v, 63) (from AVX512).
1459
+ static inline __m256i libdivide_s64_signbits(__m256i v) {
1460
+ __m256i hiBitsDuped = _mm256_shuffle_epi32(v, _MM_SHUFFLE(3, 3, 1, 1));
1461
+ __m256i signBits = _mm256_srai_epi32(hiBitsDuped, 31);
1462
+ return signBits;
1463
+ }
1464
+
1465
+ // Implementation of _mm256_srai_epi64 (from AVX512).
1466
+ static inline __m256i libdivide_s64_shift_right_vector(__m256i v, int amt) {
1467
+ const int b = 64 - amt;
1468
+ __m256i m = _mm256_set1_epi64x(1ULL << (b - 1));
1469
+ __m256i x = _mm256_srli_epi64(v, amt);
1470
+ __m256i result = _mm256_sub_epi64(_mm256_xor_si256(x, m), m);
1471
+ return result;
1472
+ }
1473
+
1474
+ // Here, b is assumed to contain one 32-bit value repeated.
1475
+ static inline __m256i libdivide_mullhi_u32_vector(__m256i a, __m256i b) {
1476
+ __m256i hi_product_0Z2Z = _mm256_srli_epi64(_mm256_mul_epu32(a, b), 32);
1477
+ __m256i a1X3X = _mm256_srli_epi64(a, 32);
1478
+ __m256i mask = _mm256_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0);
1479
+ __m256i hi_product_Z1Z3 = _mm256_and_si256(_mm256_mul_epu32(a1X3X, b), mask);
1480
+ return _mm256_or_si256(hi_product_0Z2Z, hi_product_Z1Z3);
1481
+ }
1482
+
1483
+ // b is one 32-bit value repeated.
1484
+ static inline __m256i libdivide_mullhi_s32_vector(__m256i a, __m256i b) {
1485
+ __m256i hi_product_0Z2Z = _mm256_srli_epi64(_mm256_mul_epi32(a, b), 32);
1486
+ __m256i a1X3X = _mm256_srli_epi64(a, 32);
1487
+ __m256i mask = _mm256_set_epi32(-1, 0, -1, 0, -1, 0, -1, 0);
1488
+ __m256i hi_product_Z1Z3 = _mm256_and_si256(_mm256_mul_epi32(a1X3X, b), mask);
1489
+ return _mm256_or_si256(hi_product_0Z2Z, hi_product_Z1Z3);
1490
+ }
1491
+
1492
+ // Here, y is assumed to contain one 64-bit value repeated.
1493
+ // https://stackoverflow.com/a/28827013
1494
+ static inline __m256i libdivide_mullhi_u64_vector(__m256i x, __m256i y) {
1495
+ __m256i lomask = _mm256_set1_epi64x(0xffffffff);
1496
+ __m256i xh = _mm256_shuffle_epi32(x, 0xB1); // x0l, x0h, x1l, x1h
1497
+ __m256i yh = _mm256_shuffle_epi32(y, 0xB1); // y0l, y0h, y1l, y1h
1498
+ __m256i w0 = _mm256_mul_epu32(x, y); // x0l*y0l, x1l*y1l
1499
+ __m256i w1 = _mm256_mul_epu32(x, yh); // x0l*y0h, x1l*y1h
1500
+ __m256i w2 = _mm256_mul_epu32(xh, y); // x0h*y0l, x1h*y0l
1501
+ __m256i w3 = _mm256_mul_epu32(xh, yh); // x0h*y0h, x1h*y1h
1502
+ __m256i w0h = _mm256_srli_epi64(w0, 32);
1503
+ __m256i s1 = _mm256_add_epi64(w1, w0h);
1504
+ __m256i s1l = _mm256_and_si256(s1, lomask);
1505
+ __m256i s1h = _mm256_srli_epi64(s1, 32);
1506
+ __m256i s2 = _mm256_add_epi64(w2, s1l);
1507
+ __m256i s2h = _mm256_srli_epi64(s2, 32);
1508
+ __m256i hi = _mm256_add_epi64(w3, s1h);
1509
+ hi = _mm256_add_epi64(hi, s2h);
1510
+
1511
+ return hi;
1512
+ }
1513
+
1514
+ // y is one 64-bit value repeated.
1515
+ static inline __m256i libdivide_mullhi_s64_vector(__m256i x, __m256i y) {
1516
+ __m256i p = libdivide_mullhi_u64_vector(x, y);
1517
+ __m256i t1 = _mm256_and_si256(libdivide_s64_signbits(x), y);
1518
+ __m256i t2 = _mm256_and_si256(libdivide_s64_signbits(y), x);
1519
+ p = _mm256_sub_epi64(p, t1);
1520
+ p = _mm256_sub_epi64(p, t2);
1521
+ return p;
1522
+ }
1523
+
1524
+ ////////// UINT32
1525
+
1526
+ __m256i libdivide_u32_do_vector(__m256i numers, const struct libdivide_u32_t *denom) {
1527
+ uint8_t more = denom->more;
1528
+ if (!denom->magic) {
1529
+ return _mm256_srli_epi32(numers, more);
1530
+ }
1531
+ else {
1532
+ __m256i q = libdivide_mullhi_u32_vector(numers, _mm256_set1_epi32(denom->magic));
1533
+ if (more & LIBDIVIDE_ADD_MARKER) {
1534
+ // uint32_t t = ((numer - q) >> 1) + q;
1535
+ // return t >> denom->shift;
1536
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1537
+ __m256i t = _mm256_add_epi32(_mm256_srli_epi32(_mm256_sub_epi32(numers, q), 1), q);
1538
+ return _mm256_srli_epi32(t, shift);
1539
+ }
1540
+ else {
1541
+ return _mm256_srli_epi32(q, more);
1542
+ }
1543
+ }
1544
+ }
1545
+
1546
+ __m256i libdivide_u32_branchfree_do_vector(__m256i numers, const struct libdivide_u32_branchfree_t *denom) {
1547
+ __m256i q = libdivide_mullhi_u32_vector(numers, _mm256_set1_epi32(denom->magic));
1548
+ __m256i t = _mm256_add_epi32(_mm256_srli_epi32(_mm256_sub_epi32(numers, q), 1), q);
1549
+ return _mm256_srli_epi32(t, denom->more);
1550
+ }
1551
+
1552
+ ////////// UINT64
1553
+
1554
+ __m256i libdivide_u64_do_vector(__m256i numers, const struct libdivide_u64_t *denom) {
1555
+ uint8_t more = denom->more;
1556
+ if (!denom->magic) {
1557
+ return _mm256_srli_epi64(numers, more);
1558
+ }
1559
+ else {
1560
+ __m256i q = libdivide_mullhi_u64_vector(numers, _mm256_set1_epi64x(denom->magic));
1561
+ if (more & LIBDIVIDE_ADD_MARKER) {
1562
+ // uint32_t t = ((numer - q) >> 1) + q;
1563
+ // return t >> denom->shift;
1564
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1565
+ __m256i t = _mm256_add_epi64(_mm256_srli_epi64(_mm256_sub_epi64(numers, q), 1), q);
1566
+ return _mm256_srli_epi64(t, shift);
1567
+ }
1568
+ else {
1569
+ return _mm256_srli_epi64(q, more);
1570
+ }
1571
+ }
1572
+ }
1573
+
1574
+ __m256i libdivide_u64_branchfree_do_vector(__m256i numers, const struct libdivide_u64_branchfree_t *denom) {
1575
+ __m256i q = libdivide_mullhi_u64_vector(numers, _mm256_set1_epi64x(denom->magic));
1576
+ __m256i t = _mm256_add_epi64(_mm256_srli_epi64(_mm256_sub_epi64(numers, q), 1), q);
1577
+ return _mm256_srli_epi64(t, denom->more);
1578
+ }
1579
+
1580
+ ////////// SINT32
1581
+
1582
+ __m256i libdivide_s32_do_vector(__m256i numers, const struct libdivide_s32_t *denom) {
1583
+ uint8_t more = denom->more;
1584
+ if (!denom->magic) {
1585
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1586
+ uint32_t mask = (1U << shift) - 1;
1587
+ __m256i roundToZeroTweak = _mm256_set1_epi32(mask);
1588
+ // q = numer + ((numer >> 31) & roundToZeroTweak);
1589
+ __m256i q = _mm256_add_epi32(numers, _mm256_and_si256(_mm256_srai_epi32(numers, 31), roundToZeroTweak));
1590
+ q = _mm256_srai_epi32(q, shift);
1591
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1592
+ // q = (q ^ sign) - sign;
1593
+ q = _mm256_sub_epi32(_mm256_xor_si256(q, sign), sign);
1594
+ return q;
1595
+ }
1596
+ else {
1597
+ __m256i q = libdivide_mullhi_s32_vector(numers, _mm256_set1_epi32(denom->magic));
1598
+ if (more & LIBDIVIDE_ADD_MARKER) {
1599
+ // must be arithmetic shift
1600
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1601
+ // q += ((numer ^ sign) - sign);
1602
+ q = _mm256_add_epi32(q, _mm256_sub_epi32(_mm256_xor_si256(numers, sign), sign));
1603
+ }
1604
+ // q >>= shift
1605
+ q = _mm256_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK);
1606
+ q = _mm256_add_epi32(q, _mm256_srli_epi32(q, 31)); // q += (q < 0)
1607
+ return q;
1608
+ }
1609
+ }
1610
+
1611
+ __m256i libdivide_s32_branchfree_do_vector(__m256i numers, const struct libdivide_s32_branchfree_t *denom) {
1612
+ int32_t magic = denom->magic;
1613
+ uint8_t more = denom->more;
1614
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1615
+ // must be arithmetic shift
1616
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1617
+ __m256i q = libdivide_mullhi_s32_vector(numers, _mm256_set1_epi32(magic));
1618
+ q = _mm256_add_epi32(q, numers); // q += numers
1619
+
1620
+ // If q is non-negative, we have nothing to do
1621
+ // If q is negative, we want to add either (2**shift)-1 if d is
1622
+ // a power of 2, or (2**shift) if it is not a power of 2
1623
+ uint32_t is_power_of_2 = (magic == 0);
1624
+ __m256i q_sign = _mm256_srai_epi32(q, 31); // q_sign = q >> 31
1625
+ __m256i mask = _mm256_set1_epi32((1U << shift) - is_power_of_2);
1626
+ q = _mm256_add_epi32(q, _mm256_and_si256(q_sign, mask)); // q = q + (q_sign & mask)
1627
+ q = _mm256_srai_epi32(q, shift); // q >>= shift
1628
+ q = _mm256_sub_epi32(_mm256_xor_si256(q, sign), sign); // q = (q ^ sign) - sign
1629
+ return q;
1630
+ }
1631
+
1632
+ ////////// SINT64
1633
+
1634
+ __m256i libdivide_s64_do_vector(__m256i numers, const struct libdivide_s64_t *denom) {
1635
+ uint8_t more = denom->more;
1636
+ int64_t magic = denom->magic;
1637
+ if (magic == 0) { // shift path
1638
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1639
+ uint64_t mask = (1ULL << shift) - 1;
1640
+ __m256i roundToZeroTweak = _mm256_set1_epi64x(mask);
1641
+ // q = numer + ((numer >> 63) & roundToZeroTweak);
1642
+ __m256i q = _mm256_add_epi64(numers, _mm256_and_si256(libdivide_s64_signbits(numers), roundToZeroTweak));
1643
+ q = libdivide_s64_shift_right_vector(q, shift);
1644
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1645
+ // q = (q ^ sign) - sign;
1646
+ q = _mm256_sub_epi64(_mm256_xor_si256(q, sign), sign);
1647
+ return q;
1648
+ }
1649
+ else {
1650
+ __m256i q = libdivide_mullhi_s64_vector(numers, _mm256_set1_epi64x(magic));
1651
+ if (more & LIBDIVIDE_ADD_MARKER) {
1652
+ // must be arithmetic shift
1653
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1654
+ // q += ((numer ^ sign) - sign);
1655
+ q = _mm256_add_epi64(q, _mm256_sub_epi64(_mm256_xor_si256(numers, sign), sign));
1656
+ }
1657
+ // q >>= denom->mult_path.shift
1658
+ q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK);
1659
+ q = _mm256_add_epi64(q, _mm256_srli_epi64(q, 63)); // q += (q < 0)
1660
+ return q;
1661
+ }
1662
+ }
1663
+
1664
+ __m256i libdivide_s64_branchfree_do_vector(__m256i numers, const struct libdivide_s64_branchfree_t *denom) {
1665
+ int64_t magic = denom->magic;
1666
+ uint8_t more = denom->more;
1667
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1668
+ // must be arithmetic shift
1669
+ __m256i sign = _mm256_set1_epi32((int8_t)more >> 7);
1670
+
1671
+ // libdivide_mullhi_s64(numers, magic);
1672
+ __m256i q = libdivide_mullhi_s64_vector(numers, _mm256_set1_epi64x(magic));
1673
+ q = _mm256_add_epi64(q, numers); // q += numers
1674
+
1675
+ // If q is non-negative, we have nothing to do.
1676
+ // If q is negative, we want to add either (2**shift)-1 if d is
1677
+ // a power of 2, or (2**shift) if it is not a power of 2.
1678
+ uint32_t is_power_of_2 = (magic == 0);
1679
+ __m256i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63
1680
+ __m256i mask = _mm256_set1_epi64x((1ULL << shift) - is_power_of_2);
1681
+ q = _mm256_add_epi64(q, _mm256_and_si256(q_sign, mask)); // q = q + (q_sign & mask)
1682
+ q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift
1683
+ q = _mm256_sub_epi64(_mm256_xor_si256(q, sign), sign); // q = (q ^ sign) - sign
1684
+ return q;
1685
+ }
1686
+
1687
+ #elif defined(LIBDIVIDE_SSE2)
1688
+
1689
+ static inline __m128i libdivide_u32_do_vector(__m128i numers, const struct libdivide_u32_t *denom);
1690
+ static inline __m128i libdivide_s32_do_vector(__m128i numers, const struct libdivide_s32_t *denom);
1691
+ static inline __m128i libdivide_u64_do_vector(__m128i numers, const struct libdivide_u64_t *denom);
1692
+ static inline __m128i libdivide_s64_do_vector(__m128i numers, const struct libdivide_s64_t *denom);
1693
+
1694
+ static inline __m128i libdivide_u32_branchfree_do_vector(__m128i numers, const struct libdivide_u32_branchfree_t *denom);
1695
+ static inline __m128i libdivide_s32_branchfree_do_vector(__m128i numers, const struct libdivide_s32_branchfree_t *denom);
1696
+ static inline __m128i libdivide_u64_branchfree_do_vector(__m128i numers, const struct libdivide_u64_branchfree_t *denom);
1697
+ static inline __m128i libdivide_s64_branchfree_do_vector(__m128i numers, const struct libdivide_s64_branchfree_t *denom);
1698
+
1699
+ //////// Internal Utility Functions
1700
+
1701
+ // Implementation of _mm_srai_epi64(v, 63) (from AVX512).
1702
+ static inline __m128i libdivide_s64_signbits(__m128i v) {
1703
+ __m128i hiBitsDuped = _mm_shuffle_epi32(v, _MM_SHUFFLE(3, 3, 1, 1));
1704
+ __m128i signBits = _mm_srai_epi32(hiBitsDuped, 31);
1705
+ return signBits;
1706
+ }
1707
+
1708
+ // Implementation of _mm_srai_epi64 (from AVX512).
1709
+ static inline __m128i libdivide_s64_shift_right_vector(__m128i v, int amt) {
1710
+ const int b = 64 - amt;
1711
+ __m128i m = _mm_set1_epi64x(1ULL << (b - 1));
1712
+ __m128i x = _mm_srli_epi64(v, amt);
1713
+ __m128i result = _mm_sub_epi64(_mm_xor_si128(x, m), m);
1714
+ return result;
1715
+ }
1716
+
1717
+ // Here, b is assumed to contain one 32-bit value repeated.
1718
+ static inline __m128i libdivide_mullhi_u32_vector(__m128i a, __m128i b) {
1719
+ __m128i hi_product_0Z2Z = _mm_srli_epi64(_mm_mul_epu32(a, b), 32);
1720
+ __m128i a1X3X = _mm_srli_epi64(a, 32);
1721
+ __m128i mask = _mm_set_epi32(-1, 0, -1, 0);
1722
+ __m128i hi_product_Z1Z3 = _mm_and_si128(_mm_mul_epu32(a1X3X, b), mask);
1723
+ return _mm_or_si128(hi_product_0Z2Z, hi_product_Z1Z3);
1724
+ }
1725
+
1726
+ // SSE2 does not have a signed multiplication instruction, but we can convert
1727
+ // unsigned to signed pretty efficiently. Again, b is just a 32 bit value
1728
+ // repeated four times.
1729
+ static inline __m128i libdivide_mullhi_s32_vector(__m128i a, __m128i b) {
1730
+ __m128i p = libdivide_mullhi_u32_vector(a, b);
1731
+ // t1 = (a >> 31) & y, arithmetic shift
1732
+ __m128i t1 = _mm_and_si128(_mm_srai_epi32(a, 31), b);
1733
+ __m128i t2 = _mm_and_si128(_mm_srai_epi32(b, 31), a);
1734
+ p = _mm_sub_epi32(p, t1);
1735
+ p = _mm_sub_epi32(p, t2);
1736
+ return p;
1737
+ }
1738
+
1739
+ // Here, y is assumed to contain one 64-bit value repeated.
1740
+ // https://stackoverflow.com/a/28827013
1741
+ static inline __m128i libdivide_mullhi_u64_vector(__m128i x, __m128i y) {
1742
+ __m128i lomask = _mm_set1_epi64x(0xffffffff);
1743
+ __m128i xh = _mm_shuffle_epi32(x, 0xB1); // x0l, x0h, x1l, x1h
1744
+ __m128i yh = _mm_shuffle_epi32(y, 0xB1); // y0l, y0h, y1l, y1h
1745
+ __m128i w0 = _mm_mul_epu32(x, y); // x0l*y0l, x1l*y1l
1746
+ __m128i w1 = _mm_mul_epu32(x, yh); // x0l*y0h, x1l*y1h
1747
+ __m128i w2 = _mm_mul_epu32(xh, y); // x0h*y0l, x1h*y0l
1748
+ __m128i w3 = _mm_mul_epu32(xh, yh); // x0h*y0h, x1h*y1h
1749
+ __m128i w0h = _mm_srli_epi64(w0, 32);
1750
+ __m128i s1 = _mm_add_epi64(w1, w0h);
1751
+ __m128i s1l = _mm_and_si128(s1, lomask);
1752
+ __m128i s1h = _mm_srli_epi64(s1, 32);
1753
+ __m128i s2 = _mm_add_epi64(w2, s1l);
1754
+ __m128i s2h = _mm_srli_epi64(s2, 32);
1755
+ __m128i hi = _mm_add_epi64(w3, s1h);
1756
+ hi = _mm_add_epi64(hi, s2h);
1757
+
1758
+ return hi;
1759
+ }
1760
+
1761
+ // y is one 64-bit value repeated.
1762
+ static inline __m128i libdivide_mullhi_s64_vector(__m128i x, __m128i y) {
1763
+ __m128i p = libdivide_mullhi_u64_vector(x, y);
1764
+ __m128i t1 = _mm_and_si128(libdivide_s64_signbits(x), y);
1765
+ __m128i t2 = _mm_and_si128(libdivide_s64_signbits(y), x);
1766
+ p = _mm_sub_epi64(p, t1);
1767
+ p = _mm_sub_epi64(p, t2);
1768
+ return p;
1769
+ }
1770
+
1771
+ ////////// UINT32
1772
+
1773
+ __m128i libdivide_u32_do_vector(__m128i numers, const struct libdivide_u32_t *denom) {
1774
+ uint8_t more = denom->more;
1775
+ if (!denom->magic) {
1776
+ return _mm_srli_epi32(numers, more);
1777
+ }
1778
+ else {
1779
+ __m128i q = libdivide_mullhi_u32_vector(numers, _mm_set1_epi32(denom->magic));
1780
+ if (more & LIBDIVIDE_ADD_MARKER) {
1781
+ // uint32_t t = ((numer - q) >> 1) + q;
1782
+ // return t >> denom->shift;
1783
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1784
+ __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_sub_epi32(numers, q), 1), q);
1785
+ return _mm_srli_epi32(t, shift);
1786
+ }
1787
+ else {
1788
+ return _mm_srli_epi32(q, more);
1789
+ }
1790
+ }
1791
+ }
1792
+
1793
+ __m128i libdivide_u32_branchfree_do_vector(__m128i numers, const struct libdivide_u32_branchfree_t *denom) {
1794
+ __m128i q = libdivide_mullhi_u32_vector(numers, _mm_set1_epi32(denom->magic));
1795
+ __m128i t = _mm_add_epi32(_mm_srli_epi32(_mm_sub_epi32(numers, q), 1), q);
1796
+ return _mm_srli_epi32(t, denom->more);
1797
+ }
1798
+
1799
+ ////////// UINT64
1800
+
1801
+ __m128i libdivide_u64_do_vector(__m128i numers, const struct libdivide_u64_t *denom) {
1802
+ uint8_t more = denom->more;
1803
+ if (!denom->magic) {
1804
+ return _mm_srli_epi64(numers, more);
1805
+ }
1806
+ else {
1807
+ __m128i q = libdivide_mullhi_u64_vector(numers, _mm_set1_epi64x(denom->magic));
1808
+ if (more & LIBDIVIDE_ADD_MARKER) {
1809
+ // uint32_t t = ((numer - q) >> 1) + q;
1810
+ // return t >> denom->shift;
1811
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1812
+ __m128i t = _mm_add_epi64(_mm_srli_epi64(_mm_sub_epi64(numers, q), 1), q);
1813
+ return _mm_srli_epi64(t, shift);
1814
+ }
1815
+ else {
1816
+ return _mm_srli_epi64(q, more);
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
+ __m128i libdivide_u64_branchfree_do_vector(__m128i numers, const struct libdivide_u64_branchfree_t *denom) {
1822
+ __m128i q = libdivide_mullhi_u64_vector(numers, _mm_set1_epi64x(denom->magic));
1823
+ __m128i t = _mm_add_epi64(_mm_srli_epi64(_mm_sub_epi64(numers, q), 1), q);
1824
+ return _mm_srli_epi64(t, denom->more);
1825
+ }
1826
+
1827
+ ////////// SINT32
1828
+
1829
+ __m128i libdivide_s32_do_vector(__m128i numers, const struct libdivide_s32_t *denom) {
1830
+ uint8_t more = denom->more;
1831
+ if (!denom->magic) {
1832
+ uint32_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1833
+ uint32_t mask = (1U << shift) - 1;
1834
+ __m128i roundToZeroTweak = _mm_set1_epi32(mask);
1835
+ // q = numer + ((numer >> 31) & roundToZeroTweak);
1836
+ __m128i q = _mm_add_epi32(numers, _mm_and_si128(_mm_srai_epi32(numers, 31), roundToZeroTweak));
1837
+ q = _mm_srai_epi32(q, shift);
1838
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1839
+ // q = (q ^ sign) - sign;
1840
+ q = _mm_sub_epi32(_mm_xor_si128(q, sign), sign);
1841
+ return q;
1842
+ }
1843
+ else {
1844
+ __m128i q = libdivide_mullhi_s32_vector(numers, _mm_set1_epi32(denom->magic));
1845
+ if (more & LIBDIVIDE_ADD_MARKER) {
1846
+ // must be arithmetic shift
1847
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1848
+ // q += ((numer ^ sign) - sign);
1849
+ q = _mm_add_epi32(q, _mm_sub_epi32(_mm_xor_si128(numers, sign), sign));
1850
+ }
1851
+ // q >>= shift
1852
+ q = _mm_srai_epi32(q, more & LIBDIVIDE_32_SHIFT_MASK);
1853
+ q = _mm_add_epi32(q, _mm_srli_epi32(q, 31)); // q += (q < 0)
1854
+ return q;
1855
+ }
1856
+ }
1857
+
1858
+ __m128i libdivide_s32_branchfree_do_vector(__m128i numers, const struct libdivide_s32_branchfree_t *denom) {
1859
+ int32_t magic = denom->magic;
1860
+ uint8_t more = denom->more;
1861
+ uint8_t shift = more & LIBDIVIDE_32_SHIFT_MASK;
1862
+ // must be arithmetic shift
1863
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1864
+ __m128i q = libdivide_mullhi_s32_vector(numers, _mm_set1_epi32(magic));
1865
+ q = _mm_add_epi32(q, numers); // q += numers
1866
+
1867
+ // If q is non-negative, we have nothing to do
1868
+ // If q is negative, we want to add either (2**shift)-1 if d is
1869
+ // a power of 2, or (2**shift) if it is not a power of 2
1870
+ uint32_t is_power_of_2 = (magic == 0);
1871
+ __m128i q_sign = _mm_srai_epi32(q, 31); // q_sign = q >> 31
1872
+ __m128i mask = _mm_set1_epi32((1U << shift) - is_power_of_2);
1873
+ q = _mm_add_epi32(q, _mm_and_si128(q_sign, mask)); // q = q + (q_sign & mask)
1874
+ q = _mm_srai_epi32(q, shift); // q >>= shift
1875
+ q = _mm_sub_epi32(_mm_xor_si128(q, sign), sign); // q = (q ^ sign) - sign
1876
+ return q;
1877
+ }
1878
+
1879
+ ////////// SINT64
1880
+
1881
+ __m128i libdivide_s64_do_vector(__m128i numers, const struct libdivide_s64_t *denom) {
1882
+ uint8_t more = denom->more;
1883
+ int64_t magic = denom->magic;
1884
+ if (magic == 0) { // shift path
1885
+ uint32_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1886
+ uint64_t mask = (1ULL << shift) - 1;
1887
+ __m128i roundToZeroTweak = _mm_set1_epi64x(mask);
1888
+ // q = numer + ((numer >> 63) & roundToZeroTweak);
1889
+ __m128i q = _mm_add_epi64(numers, _mm_and_si128(libdivide_s64_signbits(numers), roundToZeroTweak));
1890
+ q = libdivide_s64_shift_right_vector(q, shift);
1891
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1892
+ // q = (q ^ sign) - sign;
1893
+ q = _mm_sub_epi64(_mm_xor_si128(q, sign), sign);
1894
+ return q;
1895
+ }
1896
+ else {
1897
+ __m128i q = libdivide_mullhi_s64_vector(numers, _mm_set1_epi64x(magic));
1898
+ if (more & LIBDIVIDE_ADD_MARKER) {
1899
+ // must be arithmetic shift
1900
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1901
+ // q += ((numer ^ sign) - sign);
1902
+ q = _mm_add_epi64(q, _mm_sub_epi64(_mm_xor_si128(numers, sign), sign));
1903
+ }
1904
+ // q >>= denom->mult_path.shift
1905
+ q = libdivide_s64_shift_right_vector(q, more & LIBDIVIDE_64_SHIFT_MASK);
1906
+ q = _mm_add_epi64(q, _mm_srli_epi64(q, 63)); // q += (q < 0)
1907
+ return q;
1908
+ }
1909
+ }
1910
+
1911
+ __m128i libdivide_s64_branchfree_do_vector(__m128i numers, const struct libdivide_s64_branchfree_t *denom) {
1912
+ int64_t magic = denom->magic;
1913
+ uint8_t more = denom->more;
1914
+ uint8_t shift = more & LIBDIVIDE_64_SHIFT_MASK;
1915
+ // must be arithmetic shift
1916
+ __m128i sign = _mm_set1_epi32((int8_t)more >> 7);
1917
+
1918
+ // libdivide_mullhi_s64(numers, magic);
1919
+ __m128i q = libdivide_mullhi_s64_vector(numers, _mm_set1_epi64x(magic));
1920
+ q = _mm_add_epi64(q, numers); // q += numers
1921
+
1922
+ // If q is non-negative, we have nothing to do.
1923
+ // If q is negative, we want to add either (2**shift)-1 if d is
1924
+ // a power of 2, or (2**shift) if it is not a power of 2.
1925
+ uint32_t is_power_of_2 = (magic == 0);
1926
+ __m128i q_sign = libdivide_s64_signbits(q); // q_sign = q >> 63
1927
+ __m128i mask = _mm_set1_epi64x((1ULL << shift) - is_power_of_2);
1928
+ q = _mm_add_epi64(q, _mm_and_si128(q_sign, mask)); // q = q + (q_sign & mask)
1929
+ q = libdivide_s64_shift_right_vector(q, shift); // q >>= shift
1930
+ q = _mm_sub_epi64(_mm_xor_si128(q, sign), sign); // q = (q ^ sign) - sign
1931
+ return q;
1932
+ }
1933
+
1934
+ #endif
1935
+
1936
+ /////////// C++ stuff
1937
+
1938
+ #ifdef __cplusplus
1939
+
1940
+ // The C++ divider class is templated on both an integer type
1941
+ // (like uint64_t) and an algorithm type.
1942
+ // * BRANCHFULL is the default algorithm type.
1943
+ // * BRANCHFREE is the branchfree algorithm type.
1944
+ enum {
1945
+ BRANCHFULL,
1946
+ BRANCHFREE
1947
+ };
1948
+
1949
+ #if defined(LIBDIVIDE_AVX512)
1950
+ #define LIBDIVIDE_VECTOR_TYPE __m512i
1951
+ #elif defined(LIBDIVIDE_AVX2)
1952
+ #define LIBDIVIDE_VECTOR_TYPE __m256i
1953
+ #elif defined(LIBDIVIDE_SSE2)
1954
+ #define LIBDIVIDE_VECTOR_TYPE __m128i
1955
+ #endif
1956
+
1957
+ #if !defined(LIBDIVIDE_VECTOR_TYPE)
1958
+ #define LIBDIVIDE_DIVIDE_VECTOR(ALGO)
1959
+ #else
1960
+ #define LIBDIVIDE_DIVIDE_VECTOR(ALGO) \
1961
+ LIBDIVIDE_VECTOR_TYPE divide(LIBDIVIDE_VECTOR_TYPE n) const { \
1962
+ return libdivide_##ALGO##_do_vector(n, &denom); \
1963
+ }
1964
+ #endif
1965
+
1966
+ // The DISPATCHER_GEN() macro generates C++ methods (for the given integer
1967
+ // and algorithm types) that redirect to libdivide's C API.
1968
+ #define DISPATCHER_GEN(T, ALGO) \
1969
+ libdivide_##ALGO##_t denom; \
1970
+ dispatcher() { } \
1971
+ dispatcher(T d) \
1972
+ : denom(libdivide_##ALGO##_gen(d)) \
1973
+ { } \
1974
+ T divide(T n) const { \
1975
+ return libdivide_##ALGO##_do(n, &denom); \
1976
+ } \
1977
+ LIBDIVIDE_DIVIDE_VECTOR(ALGO) \
1978
+ T recover() const { \
1979
+ return libdivide_##ALGO##_recover(&denom); \
1980
+ }
1981
+
1982
+ // The dispatcher selects a specific division algorithm for a given
1983
+ // type and ALGO using partial template specialization.
1984
+ template<bool IS_INTEGRAL, bool IS_SIGNED, int SIZEOF, int ALGO> struct dispatcher { };
1985
+
1986
+ template<> struct dispatcher<true, true, sizeof(int32_t), BRANCHFULL> { DISPATCHER_GEN(int32_t, s32) };
1987
+ template<> struct dispatcher<true, true, sizeof(int32_t), BRANCHFREE> { DISPATCHER_GEN(int32_t, s32_branchfree) };
1988
+ template<> struct dispatcher<true, false, sizeof(uint32_t), BRANCHFULL> { DISPATCHER_GEN(uint32_t, u32) };
1989
+ template<> struct dispatcher<true, false, sizeof(uint32_t), BRANCHFREE> { DISPATCHER_GEN(uint32_t, u32_branchfree) };
1990
+ template<> struct dispatcher<true, true, sizeof(int64_t), BRANCHFULL> { DISPATCHER_GEN(int64_t, s64) };
1991
+ template<> struct dispatcher<true, true, sizeof(int64_t), BRANCHFREE> { DISPATCHER_GEN(int64_t, s64_branchfree) };
1992
+ template<> struct dispatcher<true, false, sizeof(uint64_t), BRANCHFULL> { DISPATCHER_GEN(uint64_t, u64) };
1993
+ template<> struct dispatcher<true, false, sizeof(uint64_t), BRANCHFREE> { DISPATCHER_GEN(uint64_t, u64_branchfree) };
1994
+
1995
+ // This is the main divider class for use by the user (C++ API).
1996
+ // The actual division algorithm is selected using the dispatcher struct
1997
+ // based on the integer and algorithm template parameters.
1998
+ template<typename T, int ALGO = BRANCHFULL>
1999
+ class divider {
2000
+ public:
2001
+ // We leave the default constructor empty so that creating
2002
+ // an array of dividers and then initializing them
2003
+ // later doesn't slow us down.
2004
+ divider() { }
2005
+
2006
+ // Constructor that takes the divisor as a parameter
2007
+ divider(T d) : div(d) { }
2008
+
2009
+ // Divides n by the divisor
2010
+ T divide(T n) const {
2011
+ return div.divide(n);
2012
+ }
2013
+
2014
+ // Recovers the divisor, returns the value that was
2015
+ // used to initialize this divider object.
2016
+ T recover() const {
2017
+ return div.recover();
2018
+ }
2019
+
2020
+ bool operator==(const divider<T, ALGO>& other) const {
2021
+ return div.denom.magic == other.denom.magic &&
2022
+ div.denom.more == other.denom.more;
2023
+ }
2024
+
2025
+ bool operator!=(const divider<T, ALGO>& other) const {
2026
+ return !(*this == other);
2027
+ }
2028
+
2029
+ #if defined(LIBDIVIDE_VECTOR_TYPE)
2030
+ // Treats the vector as packed integer values with the same type as
2031
+ // the divider (e.g. s32, u32, s64, u64) and divides each of
2032
+ // them by the divider, returning the packed quotients.
2033
+ LIBDIVIDE_VECTOR_TYPE divide(LIBDIVIDE_VECTOR_TYPE n) const {
2034
+ return div.divide(n);
2035
+ }
2036
+ #endif
2037
+
2038
+ private:
2039
+ // Storage for the actual divisor
2040
+ dispatcher<std::is_integral<T>::value,
2041
+ std::is_signed<T>::value, sizeof(T), ALGO> div;
2042
+ };
2043
+
2044
+ // Overload of operator / for scalar division
2045
+ template<typename T, int ALGO>
2046
+ T operator/(T n, const divider<T, ALGO>& div) {
2047
+ return div.divide(n);
2048
+ }
2049
+
2050
+ // Overload of operator /= for scalar division
2051
+ template<typename T, int ALGO>
2052
+ T& operator/=(T& n, const divider<T, ALGO>& div) {
2053
+ n = div.divide(n);
2054
+ return n;
2055
+ }
2056
+
2057
+ #if defined(LIBDIVIDE_VECTOR_TYPE)
2058
+ // Overload of operator / for vector division
2059
+ template<typename T, int ALGO>
2060
+ LIBDIVIDE_VECTOR_TYPE operator/(LIBDIVIDE_VECTOR_TYPE n, const divider<T, ALGO>& div) {
2061
+ return div.divide(n);
2062
+ }
2063
+ // Overload of operator /= for vector division
2064
+ template<typename T, int ALGO>
2065
+ LIBDIVIDE_VECTOR_TYPE& operator/=(LIBDIVIDE_VECTOR_TYPE& n, const divider<T, ALGO>& div) {
2066
+ n = div.divide(n);
2067
+ return n;
2068
+ }
2069
+ #endif
2070
+
2071
+ // libdivdie::branchfree_divider<T>
2072
+ template <typename T>
2073
+ using branchfree_divider = divider<T, BRANCHFREE>;
2074
+
2075
+ } // namespace libdivide
2076
+
2077
+ #endif // __cplusplus
2078
+
2079
+ #endif // NUMPY_CORE_INCLUDE_NUMPY_LIBDIVIDE_LIBDIVIDE_H_
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/ufuncobject.h ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_UFUNCOBJECT_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_UFUNCOBJECT_H_
3
+
4
+ #include <numpy/npy_math.h>
5
+ #include <numpy/npy_common.h>
6
+
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ /*
12
+ * The legacy generic inner loop for a standard element-wise or
13
+ * generalized ufunc.
14
+ */
15
+ typedef void (*PyUFuncGenericFunction)
16
+ (char **args,
17
+ npy_intp const *dimensions,
18
+ npy_intp const *strides,
19
+ void *innerloopdata);
20
+
21
+ /*
22
+ * The most generic one-dimensional inner loop for
23
+ * a masked standard element-wise ufunc. "Masked" here means that it skips
24
+ * doing calculations on any items for which the maskptr array has a true
25
+ * value.
26
+ */
27
+ typedef void (PyUFunc_MaskedStridedInnerLoopFunc)(
28
+ char **dataptrs, npy_intp *strides,
29
+ char *maskptr, npy_intp mask_stride,
30
+ npy_intp count,
31
+ NpyAuxData *innerloopdata);
32
+
33
+ /* Forward declaration for the type resolver and loop selector typedefs */
34
+ struct _tagPyUFuncObject;
35
+
36
+ /*
37
+ * Given the operands for calling a ufunc, should determine the
38
+ * calculation input and output data types and return an inner loop function.
39
+ * This function should validate that the casting rule is being followed,
40
+ * and fail if it is not.
41
+ *
42
+ * For backwards compatibility, the regular type resolution function does not
43
+ * support auxiliary data with object semantics. The type resolution call
44
+ * which returns a masked generic function returns a standard NpyAuxData
45
+ * object, for which the NPY_AUXDATA_FREE and NPY_AUXDATA_CLONE macros
46
+ * work.
47
+ *
48
+ * ufunc: The ufunc object.
49
+ * casting: The 'casting' parameter provided to the ufunc.
50
+ * operands: An array of length (ufunc->nin + ufunc->nout),
51
+ * with the output parameters possibly NULL.
52
+ * type_tup: Either NULL, or the type_tup passed to the ufunc.
53
+ * out_dtypes: An array which should be populated with new
54
+ * references to (ufunc->nin + ufunc->nout) new
55
+ * dtypes, one for each input and output. These
56
+ * dtypes should all be in native-endian format.
57
+ *
58
+ * Should return 0 on success, -1 on failure (with exception set),
59
+ * or -2 if Py_NotImplemented should be returned.
60
+ */
61
+ typedef int (PyUFunc_TypeResolutionFunc)(
62
+ struct _tagPyUFuncObject *ufunc,
63
+ NPY_CASTING casting,
64
+ PyArrayObject **operands,
65
+ PyObject *type_tup,
66
+ PyArray_Descr **out_dtypes);
67
+
68
+ /*
69
+ * This is the signature for the functions that may be assigned to the
70
+ * `process_core_dims_func` field of the PyUFuncObject structure.
71
+ * Implementation of this function is optional. This function is only used
72
+ * by generalized ufuncs (i.e. those with the field `core_enabled` set to 1).
73
+ * The function is called by the ufunc during the processing of the arguments
74
+ * of a call of the ufunc. The function can check the core dimensions of the
75
+ * input and output arrays and return -1 with an exception set if any
76
+ * requirements are not satisfied. If the caller of the ufunc didn't provide
77
+ * output arrays, the core dimensions associated with the output arrays (i.e.
78
+ * those that are not also used in input arrays) will have the value -1 in
79
+ * `core_dim_sizes`. This function can replace any output core dimensions
80
+ * that are -1 with a value that is appropriate for the ufunc.
81
+ *
82
+ * Parameter Description
83
+ * --------------- ------------------------------------------------------
84
+ * ufunc The ufunc object
85
+ * core_dim_sizes An array with length `ufunc->core_num_dim_ix`.
86
+ * The core dimensions of the arrays passed to the ufunc
87
+ * will have been set. If the caller of the ufunc didn't
88
+ * provide the output array(s), the output-only core
89
+ * dimensions will have the value -1.
90
+ *
91
+ * The function must not change any element in `core_dim_sizes` that is
92
+ * not -1 on input. Doing so will result in incorrect output from the
93
+ * ufunc, and could result in a crash of the Python interpreter.
94
+ *
95
+ * The function must return 0 on success, -1 on failure (with an exception
96
+ * set).
97
+ */
98
+ typedef int (PyUFunc_ProcessCoreDimsFunc)(
99
+ struct _tagPyUFuncObject *ufunc,
100
+ npy_intp *core_dim_sizes);
101
+
102
+ typedef struct _tagPyUFuncObject {
103
+ PyObject_HEAD
104
+ /*
105
+ * nin: Number of inputs
106
+ * nout: Number of outputs
107
+ * nargs: Always nin + nout (Why is it stored?)
108
+ */
109
+ int nin, nout, nargs;
110
+
111
+ /*
112
+ * Identity for reduction, any of PyUFunc_One, PyUFunc_Zero
113
+ * PyUFunc_MinusOne, PyUFunc_None, PyUFunc_ReorderableNone,
114
+ * PyUFunc_IdentityValue.
115
+ */
116
+ int identity;
117
+
118
+ /* Array of one-dimensional core loops */
119
+ PyUFuncGenericFunction *functions;
120
+ /* Array of funcdata that gets passed into the functions */
121
+ void *const *data;
122
+ /* The number of elements in 'functions' and 'data' */
123
+ int ntypes;
124
+
125
+ /* Used to be unused field 'check_return' */
126
+ int reserved1;
127
+
128
+ /* The name of the ufunc */
129
+ const char *name;
130
+
131
+ /* Array of type numbers, of size ('nargs' * 'ntypes') */
132
+ const char *types;
133
+
134
+ /* Documentation string */
135
+ const char *doc;
136
+
137
+ void *ptr;
138
+ PyObject *obj;
139
+ PyObject *userloops;
140
+
141
+ /* generalized ufunc parameters */
142
+
143
+ /* 0 for scalar ufunc; 1 for generalized ufunc */
144
+ int core_enabled;
145
+ /* number of distinct dimension names in signature */
146
+ int core_num_dim_ix;
147
+
148
+ /*
149
+ * dimension indices of input/output argument k are stored in
150
+ * core_dim_ixs[core_offsets[k]..core_offsets[k]+core_num_dims[k]-1]
151
+ */
152
+
153
+ /* numbers of core dimensions of each argument */
154
+ int *core_num_dims;
155
+ /*
156
+ * dimension indices in a flatted form; indices
157
+ * are in the range of [0,core_num_dim_ix)
158
+ */
159
+ int *core_dim_ixs;
160
+ /*
161
+ * positions of 1st core dimensions of each
162
+ * argument in core_dim_ixs, equivalent to cumsum(core_num_dims)
163
+ */
164
+ int *core_offsets;
165
+ /* signature string for printing purpose */
166
+ char *core_signature;
167
+
168
+ /*
169
+ * A function which resolves the types and fills an array
170
+ * with the dtypes for the inputs and outputs.
171
+ */
172
+ PyUFunc_TypeResolutionFunc *type_resolver;
173
+
174
+ /* A dictionary to monkeypatch ufuncs */
175
+ PyObject *dict;
176
+
177
+ /*
178
+ * This was blocked off to be the "new" inner loop selector in 1.7,
179
+ * but this was never implemented. (This is also why the above
180
+ * selector is called the "legacy" selector.)
181
+ */
182
+ #ifndef Py_LIMITED_API
183
+ vectorcallfunc vectorcall;
184
+ #else
185
+ void *vectorcall;
186
+ #endif
187
+
188
+ /* Was previously the `PyUFunc_MaskedInnerLoopSelectionFunc` */
189
+ void *reserved3;
190
+
191
+ /*
192
+ * List of flags for each operand when ufunc is called by nditer object.
193
+ * These flags will be used in addition to the default flags for each
194
+ * operand set by nditer object.
195
+ */
196
+ npy_uint32 *op_flags;
197
+
198
+ /*
199
+ * List of global flags used when ufunc is called by nditer object.
200
+ * These flags will be used in addition to the default global flags
201
+ * set by nditer object.
202
+ */
203
+ npy_uint32 iter_flags;
204
+
205
+ /* New in NPY_API_VERSION 0x0000000D and above */
206
+ #if NPY_FEATURE_VERSION >= NPY_1_16_API_VERSION
207
+ /*
208
+ * for each core_num_dim_ix distinct dimension names,
209
+ * the possible "frozen" size (-1 if not frozen).
210
+ */
211
+ npy_intp *core_dim_sizes;
212
+
213
+ /*
214
+ * for each distinct core dimension, a set of UFUNC_CORE_DIM* flags
215
+ */
216
+ npy_uint32 *core_dim_flags;
217
+
218
+ /* Identity for reduction, when identity == PyUFunc_IdentityValue */
219
+ PyObject *identity_value;
220
+ #endif /* NPY_FEATURE_VERSION >= NPY_1_16_API_VERSION */
221
+
222
+ /* New in NPY_API_VERSION 0x0000000F and above */
223
+ #if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
224
+ /* New private fields related to dispatching */
225
+ void *_dispatch_cache;
226
+ /* A PyListObject of `(tuple of DTypes, ArrayMethod/Promoter)` */
227
+ PyObject *_loops;
228
+ #endif
229
+ #if NPY_FEATURE_VERSION >= NPY_2_1_API_VERSION
230
+ /*
231
+ * Optional function to process core dimensions of a gufunc.
232
+ */
233
+ PyUFunc_ProcessCoreDimsFunc *process_core_dims_func;
234
+ #endif
235
+ } PyUFuncObject;
236
+
237
+ #include "arrayobject.h"
238
+ /* Generalized ufunc; 0x0001 reserved for possible use as CORE_ENABLED */
239
+ /* the core dimension's size will be determined by the operands. */
240
+ #define UFUNC_CORE_DIM_SIZE_INFERRED 0x0002
241
+ /* the core dimension may be absent */
242
+ #define UFUNC_CORE_DIM_CAN_IGNORE 0x0004
243
+ /* flags inferred during execution */
244
+ #define UFUNC_CORE_DIM_MISSING 0x00040000
245
+
246
+
247
+ #define UFUNC_OBJ_ISOBJECT 1
248
+ #define UFUNC_OBJ_NEEDS_API 2
249
+
250
+
251
+ #if NPY_ALLOW_THREADS
252
+ #define NPY_LOOP_BEGIN_THREADS do {if (!(loop->obj & UFUNC_OBJ_NEEDS_API)) _save = PyEval_SaveThread();} while (0);
253
+ #define NPY_LOOP_END_THREADS do {if (!(loop->obj & UFUNC_OBJ_NEEDS_API)) PyEval_RestoreThread(_save);} while (0);
254
+ #else
255
+ #define NPY_LOOP_BEGIN_THREADS
256
+ #define NPY_LOOP_END_THREADS
257
+ #endif
258
+
259
+ /*
260
+ * UFunc has unit of 0, and the order of operations can be reordered
261
+ * This case allows reduction with multiple axes at once.
262
+ */
263
+ #define PyUFunc_Zero 0
264
+ /*
265
+ * UFunc has unit of 1, and the order of operations can be reordered
266
+ * This case allows reduction with multiple axes at once.
267
+ */
268
+ #define PyUFunc_One 1
269
+ /*
270
+ * UFunc has unit of -1, and the order of operations can be reordered
271
+ * This case allows reduction with multiple axes at once. Intended for
272
+ * bitwise_and reduction.
273
+ */
274
+ #define PyUFunc_MinusOne 2
275
+ /*
276
+ * UFunc has no unit, and the order of operations cannot be reordered.
277
+ * This case does not allow reduction with multiple axes at once.
278
+ */
279
+ #define PyUFunc_None -1
280
+ /*
281
+ * UFunc has no unit, and the order of operations can be reordered
282
+ * This case allows reduction with multiple axes at once.
283
+ */
284
+ #define PyUFunc_ReorderableNone -2
285
+ /*
286
+ * UFunc unit is an identity_value, and the order of operations can be reordered
287
+ * This case allows reduction with multiple axes at once.
288
+ */
289
+ #define PyUFunc_IdentityValue -3
290
+
291
+
292
+ #define UFUNC_REDUCE 0
293
+ #define UFUNC_ACCUMULATE 1
294
+ #define UFUNC_REDUCEAT 2
295
+ #define UFUNC_OUTER 3
296
+
297
+
298
+ typedef struct {
299
+ int nin;
300
+ int nout;
301
+ PyObject *callable;
302
+ } PyUFunc_PyFuncData;
303
+
304
+ /* A linked-list of function information for
305
+ user-defined 1-d loops.
306
+ */
307
+ typedef struct _loop1d_info {
308
+ PyUFuncGenericFunction func;
309
+ void *data;
310
+ int *arg_types;
311
+ struct _loop1d_info *next;
312
+ int nargs;
313
+ PyArray_Descr **arg_dtypes;
314
+ } PyUFunc_Loop1d;
315
+
316
+
317
+ #define UFUNC_PYVALS_NAME "UFUNC_PYVALS"
318
+
319
+ /*
320
+ * THESE MACROS ARE DEPRECATED.
321
+ * Use npy_set_floatstatus_* in the npymath library.
322
+ */
323
+ #define UFUNC_FPE_DIVIDEBYZERO NPY_FPE_DIVIDEBYZERO
324
+ #define UFUNC_FPE_OVERFLOW NPY_FPE_OVERFLOW
325
+ #define UFUNC_FPE_UNDERFLOW NPY_FPE_UNDERFLOW
326
+ #define UFUNC_FPE_INVALID NPY_FPE_INVALID
327
+
328
+ #define generate_divbyzero_error() npy_set_floatstatus_divbyzero()
329
+ #define generate_overflow_error() npy_set_floatstatus_overflow()
330
+
331
+ /* Make sure it gets defined if it isn't already */
332
+ #ifndef UFUNC_NOFPE
333
+ /* Clear the floating point exception default of Borland C++ */
334
+ #if defined(__BORLANDC__)
335
+ #define UFUNC_NOFPE _control87(MCW_EM, MCW_EM);
336
+ #else
337
+ #define UFUNC_NOFPE
338
+ #endif
339
+ #endif
340
+
341
+ #include "__ufunc_api.h"
342
+
343
+ #ifdef __cplusplus
344
+ }
345
+ #endif
346
+
347
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_UFUNCOBJECT_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/include/numpy/utils.h ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef NUMPY_CORE_INCLUDE_NUMPY_UTILS_H_
2
+ #define NUMPY_CORE_INCLUDE_NUMPY_UTILS_H_
3
+
4
+ #ifndef __COMP_NPY_UNUSED
5
+ #if defined(__GNUC__)
6
+ #define __COMP_NPY_UNUSED __attribute__ ((__unused__))
7
+ #elif defined(__ICC)
8
+ #define __COMP_NPY_UNUSED __attribute__ ((__unused__))
9
+ #elif defined(__clang__)
10
+ #define __COMP_NPY_UNUSED __attribute__ ((unused))
11
+ #else
12
+ #define __COMP_NPY_UNUSED
13
+ #endif
14
+ #endif
15
+
16
+ #if defined(__GNUC__) || defined(__ICC) || defined(__clang__)
17
+ #define NPY_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
18
+ #elif defined(_MSC_VER)
19
+ #define NPY_DECL_ALIGNED(x) __declspec(align(x))
20
+ #else
21
+ #define NPY_DECL_ALIGNED(x)
22
+ #endif
23
+
24
+ /* Use this to tag a variable as not used. It will remove unused variable
25
+ * warning on support platforms (see __COM_NPY_UNUSED) and mangle the variable
26
+ * to avoid accidental use */
27
+ #define NPY_UNUSED(x) __NPY_UNUSED_TAGGED ## x __COMP_NPY_UNUSED
28
+ #define NPY_EXPAND(x) x
29
+
30
+ #define NPY_STRINGIFY(x) #x
31
+ #define NPY_TOSTRING(x) NPY_STRINGIFY(x)
32
+
33
+ #define NPY_CAT__(a, b) a ## b
34
+ #define NPY_CAT_(a, b) NPY_CAT__(a, b)
35
+ #define NPY_CAT(a, b) NPY_CAT_(a, b)
36
+
37
+ #endif /* NUMPY_CORE_INCLUDE_NUMPY_UTILS_H_ */
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/npy-pkg-config/mlib.ini ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [meta]
2
+ Name = mlib
3
+ Description = Math library used with this version of numpy
4
+ Version = 1.0
5
+
6
+ [default]
7
+ Libs=-lm
8
+ Cflags=
9
+
10
+ [msvc]
11
+ Libs=m.lib
12
+ Cflags=
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/npy-pkg-config/npymath.ini ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [meta]
2
+ Name=npymath
3
+ Description=Portable, core math library implementing C99 standard
4
+ Version=0.1
5
+
6
+ [variables]
7
+ pkgname=numpy._core
8
+ prefix=${pkgdir}
9
+ libdir=${prefix}/lib
10
+ includedir=${prefix}/include
11
+
12
+ [default]
13
+ Libs=-L${libdir} -lnpymath
14
+ Cflags=-I${includedir}
15
+ Requires=mlib
16
+
17
+ [msvc]
18
+ Libs=/LIBPATH:${libdir} npymath.lib
19
+ Cflags=/INCLUDE:${includedir}
20
+ Requires=mlib
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/lib/pkgconfig/numpy.pc ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ prefix=${pcfiledir}/../..
2
+ includedir=${prefix}/include
3
+
4
+ Name: numpy
5
+ Description: NumPy is the fundamental package for scientific computing with Python.
6
+ Version: 2.2.6
7
+ Cflags: -I${includedir}
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_casting_floatingpoint_errors.cpython-312.pyc ADDED
Binary file (9.29 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_casting_unittests.cpython-312.pyc ADDED
Binary file (39.3 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_conversion_utils.cpython-312.pyc ADDED
Binary file (13.4 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cpu_dispatcher.cpython-312.pyc ADDED
Binary file (1.54 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cpu_features.cpython-312.pyc ADDED
Binary file (19.9 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_custom_dtypes.cpython-312.pyc ADDED
Binary file (21.1 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_cython.cpython-312.pyc ADDED
Binary file (16.3 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_datetime.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:092becd14cd251cad275b78ac72eeba99356c05b873b9a513e0f3507812222de
3
+ size 174764
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_defchararray.cpython-312.pyc ADDED
Binary file (64.4 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_deprecations.cpython-312.pyc ADDED
Binary file (55.5 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dlpack.cpython-312.pyc ADDED
Binary file (13 kB). View file
 
tool_server/.venv/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dtype.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de0a8bb74aff0589f2a5ec4c92b8263fc4b34bff5fd1de60471f4f42bb7d308f
3
+ size 120308