- unsigned result = 0;
- symbol a("a"), b("b"), c("c");
-
- for (unsigned size=3; size<7; ++size) {
- matrix A(size,size);
- for (unsigned co=0; co<size-1; ++co) {
- // populate one or two elements in each row:
- for (unsigned ec=0; ec<2; ++ec) {
- ex numer = sparse_tree(a, b, c, 1+rand()%3, true, true, false);
- ex denom;
- do {
- denom = sparse_tree(a, b, c, rand()%2, false, true, false);
- } while (denom.is_zero());
- A.set(unsigned(rand()%size),co,numer/denom);
- }
- }
- // set the last column to a linear combination of two other columns
- // to guarantee that the determinant is zero:
- for (unsigned ro=0; ro<size; ++ro)
- A.set(ro,size-1,A(ro,0)-A(ro,size-2));
- if (!A.determinant().is_zero()) {
- clog << "Determinant of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "was not found to vanish!" << endl;
- ++result;
- }
- }
-
- return result;
+ unsigned result = 0;
+ symbol a("a"), b("b"), c("c");
+
+ for (unsigned size=3; size<7; ++size) {
+ matrix A(size,size);
+ for (unsigned co=0; co<size-1; ++co) {
+ // populate one or two elements in each row:
+ for (unsigned ec=0; ec<2; ++ec) {
+ ex numer = sparse_tree(a, b, c, 1+rand()%3, true, true, false);
+ ex denom;
+ do {
+ denom = sparse_tree(a, b, c, rand()%2, false, true, false);
+ } while (denom.is_zero());
+ A.set(unsigned(rand()%size),co,numer/denom);
+ }
+ }
+ // set the last column to a linear combination of two other columns
+ // to guarantee that the determinant is zero:
+ for (unsigned ro=0; ro<size; ++ro)
+ A.set(ro,size-1,A(ro,0)-A(ro,size-2));
+ if (!A.determinant().is_zero()) {
+ clog << "Determinant of " << size << "x" << size << " matrix "
+ << endl << A << endl
+ << "was not found to vanish!" << endl;
+ ++result;
+ }
+ }
+
+ return result;