]> www.ginac.de Git - ginac.git/blobdiff - check/time_antipode.cpp
Happy New Year!
[ginac.git] / check / time_antipode.cpp
index e88bd735cf4a54223bb528bc626a3856a6fc81c1..24da0b753b54e781787a0bc28995edbca5aba287 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2019 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
  *
  *  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 <utility>
-#include <vector>
-#include <set>
+#include "ginac.h"
+#include "timer.h"
+using namespace GiNaC;
+
 #include <map>
-#include <typeinfo>
+#include <set>
 #include <stdexcept>
+#include <typeinfo>
+#include <utility>
+#include <vector>
+using namespace std;
 
 // whether to run this beast or not:
-static const bool do_test = true;
+constexpr bool do_test = true;
 
 // regularization parameter:
 static const symbol x("x");
@@ -68,6 +72,7 @@ static ex div_part(const ex &exarg, const symbol &x, unsigned grad)
 /* F_ab(a, i, b, j, "x") is a common pattern in all vertex evaluators. */
 static ex F_ab(int a, int i, int b, int j, const symbol &x)
 {
+       using GiNaC::tgamma;
        if ((i==0 && a<=0) || (j==0 && b<=0))
                return 0;
        else
@@ -100,9 +105,9 @@ protected:
 class Sigma : public vertex {
 public:
        Sigma(ijpair ij = ijpair(0,0)) : vertex(ij) { }
-       vertex* copy() const { return new Sigma(*this); }
-       ijpair get_increment() const { return ijpair(indices.first+indices.second+1, 0); }
-       const ex evaluate(const symbol &x, const unsigned grad) const;
+       vertex* copy() const override { return new Sigma(*this); }
+       ijpair get_increment() const override { return ijpair(indices.first+indices.second+1, 0); }
+       const ex evaluate(const symbol &x, const unsigned grad) const override;
 private:
 };
 
@@ -128,13 +133,13 @@ const ex Sigma::evaluate(const symbol &x, const unsigned grad) const
 }
 
 
-/** Class of vertices of type Sigma_flipped, sitting in the upper fermionline of Vacuum; no consequences for Gamma. */
+/** Class of vertices of type Sigma_flipped, sitting in the upper fermion line of Vacuum; no consequences for Gamma. */
 class Sigma_flipped : public Sigma {
 public:
        Sigma_flipped(ijpair ij = ijpair(0,0)) : Sigma(ij) { }
-       vertex* copy() const { return new Sigma_flipped(*this); }
-       ijpair get_increment() const { return ijpair(0, indices.first+indices.second+1); }
-       const ex evaluate(const symbol &x, const unsigned grad) const { return Sigma::evaluate(x, grad); }
+       vertex* copy() const override { return new Sigma_flipped(*this); }
+       ijpair get_increment() const override { return ijpair(0, indices.first+indices.second+1); }
+       const ex evaluate(const symbol &x, const unsigned grad) const override { return Sigma::evaluate(x, grad); }
 private:
 };
 
@@ -145,9 +150,9 @@ private:
 class Gamma : public vertex {
 public:
        Gamma(ijpair ij = ijpair(0,0)) : vertex(ij) { }
-       vertex* copy() const { return new Gamma(*this); }
-       ijpair get_increment() const { return ijpair(indices.first+indices.second+1, 0); }
-       const ex evaluate(const symbol &x, const unsigned grad) const;
+       vertex* copy() const override { return new Gamma(*this); }
+       ijpair get_increment() const override { return ijpair(indices.first+indices.second+1, 0); }
+       const ex evaluate(const symbol &x, const unsigned grad) const override;
 private:
 };
 
@@ -179,9 +184,9 @@ const ex Gamma::evaluate(const symbol &x, const unsigned grad) const
 class Vacuum : public vertex {
 public:
        Vacuum(ijpair ij = ijpair(0,0)) : vertex(ij) { }
-       vertex* copy() const { return new Vacuum(*this); }
-       ijpair get_increment() const { return ijpair(0, indices.first+indices.second+1); }
-       const ex evaluate(const symbol &x, const unsigned grad) const;
+       vertex* copy() const override { return new Vacuum(*this); }
+       ijpair get_increment() const override { return ijpair(0, indices.first+indices.second+1); }
+       const ex evaluate(const symbol &x, const unsigned grad) const override;
 private:
 };
 
@@ -442,10 +447,10 @@ static const node tree6(unsigned cuts=0)
                        bool(cuts & 16)));
 }
 
-static unsigned test_tree(const node (*tree_generator)(unsigned=0))
+static unsigned test_tree(const node tree_generator(unsigned))
 {
-       const int edges = tree_generator().total_edges();
-       const int vertices = edges+1;
+       const int edges = tree_generator(0).total_edges();
+       const int vertices = edges+1;
        
        // fill a vector of all possible 2^edges combinations of cuts...
        vector<node> counter;
@@ -455,7 +460,7 @@ static unsigned test_tree(const node (*tree_generator)(unsigned=0))
        // ...the sum, when evaluated and reexpanded, is the antipode...
        ex result = 0;
        for (vector<node>::iterator i=counter.begin(); i!=counter.end(); ++i)
-               result = (result+i->evaluate(x,vertices)).series(x==0,vertices).expand();
+               result = (result+i->evaluate(x,vertices-1)).series(x==0,vertices-1).expand();
        
        // ...and has the nice property that in each term all the Eulers cancel:
        if (result.has(Euler)) {
@@ -479,7 +484,6 @@ unsigned time_antipode()
        timer jaeger_le_coultre;
        
        cout << "timing computation of antipodes in Yukawa theory" << flush;
-       clog << "-------computation of antipodes in Yukawa theory:" << endl;
        
        if (do_test) {
                jaeger_le_coultre.start();
@@ -490,17 +494,18 @@ unsigned time_antipode()
                result += test_tree(tree5);  cout << '.' << flush;
                result += test_tree(tree6);  cout << '.' << flush;
                
-               if (!result) {
-                       cout << " passed ";
-                       clog << "(no output)" << endl;
-               } else {
-                       cout << " failed ";
-               }
-               cout << int(1000*jaeger_le_coultre.read())*0.001 << "s (total)" << endl;
+               cout << jaeger_le_coultre.read() << "s (total)" << endl;
        } else {
                cout << " disabled" << endl;
-               clog << "(no output)" << endl;
        }
-       
        return result;
 }
+
+extern void randomify_symbol_serials();
+
+int main(int argc, char** argv)
+{
+       randomify_symbol_serials();
+       cout << setprecision(2) << showpoint;
+       return time_antipode();
+}