X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fex.cpp;h=55482551995efcad1ce2166484dd126fc48b8f2e;hp=6acde9f97f1d58b952e4d53d6246bb06208789cf;hb=094911eb78cacb6f2877a70c9ac74766df58ccea;hpb=ad5dd77c6b19c4c7b8cda7f95584f02c01d17896 diff --git a/ginac/ex.cpp b/ginac/ex.cpp index 6acde9f9..55482551 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -37,6 +37,7 @@ #include "numeric.h" #include "power.h" #include "relational.h" +#include "indexed.h" #include "input_lexer.h" #include "debugmsg.h" #include "utils.h" @@ -241,10 +242,33 @@ ex ex::subs(const ex & e) const return bp->subs(e); } -exvector ex::get_indices(void) const +/** Return a vector containing the free indices of the object. */ +exvector ex::get_free_indices(void) const { GINAC_ASSERT(bp!=0); - return bp->get_indices(); + return bp->get_free_indices(); +} + +/** Simplify/canonicalize expression containing indexed objects. This + * performs contraction of dummy indices where possible and checks whether + * the free indices in sums are consistent. + * + * @return simplified expression */ +ex ex::simplify_indexed(void) const +{ + return GiNaC::simplify_indexed(*this); +} + +/** Simplify/canonicalize expression containing indexed objects. This + * performs contraction of dummy indices where possible, checks whether + * the free indices in sums are consistent, and automatically replaces + * scalar products by known values if desired. + * + * @param sp Scalar products to be replaced automatically + * @return simplified expression */ +ex ex::simplify_indexed(const scalar_products & sp) const +{ + return GiNaC::simplify_indexed(*this, sp); } ex ex::simplify_ncmul(const exvector & v) const