HepLib
  • About HepLib
  • Installation
  • Usage in C++
  • Objects in C++
  • Examples in C++
  • Usage in Python
  • Objects in Python
  • Examples in Python
  • Utils in HepLib
  • Try & Run online
  • Release @GitHub
  • Document @Doxygen
Powered by GitBook
On this page
  • 1. Prepare the C++ Code
  • 2. Compile and Run

Usage in C++

The usage of HepLib is similar to other C++ library by including the proper header files in the C++ source code, compiling the program and linking with HepLib and other necessary libraries.

1. Prepare the C++ Code

#include "HepLib.h"
using namespace HepLib;
using namespace FC;
int main(int argc, char** argv) {
    Index mu("mu"), nu("nu");
    Vector p1("p1"), p2("p2");
    Symbol m("m");
    //note GAS(1) in gline, corresponds to the identity matrix
    ex gline = GAS(p1)*GAS(mu)*(GAS(p2)+m*GAS(1))*GAS(mu);
    ex trace = form(TR(gline));
    hout << trace << endl;
    return 0;
}

The above code trace.cpp shows how to perform the D-dimensional trace on a Dirac-𝛾 chain:

Tr ⁣ ⁣ ⁣[p ⁣ ⁣ ⁣/1γμ(p ⁣ ⁣ ⁣/2+m)γμ]\huge{\rm Tr}\!\!\!\left[p\!\!\!/_1 \gamma^\mu (p\!\!\!/_2 + m) \gamma_\mu \right]Tr[p/1​γμ(p/2​+m)γμ​]

2. Compile and Run

  • One can compile the trace.cpp using heplib++ and run it as follows:

<INSTALL PATH>/bin/heplib++ -o trace trace.cpp
./trace
# 8*p2.p1+(-4)*D*p2.p1
  • One can also compile the program with pkg-config as follows:

export PKG_CONFIG_PATH=<INSTALL PATH>/lib/pkgconfig:$PKG_CONFIG_PATH
g++ $(pkg-config --cflags --libs HepLib) -o trace trace.cpp
  • One can also provide the g++ flags explicitly as follows:

g++ -I <INSTALL PATH>/include -L <INSTALL PATH>/lib -Wl,-rapth,<INSTALL PATH>/lib -lHepLib -lginac -o trace trace.cpp
PreviousInstallationNextObjects in C++

Last updated 4 years ago