5
5
#define NO_IMPORT_ARRAY
6
6
#define NO_IMPORT_UFUNC
7
7
8
- #include < Python.h>
9
- #include < sleef.h>
10
- #include < sleefquad.h>
11
- #include < vector>
8
+ #include < Python.h>
9
+ #include < sleef.h>
10
+ #include < sleefquad.h>
11
+ #include < vector>
12
12
13
13
#include " numpy/arrayobject.h"
14
14
#include " numpy/ndarraytypes.h"
18
18
#include " casts.h"
19
19
#include " dtype.h"
20
20
21
-
22
- static NPY_CASTING quad_to_quad_resolve_descriptors (PyObject *NPY_UNUSED (self),
23
- PyArray_DTypeMeta *NPY_UNUSED(dtypes[2 ]),
24
- QuadPrecDTypeObject *given_descrs[2],
25
- QuadPrecDTypeObject *loop_descrs[2],
26
- npy_intp *view_offset)
21
+ static NPY_CASTING
22
+ quad_to_quad_resolve_descriptors (PyObject *NPY_UNUSED (self),
23
+ PyArray_DTypeMeta *NPY_UNUSED(dtypes[2 ]),
24
+ QuadPrecDTypeObject *given_descrs[2],
25
+ QuadPrecDTypeObject *loop_descrs[2], npy_intp *view_offset)
27
26
{
28
27
Py_INCREF (given_descrs[0 ]);
29
28
loop_descrs[0 ] = given_descrs[0 ];
@@ -41,10 +40,10 @@ static NPY_CASTING quad_to_quad_resolve_descriptors(PyObject *NPY_UNUSED(self),
41
40
return NPY_SAME_KIND_CASTING;
42
41
}
43
42
44
- static int quad_to_quad_strided_loop (
45
- PyArrayMethod_Context *context,
46
- char * const data [], npy_intp const dimensions [],
47
- npy_intp const strides[], void *NPY_UNUSED (auxdata))
43
+ static int
44
+ quad_to_quad_strided_loop ( PyArrayMethod_Context *context, char * const data[] ,
45
+ npy_intp const dimensions [], npy_intp const strides [],
46
+ void *NPY_UNUSED (auxdata))
48
47
{
49
48
npy_intp N = dimensions[0 ];
50
49
char *in_ptr = data[0 ];
@@ -62,45 +61,43 @@ static int quad_to_quad_strided_loop(
62
61
return 0 ;
63
62
}
64
63
65
- static std::vector<PyArrayMethod_Spec *>specs;
66
-
64
+ static std::vector<PyArrayMethod_Spec *> specs;
67
65
68
- PyArrayMethod_Spec ** init_casts_internal (void )
66
+ PyArrayMethod_Spec **
67
+ init_casts_internal (void )
69
68
{
70
69
PyArray_DTypeMeta **quad2quad_dtypes = new PyArray_DTypeMeta *[2 ]{nullptr , nullptr };
71
70
72
- specs.push_back (new PyArrayMethod_Spec {
73
- .name = " cast_QuadPrec_to_QuadPrec" ,
74
- .nin = 1 ,
75
- .nout = 1 ,
76
- .casting = NPY_SAME_KIND_CASTING,
77
- .flags = NPY_METH_SUPPORTS_UNALIGNED,
78
- .dtypes = quad2quad_dtypes,
79
- .slots = new PyType_Slot[3 ]{
80
- {NPY_METH_resolve_descriptors, (void *)&quad_to_quad_resolve_descriptors},
81
- {NPY_METH_strided_loop, (void *)&quad_to_quad_strided_loop},
82
- {0 , NULL }
83
- }});
84
-
85
-
71
+ specs.push_back (new PyArrayMethod_Spec{
72
+ .name = " cast_QuadPrec_to_QuadPrec" ,
73
+ .nin = 1 ,
74
+ .nout = 1 ,
75
+ .casting = NPY_SAME_KIND_CASTING,
76
+ .flags = NPY_METH_SUPPORTS_UNALIGNED,
77
+ .dtypes = quad2quad_dtypes,
78
+ .slots = new PyType_Slot[4 ]{
79
+ {NPY_METH_resolve_descriptors, (void *)&quad_to_quad_resolve_descriptors},
80
+ {NPY_METH_strided_loop, (void *)&quad_to_quad_strided_loop},
81
+ {NPY_METH_unaligned_strided_loop, (void *)&quad_to_quad_strided_loop},
82
+ {0 , NULL }}});
83
+
86
84
return specs.data ();
87
85
}
88
86
89
- PyArrayMethod_Spec ** init_casts (void )
87
+ PyArrayMethod_Spec **
88
+ init_casts (void )
90
89
{
91
- try
92
- {
90
+ try {
93
91
return init_casts_internal ();
94
92
}
95
- catch (const std::exception& e)
96
- {
93
+ catch (const std::exception &e) {
97
94
PyErr_NoMemory ();
98
95
return nullptr ;
99
96
}
100
-
101
97
}
102
98
103
- void free_casts (void )
99
+ void
100
+ free_casts (void )
104
101
{
105
102
for (auto cast : specs) {
106
103
if (cast == nullptr ) {
0 commit comments