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

◆ bareiss_det()

ring_elem DetComputation::bareiss_det ( )
private

Definition at line 345 of file det.cpp.

346{
347 // Computes the determinant of the p by p matrix D. (dense form).
348 int sign = 1;
349 size_t pivot_col;
350
351 ring_elem pivot = R->from_long(0);
352 ring_elem lastpivot = R->from_long(0);
353
354 for (size_t r = p - 1; r >= 1; --r)
355 {
356 R->remove(lastpivot);
357 lastpivot = pivot;
358 if (!get_pivot(D, r, pivot, pivot_col)) // sets pivot_col and pivot
359 {
360 // Remove the rest of D.
361 for (size_t i = 0; i <= r; i++)
362 for (size_t j = 0; j <= r; j++) R->remove(D[i][j]);
363 R->remove(lastpivot);
364 return R->from_long(0);
365 }
366 for (size_t i = 0; i < r; i++) gauss(D, i, r, pivot_col, lastpivot);
367
368 if (((r + pivot_col) % 2) == 1)
369 sign = -sign; // MES: do I need to rethink this logic?
370
371 for (size_t c = 0; c <= r; c++)
372 if (c != pivot_col)
373 R->remove(D[r][c]);
374 else
375 D[r][c] = ZERO_RINGELEM;
376 }
377
378 R->remove(pivot);
379 R->remove(lastpivot);
380 ring_elem r = D[0][0];
381 D[0][0] = ZERO_RINGELEM;
382
383 if (sign < 0) R->negate_to(r);
384
385 return r;
386}
const Ring * R
Definition det.hpp:56
void gauss(ring_elem **D, size_t i, size_t r, size_t pivot_col, ring_elem lastpivot)
Definition det.cpp:327
ring_elem ** D
Definition det.hpp:80
bool get_pivot(ring_elem **D, size_t p, ring_elem &pivot, size_t &pivot_col)
Definition det.cpp:291
#define ZERO_RINGELEM
Definition ring.hpp:677

References D, gauss(), get_pivot(), p, R, and ZERO_RINGELEM.

Referenced by step().