Hi ginac'ers, Brand new to this, so sorry if this is old hat. Couldn't find it in the archives. I want to do some simple calculations involving 4-momenta and dirac matrices. Simplest case I want to get the invariant mass of a 4-momentum. I've got this for now. #include<iostream> #include<ginac/ginac.h> using namespace std; using namespace GiNaC; int main() { symbol mu_sym("mu"); varidx mu(mu_sym, 4); symbol p1_sym("p1"); ex p1 = indexed(p1_sym, mu); symbol p2_sym("p2"); ex p2 = indexed(p2_sym, mu.toggle_variance()); ex mass = p1 * p2; cerr << mass << endl; return 0; } It looks OK, but I need to be able to enter in data for p1 and p2 so I can calculate the mass. I don't know how to do this. Anyone know? Also, right now I've got two separate expressions for the raised and lowered indices of the momentum (p1, p2). Is there an easier way to do this? Thanks in advance for any help anyone can offer. -- --------------------------- Matt Bellis Carnegie Mellon University (office) 412-268-6949 (cell) 412-310-4586 ---------------------------
Hi! On Thu, Aug 05, 2004 at 03:19:07AM -0400, Matt Bellis wrote:
I want to do some simple calculations involving 4-momenta and dirac matrices. Simplest case I want to get the invariant mass of a 4-momentum.
xloops has a momentum class where you can assign components or invariants (or not), and do calculations with it. See http://down.physik.uni-mainz.de/cgi-bin/viewcvs.cgi/xloops/lib/?cvsroot=ThEP files "momentum.cpp" and "momentum.h". For example, you can write momentum p(symbol("p")); p.assign(1938.0, 1696.0, 0, 0); // E and \sqrt(\vec{p}^2) in MeV // with indices varidx mu(symbol("mu"), 4); ex mass_sq = indexed(p, mu) * indexed(p, mu.toggle_variance()); cout << sqrt(simplify_indexed(mass_sq)) << endl; // easier, without indices cout << sqrt(p.get_square()) << endl; Bye, Christian -- / Physics is an algorithm \/ http://www.uni-mainz.de/~bauec002/
participants (2)
-
Christian Bauer
-
Matt Bellis