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/int8.hpp>
9 #include <pythonic/include/types/ndarray.hpp>
10 #include <pythonic/include/types/int.hpp>
11 #include <pythonic/include/types/int64.hpp>
12 #include <pythonic/types/int64.hpp>
13 #include <pythonic/types/int8.hpp>
14 #include <pythonic/types/ndarray.hpp>
15 #include <pythonic/types/int.hpp>
16 #include <pythonic/include/builtins/getattr.hpp>
17 #include <pythonic/include/builtins/range.hpp>
18 #include <pythonic/include/numpy/roll.hpp>
19 #include <pythonic/include/operator_/add.hpp>
20 #include <pythonic/include/operator_/ixor.hpp>
21 #include <pythonic/include/operator_/mod.hpp>
22 #include <pythonic/include/operator_/neg.hpp>
23 #include <pythonic/include/operator_/xor_.hpp>
24 #include <pythonic/include/types/str.hpp>
25 #include <pythonic/builtins/getattr.hpp>
26 #include <pythonic/builtins/range.hpp>
27 #include <pythonic/numpy/roll.hpp>
28 #include <pythonic/operator_/add.hpp>
29 #include <pythonic/operator_/ixor.hpp>
30 #include <pythonic/operator_/mod.hpp>
31 #include <pythonic/operator_/neg.hpp>
32 #include <pythonic/operator_/xor_.hpp>
33 #include <pythonic/types/str.hpp>
34 namespace __pythran__max_len_seq_inner
35 {
36 struct _max_len_seq_inner
37 {
38 typedef void callable;
39 ;
40 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
41 struct type
42 {
43 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type0;
44 typedef typename pythonic::assignable<long>::type __type1;
45 typedef decltype(std::declval<__type0>()[std::declval<__type1>()]) __type2;
46 typedef typename pythonic::assignable<decltype(std::declval<__type0>()[std::declval<__type1>()])>::type __type3;
47 typedef container<typename std::remove_reference<__type2>::type> __type5;
48 typedef typename __combined<__type0,__type5>::type __type6;
49 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type7;
50 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type8;
51 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type7>())) __type10;
52 typedef typename std::tuple_element<0,typename std::remove_reference<__type10>::type>::type __type11;
53 typedef typename pythonic::lazy<__type11>::type __type12;
54 typedef decltype(std::declval<__type8>()(std::declval<__type12>())) __type13;
55 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type13>::type::iterator>::value_type>::type __type14;
56 typedef decltype(std::declval<__type7>()[std::declval<__type14>()]) __type15;
57 typedef decltype(pythonic::operator_::add(std::declval<__type15>(), std::declval<__type1>())) __type17;
58 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type18;
59 typedef decltype(pythonic::operator_::mod(std::declval<__type17>(), std::declval<__type18>())) __type19;
60 typedef decltype(std::declval<__type6>()[std::declval<__type19>()]) __type20;
61 typedef typename __combined<__type3,__type20>::type __type21;
62 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::numpy::functor::roll{})>::type>::type __type22;
63 typedef container<typename std::remove_reference<__type20>::type> __type23;
64 typedef container<typename std::remove_reference<__type21>::type> __type25;
65 typedef indexable<__type1> __type27;
66 typedef typename __combined<__type0,__type5,__type23,__type25,__type27>::type __type28;
67 typedef long __type31;
68 typedef decltype(pythonic::operator_::add(std::declval<__type1>(), std::declval<__type31>())) __type32;
69 typedef typename pythonic::assignable<decltype(pythonic::operator_::mod(std::declval<__type32>(), std::declval<__type18>()))>::type __type34;
70 typedef typename __combined<__type1,__type34>::type __type35;
71 typedef decltype(pythonic::operator_::neg(std::declval<__type35>())) __type36;
72 typedef __type2 __ptype0;
73 typedef __type21 __ptype1;
74 typedef typename pythonic::returnable<decltype(std::declval<__type22>()(std::declval<__type28>(), std::declval<__type36>(), std::declval<__type31>()))>::type result_type;
75 }
76 ;
77 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
78 typename type<argument_type0, argument_type1, argument_type2, argument_type3, argument_type4>::result_type operator()(argument_type0&& taps, argument_type1&& state, argument_type2&& nbits, argument_type3&& length, argument_type4&& seq) const
79 ;
80 } ;
81 template <typename argument_type0 , typename argument_type1 , typename argument_type2 , typename argument_type3 , typename argument_type4 >
operator ()(argument_type0 && taps,argument_type1 && state,argument_type2 && nbits,argument_type3 && length,argument_type4 && seq) const82 typename _max_len_seq_inner::type<argument_type0, argument_type1, argument_type2, argument_type3, argument_type4>::result_type _max_len_seq_inner::operator()(argument_type0&& taps, argument_type1&& state, argument_type2&& nbits, argument_type3&& length, argument_type4&& seq) const
83 {
84 typedef typename pythonic::assignable<long>::type __type0;
85 typedef long __type2;
86 typedef decltype(pythonic::operator_::add(std::declval<__type0>(), std::declval<__type2>())) __type3;
87 typedef typename std::remove_cv<typename std::remove_reference<argument_type2>::type>::type __type4;
88 typedef typename pythonic::assignable<decltype(pythonic::operator_::mod(std::declval<__type3>(), std::declval<__type4>()))>::type __type5;
89 typedef typename std::remove_cv<typename std::remove_reference<argument_type1>::type>::type __type6;
90 typedef typename __combined<__type0,__type5>::type __type8;
91 typedef decltype(std::declval<__type6>()[std::declval<__type8>()]) __type9;
92 typedef container<typename std::remove_reference<__type9>::type> __type10;
93 typedef typename __combined<__type6,__type10>::type __type11;
94 typedef typename std::remove_cv<typename std::remove_reference<argument_type0>::type>::type __type12;
95 typedef typename std::remove_cv<typename std::remove_reference<decltype(pythonic::builtins::functor::range{})>::type>::type __type13;
96 typedef decltype(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, std::declval<__type12>())) __type15;
97 typedef typename std::tuple_element<0,typename std::remove_reference<__type15>::type>::type __type16;
98 typedef typename pythonic::lazy<__type16>::type __type17;
99 typedef decltype(std::declval<__type13>()(std::declval<__type17>())) __type18;
100 typedef typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type18>::type::iterator>::value_type>::type __type19;
101 typedef decltype(std::declval<__type12>()[std::declval<__type19>()]) __type20;
102 typedef decltype(pythonic::operator_::add(std::declval<__type20>(), std::declval<__type8>())) __type22;
103 typedef decltype(pythonic::operator_::mod(std::declval<__type22>(), std::declval<__type4>())) __type24;
104 typedef decltype(std::declval<__type11>()[std::declval<__type24>()]) __type25;
105 typedef container<typename std::remove_reference<__type25>::type> __type26;
106 typedef typename pythonic::assignable<decltype(std::declval<__type6>()[std::declval<__type8>()])>::type __type27;
107 typedef typename __combined<__type27,__type25>::type __type28;
108 typedef container<typename std::remove_reference<__type28>::type> __type29;
109 typedef indexable<__type8> __type31;
110 typedef typename std::remove_cv<typename std::remove_reference<argument_type3>::type>::type __type32;
111 typedef decltype(std::declval<__type13>()(std::declval<__type32>())) __type33;
112 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type18>::type::iterator>::value_type>::type>::type ti;
113 typename pythonic::assignable<typename std::remove_cv<typename std::iterator_traits<typename std::remove_reference<__type33>::type::iterator>::value_type>::type>::type i;
114 typename pythonic::lazy<decltype(std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, taps)))>::type n_taps = std::get<0>(pythonic::builtins::getattr(pythonic::types::attr::SHAPE{}, taps));
115 typename pythonic::assignable<typename __combined<__type0,__type5>::type>::type idx = 0L;
116 {
117 long __target139838532972448 = length;
118 for (long i=0L; i < __target139838532972448; i += 1L)
119 {
120 typename pythonic::assignable<typename __combined<__type27,__type25>::type>::type feedback = state.fast(idx);
121 seq.fast(i) = feedback;
122 {
123 long __target139838532969952 = n_taps;
124 for (long ti=0L; ti < __target139838532969952; ti += 1L)
125 {
126 feedback ^= state.fast(pythonic::operator_::mod(pythonic::operator_::add(taps.fast(ti), idx), nbits));
127 }
128 }
129 state.fast(idx) = feedback;
130 idx = pythonic::operator_::mod(pythonic::operator_::add(idx, 1L), nbits);
131 }
132 }
133 return pythonic::numpy::functor::roll{}(state, pythonic::operator_::neg(idx), 0L);
134 }
135 }
136 #include <pythonic/python/exception_handler.hpp>
137 #ifdef ENABLE_PYTHON_MODULE
_max_len_seq_inner0(pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>> && taps,pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>> && state,long && nbits,long && length,pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>> && seq)138 typename __pythran__max_len_seq_inner::_max_len_seq_inner::type<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>, long, long, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>::result_type _max_len_seq_inner0(pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>&& taps, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>&& state, long&& nbits, long&& length, pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>&& seq)
139 {
140
141 PyThreadState *_save = PyEval_SaveThread();
142 try {
143 auto res = __pythran__max_len_seq_inner::_max_len_seq_inner()(taps, state, nbits, length, seq);
144 PyEval_RestoreThread(_save);
145 return res;
146 }
147 catch(...) {
148 PyEval_RestoreThread(_save);
149 throw;
150 }
151 ;
152 }
153
154 static PyObject *
__pythran_wrap__max_len_seq_inner0(PyObject * self,PyObject * args,PyObject * kw)155 __pythran_wrap__max_len_seq_inner0(PyObject *self, PyObject *args, PyObject *kw)
156 {
157 PyObject* args_obj[5+1];
158 char const* keywords[] = {"taps", "state", "nbits", "length", "seq", nullptr};
159 if(! PyArg_ParseTupleAndKeywords(args, kw, "OOOOO",
160 (char**)keywords , &args_obj[0], &args_obj[1], &args_obj[2], &args_obj[3], &args_obj[4]))
161 return nullptr;
162 if(is_convertible<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>>(args_obj[0]) && is_convertible<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[1]) && is_convertible<long>(args_obj[2]) && is_convertible<long>(args_obj[3]) && is_convertible<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[4]))
163 return to_python(_max_len_seq_inner0(from_python<pythonic::types::ndarray<npy_int64,pythonic::types::pshape<long>>>(args_obj[0]), from_python<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[1]), from_python<long>(args_obj[2]), from_python<long>(args_obj[3]), from_python<pythonic::types::ndarray<npy_int8,pythonic::types::pshape<long>>>(args_obj[4])));
164 else {
165 return nullptr;
166 }
167 }
168
169 static PyObject *
__pythran_wrapall__max_len_seq_inner(PyObject * self,PyObject * args,PyObject * kw)170 __pythran_wrapall__max_len_seq_inner(PyObject *self, PyObject *args, PyObject *kw)
171 {
172 return pythonic::handle_python_exception([self, args, kw]()
173 -> PyObject* {
174
175 if(PyObject* obj = __pythran_wrap__max_len_seq_inner0(self, args, kw))
176 return obj;
177 PyErr_Clear();
178
179 return pythonic::python::raise_invalid_argument(
180 "_max_len_seq_inner", "\n"" - _max_len_seq_inner(int64[:], int8[:], int, int, int8[:])", args, kw);
181 });
182 }
183
184
185 static PyMethodDef Methods[] = {
186 {
187 "_max_len_seq_inner",
188 (PyCFunction)__pythran_wrapall__max_len_seq_inner,
189 METH_VARARGS | METH_KEYWORDS,
190 "Supported prototypes:\n""\n"" - _max_len_seq_inner(int64[:], int8[:], int, int, int8[:])"},
191 {NULL, NULL, 0, NULL}
192 };
193
194
195 #if PY_MAJOR_VERSION >= 3
196 static struct PyModuleDef moduledef = {
197 PyModuleDef_HEAD_INIT,
198 "_max_len_seq_inner", /* m_name */
199 "", /* m_doc */
200 -1, /* m_size */
201 Methods, /* m_methods */
202 NULL, /* m_reload */
203 NULL, /* m_traverse */
204 NULL, /* m_clear */
205 NULL, /* m_free */
206 };
207 #define PYTHRAN_RETURN return theModule
208 #define PYTHRAN_MODULE_INIT(s) PyInit_##s
209 #else
210 #define PYTHRAN_RETURN return
211 #define PYTHRAN_MODULE_INIT(s) init##s
212 #endif
213 PyMODINIT_FUNC
214 PYTHRAN_MODULE_INIT(_max_len_seq_inner)(void)
215 #ifndef _WIN32
216 __attribute__ ((visibility("default")))
217 __attribute__ ((externally_visible))
218 #endif
219 ;
220 PyMODINIT_FUNC
PYTHRAN_MODULE_INIT(_max_len_seq_inner)221 PYTHRAN_MODULE_INIT(_max_len_seq_inner)(void) {
222 import_array()
223 #if PY_MAJOR_VERSION >= 3
224 PyObject* theModule = PyModule_Create(&moduledef);
225 #else
226 PyObject* theModule = Py_InitModule3("_max_len_seq_inner",
227 Methods,
228 ""
229 );
230 #endif
231 if(! theModule)
232 PYTHRAN_RETURN;
233 PyObject * theDoc = Py_BuildValue("(sss)",
234 "0.9.11",
235 "2021-08-01 14:59:05.891799",
236 "ccd4c6b01dd37c8a698a8beaea85985732ea19d0ab7d0883d689f577fbda0424");
237 if(! theDoc)
238 PYTHRAN_RETURN;
239 PyModule_AddObject(theModule,
240 "__pythran__",
241 theDoc);
242
243
244 PYTHRAN_RETURN;
245 }
246
247 #endif