Generated by Cython 0.29.13
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: CACompute.cpp
+001: # distutils: language=c++
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
002: """
003: cdef extern from "Compute.cpp":
004: cdef struct compute_return:
005: int lower_x, lower_y, upper_x, upper_y
006: unordered_map[pair[int, int], int] dict_grid
007: unordered_set[pair[int, int]] cells_changed
008:
009: cdef compute_return compute(vector[pair[int, int]] neighbourhood, bool first,
010: unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
011: int upper_y, unordered_map[pair[int, int], int] copy_grid,
012: unordered_map[pair[int, int], int] dict_grid)
013:
014:
015: cpdef pycompute(vector[pair[int, int]] neighbourhood, bool first,
016: unordered_set[pair[int, int]] cells_changed, int lower_x, int upper_x, int lower_y,
017: int upper_y, unordered_map[pair[int, int], int] copy_grid,
018: unordered_map[pair[int, int], int] dict_grid):
019:
020: cdef compute_return ans = compute(neighbourhood, first, cells_changed, lower_x, upper_x, lower_y, upper_y,
021: copy_grid, dict_grid)
022:
023: return ans.lower_x, ans.lower_y, ans.upper_x, ans.upper_y, ans.cells_changed, ans.dict_grid
024:
025:
026: """
027:
+028: import importlib
__pyx_t_1 = __Pyx_Import(__pyx_n_s_importlib, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_importlib, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+029: import transFunc
__pyx_t_1 = __Pyx_Import(__pyx_n_s_transFunc, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_transFunc, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
030: from libcpp.vector cimport vector
031: from libcpp.pair cimport pair
032: from libcpp.map cimport map
033: from libcpp.unordered_map cimport unordered_map
034: from libcpp.unordered_set cimport unordered_set
035:
036: cdef extern from "compute.cpp":
037: pass
038:
039:
040: cdef unordered_map[pair[int, int], int] depends_cache
041: cdef map[pair[vector[int], int], int] transition_func_cache
+042: cdef int alternating_period2 = transFunc.alternating_period
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_9CACompute_alternating_period2 = __pyx_t_3;
043:
+044: cpdef void reload():
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static void __pyx_f_9CACompute_reload(CYTHON_UNUSED int __pyx_skip_dispatch) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload", 0);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_WriteUnraisable("CACompute.reload", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
__pyx_L0:;
__Pyx_RefNannyFinishContext();
}
/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_9CACompute_1reload(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload (wrapper)", 0);
__pyx_r = __pyx_pf_9CACompute_reload(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_9CACompute_reload(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("reload", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_void_to_None(__pyx_f_9CACompute_reload(0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __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("CACompute.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
045: global depends_cache, transition_func_cache, alternating_period2
+046: importlib.reload(transFunc)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_importlib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reload); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+047: depends_cache.clear()
__pyx_v_9CACompute_depends_cache.clear();
+048: transition_func_cache.clear()
__pyx_v_9CACompute_transition_func_cache.clear();
+049: alternating_period2 = transFunc.alternating_period
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_alternating_period); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_9CACompute_alternating_period2 = __pyx_t_5;
050:
+051: cpdef compute(vector[pair[int, int]] neighbourhood,
static PyObject *__pyx_pw_9CACompute_3compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_9CACompute_compute(std::vector<std::pair<int,int> > __pyx_v_neighbourhood, std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed, std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid, int __pyx_v_generations, CYTHON_UNUSED int __pyx_skip_dispatch) {
std::vector<int> __pyx_v_neighbours;
std::unordered_set<std::pair<int,int> > __pyx_v_cells_to_check;
int __pyx_v_ans;
std::pair<int,int> __pyx_v_coordinates;
std::pair<int,int> __pyx_v_coordinates2;
std::pair<int,int> __pyx_v_neighbour;
std::pair<int,int> __pyx_v_coor;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute", 0);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_9CACompute_3compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_9CACompute_3compute(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
std::vector<std::pair<int,int> > __pyx_v_neighbourhood;
std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed;
std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid;
std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid;
int __pyx_v_generations;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_neighbourhood,&__pyx_n_s_cells_changed,&__pyx_n_s_copy_grid,&__pyx_n_s_dict_grid,&__pyx_n_s_generations,0};
PyObject* values[5] = {0,0,0,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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
CYTHON_FALLTHROUGH;
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] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_neighbourhood)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cells_changed)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 1); __PYX_ERR(0, 51, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_copy_grid)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 2); __PYX_ERR(0, 51, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dict_grid)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 3); __PYX_ERR(0, 51, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_generations)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, 4); __PYX_ERR(0, 51, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compute") < 0)) __PYX_ERR(0, 51, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
}
__pyx_v_neighbourhood = __pyx_convert_vector_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L3_error)
__pyx_v_cells_changed = __pyx_convert_unordered_set_from_py_std_3a__3a_pair_3c_int_2c_int_3e___(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 52, __pyx_L3_error)
__pyx_v_copy_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
__pyx_v_dict_grid = __pyx_convert_unordered_map_from_py_std_3a__3a_pair_3c_int_2c_int_3e_____and_int(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L3_error)
__pyx_v_generations = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_generations == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 54, __pyx_L3_error)
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("compute", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 51, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_9CACompute_2compute(__pyx_self, __pyx_v_neighbourhood, __pyx_v_cells_changed, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_9CACompute_2compute(CYTHON_UNUSED PyObject *__pyx_self, std::vector<std::pair<int,int> > __pyx_v_neighbourhood, std::unordered_set<std::pair<int,int> > __pyx_v_cells_changed, std::unordered_map<std::pair<int,int> ,int> __pyx_v_copy_grid, std::unordered_map<std::pair<int,int> ,int> __pyx_v_dict_grid, int __pyx_v_generations) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("compute", 0);
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_f_9CACompute_compute(__pyx_v_neighbourhood, __pyx_v_cells_changed, __pyx_v_copy_grid, __pyx_v_dict_grid, __pyx_v_generations, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __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("CACompute.compute", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
052: unordered_set[pair[int, int]] cells_changed,
053: unordered_map[pair[int, int], int] copy_grid, unordered_map[pair[int, int], int] dict_grid,
054: int generations):
055:
056: cdef vector[int] neighbours
+057: neighbours.reserve(neighbourhood.size() + 1)
__pyx_v_neighbours.reserve((__pyx_v_neighbourhood.size() + 1));
058:
059: cdef unordered_set[pair[int, int]] cells_to_check
060:
061: cdef int i, j
062: cdef int ans
063: cdef pair[int, int] coordinates, coordinates2
064: cdef pair[int, int] neighbour
065:
+066: for coor in cells_changed:
__pyx_t_1 = __pyx_v_cells_changed.begin();
for (;;) {
if (!(__pyx_t_1 != __pyx_v_cells_changed.end())) break;
__pyx_t_2 = *__pyx_t_1;
++__pyx_t_1;
__pyx_v_coor = __pyx_t_2;
/* … */
}
+067: for neighbour in neighbourhood:
__pyx_t_3 = __pyx_v_neighbourhood.begin();
for (;;) {
if (!(__pyx_t_3 != __pyx_v_neighbourhood.end())) break;
__pyx_t_2 = *__pyx_t_3;
++__pyx_t_3;
__pyx_v_neighbour = __pyx_t_2;
/* … */
}
+068: coordinates.first = coor.first + neighbour.first
__pyx_v_coordinates.first = (__pyx_v_coor.first + __pyx_v_neighbour.first);
+069: coordinates.second = coor.second + neighbour.second
__pyx_v_coordinates.second = (__pyx_v_coor.second + __pyx_v_neighbour.second);
+070: cells_to_check.insert(coordinates)
(void)(__pyx_v_cells_to_check.insert(__pyx_v_coordinates));
071:
+072: cells_to_check.insert(coor)
(void)(__pyx_v_cells_to_check.insert(__pyx_v_coor));
073:
+074: if alternating_period2 > 1:
__pyx_t_4 = ((__pyx_v_9CACompute_alternating_period2 > 1) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L7;
}
+075: if generations % (alternating_period2 - 1) == 0:
__pyx_t_4 = (((__pyx_v_generations % (__pyx_v_9CACompute_alternating_period2 - 1)) == 0) != 0);
if (__pyx_t_4) {
/* … */
}
+076: cells_changed.clear()
__pyx_v_cells_changed.clear();
077: else:
+078: cells_changed.clear()
/*else*/ {
__pyx_v_cells_changed.clear();
}
__pyx_L7:;
079:
+080: for coordinates in cells_to_check:
__pyx_t_1 = __pyx_v_cells_to_check.begin();
for (;;) {
if (!(__pyx_t_1 != __pyx_v_cells_to_check.end())) break;
__pyx_t_2 = *__pyx_t_1;
++__pyx_t_1;
__pyx_v_coordinates = __pyx_t_2;
/* … */
}
+081: neighbours.clear()
__pyx_v_neighbours.clear();
+082: ans = -1
__pyx_v_ans = -1;
083:
+084: if copy_grid.find(coordinates) == copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) == __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L11;
}
+085: if depends_cache.find(pair[int, int] (0, generations % alternating_period2)) == \
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 85, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_depends_cache.find(__pyx_t_2) == __pyx_v_9CACompute_depends_cache.end()) != 0);
/* … */
if (__pyx_t_4) {
/* … */
goto __pyx_L12;
}
086: depends_cache.end():
+087: ans = transFunc.depend_on_neighbours(0, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_0, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_int_0, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_int_0); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_9;
+088: depends_cache[pair[int, int] (0, generations % alternating_period2)] = ans
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 88, __pyx_L1_error)
}
(__pyx_v_9CACompute_depends_cache[__pyx_t_2]) = __pyx_v_ans;
089: else:
+090: ans = depends_cache[pair[int, int] (0, generations % alternating_period2)]
/*else*/ {
try {
__pyx_t_2 = std::pair<int,int> (0, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 90, __pyx_L1_error)
}
__pyx_v_ans = (__pyx_v_9CACompute_depends_cache[__pyx_t_2]);
}
__pyx_L12:;
091: else:
+092: if depends_cache.find(pair[int, int] (copy_grid[coordinates],
/*else*/ {
/* … */
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 92, __pyx_L1_error)
}
/* … */
if (__pyx_t_4) {
/* … */
goto __pyx_L13;
}
+093: generations % alternating_period2)) == \
__pyx_t_4 = ((__pyx_v_9CACompute_depends_cache.find(__pyx_t_2) == __pyx_v_9CACompute_depends_cache.end()) != 0);
094: depends_cache.end():
+095: ans = transFunc.depend_on_neighbours(copy_grid[coordinates], generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_depend_on_neighbours); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_copy_grid[__pyx_v_coordinates])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_t_7, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_9, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_9, __pyx_t_6); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_9;
+096: depends_cache[pair[int, int] (copy_grid[coordinates], generations % alternating_period2)] = ans
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 96, __pyx_L1_error)
}
(__pyx_v_9CACompute_depends_cache[__pyx_t_2]) = __pyx_v_ans;
097: else:
+098: ans = depends_cache[pair[int, int] (copy_grid[coordinates], generations % alternating_period2)]
/*else*/ {
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_copy_grid[__pyx_v_coordinates]), (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 98, __pyx_L1_error)
}
__pyx_v_ans = (__pyx_v_9CACompute_depends_cache[__pyx_t_2]);
}
__pyx_L13:;
}
__pyx_L11:;
099:
+100: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+101: for neighbour in neighbourhood:
__pyx_t_3 = __pyx_v_neighbourhood.begin();
for (;;) {
if (!(__pyx_t_3 != __pyx_v_neighbourhood.end())) break;
__pyx_t_2 = *__pyx_t_3;
++__pyx_t_3;
__pyx_v_neighbour = __pyx_t_2;
/* … */
}
+102: coordinates2 = pair[int, int] (coordinates.first + neighbour.first,
try {
__pyx_t_2 = std::pair<int,int> ((__pyx_v_coordinates.first + __pyx_v_neighbour.first), (__pyx_v_coordinates.second + __pyx_v_neighbour.second));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 102, __pyx_L1_error)
}
__pyx_v_coordinates2 = __pyx_t_2;
103: coordinates.second + neighbour.second)
+104: if copy_grid.find(coordinates2) != copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates2) != __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L17;
}
+105: neighbours.push_back(copy_grid[coordinates2])
try {
__pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates2]));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 105, __pyx_L1_error)
}
106: else:
+107: neighbours.push_back(0)
/*else*/ {
try {
__pyx_v_neighbours.push_back(0);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 107, __pyx_L1_error)
}
}
__pyx_L17:;
108:
+109: if copy_grid.find(coordinates) != copy_grid.end():
__pyx_t_4 = ((__pyx_v_copy_grid.find(__pyx_v_coordinates) != __pyx_v_copy_grid.end()) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L18;
}
+110: neighbours.push_back(copy_grid[coordinates])
try {
__pyx_v_neighbours.push_back((__pyx_v_copy_grid[__pyx_v_coordinates]));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 110, __pyx_L1_error)
}
+111: if transition_func_cache.find(
if (__pyx_t_4) {
/* … */
goto __pyx_L19;
}
+112: pair[vector[int], int] (neighbours, generations % alternating_period2)) == \
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 112, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_transition_func_cache.find(__pyx_t_12) == __pyx_v_9CACompute_transition_func_cache.end()) != 0);
113: transition_func_cache.end():
+114: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+115: ans = transFunc.transition_func(neighbours, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_10, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_10, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_7) { __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL; } __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, __pyx_t_6); __pyx_t_10 = 0; __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 115, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_9;
116: transition_func_cache[
+117: pair[vector[int], int] (neighbours, generations % alternating_period2)] = ans
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 117, __pyx_L1_error)
}
(__pyx_v_9CACompute_transition_func_cache[__pyx_t_12]) = __pyx_v_ans;
118: else:
+119: if ans == -1: ans = transition_func_cache[
/*else*/ {
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
__pyx_v_ans = (__pyx_v_9CACompute_transition_func_cache[__pyx_t_12]);
}
}
__pyx_L19:;
+120: pair[vector[int], int] (neighbours, generations % alternating_period2)]
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 120, __pyx_L1_error)
}
121:
+122: if ans == 0:
__pyx_t_4 = ((__pyx_v_ans == 0) != 0);
if (__pyx_t_4) {
/* … */
goto __pyx_L22;
}
+123: dict_grid.erase(coordinates)
(void)(__pyx_v_dict_grid.erase(__pyx_v_coordinates));
+124: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
+125: elif ans != copy_grid[coordinates]:
__pyx_t_4 = ((__pyx_v_ans != (__pyx_v_copy_grid[__pyx_v_coordinates])) != 0);
if (__pyx_t_4) {
/* … */
}
__pyx_L22:;
+126: dict_grid[coordinates] = ans
(__pyx_v_dict_grid[__pyx_v_coordinates]) = __pyx_v_ans;
+127: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
128: else:
+129: neighbours.push_back(0)
/*else*/ {
try {
__pyx_v_neighbours.push_back(0);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 129, __pyx_L1_error)
}
+130: if transition_func_cache.find(
if (__pyx_t_4) {
/* … */
goto __pyx_L23;
}
+131: pair[vector[int], int] (neighbours, generations % alternating_period2)) == \
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 131, __pyx_L1_error)
}
/* … */
__pyx_t_4 = ((__pyx_v_9CACompute_transition_func_cache.find(__pyx_t_12) == __pyx_v_9CACompute_transition_func_cache.end()) != 0);
132: transition_func_cache.end():
+133: if ans == -1:
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
}
+134: ans = transFunc.transition_func(neighbours, generations % alternating_period2)
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_transFunc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_transition_func); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __pyx_convert_vector_to_py_int(__pyx_v_neighbours); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_generations % __pyx_v_9CACompute_alternating_period2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_6}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_11, __pyx_t_6}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_10) { __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_9, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_9, __pyx_t_6); __pyx_t_11 = 0; __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_ans = __pyx_t_9;
135: transition_func_cache[
+136: pair[vector[int], int] (neighbours, generations % alternating_period2)] = ans
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 136, __pyx_L1_error)
}
(__pyx_v_9CACompute_transition_func_cache[__pyx_t_12]) = __pyx_v_ans;
137: else:
+138: if ans == -1: ans = transition_func_cache[
/*else*/ {
__pyx_t_4 = ((__pyx_v_ans == -1L) != 0);
if (__pyx_t_4) {
/* … */
__pyx_v_ans = (__pyx_v_9CACompute_transition_func_cache[__pyx_t_12]);
}
}
__pyx_L23:;
+139: pair[vector[int], int] (neighbours, generations % alternating_period2)]
try {
__pyx_t_12 = std::pair<std::vector<int> ,int> (__pyx_v_neighbours, (__pyx_v_generations % __pyx_v_9CACompute_alternating_period2));
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 139, __pyx_L1_error)
}
140:
+141: if ans != 0:
__pyx_t_4 = ((__pyx_v_ans != 0) != 0);
if (__pyx_t_4) {
/* … */
}
}
__pyx_L18:;
+142: dict_grid.insert(pair[pair[int, int], int] (coordinates, ans))
try {
__pyx_t_13 = std::pair<std::pair<int,int> ,int> (__pyx_v_coordinates, __pyx_v_ans);
} catch(...) {
__Pyx_CppExn2PyErr();
__PYX_ERR(0, 142, __pyx_L1_error)
}
(void)(__pyx_v_dict_grid.insert(__pyx_t_13));
+143: cells_changed.insert(coordinates)
(void)(__pyx_v_cells_changed.insert(__pyx_v_coordinates));
144:
+145: return cells_changed, dict_grid
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __pyx_convert_unordered_set_to_py_std_3a__3a_pair_3c_int_2c_int_3e___(__pyx_v_cells_changed); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __pyx_convert_unordered_map_to_py_std_3a__3a_pair_3c_int_2c_int_3e_______int(__pyx_v_dict_grid); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8); __pyx_t_5 = 0; __pyx_t_8 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0;