#include "lst.h"
#include "archive.h"
#include "utils.h"
+#include "integral.h"
namespace GiNaC {
return free_indices;
}
+struct is_summation_idx : public std::unary_function<ex, bool> {
+ bool operator()(const ex & e)
+ {
+ return is_dummy_pair(e, e);
+ }
+};
+
exvector power::get_free_indices() const
{
- // Return free indices of basis
- return basis.get_free_indices();
+ // Get free indices of basis
+ exvector basis_indices = basis.get_free_indices();
+
+ if (exponent.info(info_flags::even)) {
+ // If the exponent is an even number, then any "free" index that
+ // forms a dummy pair with itself is actually a summation index
+ exvector really_free;
+ std::remove_copy_if(basis_indices.begin(), basis_indices.end(),
+ std::back_inserter(really_free), is_summation_idx());
+ return really_free;
+ } else
+ return basis_indices;
+}
+
+exvector integral::get_free_indices() const
+{
+ if (a.get_free_indices().size() || b.get_free_indices().size())
+ throw (std::runtime_error("integral::get_free_indices: boundary values should not have free indices"));
+ return f.get_free_indices();
}
/** Rename dummy indices in an expression.
* performs contraction of dummy indices where possible and checks whether
* the free indices in sums are consistent.
*
+ * @param options Simplification options (currently unused)
* @return simplified expression */
ex ex::simplify_indexed(unsigned options) const
{
* scalar products by known values if desired.
*
* @param sp Scalar products to be replaced automatically
+ * @param options Simplification options (currently unused)
* @return simplified expression */
ex ex::simplify_indexed(const scalar_products & sp, unsigned options) const
{