+ for (unsigned r1=0; r1<row-1; ++r1) {
+ int indx = tmp.pivot(r1);
+ if (indx==-1)
+ return _ex0();
+ if (indx>0)
+ sign = -sign;
+ if (r1>0) {
+ divisor = tmp.m[(r1-1)*col+(r1-1)].expand();
+ // delete the elements we don't need anymore:
+ for (unsigned c=0; c<col; ++c)
+ tmp.m[(r1-1)*col+c] = _ex0();
+ }
+ for (unsigned r2=r1+1; r2<row; ++r2) {
+ for (unsigned c=r1+1; c<col; ++c) {
+ lst srl; // symbol replacement list for .to_rational()
+ dividend = (tmp.m[r1*tmp.col+r1]*tmp.m[r2*tmp.col+c]
+ -tmp.m[r2*tmp.col+r1]*tmp.m[r1*tmp.col+c]).expand();
+ if (normalize) {
+#ifdef DO_GINAC_ASSERT
+ GINAC_ASSERT(rat_divide(dividend.to_rational(srl),
+ divisor.to_rational(srl),
+ tmp.m[r2*tmp.col+c],true));
+#else
+ rat_divide(dividend.to_rational(srl),
+ divisor.to_rational(srl),
+ tmp.m[r2*tmp.col+c],false);
+#endif
+ }
+ else {
+#ifdef DO_GINAC_ASSERT
+ GINAC_ASSERT(divide(dividend.to_rational(srl),
+ divisor.to_rational(srl),
+ tmp.m[r2*tmp.col+c],true));
+#else
+ divide(dividend.to_rational(srl),
+ divisor.to_rational(srl),
+ tmp.m[r2*tmp.col+c],false);
+#endif
+ }
+ tmp.m[r2*tmp.col+c] = tmp.m[r2*tmp.col+c].subs(srl);
+ }
+ for (unsigned c=0; c<=r1; ++c)
+ tmp.m[r2*tmp.col+c] = _ex0();
+ }
+ }
+
+ return sign*tmp.m[tmp.row*tmp.col-1];