]> www.ginac.de Git - ginac.git/commitdiff
- Primitive heuristics to make determinants of sparse matrices work.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 27 Mar 2000 17:43:54 +0000 (17:43 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 27 Mar 2000 17:43:54 +0000 (17:43 +0000)
ginac/matrix.cpp

index 37716290f77317e4916b1705073ba3834332b1ce..fab7b5fde949e1a68f02623a04fe6d6636cb0140 100644 (file)
@@ -469,6 +469,16 @@ ex matrix::determinant(void) const
     if (numeric_flag)
         return determinant_numeric();
     
+    if (5*sparse_count<row*col) {     // MAGIC, maybe 10 some bright day?
+        matrix M(*this);
+        // int sign = M.division_free_elimination();
+        int sign = M.fraction_free_elimination();
+        if (normal_flag)
+            return sign*M(row-1,col-1).normal();
+        else
+            return sign*M(row-1,col-1).expand();
+    }
+    
     // Now come the minor expansion schemes.  We always develop such that the
     // smallest minors (i.e, the trivial 1x1 ones) are on the rightmost column.
     // For this to be efficient it turns out that the emptiest columns (i.e.
@@ -498,11 +508,6 @@ ex matrix::determinant(void) const
             result[r*col+c] = m[r*col+(*i)];
     }
     
-    if (0*sparse_count>row*col) {     // MAGIC, maybe 10 some day?
-        if (normal_flag)
-            return sign*matrix(row,col,result).determinant_minor_sparse().normal();
-        return sign*matrix(row,col,result).determinant_minor_sparse();
-    }
     if (normal_flag)
         return sign*matrix(row,col,result).determinant_minor_dense().normal();
     return sign*matrix(row,col,result).determinant_minor_dense();