1 #include <pythonic/core.hpp>
2 #include <pythonic/python/core.hpp>
3 #include <pythonic/types/bool.hpp>
4 #include <pythonic/types/int.hpp>
5 #ifdef _OPENMP
6 #include <omp.h>
7 #endif
8 #include <pythonic/include/types/ndarray.hpp>
9 #include <pythonic/include/types/numpy_texpr.hpp>
10 #include <pythonic/include/types/int32.hpp>
11 #include <pythonic/include/types/int.hpp>
12 #include <pythonic/types/int32.hpp>
13 #include <pythonic/types/numpy_texpr.hpp>
14 #include <pythonic/types/ndarray.hpp>
15 #include <pythonic/types/int.hpp>
16 #include <pythonic/include/builtins/False.hpp>
17 #include <pythonic/include/builtins/True.hpp>
18 #include <pythonic/include/builtins/getattr.hpp>
19 #include <pythonic/include/builtins/pythran/and_.hpp>
20 #include <pythonic/include/builtins/range.hpp>
21 #include <pythonic/include/builtins/tuple.hpp>
22 #include <pythonic/include/numpy/empty.hpp>
23 #include <pythonic/include/numpy/intp.hpp>
24 #include <pythonic/include/numpy/ndarray/fill.hpp>
25 #include <pythonic/include/numpy/ones.hpp>
26 #include <pythonic/include/operator_/add.hpp>
27 #include <pythonic/include/operator_/eq.hpp>
28 #include <pythonic/include/operator_/ge.hpp>
29 #include <pythonic/include/operator_/gt.hpp>
30 #include <pythonic/include/operator_/iadd.hpp>
31 #include <pythonic/include/operator_/lt.hpp>
32 #include <pythonic/include/operator_/neg.hpp>
33 #include <pythonic/include/operator_/not_.hpp>
34 #include <pythonic/include/types/slice.hpp>
35 #include <pythonic/include/types/str.hpp>
36 #include <pythonic/builtins/False.hpp>
37 #include <pythonic/builtins/True.hpp>
38 #include <pythonic/builtins/getattr.hpp>
39 #include <pythonic/builtins/pythran/and_.hpp>
40 #include <pythonic/builtins/range.hpp>
41 #include <pythonic/builtins/tuple.hpp>
42 #include <pythonic/numpy/empty.hpp>
43 #include <pythonic/numpy/intp.hpp>
44 #include <pythonic/numpy/ndarray/fill.hpp>
45 #include <pythonic/numpy/ones.hpp>
46 #include <pythonic/operator_/add.hpp>
47 #include <pythonic/operator_/eq.hpp>
48 #include <pythonic/operator_/ge.hpp>
49 #include <pythonic/operator_/gt.hpp>
50 #include <pythonic/operator_/iadd.hpp>
51 #include <pythonic/operator_/lt.hpp>
52 #include <pythonic/operator_/neg.hpp>
53 #include <pythonic/operator_/not_.hpp>
54 #include <pythonic/types/slice.hpp>
55 #include <pythonic/types/str.hpp>
56 namespace __pythran__group_columns
57 {
58 struct group_sparse
59 {
60 typedef void callable;
61 typedef void pure;
62 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 >
63 struct type
64 {
65 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::ones{})>::type>::type __type0;
66 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type1;
67 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::intp{})>::type>::type __type2;
68 typedef decltype(std::declval<__type0>()(std::declval<__type1>(), std::declval<__type2>())) __type3;
69 typedef typename pythonic::assignable<decltype(pythonic::operator_::neg(std::declval<__type3>()))>::type __type4;
70 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type5;
71 typedef decltype(std::declval<__type5>()(std::declval<__type1>())) __type7;
72 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type __type8;
73 typedef indexable<__type8> __type9;
74 typedef typename __combined<__type4,__type9>::type __type10;
75 typedef typename pythonic::assignable<long>::type __type11;
76 typedef container<typename std::remove_reference<__type11>::type> __type12;
77 typedef typename __combined<__type10,__type12,__type9,__type12>::type __type13;
78 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type13>())) __type14;
79 typedef typename std::tuple_element<0,typename std::remove_reference<__type14>::type>::type __type15;
80 typedef decltype(std::declval<__type5>()(std::declval<__type15>())) __type16;
81 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type16>::type::iterator>::value_type>::type __type17;
82 typedef indexable<__type17> __type18;
83 typedef typename __combined<__type10,__type18>::type __type19;
84 typedef typename pythonic::returnable<typename __combined<__type19,__type12,__type9,__type12,__type18>::type>::type result_type;
85 }
86 ;
87 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 >
88 typename type<argument_type0, argument_type1, argument_type2, argument_type3>::result_type operator()(argument_type0&& m, argument_type1&& n, argument_type2&& indices, argument_type3&& indptr) const
89 ;
90 } ;
91 struct group_dense
92 {
93 typedef void callable;
94 typedef void pure;
95 template <typename argument_type0 , typename argument_type1 , typename argument_type2 >
96 struct type
97 {
98 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::ones{})>::type>::type __type0;
99 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type1;
100 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::intp{})>::type>::type __type2;
101 typedef decltype(std::declval<__type0>()(std::declval<__type1>(), std::declval<__type2>())) __type3;
102 typedef typename pythonic::assignable<decltype(pythonic::operator_::neg(std::declval<__type3>()))>::type __type4;
103 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type5;
104 typedef decltype(std::declval<__type5>()(std::declval<__type1>())) __type7;
105 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type __type8;
106 typedef indexable<__type8> __type9;
107 typedef typename __combined<__type4,__type9>::type __type10;
108 typedef typename pythonic::assignable<long>::type __type11;
109 typedef container<typename std::remove_reference<__type11>::type> __type12;
110 typedef typename __combined<__type10,__type12,__type9,__type12>::type __type13;
111 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type13>())) __type14;
112 typedef typename std::tuple_element<0,typename std::remove_reference<__type14>::type>::type __type15;
113 typedef decltype(std::declval<__type5>()(std::declval<__type15>())) __type16;
114 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type16>::type::iterator>::value_type>::type __type17;
115 typedef indexable<__type17> __type18;
116 typedef typename __combined<__type10,__type18>::type __type19;
117 typedef typename pythonic::returnable<typename __combined<__type19,__type12,__type9,__type12,__type18>::type>::type result_type;
118 }
119 ;
120 template <typename argument_type0 , typename argument_type1 , typename argument_type2 >
121 typename type<argument_type0, argument_type1, argument_type2>::result_type operator()(argument_type0&& m, argument_type1&& n, argument_type2&& A) const
122 ;
123 } ;
124 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 >
operator ()(argument_type0 && m,argument_type1 && n,argument_type2 && indices,argument_type3 && indptr) const125 typename group_sparse::type<argument_type0, argument_type1, argument_type2, argument_type3>::result_type group_sparse::operator()(argument_type0&& m, argument_type1&& n, argument_type2&& indices, argument_type3&& indptr) const
126 {
127 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::ones{})>::type>::type __type0;
128 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type1;
129 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::intp{})>::type>::type __type2;
130 typedef decltype(std::declval<__type0>()(std::declval<__type1>(), std::declval<__type2>())) __type3;
131 typedef typename pythonic::assignable<decltype(pythonic::operator_::neg(std::declval<__type3>()))>::type __type4;
132 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type5;
133 typedef decltype(std::declval<__type5>()(std::declval<__type1>())) __type7;
134 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type __type8;
135 typedef indexable<__type8> __type9;
136 typedef typename __combined<__type4,__type9>::type __type10;
137 typedef typename pythonic::assignable<long>::type __type11;
138 typedef long __type12;
139 typedef decltype(pythonic::operator_::add(std::declval<__type11>(), std::declval<__type12>())) __type13;
140 typedef typename __combined<__type11,__type13>::type __type14;
141 typedef typename __combined<__type14,__type12>::type __type15;
142 typedef container<typename std::remove_reference<__type15>::type> __type16;
143 typedef typename __combined<__type10,__type16,__type9,__type16>::type __type17;
144 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type17>())) __type18;
145 typedef typename std::tuple_element<0,typename std::remove_reference<__type18>::type>::type __type19;
146 typedef decltype(std::declval<__type5>()(std::declval<__type19>())) __type20;
147 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type20>::type::iterator>::value_type>::type __type21;
148 typedef indexable<__type21> __type22;
149 typedef typename __combined<__type10,__type22>::type __type23;
150 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::empty{})>::type>::type __type26;
151 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type27;
152 typedef typename pythonic::assignable<decltype(std::declval<__type26>()(std::declval<__type27>(), std::declval<__type2>()))>::type __type28;
153 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type29;
154 typedef typename std::remove_cv<typename std::remove_reference<argument_type3>::type>::type __type30;
155 typedef decltype(std::declval<__type30>()[std::declval<__type8>()]) __type32;
156 typedef decltype(pythonic::operator_::add(std::declval<__type8>(), std::declval<__type12>())) __type35;
157 typedef decltype(std::declval<__type30>()[std::declval<__type35>()]) __type36;
158 typedef decltype(std::declval<__type5>()(std::declval<__type32>(), std::declval<__type36>())) __type37;
159 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type37>::type::iterator>::value_type>::type __type38;
160 typedef decltype(std::declval<__type29>()[std::declval<__type38>()]) __type39;
161 typedef indexable<__type39> __type40;
162 typedef typename __combined<__type28,__type40>::type __type41;
163 typedef decltype(std::declval<__type30>()[std::declval<__type21>()]) __type45;
164 typedef decltype(pythonic::operator_::add(std::declval<__type21>(), std::declval<__type12>())) __type48;
165 typedef decltype(std::declval<__type30>()[std::declval<__type48>()]) __type49;
166 typedef decltype(std::declval<__type5>()(std::declval<__type45>(), std::declval<__type49>())) __type50;
167 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type50>::type::iterator>::value_type>::type __type51;
168 typedef decltype(std::declval<__type29>()[std::declval<__type51>()]) __type52;
169 typedef indexable<__type52> __type53;
170 typedef typename __combined<__type41,__type53>::type __type54;
171 typedef container<typename std::remove_reference<__type12>::type> __type55;
172 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type37>::type::iterator>::value_type>::type>::type k;
173 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type50>::type::iterator>::value_type>::type>::type k__;
174 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type20>::type::iterator>::value_type>::type>::type j;
175 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type>::type i;
176 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type50>::type::iterator>::value_type>::type>::type k_;
177 typename pythonic::assignable<typename __combined<__type23,__type16,__type9,__type16,__type22>::type>::type groups = pythonic::operator_::neg(pythonic::numpy::functor::ones{}(n, pythonic::numpy::functor::intp{}));
178 typename pythonic::assignable<typename __combined<__type14,__type12>::type>::type current_group = 0L;
179 typename pythonic::assignable<typename __combined<__type54,__type55,__type40,__type53>::type>::type union_ = pythonic::numpy::functor::empty{}(m, pythonic::numpy::functor::intp{});
180 {
181 long __target139838532232432 = n;
182 for (long i=0L; i < __target139838532232432; i += 1L)
183 {
184 if (pythonic::operator_::ge(groups.fast(i), 0L))
185 {
186 continue;
187 }
188 groups.fast(i) = current_group;
189 typename pythonic::lazy<decltype(pythonic::builtins::True)>::type all_grouped = pythonic::builtins::True;
190 pythonic::numpy::ndarray::functor::fill{}(union_, 0L);
191 {
192 long __target139838529692864 = indptr.fast(pythonic::operator_::add(i, 1L));
193 for (long k=indptr.fast(i); k < __target139838529692864; k += 1L)
194 {
195 union_[indices[k]] = 1L;
196 }
197 }
198 {
199 long __target139838529693344 = std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, groups));
200 for (long j=0L; j < __target139838529693344; j += 1L)
201 {
202 if (pythonic::operator_::lt(groups.fast(j), 0L))
203 {
204 all_grouped = pythonic::builtins::False;
205 }
206 else
207 {
208 continue;
209 }
210 typename pythonic::lazy<decltype(pythonic::builtins::False)>::type intersect = pythonic::builtins::False;
211 {
212 long __target139838529729632 = indptr.fast(pythonic::operator_::add(j, 1L));
213 for (long k_=indptr.fast(j); k_ < __target139838529729632; k_ += 1L)
214 {
215 if (pythonic::operator_::eq(union_[indices[k_]], 1L))
216 {
217 intersect = pythonic::builtins::True;
218 break;
219 }
220 }
221 }
222 if (pythonic::operator_::not_(intersect))
223 {
224 {
225 long __target139838529623856 = indptr.fast(pythonic::operator_::add(j, 1L));
226 for (long k__=indptr.fast(j); k__ < __target139838529623856; k__ += 1L)
227 {
228 union_[indices[k__]] = 1L;
229 }
230 }
231 groups.fast(j) = current_group;
232 }
233 }
234 }
235 if (all_grouped)
236 {
237 break;
238 }
239 else
240 {
241 current_group += 1L;
242 }
243 }
244 }
245 return groups;
246 }
247 template <typename argument_type0 , typename argument_type1 , typename argument_type2 >
operator ()(argument_type0 && m,argument_type1 && n,argument_type2 && A) const248 typename group_dense::type<argument_type0, argument_type1, argument_type2>::result_type group_dense::operator()(argument_type0&& m, argument_type1&& n, argument_type2&& A) const
249 {
250 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::ones{})>::type>::type __type0;
251 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type1;
252 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::intp{})>::type>::type __type2;
253 typedef decltype(std::declval<__type0>()(std::declval<__type1>(), std::declval<__type2>())) __type3;
254 typedef typename pythonic::assignable<decltype(pythonic::operator_::neg(std::declval<__type3>()))>::type __type4;
255 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type5;
256 typedef decltype(std::declval<__type5>()(std::declval<__type1>())) __type7;
257 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type __type8;
258 typedef indexable<__type8> __type9;
259 typedef typename __combined<__type4,__type9>::type __type10;
260 typedef typename pythonic::assignable<long>::type __type11;
261 typedef long __type12;
262 typedef decltype(pythonic::operator_::add(std::declval<__type11>(), std::declval<__type12>())) __type13;
263 typedef typename __combined<__type11,__type13>::type __type14;
264 typedef typename __combined<__type14,__type12>::type __type15;
265 typedef container<typename std::remove_reference<__type15>::type> __type16;
266 typedef typename __combined<__type10,__type16,__type9,__type16>::type __type17;
267 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type17>())) __type18;
268 typedef typename std::tuple_element<0,typename std::remove_reference<__type18>::type>::type __type19;
269 typedef decltype(std::declval<__type5>()(std::declval<__type19>())) __type20;
270 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type20>::type::iterator>::value_type>::type __type21;
271 typedef indexable<__type21> __type22;
272 typedef typename __combined<__type10,__type22>::type __type23;
273 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::empty{})>::type>::type __type26;
274 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type27;
275 typedef typename pythonic::assignable<decltype(std::declval<__type26>()(std::declval<__type27>(), std::declval<__type2>()))>::type __type28;
276 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type29;
277 typedef typename pythonic::assignable<decltype(pythonic::builtins::getattr(pythonic::types::attr::T{}, std::declval<__type29>()))>::type __type30;
278 typedef decltype(std::declval<__type30>()[std::declval<__type21>()]) __type32;
279 typedef decltype(pythonic::operator_::add(std::declval<__type28>(), std::declval<__type32>())) __type33;
280 typedef typename __combined<__type28,__type33>::type __type34;
281 typedef decltype(std::declval<__type30>()[std::declval<__type8>()]) __type37;
282 typedef decltype(std::declval<__type5>()(std::declval<__type27>())) __type39;
283 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type39>::type::iterator>::value_type>::type>::type k;
284 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type20>::type::iterator>::value_type>::type>::type j;
285 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type7>::type::iterator>::value_type>::type>::type i;
286 typename pythonic::assignable_noescape<decltype(pythonic::builtins::getattr(pythonic::types::attr::T{}, A))>::type B = pythonic::builtins::getattr(pythonic::types::attr::T{}, A);
287 typename pythonic::assignable<typename __combined<__type23,__type16,__type9,__type16,__type22>::type>::type groups = pythonic::operator_::neg(pythonic::numpy::functor::ones{}(n, pythonic::numpy::functor::intp{}));
288 typename pythonic::assignable<typename __combined<__type14,__type12>::type>::type current_group = 0L;
289 typename pythonic::assignable<typename __combined<__type34,__type37,__type32>::type>::type union_ = pythonic::numpy::functor::empty{}(m, pythonic::numpy::functor::intp{});
290 {
291 long __target139838532312176 = n;
292 for (long i=0L; i < __target139838532312176; i += 1L)
293 {
294 if (pythonic::operator_::ge(groups.fast(i), 0L))
295 {
296 continue;
297 }
298 groups.fast(i) = current_group;
299 typename pythonic::lazy<decltype(pythonic::builtins::True)>::type all_grouped = pythonic::builtins::True;
300 union_[pythonic::types::contiguous_slice(pythonic::builtins::None,pythonic::builtins::None)] = B.fast(i);
301 {
302 long __target139838532383360 = std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, groups));
303 for (long j=0L; j < __target139838532383360; j += 1L)
304 {
305 if (pythonic::operator_::lt(groups.fast(j), 0L))
306 {
307 all_grouped = pythonic::builtins::False;
308 }
309 else
310 {
311 continue;
312 }
313 typename pythonic::lazy<decltype(pythonic::builtins::False)>::type intersect = pythonic::builtins::False;
314 {
315 long __target139838532385424 = m;
316 for (long k=0L; k < __target139838532385424; k += 1L)
317 {
318 if (pythonic::builtins::pythran::and_([&] () { return pythonic::operator_::gt(union_.fast(k), 0L); }, [&] () { return pythonic::operator_::gt(B.fast(pythonic::types::make_tuple(j, k)), 0L); }))
319 {
320 intersect = pythonic::builtins::True;
321 break;
322 }
323 }
324 }
325 if (pythonic::operator_::not_(intersect))
326 {
327 union_ += B.fast(j);
328 groups.fast(j) = current_group;
329 }
330 }
331 }
332 if (all_grouped)
333 {
334 break;
335 }
336 else
337 {
338 current_group += 1L;
339 }
340 }
341 }
342 return groups;
343 }
344 }
345 #include <pythonic/python/exception_handler.hpp>
346 #ifdef ENABLE_PYTHON_MODULE
group_sparse0(long && m,long && n,pythonic::types::ndarray<long,pythonic::types::pshape<long>> && indices,pythonic::types::ndarray<long,pythonic::types::pshape<long>> && indptr)347 typename __pythran__group_columns::group_sparse::type<long, long, pythonic::types::ndarray<long,pythonic::types::pshape<long>>, pythonic::types::ndarray<long,pythonic::types::pshape<long>>>::result_type group_sparse0(long&& m, long&& n, pythonic::types::ndarray<long,pythonic::types::pshape<long>>&& indices, pythonic::types::ndarray<long,pythonic::types::pshape<long>>&& indptr)
348 {
349
350 PyThreadState *_save = PyEval_SaveThread();
351 try {
352 auto res = __pythran__group_columns::group_sparse()(m, n, indices, indptr);
353 PyEval_RestoreThread(_save);
354 return res;
355 }
356 catch(...) {
357 PyEval_RestoreThread(_save);
358 throw;
359 }
360 ;
361 }
group_sparse1(long && m,long && n,pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>> && indices,pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>> && indptr)362 typename __pythran__group_columns::group_sparse::type<long, long, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>>::result_type group_sparse1(long&& m, long&& n, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>&& indices, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>&& indptr)
363 {
364
365 PyThreadState *_save = PyEval_SaveThread();
366 try {
367 auto res = __pythran__group_columns::group_sparse()(m, n, indices, indptr);
368 PyEval_RestoreThread(_save);
369 return res;
370 }
371 catch(...) {
372 PyEval_RestoreThread(_save);
373 throw;
374 }
375 ;
376 }
group_dense0(long && m,long && n,pythonic::types::ndarray<long,pythonic::types::pshape<long,long>> && A)377 typename __pythran__group_columns::group_dense::type<long, long, pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>::result_type group_dense0(long&& m, long&& n, pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>&& A)
378 {
379
380 PyThreadState *_save = PyEval_SaveThread();
381 try {
382 auto res = __pythran__group_columns::group_dense()(m, n, A);
383 PyEval_RestoreThread(_save);
384 return res;
385 }
386 catch(...) {
387 PyEval_RestoreThread(_save);
388 throw;
389 }
390 ;
391 }
group_dense1(long && m,long && n,pythonic::types::numpy_texpr<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>> && A)392 typename __pythran__group_columns::group_dense::type<long, long, pythonic::types::numpy_texpr<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>>::result_type group_dense1(long&& m, long&& n, pythonic::types::numpy_texpr<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>&& A)
393 {
394
395 PyThreadState *_save = PyEval_SaveThread();
396 try {
397 auto res = __pythran__group_columns::group_dense()(m, n, A);
398 PyEval_RestoreThread(_save);
399 return res;
400 }
401 catch(...) {
402 PyEval_RestoreThread(_save);
403 throw;
404 }
405 ;
406 }
group_dense2(long && m,long && n,pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>> && A)407 typename __pythran__group_columns::group_dense::type<long, long, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>::result_type group_dense2(long&& m, long&& n, pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>&& A)
408 {
409
410 PyThreadState *_save = PyEval_SaveThread();
411 try {
412 auto res = __pythran__group_columns::group_dense()(m, n, A);
413 PyEval_RestoreThread(_save);
414 return res;
415 }
416 catch(...) {
417 PyEval_RestoreThread(_save);
418 throw;
419 }
420 ;
421 }
group_dense3(long && m,long && n,pythonic::types::numpy_texpr<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>> && A)422 typename __pythran__group_columns::group_dense::type<long, long, pythonic::types::numpy_texpr<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>>::result_type group_dense3(long&& m, long&& n, pythonic::types::numpy_texpr<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>&& A)
423 {
424
425 PyThreadState *_save = PyEval_SaveThread();
426 try {
427 auto res = __pythran__group_columns::group_dense()(m, n, A);
428 PyEval_RestoreThread(_save);
429 return res;
430 }
431 catch(...) {
432 PyEval_RestoreThread(_save);
433 throw;
434 }
435 ;
436 }
437
438 static PyObject *
__pythran_wrap_group_sparse0(PyObject * self,PyObject * args,PyObject * kw)439 __pythran_wrap_group_sparse0(PyObject *self, PyObject *args, PyObject *kw)
440 {
441 PyObject* args_obj[4+1];
442 char const* keywords[] = {"m", "n", "indices", "indptr", nullptr};
443 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOOO",
444 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2], &args_obj[3]))
445 return nullptr;
446 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::ndarray<long,pythonic::types::pshape<long>>>(args_obj[2]) && is_convertible<pythonic::types::ndarray<long,pythonic::types::pshape<long>>>(args_obj[3]))
447 return to_python(group_sparse0(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::ndarray<long,pythonic::types::pshape<long>>>(args_obj[2]), from_python<pythonic::types::ndarray<long,pythonic::types::pshape<long>>>(args_obj[3])));
448 else {
449 return nullptr;
450 }
451 }
452
453 static PyObject *
__pythran_wrap_group_sparse1(PyObject * self,PyObject * args,PyObject * kw)454 __pythran_wrap_group_sparse1(PyObject *self, PyObject *args, PyObject *kw)
455 {
456 PyObject* args_obj[4+1];
457 char const* keywords[] = {"m", "n", "indices", "indptr", nullptr};
458 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOOO",
459 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2], &args_obj[3]))
460 return nullptr;
461 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>>(args_obj[2]) && is_convertible<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>>(args_obj[3]))
462 return to_python(group_sparse1(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>>(args_obj[2]), from_python<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long>>>(args_obj[3])));
463 else {
464 return nullptr;
465 }
466 }
467
468 static PyObject *
__pythran_wrap_group_dense0(PyObject * self,PyObject * args,PyObject * kw)469 __pythran_wrap_group_dense0(PyObject *self, PyObject *args, PyObject *kw)
470 {
471 PyObject* args_obj[3+1];
472 char const* keywords[] = {"m", "n", "A", nullptr};
473 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOO",
474 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2]))
475 return nullptr;
476 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>(args_obj[2]))
477 return to_python(group_dense0(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>(args_obj[2])));
478 else {
479 return nullptr;
480 }
481 }
482
483 static PyObject *
__pythran_wrap_group_dense1(PyObject * self,PyObject * args,PyObject * kw)484 __pythran_wrap_group_dense1(PyObject *self, PyObject *args, PyObject *kw)
485 {
486 PyObject* args_obj[3+1];
487 char const* keywords[] = {"m", "n", "A", nullptr};
488 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOO",
489 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2]))
490 return nullptr;
491 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::numpy_texpr<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>>(args_obj[2]))
492 return to_python(group_dense1(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::numpy_texpr<pythonic::types::ndarray<long,pythonic::types::pshape<long,long>>>>(args_obj[2])));
493 else {
494 return nullptr;
495 }
496 }
497
498 static PyObject *
__pythran_wrap_group_dense2(PyObject * self,PyObject * args,PyObject * kw)499 __pythran_wrap_group_dense2(PyObject *self, PyObject *args, PyObject *kw)
500 {
501 PyObject* args_obj[3+1];
502 char const* keywords[] = {"m", "n", "A", nullptr};
503 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOO",
504 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2]))
505 return nullptr;
506 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>(args_obj[2]))
507 return to_python(group_dense2(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>(args_obj[2])));
508 else {
509 return nullptr;
510 }
511 }
512
513 static PyObject *
__pythran_wrap_group_dense3(PyObject * self,PyObject * args,PyObject * kw)514 __pythran_wrap_group_dense3(PyObject *self, PyObject *args, PyObject *kw)
515 {
516 PyObject* args_obj[3+1];
517 char const* keywords[] = {"m", "n", "A", nullptr};
518 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOO",
519 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2]))
520 return nullptr;
521 if(is_convertible<long>(args_obj[0]) && is_convertible<long>(args_obj[1]) && is_convertible<pythonic::types::numpy_texpr<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>>(args_obj[2]))
522 return to_python(group_dense3(from_python<long>(args_obj[0]), from_python<long>(args_obj[1]), from_python<pythonic::types::numpy_texpr<pythonic::types::ndarray<npy_int32,pythonic::types::pshape<long,long>>>>(args_obj[2])));
523 else {
524 return nullptr;
525 }
526 }
527
528 static PyObject *
__pythran_wrapall_group_sparse(PyObject * self,PyObject * args,PyObject * kw)529 __pythran_wrapall_group_sparse(PyObject *self, PyObject *args, PyObject *kw)
530 {
531 return pythonic::handle_python_exception([self, args, kw]()
532 -> PyObject* {
533
534 if(PyObject* obj = __pythran_wrap_group_sparse0(self, args, kw))
535 return obj;
536 PyErr_Clear();
537
538
539 if(PyObject* obj = __pythran_wrap_group_sparse1(self, args, kw))
540 return obj;
541 PyErr_Clear();
542
543 return pythonic::python::raise_invalid_argument(
544 "group_sparse", "\n"" - group_sparse(int, int, int[:], int[:])\n"" - group_sparse(int, int, int32[:], int32[:])", args, kw);
545 });
546 }
547
548
549 static PyObject *
__pythran_wrapall_group_dense(PyObject * self,PyObject * args,PyObject * kw)550 __pythran_wrapall_group_dense(PyObject *self, PyObject *args, PyObject *kw)
551 {
552 return pythonic::handle_python_exception([self, args, kw]()
553 -> PyObject* {
554
555 if(PyObject* obj = __pythran_wrap_group_dense0(self, args, kw))
556 return obj;
557 PyErr_Clear();
558
559
560 if(PyObject* obj = __pythran_wrap_group_dense1(self, args, kw))
561 return obj;
562 PyErr_Clear();
563
564
565 if(PyObject* obj = __pythran_wrap_group_dense2(self, args, kw))
566 return obj;
567 PyErr_Clear();
568
569
570 if(PyObject* obj = __pythran_wrap_group_dense3(self, args, kw))
571 return obj;
572 PyErr_Clear();
573
574 return pythonic::python::raise_invalid_argument(
575 "group_dense", "\n"" - group_dense(int, int, int[:,:])\n"" - group_dense(int, int, int32[:,:])", args, kw);
576 });
577 }
578
579
580 static PyMethodDef Methods[] = {
581 {
582 "group_sparse",
583 (PyCFunction)__pythran_wrapall_group_sparse,
584 METH_VARARGS | METH_KEYWORDS,
585 "Supported prototypes:\n""\n"" - group_sparse(int, int, int[:], int[:])\n"" - group_sparse(int, int, int32[:], int32[:])"},{
586 "group_dense",
587 (PyCFunction)__pythran_wrapall_group_dense,
588 METH_VARARGS | METH_KEYWORDS,
589 "Supported prototypes:\n""\n"" - group_dense(int, int, int[:,:])\n"" - group_dense(int, int, int32[:,:])"},
590 {NULL, NULL, 0, NULL}
591 };
592
593
594 #if PY_MAJOR_VERSION >= 3
595 static struct PyModuleDef moduledef = {
596 PyModuleDef_HEAD_INIT,
597 "_group_columns", /* m_name */
598 "\n""Pythran implementation of columns grouping for finite difference Jacobian\n""estimation. Used by ._numdiff.group_columns and based on the Cython version.\n""", /* m_doc */
599 -1, /* m_size */
600 Methods, /* m_methods */
601 NULL, /* m_reload */
602 NULL, /* m_traverse */
603 NULL, /* m_clear */
604 NULL, /* m_free */
605 };
606 #define PYTHRAN_RETURN return theModule
607 #define PYTHRAN_MODULE_INIT(s) PyInit_##s
608 #else
609 #define PYTHRAN_RETURN return
610 #define PYTHRAN_MODULE_INIT(s) init##s
611 #endif
612 PyMODINIT_FUNC
613 PYTHRAN_MODULE_INIT(_group_columns)(void)
614 #ifndef _WIN32
615 __attribute__ ((visibility("default")))
616 __attribute__ ((externally_visible))
617 #endif
618 ;
619 PyMODINIT_FUNC
PYTHRAN_MODULE_INIT(_group_columns)620 PYTHRAN_MODULE_INIT(_group_columns)(void) {
621 import_array()
622 #if PY_MAJOR_VERSION >= 3
623 PyObject* theModule = PyModule_Create(&moduledef);
624 #else
625 PyObject* theModule = Py_InitModule3("_group_columns",
626 Methods,
627 "\n""Pythran implementation of columns grouping for finite difference Jacobian\n""estimation. Used by ._numdiff.group_columns and based on the Cython version.\n"""
628 );
629 #endif
630 if(! theModule)
631 PYTHRAN_RETURN;
632 PyObject * theDoc = Py_BuildValue("(sss)",
633 "0.9.11",
634 "2021-08-01 14:59:05.739047",
635 "ac77c0cfb3b65ea485951fd3a308c3ac40dd2c1905835b2982a66e23bfff0ebc");
636 if(! theDoc)
637 PYTHRAN_RETURN;
638 PyModule_AddObject(theModule,
639 "__pythran__",
640 theDoc);
641
642
643 PYTHRAN_RETURN;
644 }
645
646 #endif