1 /** @file check_matrices.cpp
3 * Here we test manipulations on GiNaC's symbolic matrices. */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // determinants of some sparse symbolic size x size matrices
26 static unsigned matrix_determinants(void)
31 for (int size=3; size<16; ++size) {
33 for (int c=0; c<size; ++c) {
34 for (int r=0;r<size-1; ++r)
35 // populate 10 percent of the entries, the rest remains 0:
36 if (!(int)(10.0*rand()/(RAND_MAX+1.0)))
37 A.set(r,c,dense_univariate_poly(a,5));
38 // set the last line to a linear combination of two other lines
39 // to guarantee that the determinant vanishes:
40 A.set(size-1,c,A(0,c)-A(size-2,c));
42 if (!A.determinant().is_zero()) {
43 clog << "Determinant of " << size << "x" << size << " matrix "
45 << "was not found to vanish!" << endl;
53 unsigned check_matrices(void)
57 cout << "checking symbolic matrix manipulations" << flush;
58 clog << "---------symbolic matrix manipulations:" << endl;
60 result += matrix_determinants(); cout << '.' << flush;
63 cout << " passed " << endl;
64 clog << "(no output)" << endl;
66 cout << " failed " << endl;