Generated by Cython 0.26
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: bit.cpp
+001: """Functions for working with bitvectors.
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_pyintbitcount_line_7, __pyx_kp_u_Return_number_of_set_bits_1s_in) < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_bitcount_line_19, __pyx_kp_u_Return_number_of_set_bits_1s_bit) < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_pyintnextset_line_27, __pyx_kp_u_Return_index_of_first_set_bit_st) < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u_fanout_line_42, __pyx_kp_u_Return_number_of_contiguous_comp) < 0) __PYX_ERR(1, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_2, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
002:
003: NB: most functions are in bit.pxd to facilitate function inlining."""
004: from __future__ import print_function
005:
006:
+007: def pyintbitcount(a):
/* Python wrapper */
static PyObject *__pyx_pw_8discodop_3bit_1pyintbitcount(PyObject *__pyx_self, PyObject *__pyx_v_a); /*proto*/
static char __pyx_doc_8discodop_3bit_pyintbitcount[] = "pyintbitcount(a)\nReturn number of set bits (1s) in a Python integer.\n\n\t>>> pyintbitcount(0b0011101)\n\t4";
static PyMethodDef __pyx_mdef_8discodop_3bit_1pyintbitcount = {"pyintbitcount", (PyCFunction)__pyx_pw_8discodop_3bit_1pyintbitcount, METH_O, __pyx_doc_8discodop_3bit_pyintbitcount};
static PyObject *__pyx_pw_8discodop_3bit_1pyintbitcount(PyObject *__pyx_self, PyObject *__pyx_v_a) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pyintbitcount (wrapper)", 0);
__pyx_r = __pyx_pf_8discodop_3bit_pyintbitcount(__pyx_self, ((PyObject *)__pyx_v_a));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8discodop_3bit_pyintbitcount(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a) {
PyObject *__pyx_v_count = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pyintbitcount", 0);
__Pyx_INCREF(__pyx_v_a);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("discodop.bit.pyintbitcount", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_count);
__Pyx_XDECREF(__pyx_v_a);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__2 = PyTuple_Pack(2, __pyx_n_s_a, __pyx_n_s_count); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__2);
__Pyx_GIVEREF(__pyx_tuple__2);
/* … */
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8discodop_3bit_1pyintbitcount, NULL, __pyx_n_s_discodop_bit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyintbitcount, __pyx_t_1) < 0) __PYX_ERR(1, 7, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_discodop_bit_pyx, __pyx_n_s_pyintbitcount, 7, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(1, 7, __pyx_L1_error)
008: """Return number of set bits (1s) in a Python integer.
009:
010: >>> pyintbitcount(0b0011101)
011: 4"""
+012: count = 0
__Pyx_INCREF(__pyx_int_0);
__pyx_v_count = __pyx_int_0;
+013: while a:
while (1) {
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 13, __pyx_L1_error)
if (!__pyx_t_1) break;
+014: a &= a - 1
__pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_v_a, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_InPlaceAnd(__pyx_v_a, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_3); __pyx_t_3 = 0;
+015: count += 1
__pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_count, __pyx_int_1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_count, __pyx_t_3); __pyx_t_3 = 0; }
+016: return count
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_count); __pyx_r = __pyx_v_count; goto __pyx_L0;
017:
018:
+019: cpdef int bitcount(uint64_t vec):
static PyObject *__pyx_pw_8discodop_3bit_3bitcount(PyObject *__pyx_self, PyObject *__pyx_arg_vec); /*proto*/
static int __pyx_f_8discodop_3bit_bitcount(uint64_t __pyx_v_vec, CYTHON_UNUSED int __pyx_skip_dispatch) {
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("bitcount", 0);
/* … */
/* function exit code */
__pyx_L0:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_8discodop_3bit_3bitcount(PyObject *__pyx_self, PyObject *__pyx_arg_vec); /*proto*/
static char __pyx_doc_8discodop_3bit_2bitcount[] = "bitcount(uint64_t vec) -> int\nReturn number of set bits (1s).\n\n\t>>> bitcount(0b0011101)\n\t4";
static PyObject *__pyx_pw_8discodop_3bit_3bitcount(PyObject *__pyx_self, PyObject *__pyx_arg_vec) {
uint64_t __pyx_v_vec;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("bitcount (wrapper)", 0);
assert(__pyx_arg_vec); {
__pyx_v_vec = __Pyx_PyInt_As_uint64_t(__pyx_arg_vec); if (unlikely((__pyx_v_vec == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 19, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
__Pyx_AddTraceback("discodop.bit.bitcount", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_8discodop_3bit_2bitcount(__pyx_self, ((uint64_t)__pyx_v_vec));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8discodop_3bit_2bitcount(CYTHON_UNUSED PyObject *__pyx_self, uint64_t __pyx_v_vec) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("bitcount", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_bitcount(__pyx_v_vec, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 19, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("discodop.bit.bitcount", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
020: """Return number of set bits (1s).
021:
022: >>> bitcount(0b0011101)
023: 4"""
+024: return bit_popcount(vec)
__pyx_r = bit_popcount(__pyx_v_vec); goto __pyx_L0;
025:
026:
+027: cpdef int pyintnextset(a, int pos):
static PyObject *__pyx_pw_8discodop_3bit_5pyintnextset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_8discodop_3bit_pyintnextset(PyObject *__pyx_v_a, int __pyx_v_pos, CYTHON_UNUSED int __pyx_skip_dispatch) {
uint64_t __pyx_v_mask;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pyintnextset", 0);
__Pyx_INCREF(__pyx_v_a);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_WriteUnraisable("discodop.bit.pyintnextset", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_a);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_8discodop_3bit_5pyintnextset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8discodop_3bit_4pyintnextset[] = "pyintnextset(a, int pos) -> int\nReturn index of first set bit, starting from pos.\n\n\t>>> pyintnextset(0b001101, 1)\n\t2";
static PyObject *__pyx_pw_8discodop_3bit_5pyintnextset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_a = 0;
int __pyx_v_pos;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pyintnextset (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_a,&__pyx_n_s_pos,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_a)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_pos)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("pyintnextset", 1, 2, 2, 1); __PYX_ERR(1, 27, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pyintnextset") < 0)) __PYX_ERR(1, 27, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_a = values[0];
__pyx_v_pos = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 27, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("pyintnextset", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 27, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("discodop.bit.pyintnextset", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_8discodop_3bit_4pyintnextset(__pyx_self, __pyx_v_a, __pyx_v_pos);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8discodop_3bit_4pyintnextset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, int __pyx_v_pos) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pyintnextset", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_pyintnextset(__pyx_v_a, __pyx_v_pos, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 27, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("discodop.bit.pyintnextset", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
028: """Return index of first set bit, starting from pos.
029:
030: >>> pyintnextset(0b001101, 1)
031: 2"""
+032: cdef uint64_t mask = -1
__pyx_v_mask = -1LL;
+033: a >>= pos
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_InPlaceRshift(__pyx_v_a, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_2); __pyx_t_2 = 0;
+034: if a == 0:
__pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_v_a, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+035: return -1
__pyx_r = -1;
goto __pyx_L0;
+036: while a & mask == 0:
while (1) {
__pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_mask); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyNumber_And(__pyx_v_a, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 36, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 36, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (!__pyx_t_3) break;
+037: a >>= (8 * sizeof(uint64_t))
__pyx_t_2 = __Pyx_PyInt_FromSize_t((8 * (sizeof(uint64_t)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_InPlaceRshift(__pyx_v_a, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_a, __pyx_t_1); __pyx_t_1 = 0;
+038: pos += (8 * sizeof(uint64_t))
__pyx_v_pos = (__pyx_v_pos + (8 * (sizeof(uint64_t)))); }
+039: return pos + bit_ctz(a & mask)
__pyx_t_1 = __Pyx_PyInt_From_uint64_t(__pyx_v_mask); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_And(__pyx_v_a, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_t_2); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = (__pyx_v_pos + bit_ctz(__pyx_t_4)); goto __pyx_L0;
040:
041:
+042: cpdef int fanout(arg):
static PyObject *__pyx_pw_8discodop_3bit_7fanout(PyObject *__pyx_self, PyObject *__pyx_v_arg); /*proto*/
static int __pyx_f_8discodop_3bit_fanout(PyObject *__pyx_v_arg, CYTHON_UNUSED int __pyx_skip_dispatch) {
uint32_t __pyx_v_result;
uint64_t __pyx_v_vec;
PyObject *__pyx_v_prev = NULL;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("fanout", 0);
__Pyx_INCREF(__pyx_v_arg);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_WriteUnraisable("discodop.bit.fanout", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_prev);
__Pyx_XDECREF(__pyx_v_arg);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_8discodop_3bit_7fanout(PyObject *__pyx_self, PyObject *__pyx_v_arg); /*proto*/
static char __pyx_doc_8discodop_3bit_6fanout[] = "fanout(arg) -> int\nReturn number of contiguous components in bit vector (gaps plus one).\n\n\t>>> fanout(0b011011011)\n\t3";
static PyObject *__pyx_pw_8discodop_3bit_7fanout(PyObject *__pyx_self, PyObject *__pyx_v_arg) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("fanout (wrapper)", 0);
__pyx_r = __pyx_pf_8discodop_3bit_6fanout(__pyx_self, ((PyObject *)__pyx_v_arg));
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8discodop_3bit_6fanout(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arg) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("fanout", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_fanout(__pyx_v_arg, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 42, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("discodop.bit.fanout", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
043: """Return number of contiguous components in bit vector (gaps plus one).
044:
045: >>> fanout(0b011011011)
046: 3"""
+047: cdef uint32_t result = 0
__pyx_v_result = 0;
048: cdef uint64_t vec
+049: if arg < ((1UL << (8UL * sizeof(uint64_t) - 1UL)) - 1UL):
__pyx_t_1 = __Pyx_PyInt_FromSize_t(((1UL << ((8UL * (sizeof(uint64_t))) - 1UL)) - 1UL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_v_arg, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+050: vec = arg
__pyx_t_4 = __Pyx_PyInt_As_uint64_t(__pyx_v_arg); if (unlikely((__pyx_t_4 == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(1, 50, __pyx_L1_error)
__pyx_v_vec = __pyx_t_4;
+051: while vec:
while (1) {
__pyx_t_3 = (__pyx_v_vec != 0);
if (!__pyx_t_3) break;
+052: vec >>= bit_ctz(vec)
__pyx_v_vec = (__pyx_v_vec >> bit_ctz(__pyx_v_vec));
+053: vec >>= bit_ctz(~vec)
__pyx_v_vec = (__pyx_v_vec >> bit_ctz((~__pyx_v_vec)));
+054: result += 1
__pyx_v_result = (__pyx_v_result + 1);
}
055: else:
056: # when the argument does not fit in unsigned long long, resort to plain
057: # Python code to use Python's bigints. This algorithm is based
058: # on a bit counting algorihm. It goes through as many iterations as
059: # there are set bits (while the other algorithm jumps over contiguous
060: # sequences of set bits in one go).
+061: prev = arg
/*else*/ {
__Pyx_INCREF(__pyx_v_arg);
__pyx_v_prev = __pyx_v_arg;
+062: result = 0
__pyx_v_result = 0;
+063: while arg:
while (1) {
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_arg); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 63, __pyx_L1_error)
if (!__pyx_t_3) break;
+064: arg &= arg - 1
__pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_v_arg, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_InPlaceAnd(__pyx_v_arg, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_arg, __pyx_t_1); __pyx_t_1 = 0;
+065: if ((prev - arg) << 1) & prev == 0:
__pyx_t_1 = PyNumber_Subtract(__pyx_v_prev, __pyx_v_arg); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_LshiftObjC(__pyx_t_1, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_And(__pyx_t_2, __pyx_v_prev); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+066: result += 1
__pyx_v_result = (__pyx_v_result + 1);
+067: prev = arg
__Pyx_INCREF(__pyx_v_arg); __Pyx_DECREF_SET(__pyx_v_prev, __pyx_v_arg); } } __pyx_L3:;
+068: return result
__pyx_r = __pyx_v_result; goto __pyx_L0;
069:
070:
+071: def test():
/* Python wrapper */
static PyObject *__pyx_pw_8discodop_3bit_9test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8discodop_3bit_8test[] = "test()";
static PyMethodDef __pyx_mdef_8discodop_3bit_9test = {"test", (PyCFunction)__pyx_pw_8discodop_3bit_9test, METH_NOARGS, __pyx_doc_8discodop_3bit_8test};
static PyObject *__pyx_pw_8discodop_3bit_9test(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("test (wrapper)", 0);
__pyx_r = __pyx_pf_8discodop_3bit_8test(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_8discodop_3bit_8test(CYTHON_UNUSED PyObject *__pyx_self) {
uint64_t __pyx_v_ulongvec[2];
PyObject *__pyx_v_bigpyint = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("test", 0);
/* … */
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("discodop.bit.test", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_bigpyint);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__4 = PyTuple_Pack(2, __pyx_n_s_ulongvec, __pyx_n_s_bigpyint); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 71, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__4);
__Pyx_GIVEREF(__pyx_tuple__4);
/* … */
__pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8discodop_3bit_9test, NULL, __pyx_n_s_discodop_bit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 71, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(1, 71, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
072: cdef uint64_t ulongvec[2]
+073: bigpyint = 0b11100110101111001101011111100110101001100110
__Pyx_INCREF(__pyx_int_15856171903590);
__pyx_v_bigpyint = __pyx_int_15856171903590;
+074: assert nextset(0b001100110, 3) == 5
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_nextset(102, 3) == 5) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 74, __pyx_L1_error)
}
}
#endif
+075: assert nextset(0b001100110, 7) == -1
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_nextset(102, 7) == -1L) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 75, __pyx_L1_error)
}
}
#endif
+076: assert nextunset(0b001100110, 1) == 3
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_nextunset(102, 1) == 3) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 76, __pyx_L1_error)
}
}
#endif
+077: assert nextunset(~0UL, 0) == 64
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_nextunset((~0UL), 0) == 64) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 77, __pyx_L1_error)
}
}
#endif
+078: assert pyintnextset(0b001100110, 3) == 5
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_pyintnextset(__pyx_int_102, 3, 0) == 5) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 78, __pyx_L1_error)
}
}
#endif
+079: assert pyintnextset(0b001100110, 7) == -1
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_pyintnextset(__pyx_int_102, 7, 0) == -1L) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 79, __pyx_L1_error)
}
}
#endif
+080: assert pyintnextset(bigpyint, 3) == 5
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_pyintnextset(__pyx_v_bigpyint, 3, 0) == 5) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 80, __pyx_L1_error)
}
}
#endif
+081: assert pyintnextset(bigpyint, 7) == 9
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_pyintnextset(__pyx_v_bigpyint, 7, 0) == 9) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 81, __pyx_L1_error)
}
}
#endif
+082: assert bitcount(0b001100110) == 4
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_bitcount(102, 0) == 4) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 82, __pyx_L1_error)
}
}
#endif
+083: assert bitlength(0b001100110) == 7
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_bitlength(102) == 7) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 83, __pyx_L1_error)
}
}
#endif
+084: assert testbit(0b001100110, 1)
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!(__pyx_fuse_2__pyx_f_8discodop_3bit_testbit(102, 1) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 84, __pyx_L1_error)
}
}
#endif
+085: assert not testbit(0b001100110, 3)
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((!(__pyx_fuse_2__pyx_f_8discodop_3bit_testbit(102, 3) != 0)) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 85, __pyx_L1_error)
}
}
#endif
+086: assert fanout(0b0111100) == 1
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_fanout(__pyx_int_60, 0) == 1) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 86, __pyx_L1_error)
}
}
#endif
+087: assert fanout(0b1000001) == 2
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_fanout(__pyx_int_65, 0) == 2) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 87, __pyx_L1_error)
}
}
#endif
+088: assert fanout(0b011011011) == 3
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_fanout(__pyx_int_219, 0) == 3) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
__PYX_ERR(1, 88, __pyx_L1_error)
}
}
#endif
+089: ulongvec[0] = 1UL << (sizeof(uint64_t) * 8 - 1)
(__pyx_v_ulongvec[0]) = (1UL << (((sizeof(uint64_t)) * 8) - 1));
+090: ulongvec[1] = 1
(__pyx_v_ulongvec[1]) = 1;
+091: assert anextset(ulongvec, 0, 2) == sizeof(uint64_t) * 8 - 1, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2) == (((sizeof(uint64_t)) * 8) - 1)) != 0))) {
+092: anextset(ulongvec, 0, 2), sizeof(uint64_t) * 8 - 1)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_FromSize_t((((sizeof(uint64_t)) * 8) - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 91, __pyx_L1_error) } } #endif
+093: assert anextset(ulongvec, sizeof(uint64_t) * 8, 2) == sizeof(uint64_t) * 8, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, ((sizeof(uint64_t)) * 8), 2) == ((sizeof(uint64_t)) * 8)) != 0))) {
+094: anextset(ulongvec, sizeof(uint64_t) * 8, 2), sizeof(uint64_t) * 8)
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, ((sizeof(uint64_t)) * 8), 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_FromSize_t(((sizeof(uint64_t)) * 8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 93, __pyx_L1_error) } } #endif
+095: assert anextunset(ulongvec, 0, 2) == 0, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, 0, 2) == 0) != 0))) {
+096: anextunset(ulongvec, 0, 2), 0)
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, 0, 2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 95, __pyx_L1_error) } } #endif
+097: assert anextunset(ulongvec, sizeof(uint64_t) * 8 - 1, 2) == (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
/* … */
if (unlikely(!((__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, (((sizeof(uint64_t)) * 8) - 1), 2) == (((sizeof(uint64_t)) * 8) + 1)) != 0))) {
+098: sizeof(uint64_t) * 8 + 1), (anextunset(ulongvec,
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, (((sizeof(uint64_t)) * 8) - 1), 2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 97, __pyx_L1_error) } } #endif
+099: sizeof(uint64_t) * 8 - 1, 2), sizeof(uint64_t) * 8 + 1)
__pyx_t_1 = __Pyx_PyInt_FromSize_t((((sizeof(uint64_t)) * 8) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+100: ulongvec[0] = 0
(__pyx_v_ulongvec[0]) = 0;
+101: assert anextset(ulongvec, 0, 2) == sizeof(uint64_t) * 8, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2) == ((sizeof(uint64_t)) * 8)) != 0))) {
+102: anextset(ulongvec, 0, 2), sizeof(uint64_t) * 8)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_FromSize_t(((sizeof(uint64_t)) * 8)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 101, __pyx_L1_error) } } #endif
+103: ulongvec[1] = 0
(__pyx_v_ulongvec[1]) = 0;
+104: assert anextset(ulongvec, 0, 2) == -1, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2) == -1L) != 0))) {
+105: anextset(ulongvec, 0, 2), -1)
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextset(__pyx_v_ulongvec, 0, 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_neg_1); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 104, __pyx_L1_error) } } #endif
+106: ulongvec[0] = ~0UL
(__pyx_v_ulongvec[0]) = (~0UL);
+107: assert anextunset(ulongvec, 0, 2) == sizeof(uint64_t) * 8, (
#ifndef CYTHON_WITHOUT_ASSERTIONS
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, 0, 2) == ((sizeof(uint64_t)) * 8)) != 0))) {
+108: anextunset(ulongvec, 0, 2), sizeof(uint64_t) * 8)
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_f_8discodop_3bit_anextunset(__pyx_v_ulongvec, 0, 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_FromSize_t(((sizeof(uint64_t)) * 8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 107, __pyx_L1_error) } } #endif
+109: print('it worked')
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_it_worked); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_);
110:
+111: __all__ = ['bitcount', 'fanout', 'pyintbitcount', 'pyintnextset']
__pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_bitcount); __Pyx_GIVEREF(__pyx_n_u_bitcount); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_bitcount); __Pyx_INCREF(__pyx_n_u_fanout); __Pyx_GIVEREF(__pyx_n_u_fanout); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_fanout); __Pyx_INCREF(__pyx_n_u_pyintbitcount); __Pyx_GIVEREF(__pyx_n_u_pyintbitcount); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_u_pyintbitcount); __Pyx_INCREF(__pyx_n_u_pyintnextset); __Pyx_GIVEREF(__pyx_n_u_pyintnextset); PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_u_pyintnextset); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) __PYX_ERR(1, 111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;