X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Ftime_toeplitz.cpp;h=813e5214fd741468156a2bfd2ee4da36d897c626;hp=6f138d3e50c94d6d1489acc5298e0b5723a0019f;hb=aff357309f6611a59efb10d06d3dcfd3812a9ec5;hpb=fdf2f2da4e2b00870cd05c2ac9121de53e56ce3b diff --git a/check/time_toeplitz.cpp b/check/time_toeplitz.cpp index 6f138d3e..813e5214 100644 --- a/check/time_toeplitz.cpp +++ b/check/time_toeplitz.cpp @@ -6,7 +6,7 @@ */ /* - * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,90 +20,100 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "times.h" +#include +#include +#include "ginac.h" +#include "timer.h" +using namespace std; +using namespace GiNaC; static unsigned toeplitz_det(unsigned size) { - unsigned result = 0; - symbol a("a"), b("b"); - ex p[8] = {a, - b, - a+b, - pow(a,2) + a*b + pow(b,2), - pow(a,3) + pow(a,2)*b - a*pow(b,2) + pow(b,3), - pow(a,4) + pow(a,3)*b + pow(a*b,2) + a*pow(b,3) + pow(b,4), - pow(a,5) + pow(a,4)*b + pow(a,3)*pow(b,2) - pow(a,2)*pow(b,3) + a*pow(b,4) + pow(b,5), - pow(a,6) + pow(a,5)*b + pow(a,4)*pow(b,2) + pow(a*b,3) + pow(a,2)*pow(b,4) + a*pow(b,5) + pow(b,6) - }; - - // construct Toeplitz matrix: - matrix M(size,size); - for (unsigned ro=0; ro sizes; + vector times; + timer longines; + + sizes.push_back(7); + sizes.push_back(8); + sizes.push_back(9); + sizes.push_back(10); + + for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { + int count = 1; + longines.start(); + result += toeplitz_det(*i); + // correct for very small times: + while (longines.read()<0.1) { + toeplitz_det(*i); + ++count; + } + times.push_back(longines.read()/count); + cout << '.' << flush; + } + + // print the report: + cout << endl << " dim: "; + for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) + cout << '\t' << *i << 'x' << *i; + cout << endl << " time/s:"; + for (vector::iterator i=times.begin(); i!=times.end(); ++i) + cout << '\t' << *i; + cout << endl; + + return result; } -unsigned time_toeplitz(void) +extern void randomify_symbol_serials(); + +int main(int argc, char** argv) { - unsigned result = 0; - - cout << "timing determinant of polyvariate symbolic Toeplitz matrices" << flush; - clog << "-------determinant of polyvariate symbolic Toeplitz matrices:" << endl; - - vector sizes; - vector times; - timer longines; - - sizes.push_back(5); - sizes.push_back(6); - sizes.push_back(7); - sizes.push_back(8); - - for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { - int count = 1; - longines.start(); - result += toeplitz_det(*i); - // correct for very small times: - while (longines.read()<0.1) { - toeplitz_det(*i); - ++count; - } - times.push_back(longines.read()/count); - cout << '.' << flush; - } - - if (!result) { - cout << " passed "; - clog << "(no output)" << endl; - } else { - cout << " failed "; - } - // print the report: - cout << endl << " dim: "; - for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) - cout << '\t' << *i << 'x' << *i; - cout << endl << " time/s:"; - for (vector::iterator i=times.begin(); i!=times.end(); ++i) - cout << '\t' << int(1000*(*i))*0.001; - cout << endl; - - return result; + randomify_symbol_serials(); + cout << setprecision(2) << showpoint; + return time_toeplitz(); }