]> www.ginac.de Git - ginac.git/blobdiff - check/exam_polygcd.cpp
G_numeric: put convergence/acceleration transofrmations into helper functions.
[ginac.git] / check / exam_polygcd.cpp
index 2132d765068cd349520eaf36b89b886d1a0e8f41..79d4d5ed93adbea3f6c120bf7d719d69b4114f32 100644 (file)
@@ -4,7 +4,7 @@
  *  rational function normalization in normalization.cpp. */
 
 /*
  *  rational function normalization in normalization.cpp. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 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
  *
  *  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
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
  *
  *  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 "exams.h"
+#include <iostream>
+#include "ginac.h"
+using namespace std;
+using namespace GiNaC;
 
 const int MAX_VARIABLES = 3;
 
 
 const int MAX_VARIABLES = 3;
 
@@ -29,7 +32,7 @@ static symbol x("x"), z("z");
 static symbol y[MAX_VARIABLES];
 
 // GCD = 1
 static symbol y[MAX_VARIABLES];
 
 // GCD = 1
-static unsigned poly_gcd1(void)
+static unsigned poly_gcd1()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
@@ -51,7 +54,7 @@ static unsigned poly_gcd1(void)
 }
 
 // Linearly dense quartic inputs with quadratic GCDs
 }
 
 // Linearly dense quartic inputs with quadratic GCDs
-static unsigned poly_gcd2(void)
+static unsigned poly_gcd2()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
@@ -74,7 +77,7 @@ static unsigned poly_gcd2(void)
 }
 
 // Sparse GCD and inputs where degrees are proportional to the number of variables
 }
 
 // Sparse GCD and inputs where degrees are proportional to the number of variables
-static unsigned poly_gcd3(void)
+static unsigned poly_gcd3()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, v + 1);
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, v + 1);
@@ -94,7 +97,7 @@ static unsigned poly_gcd3(void)
 }
 
 // Variation of case 3; major performance degradation with PRS
 }
 
 // Variation of case 3; major performance degradation with PRS
-static unsigned poly_gcd3p(void)
+static unsigned poly_gcd3p()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, v + 1);
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, v + 1);
@@ -117,7 +120,7 @@ static unsigned poly_gcd3p(void)
 }
 
 // Quadratic non-monic GCD; f and g have other quadratic factors
 }
 
 // Quadratic non-monic GCD; f and g have other quadratic factors
-static unsigned poly_gcd4(void)
+static unsigned poly_gcd4()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, 2) * pow(y[0], 2);
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = pow(x, 2) * pow(y[0], 2);
@@ -142,7 +145,7 @@ static unsigned poly_gcd4(void)
 }
 
 // Completely dense non-monic quadratic inputs with dense non-monic linear GCDs
 }
 
 // Completely dense non-monic quadratic inputs with dense non-monic linear GCDs
-static unsigned poly_gcd5(void)
+static unsigned poly_gcd5()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x + 1;
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x + 1;
@@ -167,7 +170,7 @@ static unsigned poly_gcd5(void)
 }
 
 // Sparse non-monic quadratic inputs with linear GCDs
 }
 
 // Sparse non-monic quadratic inputs with linear GCDs
-static unsigned poly_gcd5p(void)
+static unsigned poly_gcd5p()
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
 {
        for (int v=1; v<=MAX_VARIABLES; v++) {
                ex e1 = x;
@@ -187,7 +190,7 @@ static unsigned poly_gcd5p(void)
 }
 
 // Trivariate inputs with increasing degrees
 }
 
 // Trivariate inputs with increasing degrees
-static unsigned poly_gcd6(void)
+static unsigned poly_gcd6()
 {
        symbol y("y");
 
 {
        symbol y("y");
 
@@ -205,7 +208,7 @@ static unsigned poly_gcd6(void)
 }
 
 // Trivariate polynomials whose GCD has common factors with its cofactors
 }
 
 // Trivariate polynomials whose GCD has common factors with its cofactors
-static unsigned poly_gcd7(void)
+static unsigned poly_gcd7()
 {
        symbol y("y");
        ex p = x - y * z + 1;
 {
        symbol y("y");
        ex p = x - y * z + 1;
@@ -226,12 +229,11 @@ static unsigned poly_gcd7(void)
        return 0;
 }
 
        return 0;
 }
 
-unsigned exam_polygcd(void)
+unsigned exam_polygcd()
 {
        unsigned result = 0;
        
        cout << "examining polynomial GCD computation" << flush;
 {
        unsigned result = 0;
        
        cout << "examining polynomial GCD computation" << flush;
-       clog << "----------polynomial GCD computation:" << endl;
        
        result += poly_gcd1();  cout << '.' << flush;
        result += poly_gcd2();  cout << '.' << flush;
        
        result += poly_gcd1();  cout << '.' << flush;
        result += poly_gcd2();  cout << '.' << flush;
@@ -243,12 +245,10 @@ unsigned exam_polygcd(void)
        result += poly_gcd6();  cout << '.' << flush;
        result += poly_gcd7();  cout << '.' << flush;
        
        result += poly_gcd6();  cout << '.' << flush;
        result += poly_gcd7();  cout << '.' << flush;
        
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
-       
        return result;
 }
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_polygcd();
+}