* Depth-first bounded Euclid search */
| 310 | * Depth-first bounded Euclid search |
| 311 | */ |
| 312 | static mem_overlap_t |
| 313 | diophantine_dfs(unsigned int n, |
| 314 | unsigned int v, |
| 315 | diophantine_term_t *E, |
| 316 | diophantine_term_t *Ep, |
| 317 | npy_int64 *Gamma, npy_int64 *Epsilon, |
| 318 | npy_int64 b, |
| 319 | Py_ssize_t max_work, |
| 320 | int require_ub_nontrivial, |
| 321 | npy_int64 *x, |
| 322 | Py_ssize_t *count) |
| 323 | { |
| 324 | npy_int64 a_gcd, gamma, epsilon, a1, u1, a2, u2, c, r, c1, c2, t, t_l, t_u, b2, x1, x2; |
| 325 | npy_extint128_t x10, x20, t_l1, t_l2, t_u1, t_u2; |
| 326 | mem_overlap_t res; |
| 327 | char overflow = 0; |
| 328 | |
| 329 | if (max_work >= 0 && *count >= max_work) { |
| 330 | return MEM_OVERLAP_TOO_HARD; |
| 331 | } |
| 332 | |
| 333 | /* Fetch precomputed values for the reduced problem */ |
| 334 | if (v == 1) { |
| 335 | a1 = E[0].a; |
| 336 | u1 = E[0].ub; |
| 337 | } |
| 338 | else { |
| 339 | a1 = Ep[v-2].a; |
| 340 | u1 = Ep[v-2].ub; |
| 341 | } |
| 342 | |
| 343 | a2 = E[v].a; |
| 344 | u2 = E[v].ub; |
| 345 | |
| 346 | a_gcd = Ep[v-1].a; |
| 347 | gamma = Gamma[v-1]; |
| 348 | epsilon = Epsilon[v-1]; |
| 349 | |
| 350 | /* Generate set of allowed solutions */ |
| 351 | c = b / a_gcd; |
| 352 | r = b % a_gcd; |
| 353 | if (r != 0) { |
| 354 | ++*count; |
| 355 | return MEM_OVERLAP_NO; |
| 356 | } |
| 357 | |
| 358 | c1 = a2 / a_gcd; |
| 359 | c2 = a1 / a_gcd; |
| 360 | |
| 361 | /* |
| 362 | The set to enumerate is: |
| 363 | x1 = gamma*c + c1*t |
| 364 | x2 = epsilon*c - c2*t |
| 365 | t integer |
| 366 | 0 <= x1 <= u1 |
| 367 | 0 <= x2 <= u2 |
| 368 | and we have c, c1, c2 >= 0 |
| 369 | */ |
no test coverage detected