From: Richard Kreckel Date: Sun, 26 Mar 2000 18:45:39 +0000 (+0000) Subject: - added test O1 from Lewis-Wester paper. X-Git-Tag: release_0-6-0~49 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=70ff026226b1a1a7530e8a1d934b98ad42795a1d - added test O1 from Lewis-Wester paper. - corrected a thinko in computing the time. --- diff --git a/check/Makefile.am b/check/Makefile.am index 1fcec8ad..a877fdb5 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -12,7 +12,8 @@ checks_LDADD = ../ginac/libginac.la times_SOURCES = time_dennyfliegner.cpp time_gammaseries.cpp \ time_vandermonde.cpp time_toeplitz.cpp time_lw_A.cpp time_lw_B.cpp \ time_lw_C.cpp time_lw_D.cpp time_lw_E.cpp time_lw_F.cpp time_lw_G.cpp \ - time_lw_H.cpp time_lw_P.cpp time_lw_Pprime.cpp timer.cpp times.cpp times.h + time_lw_H.cpp time_lw_O.cpp time_lw_P.cpp time_lw_Pprime.cpp \ + timer.cpp times.cpp times.h times_LDADD = ../ginac/libginac.la INCLUDES = -I$(srcdir)/../ginac CLEANFILES = exams.out checks.out times.out diff --git a/check/Makefile.in b/check/Makefile.in index 7ffe01e9..3a7cd3b6 100644 --- a/check/Makefile.in +++ b/check/Makefile.in @@ -111,7 +111,7 @@ exams_LDADD = ../ginac/libginac.la checks_SOURCES = check_numeric.cpp check_inifcns.cpp check_matrices.cpp check_lsolve.cpp genex.cpp checks.cpp checks.h checks_LDADD = ../ginac/libginac.la -times_SOURCES = time_dennyfliegner.cpp time_gammaseries.cpp time_vandermonde.cpp time_toeplitz.cpp time_lw_A.cpp time_lw_B.cpp time_lw_C.cpp time_lw_D.cpp time_lw_E.cpp time_lw_F.cpp time_lw_G.cpp time_lw_H.cpp time_lw_P.cpp time_lw_Pprime.cpp timer.cpp times.cpp times.h +times_SOURCES = time_dennyfliegner.cpp time_gammaseries.cpp time_vandermonde.cpp time_toeplitz.cpp time_lw_A.cpp time_lw_B.cpp time_lw_C.cpp time_lw_D.cpp time_lw_E.cpp time_lw_F.cpp time_lw_G.cpp time_lw_H.cpp time_lw_O.cpp time_lw_P.cpp time_lw_Pprime.cpp timer.cpp times.cpp times.h times_LDADD = ../ginac/libginac.la INCLUDES = -I$(srcdir)/../ginac @@ -137,8 +137,8 @@ checks_DEPENDENCIES = ../ginac/libginac.la checks_LDFLAGS = times_OBJECTS = time_dennyfliegner.o time_gammaseries.o \ time_vandermonde.o time_toeplitz.o time_lw_A.o time_lw_B.o time_lw_C.o \ -time_lw_D.o time_lw_E.o time_lw_F.o time_lw_G.o time_lw_H.o time_lw_P.o \ -time_lw_Pprime.o timer.o times.o +time_lw_D.o time_lw_E.o time_lw_F.o time_lw_G.o time_lw_H.o time_lw_O.o \ +time_lw_P.o time_lw_Pprime.o timer.o times.o times_DEPENDENCIES = ../ginac/libginac.la times_LDFLAGS = CXXFLAGS = @CXXFLAGS@ @@ -167,7 +167,7 @@ DEP_FILES = .deps/check_inifcns.P .deps/check_lsolve.P \ .deps/exams.P .deps/genex.P .deps/time_dennyfliegner.P \ .deps/time_gammaseries.P .deps/time_lw_A.P .deps/time_lw_B.P \ .deps/time_lw_C.P .deps/time_lw_D.P .deps/time_lw_E.P .deps/time_lw_F.P \ -.deps/time_lw_G.P .deps/time_lw_H.P .deps/time_lw_P.P \ +.deps/time_lw_G.P .deps/time_lw_H.P .deps/time_lw_O.P .deps/time_lw_P.P \ .deps/time_lw_Pprime.P .deps/time_toeplitz.P .deps/time_vandermonde.P \ .deps/timer.P .deps/times.P SOURCES = $(exams_SOURCES) $(checks_SOURCES) $(times_SOURCES) diff --git a/check/time_lw_A.cpp b/check/time_lw_A.cpp index c21bcede..2fa40c92 100644 --- a/check/time_lw_A.cpp +++ b/check/time_lw_A.cpp @@ -39,7 +39,7 @@ static unsigned test(void) unsigned time_lw_A(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_B.cpp b/check/time_lw_B.cpp index 00bbc00a..3431203d 100644 --- a/check/time_lw_B.cpp +++ b/check/time_lw_B.cpp @@ -40,7 +40,7 @@ static unsigned test(void) unsigned time_lw_B(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_C.cpp b/check/time_lw_C.cpp index dbb128dd..8885d870 100644 --- a/check/time_lw_C.cpp +++ b/check/time_lw_C.cpp @@ -44,7 +44,7 @@ static unsigned test(void) unsigned time_lw_C(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_D.cpp b/check/time_lw_D.cpp index abd0abe6..092d5cc9 100644 --- a/check/time_lw_D.cpp +++ b/check/time_lw_D.cpp @@ -42,7 +42,7 @@ static unsigned test(void) unsigned time_lw_D(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_E.cpp b/check/time_lw_E.cpp index dfeac7d6..934d52b5 100644 --- a/check/time_lw_E.cpp +++ b/check/time_lw_E.cpp @@ -42,7 +42,7 @@ static unsigned test(void) unsigned time_lw_E(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_F.cpp b/check/time_lw_F.cpp index 49d0d636..ce8920e5 100644 --- a/check/time_lw_F.cpp +++ b/check/time_lw_F.cpp @@ -41,7 +41,7 @@ static unsigned test(void) unsigned time_lw_F(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_G.cpp b/check/time_lw_G.cpp index 771b4372..75dd4261 100644 --- a/check/time_lw_G.cpp +++ b/check/time_lw_G.cpp @@ -44,7 +44,7 @@ static unsigned test(void) unsigned time_lw_G(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_H.cpp b/check/time_lw_H.cpp index 1bbe19d9..a7c5c852 100644 --- a/check/time_lw_H.cpp +++ b/check/time_lw_H.cpp @@ -42,7 +42,7 @@ static unsigned test(void) unsigned time_lw_H(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_O.cpp b/check/time_lw_O.cpp new file mode 100644 index 00000000..c6af8c8c --- /dev/null +++ b/check/time_lw_O.cpp @@ -0,0 +1,127 @@ +/** @file time_lw_O.cpp + * + * Test O1 from the paper "Comparison of Polynomial-Oriented CAS" by Robert H. + * Lewis and Michael Wester. */ + +/* + * GiNaC Copyright (C) 1999-2000 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 + */ + +#include "times.h" + +static unsigned test1(void) +{ + symbol a1("a1"), a2("a2"), a3("a3"), a4("a4"), a5("a5"), a6("a6"); + symbol b1("b1"), b2("b2"), b3("b3"), b4("b4"), b5("b5"), b6("b6"); + symbol c1("c1"), c2("c2"), c3("c3"), c4("c4"), c5("c5"), c6("c6"); + ex w1[15][15] = { + {a6, a5, a4, a3, a2, a1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + {0, 0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0 }, + {0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1, 0, 0 }, + {0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1, 0 }, + {0, 0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1}, + {0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1, 0, 0 }, + {0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1, 0 }, + {0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0, 0 }, + {0, 0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1}, + {0, 0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1}, + {0, 0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0 }, + {0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1, 0 } + }; + ex w2[15][15] = { + {b6, b5, b4, b3, b2, b1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + {0, 0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0 }, + {0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1, 0, 0 }, + {0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1, 0 }, + {0, 0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1}, + {0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1, 0, 0 }, + {0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1, 0 }, + {0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0, 0 }, + {0, 0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1}, + {0, 0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1}, + {0, 0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0 }, + {0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1, 0 } + }; + ex w3[15][15] = { + {c6, c5, c4, c3, c2, c1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + {0, 0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0 }, + {0, c6, 0, c5, c4, 0, c3, c2, c1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1, 0, 0 }, + {0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1, 0 }, + {0, 0, 0, 0, 0, c6, 0, 0, c5, c4, 0, 0, c3, c2, c1}, + {0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1, 0, 0 }, + {0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1, 0 }, + {0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0, 0 }, + {0, 0, a6, 0, a5, a4, 0, a3, a2, a1, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, 0, a6, 0, 0, a5, a4, 0, 0, a3, a2, a1}, + {0, 0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1}, + {0, 0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0 }, + {0, b6, 0, b5, b4, 0, b3, b2, b1, 0, 0, 0, 0, 0, 0 }, + {0, 0, 0, 0, b6, 0, 0, b5, b4, 0, 0, b3, b2, b1, 0 } + }; + matrix d1(15,15), d2(15,15), d3(15,15); + for (unsigned r=0; r<15; ++r) { + for (unsigned c=0; c<15; ++c) { + d1.set(r,c,w1[r][c]); + d2.set(r,c,w2[r][c]); + d3.set(r,c,w3[r][c]); + } + } + unsigned nops1 = nops(d1.determinant()); cout << '.' << flush; + unsigned nops2 = nops(d2.determinant()); cout << '.' << flush; + unsigned nops3 = nops(d3.determinant()); cout << '.' << flush; + + if ((nops1 != 37490) || (nops2 != 37490) || (nops3 != 37490)) { + clog << "Determinant from van der Waerden's example were miscalculated" << endl; + return 1; + } + return 0; +} + +unsigned time_lw_O(void) +{ + unsigned result = 0; + unsigned count = 0; + timer rolex; + double time = .0; + + cout << "timing Lewis-Wester test O1 (three 15x15 dets)" << flush; + clog << "-------Lewis-Wester test O1 (three 15x15 dets)" << endl; + + rolex.start(); + // correct for very small times: + do { + result = test1(); + ++count; + } while ((time=rolex.read())<0.1 && !result); + + if (!result) { + cout << " passed "; + clog << "(no output)" << endl; + } else { + cout << " failed "; + } + cout << int(1000*(time/(3*count)))*0.001 << "s (average)" << endl; + + return result; +} diff --git a/check/time_lw_P.cpp b/check/time_lw_P.cpp index 37772ef1..3145093a 100644 --- a/check/time_lw_P.cpp +++ b/check/time_lw_P.cpp @@ -46,7 +46,7 @@ static unsigned test(void) unsigned time_lw_P(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/time_lw_Pprime.cpp b/check/time_lw_Pprime.cpp index 88854b29..5fb670da 100644 --- a/check/time_lw_Pprime.cpp +++ b/check/time_lw_Pprime.cpp @@ -61,7 +61,7 @@ static unsigned test(void) unsigned time_lw_Pprime(void) { unsigned result = 0; - unsigned count = 1; + unsigned count = 0; timer rolex; double time = .0; diff --git a/check/times.cpp b/check/times.cpp index 65ca3baf..5628aa4c 100644 --- a/check/times.cpp +++ b/check/times.cpp @@ -125,6 +125,14 @@ int main() ++result; } + try { + for (int i=0; i<1; ++i) + result += time_lw_O(); + } catch (const exception &e) { + cout << "Error: caught exception " << e.what() << endl; + ++result; + } + try { for (int i=0; i<1; ++i) result += time_lw_P(); diff --git a/check/times.h b/check/times.h index c4919751..26a33552 100644 --- a/check/times.h +++ b/check/times.h @@ -59,6 +59,7 @@ unsigned time_lw_E(); unsigned time_lw_F(); unsigned time_lw_G(); unsigned time_lw_H(); +unsigned time_lw_O(); unsigned time_lw_P(); unsigned time_lw_Pprime(); diff --git a/check/times.ref b/check/times.ref index 074fbdf8..1ae35418 100644 --- a/check/times.ref +++ b/check/times.ref @@ -22,6 +22,8 @@ (no output) -------Lewis-Wester test H (det of 80x80 Hilbert) (no output) +-------Lewis-Wester test O1 (three 15x15 dets) +(no output) -------Lewis-Wester test P (det of sparse rank 101) (no output) -------Lewis-Wester test P' (det of less sparse rank 101)