numexpr 2.10.2__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,107 @@
1
+ #ifndef NUMEXPR_INTERPRETER_HPP
2
+ #define NUMEXPR_INTERPRETER_HPP
3
+
4
+ #include "numexpr_config.hpp"
5
+
6
+ // Forward declaration
7
+ struct NumExprObject;
8
+
9
+ enum OpCodes {
10
+ #define OPCODE(n, e, ...) e = n,
11
+ #include "opcodes.hpp"
12
+ #undef OPCODE
13
+ };
14
+
15
+ enum FuncFFCodes {
16
+ #define FUNC_FF(fop, ...) fop,
17
+ #include "functions.hpp"
18
+ #undef FUNC_FF
19
+ };
20
+
21
+ enum FuncFFFCodes {
22
+ #define FUNC_FFF(fop, ...) fop,
23
+ #include "functions.hpp"
24
+ #undef FUNC_FFF
25
+ };
26
+
27
+ enum FuncDDCodes {
28
+ #define FUNC_DD(fop, ...) fop,
29
+ #include "functions.hpp"
30
+ #undef FUNC_DD
31
+ };
32
+
33
+ enum FuncDDDCodes {
34
+ #define FUNC_DDD(fop, ...) fop,
35
+ #include "functions.hpp"
36
+ #undef FUNC_DDD
37
+ };
38
+
39
+ enum FuncCCCodes {
40
+ #define FUNC_CC(fop, ...) fop,
41
+ #include "functions.hpp"
42
+ #undef FUNC_CC
43
+ };
44
+
45
+ enum FuncCCCCodes {
46
+ #define FUNC_CCC(fop, ...) fop,
47
+ #include "functions.hpp"
48
+ #undef FUNC_CCC
49
+ };
50
+
51
+ struct vm_params {
52
+ int prog_len;
53
+ unsigned char *program;
54
+ int n_inputs;
55
+ int n_constants;
56
+ int n_temps;
57
+ unsigned int r_end;
58
+ char *output;
59
+ char **inputs;
60
+ char **mem;
61
+ npy_intp *memsteps;
62
+ npy_intp *memsizes;
63
+ struct index_data *index_data;
64
+ // Memory for output buffering. If output buffering is unneeded,
65
+ // it contains NULL.
66
+ char *out_buffer;
67
+ };
68
+
69
+ // Structure for parameters in worker threads
70
+ struct thread_data {
71
+ npy_intp start;
72
+ npy_intp vlen;
73
+ npy_intp block_size;
74
+ vm_params params;
75
+ int ret_code;
76
+ int *pc_error;
77
+ char **errmsg;
78
+ // NOTE: memsteps, iter, and reduce_iter are arrays, they MUST be allocated
79
+ // to length `global_max_threads` before module load.
80
+ // One memsteps array per thread
81
+ // npy_intp *memsteps[MAX_THREADS];
82
+ npy_intp **memsteps;
83
+ // One iterator per thread */
84
+ // NpyIter *iter[MAX_THREADS];
85
+ NpyIter **iter;
86
+ // When doing nested iteration for a reduction
87
+ // NpyIter *reduce_iter[MAX_THREADS]
88
+ NpyIter **reduce_iter;
89
+ // Flag indicating reduction is the outer loop instead of the inner
90
+ bool reduction_outer_loop;
91
+ // Flag indicating whether output buffering is needed
92
+ bool need_output_buffering;
93
+ };
94
+
95
+ // Global state which holds thread parameters
96
+ extern thread_data th_params;
97
+
98
+ PyObject *NumExpr_run(NumExprObject *self, PyObject *args, PyObject *kwds);
99
+
100
+ char get_return_sig(PyObject* program);
101
+ int check_program(NumExprObject *self);
102
+ int get_temps_space(const vm_params& params, char **mem, size_t block_size);
103
+ void free_temps_space(const vm_params& params, char **mem);
104
+ int vm_engine_iter_task(NpyIter *iter, npy_intp *memsteps,
105
+ const vm_params& params, int *pc_error, char **errmsg);
106
+
107
+ #endif // NUMEXPR_INTERPRETER_HPP
@@ -0,0 +1,102 @@
1
+ #ifndef NUMEXPR_MISSING_POSIX_FUNCTIONS_HPP
2
+ #define NUMEXPR_MISSING_POSIX_FUNCTIONS_HPP
3
+
4
+ /*********************************************************************
5
+ Numexpr - Fast numerical array expression evaluator for NumPy.
6
+
7
+ License: MIT
8
+ Author: See AUTHORS.txt
9
+
10
+ See LICENSE.txt for details about copyright and rights to use.
11
+ **********************************************************************/
12
+
13
+ /* These functions are not included in some non-POSIX compilers,
14
+ like MSVC 7.1 */
15
+
16
+
17
+ /* Double precision versions */
18
+
19
+ inline double log1p(double x)
20
+ {
21
+ double u = 1.0 + x;
22
+ if (u == 1.0) {
23
+ return x;
24
+ } else {
25
+ return log(u) * x / (u-1.0);
26
+ }
27
+ }
28
+
29
+ inline double expm1(double x)
30
+ {
31
+ double u = exp(x);
32
+ if (u == 1.0) {
33
+ return x;
34
+ } else if (u-1.0 == -1.0) {
35
+ return -1;
36
+ } else {
37
+ return (u-1.0) * x/log(u);
38
+ }
39
+ }
40
+
41
+ inline double asinh(double xx)
42
+ {
43
+ double x, d;
44
+ int sign;
45
+ if (xx < 0.0) {
46
+ sign = -1;
47
+ x = -xx;
48
+ }
49
+ else {
50
+ sign = 1;
51
+ x = xx;
52
+ }
53
+ if (x > 1e8) {
54
+ d = x;
55
+ } else {
56
+ d = sqrt(x*x + 1.0);
57
+ }
58
+ return sign*log1p(x*(1.0 + x/(d+1.0)));
59
+ }
60
+
61
+ inline double acosh(double x)
62
+ {
63
+ return 2*log(sqrt((x+1.0)/2)+sqrt((x-1.0)/2));
64
+ }
65
+
66
+ inline double atanh(double x)
67
+ {
68
+ /* This definition is different from that in NumPy 1.3 and follows
69
+ the convention of MatLab. This will allow for double checking both
70
+ approaches. */
71
+ return 0.5*log((1.0+x)/(1.0-x));
72
+ }
73
+
74
+
75
+ /* Single precision versions */
76
+
77
+ inline float log1pf(float x)
78
+ {
79
+ return (float) log1p((double)x);
80
+ }
81
+
82
+ inline float expm1f(float x)
83
+ {
84
+ return (float) expm1((double)x);
85
+ }
86
+
87
+ inline float asinhf(float x)
88
+ {
89
+ return (float) asinh((double)x);
90
+ }
91
+
92
+ inline float acoshf(float x)
93
+ {
94
+ return (float) acosh((double)x);
95
+ }
96
+
97
+ inline float atanhf(float x)
98
+ {
99
+ return (float) atanh((double)x);
100
+ }
101
+
102
+ #endif // NUMEXPR_MISSING_POSIX_FUNCTIONS_HPP