X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=check%2Ftime_toeplitz.cpp;h=87284c0f9eeb773ce0b3b28b4fe84a11b7eb71b7;hb=afb0ccaa49a0cca001d854594e09125a58434123;hp=573f00f943805ac76bcf0067c5c4f68df206785d;hpb=1f5afe37b4c079821de9810435fa9fa11e4ea17b;p=ginac.git diff --git a/check/time_toeplitz.cpp b/check/time_toeplitz.cpp index 573f00f9..87284c0f 100644 --- a/check/time_toeplitz.cpp +++ b/check/time_toeplitz.cpp @@ -6,7 +6,7 @@ */ /* - * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2018 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,24 +20,31 @@ * * 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 "ginac.h" +#include "timer.h" +using namespace GiNaC; + +#include +#include +using namespace std; static unsigned toeplitz_det(unsigned size) { unsigned result = 0; const symbol a("a"), b("b"); - ex p[9] = {ex("a",lst(a,b)), - ex("b",lst(a,b)), - ex("a+b",lst(a,b)), - ex("a^2+a*b+b^2",lst(a,b)), - ex("a^3+a^2*b-a*b^2+b^3",lst(a,b)), - ex("a^4+a^3*b+a^2*b^2+a*b^3+b^4",lst(a,b)), - ex("a^5+a^4*b+a^3*b^2-a^2*b^3+a*b^4+b^5",lst(a,b)), - ex("a^6+a^5*b+a^4*b^2+a^3*b^3+a^2*b^4+a*b^5+b^6",lst(a,b)), - ex("a^7+a^6*b+a^5*b^2+a^4*b^3-a^3*b^4+a^2*b^5+a*b^6+b^7",lst(a,b)) + ex p[10] = {ex("a",lst{a,b}), + ex("b",lst{a,b}), + ex("a+b",lst{a,b}), + ex("a^2+a*b+b^2",lst{a,b}), + ex("a^3+a^2*b-a*b^2+b^3",lst{a,b}), + ex("a^4+a^3*b+a^2*b^2+a*b^3+b^4",lst{a,b}), + ex("a^5+a^4*b+a^3*b^2-a^2*b^3+a*b^4+b^5",lst{a,b}), + ex("a^6+a^5*b+a^4*b^2+a^3*b^3+a^2*b^4+a*b^5+b^6",lst{a,b}), + ex("a^7+a^6*b+a^5*b^2+a^4*b^3-a^3*b^4+a^2*b^5+a*b^6+b^7",lst{a,b}), + ex("a^8+a^7*b+a^6*b^2+a^5*b^3+a^4*b^4+a^3*b^5+a^2*b^6+a*b^7+b^8",lst{a,b}) }; // construct Toeplitz matrix (diagonal structure: [[x,y,z],[y,x,y],[z,y,x]]): @@ -54,7 +61,7 @@ static unsigned toeplitz_det(unsigned size) // dirty consistency check of result: if (!tdet.subs(a==0).subs(b==0).is_zero()) { - clog << "Determaint of Toeplitz matrix " << endl + clog << "Determinant of Toeplitz matrix " << endl << "M==" << M << endl << "was miscalculated: det(M)==" << tdet << endl; ++result; @@ -63,22 +70,16 @@ static unsigned toeplitz_det(unsigned size) return result; } -unsigned time_toeplitz(void) +unsigned time_toeplitz() { unsigned result = 0; cout << "timing determinant of polyvariate symbolic Toeplitz matrices" << flush; - clog << "-------determinant of polyvariate symbolic Toeplitz matrices:" << endl; - vector sizes; + vector sizes = {7, 8, 9, 10}; vector times; timer longines; - sizes.push_back(6); - sizes.push_back(7); - sizes.push_back(8); - sizes.push_back(9); - for (vector::iterator i=sizes.begin(); i!=sizes.end(); ++i) { int count = 1; longines.start(); @@ -92,20 +93,23 @@ unsigned time_toeplitz(void) 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 << '\t' << *i; cout << endl; return result; } + +extern void randomify_symbol_serials(); + +int main(int argc, char** argv) +{ + randomify_symbol_serials(); + cout << setprecision(2) << showpoint; + return time_toeplitz(); +}