Macaulay2 Engine
Loading...
Searching...
No Matches

◆ calc_det()

ring_elem DetComputation::calc_det ( size_t * r,
size_t * c,
int p )
private

Definition at line 387 of file det.cpp.

390{
391 if (p0 == 1) return M->elem(static_cast<int>(r[0]), static_cast<int>(c[0]));
392 ring_elem answer = R->from_long(0);
393
394 int negate = 1;
395 for (int i = p0 - 1; i >= 0; i--)
396 {
397 std::swap(c[i], c[p0 - 1]);
398 negate = !negate;
399 ring_elem g =
400 M->elem(static_cast<int>(r[p0 - 1]), static_cast<int>(c[p0 - 1]));
401 if (R->is_zero(g))
402 {
403 R->remove(g);
404 continue;
405 }
406 ring_elem h = calc_det(r, c, p0 - 1);
407 ring_elem gh = R->mult(g, h);
408 R->remove(g);
409 R->remove(h);
410 if (negate)
411 R->subtract_to(answer, gh);
412 else
413 R->add_to(answer, gh);
414 }
415
416 // pulling out the columns has disordered c. Fix it.
417
418 size_t temp = c[p0 - 1];
419 for (size_t i = p0 - 1; i > 0; i--) c[i] = c[i - 1];
420 c[0] = temp;
421
422 return answer;
423}
const Ring * R
Definition det.hpp:56
ring_elem calc_det(size_t *r, size_t *c, int p)
Definition det.cpp:387
const Matrix * M
Definition det.hpp:57
mpreal & negate(mpreal &x)
Definition mpreal.h:2047
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Definition mpreal.h:3244

References calc_det(), M, R, and std::swap().

Referenced by calc_det(), and step().