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

◆ calc_pfaff() [1/2]

ring_elem PfaffianComputation::calc_pfaff ( size_t * r,
int p )
private

Definition at line 62 of file pfaff.cpp.

66{
67 if (p2 == 2) return M->elem(static_cast<int>(r[0]), static_cast<int>(r[1]));
68 ring_elem result = R->from_long(0);
69
70 bool negate = true;
71 for (int i = p2 - 2; i >= 0; i--)
72 {
73 std::swap(r[i], r[p2 - 2]);
74 negate = !negate;
75 ring_elem g =
76 M->elem(static_cast<int>(r[p2 - 2]), static_cast<int>(r[p2 - 1]));
77 if (R->is_zero(g))
78 {
79 R->remove(g);
80 continue;
81 }
82 ring_elem h = calc_pfaff(r, p2 - 2);
83 ring_elem gh = R->mult(g, h);
84 R->remove(g);
85 R->remove(h);
86 if (negate)
87 R->subtract_to(result, gh);
88 else
89 R->add_to(result, gh);
90 }
91
92 // pulling out the columns has disordered r. Fix it.
93
94 size_t temp = r[p2 - 2];
95 for (size_t i = p2 - 2; i > 0; i--) r[i] = r[i - 1];
96 r[0] = temp;
97
98 return result;
99}
const Ring * R
Definition pfaff.hpp:51
ring_elem calc_pfaff(void)
Definition pfaff.cpp:57
const Matrix * M
Definition pfaff.hpp:52
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpreal & negate(mpreal &x)
Definition mpreal.h:2047
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Definition mpreal.h:3244

References calc_pfaff(), M, R, result(), and std::swap().

Referenced by Matrix::pfaffian().