namespace GiNaC {
GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
+GINAC_IMPLEMENT_REGISTERED_CLASS(diracone, tensor)
GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor)
//////////
DEFAULT_COPY(clifford)
DEFAULT_DESTROY(clifford)
+DEFAULT_CTORS(diracone)
DEFAULT_CTORS(diracgamma)
//////////
tinfo_key = TINFO_clifford;
}
+/** Construct object without any indices. This constructor is for internal
+ * use only. Use the dirac_one() function instead.
+ * @see dirac_one */
+clifford::clifford(const ex & b) : inherited(b)
+{
+ debugmsg("clifford constructor from ex", LOGLEVEL_CONSTRUCT);
+ tinfo_key = TINFO_clifford;
+}
+
clifford::clifford(const exvector & v, bool discardable) : inherited(indexed::unknown, v, discardable)
{
debugmsg("clifford constructor from exvector", LOGLEVEL_CONSTRUCT);
//////////
DEFAULT_ARCHIVING(clifford)
+DEFAULT_ARCHIVING(diracone)
DEFAULT_ARCHIVING(diracgamma)
//////////
return inherited::compare_same_type(other);
}
+DEFAULT_COMPARE(diracone)
DEFAULT_COMPARE(diracgamma)
+DEFAULT_PRINT(diracone, "ONE")
DEFAULT_PRINT(diracgamma, "gamma")
+/** Contraction of a gamma matrix with something else. */
+bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+{
+ GINAC_ASSERT(is_ex_of_type(*self, indexed));
+ GINAC_ASSERT(is_ex_of_type(*other, indexed));
+ GINAC_ASSERT(is_ex_of_type(self->op(0), diracgamma));
+
+ if (is_ex_of_type(other->op(0), diracgamma)) {
+
+ // gamma~mu*gamma.mu = dim*ONE
+ if (other - self == 1) {
+ *self = ex_to_idx(self->op(1)).get_dim();
+ *other = dirac_one();
+ return true;
+
+ // gamma~mu*gamma~alpha*gamma.mu = (2-dim)*gamma~alpha
+ } else if (other - self == 2) {
+ *self = 2 - ex_to_idx(self->op(1)).get_dim();
+ *other = _ex1();
+ return true;
+ }
+ }
+
+ return false;
+}
+
/** Perform automatic simplification on noncommutative product of clifford
- * objects. */
+ * objects. This removes superfluous ONEs. */
ex clifford::simplify_ncmul(const exvector & v) const
{
- //!! to be implemented
- return nonsimplified_ncmul(v);
+ exvector s;
+ s.reserve(v.size());
+
+ exvector::const_iterator it = v.begin(), itend = v.end();
+ while (it != itend) {
+ if (!is_ex_of_type(it->op(0), diracone))
+ s.push_back(*it);
+ it++;
+ }
+
+ if (s.size() == 0)
+ return clifford(diracone());
+ else if (s.size() == v.size())
+ return simplified_ncmul(v);
+ else
+ return simplified_ncmul(s);
}
ex clifford::thisexprseq(const exvector & v) const
// global functions
//////////
+ex dirac_one(void)
+{
+ return clifford(diracone());
+}
+
ex dirac_gamma(const ex & mu)
{
if (!is_ex_of_type(mu, varidx))
throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
+
return clifford(diracgamma(), mu);
}
// other constructors
public:
+ clifford(const ex & b);
clifford(const ex & b, const ex & mu);
// internal constructors
};
+/** This class represents the Clifford algebra unity element. */
+class diracone : public tensor
+{
+ GINAC_DECLARE_REGISTERED_CLASS(diracone, tensor)
+
+ // functions overriding virtual functions from bases classes
+public:
+ void print(std::ostream & os, unsigned upper_precedence=0) const;
+};
+
+
/** This class represents the Dirac gamma Lorentz vector. */
class diracgamma : public tensor
{
// functions overriding virtual functions from bases classes
public:
void print(std::ostream & os, unsigned upper_precedence=0) const;
+ bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
};
}
+/** Create a Clifford unity object.
+ *
+ * @return newly constructed object */
+ex dirac_one(void);
+
/** Create a Dirac gamma object.
*
* @param mu Index (must be of class varidx or a derived class)
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <algorithm>
+#include <stdexcept>
+
#include "color.h"
#include "ex.h"
+#include "idx.h"
#include "ncmul.h"
#include "numeric.h"
+#include "power.h" // for sqrt()
#include "archive.h"
#include "debugmsg.h"
#include "utils.h"
* objects. This removes superfluous ONEs. */
ex color::simplify_ncmul(const exvector & v) const
{
- //!! to be implemented
- return nonsimplified_ncmul(v);
+ //!! TODO: sort by representation label
+ exvector s;
+ s.reserve(v.size());
+
+ exvector::const_iterator it = v.begin(), itend = v.end();
+ while (it != itend) {
+ if (!is_ex_of_type(it->op(0), su3one))
+ s.push_back(*it);
+ it++;
+ }
+
+ if (s.size() == 0)
+ return color(su3one());
+ else if (s.size() == v.size())
+ return simplified_ncmul(v);
+ else
+ return simplified_ncmul(s);
}
ex color::thisexprseq(const exvector & v) const
return color(representation_label, vp);
}
+/** Given a vector iv3 of three indices and a vector iv2 of two indices that
+ * is a subset of iv3, return the (free) index that is in iv3 but not in
+ * iv2 and the sign introduced by permuting that index to the front.
+ *
+ * @param iv3 Vector of 3 indices
+ * @param iv2 Vector of 2 indices, must be a subset of iv3
+ * @param sig Returs sign introduced by index permutation
+ * @return the free index (the one that is in iv3 but not in iv2) */
+static ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, int & sig)
+{
+ GINAC_ASSERT(iv3.size() == 3);
+ GINAC_ASSERT(iv2.size() == 2);
+
+ sig = 1;
+
+#define TEST_PERMUTATION(A,B,C,P) \
+ if (iv3[B].is_equal(iv2[0]) && iv3[C].is_equal(iv2[1])) { \
+ sig = P; \
+ return iv3[A]; \
+ }
+
+ TEST_PERMUTATION(0,1,2, 1);
+ TEST_PERMUTATION(0,2,1, -1);
+ TEST_PERMUTATION(1,0,2, -1);
+ TEST_PERMUTATION(1,2,0, 1);
+ TEST_PERMUTATION(2,0,1, 1);
+ TEST_PERMUTATION(2,1,0, -1);
+
+ throw(std::logic_error("permute_free_index_to_front(): no valid permutation found"));
+}
+
+/** Automatic symbolic evaluation of indexed symmetric structure constant. */
+ex su3d::eval_indexed(const basic & i) const
+{
+ GINAC_ASSERT(is_of_type(i, indexed));
+ GINAC_ASSERT(i.nops() == 4);
+ GINAC_ASSERT(is_ex_of_type(i.op(0), su3d));
+
+ // Convolutions are zero
+ if (static_cast<const indexed &>(i).get_dummy_indices().size() != 0)
+ return _ex0();
+
+ // Numeric evaluation
+ if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
+
+ // Sort indices
+ int v[3];
+ for (unsigned j=0; j<3; j++)
+ v[j] = ex_to_numeric(ex_to_idx(i.op(j + 1)).get_value()).to_int();
+ if (v[0] > v[1]) std::swap(v[0], v[1]);
+ if (v[0] > v[2]) std::swap(v[0], v[2]);
+ if (v[1] > v[2]) std::swap(v[1], v[2]);
+
+#define CMPINDICES(A,B,C) ((v[0] == (A)) && (v[1] == (B)) && (v[2] == (C)))
+
+ // Check for non-zero elements
+ if (CMPINDICES(1,4,6) || CMPINDICES(1,5,7) || CMPINDICES(2,5,6)
+ || CMPINDICES(3,4,4) || CMPINDICES(3,5,5))
+ return _ex1_2();
+ else if (CMPINDICES(2,4,7) || CMPINDICES(3,6,6) || CMPINDICES(3,7,7))
+ return _ex_1_2();
+ else if (CMPINDICES(1,1,8) || CMPINDICES(2,2,8) || CMPINDICES(3,3,8))
+ return sqrt(_ex3())/3;
+ else if (CMPINDICES(8,8,8))
+ return -sqrt(_ex3())/3;
+ else if (CMPINDICES(4,4,8) || CMPINDICES(5,5,8)
+ || CMPINDICES(6,6,8) || CMPINDICES(7,7,8))
+ return -sqrt(_ex3())/6;
+ else
+ return _ex0();
+ }
+
+ // No further simplifications
+ return i.hold();
+}
+
+/** Automatic symbolic evaluation of indexed antisymmetric structure constant. */
+ex su3f::eval_indexed(const basic & i) const
+{
+ GINAC_ASSERT(is_of_type(i, indexed));
+ GINAC_ASSERT(i.nops() == 4);
+ GINAC_ASSERT(is_ex_of_type(i.op(0), su3f));
+
+ // Numeric evaluation
+ if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
+
+ // Sort indices, remember permutation sign
+ int v[3];
+ for (unsigned j=0; j<3; j++)
+ v[j] = ex_to_numeric(ex_to_idx(i.op(j + 1)).get_value()).to_int();
+ int sign = 1;
+ if (v[0] > v[1]) { std::swap(v[0], v[1]); sign = -sign; }
+ if (v[0] > v[2]) { std::swap(v[0], v[2]); sign = -sign; }
+ if (v[1] > v[2]) { std::swap(v[1], v[2]); sign = -sign; }
+
+ // Check for non-zero elements
+ if (CMPINDICES(1,2,3))
+ return sign;
+ else if (CMPINDICES(1,4,7) || CMPINDICES(2,4,6)
+ || CMPINDICES(2,5,7) || CMPINDICES(3,4,5))
+ return _ex1_2() * sign;
+ else if (CMPINDICES(1,5,6) || CMPINDICES(3,6,7))
+ return _ex_1_2() * sign;
+ else if (CMPINDICES(4,5,8) || CMPINDICES(6,7,8))
+ return sqrt(_ex3())/2 * sign;
+ else
+ return _ex0();
+ }
+
+ // No further simplifications
+ return i.hold();
+}
+
+
+/** Contraction of an indexed symmetric structure constant with something else. */
+bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+{
+ GINAC_ASSERT(is_ex_of_type(*self, indexed));
+ GINAC_ASSERT(is_ex_of_type(*other, indexed));
+ GINAC_ASSERT(self->nops() == 4);
+ GINAC_ASSERT(is_ex_of_type(self->op(0), su3d));
+
+ if (is_ex_exactly_of_type(other->op(0), su3d) || is_ex_exactly_of_type(other->op(0), su3f)) {
+
+ // Find the dummy indices of the contraction
+ exvector dummy_indices;
+ dummy_indices = ex_to_indexed(*self).get_dummy_indices(ex_to_indexed(*other));
+
+ if (is_ex_exactly_of_type(other->op(0), su3d)) {
+
+ // d.abc*d.abc=40/3
+ if (dummy_indices.size() == 3) {
+ *self = numeric(40, 3);
+ *other = _ex1();
+ return true;
+
+ // d.akl*d.bkl=5/3*delta.ab
+ } else if (dummy_indices.size() == 2) {
+ exvector a = index_set_difference(ex_to_indexed(*self).get_indices(), dummy_indices);
+ exvector b = index_set_difference(ex_to_indexed(*other).get_indices(), dummy_indices);
+ GINAC_ASSERT(a.size() > 0);
+ GINAC_ASSERT(b.size() > 0);
+ *self = numeric(5, 3) * delta_tensor(a[0], b[0]);
+ *other = _ex1();
+ return true;
+ }
+
+ } else {
+
+ // d.akl*f.bkl=0 (includes the case a=b)
+ if (dummy_indices.size() >= 2) {
+ *self = _ex0();
+ *other = _ex0();
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+/** Contraction of an indexed antisymmetric structure constant with something else. */
+bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
+{
+ GINAC_ASSERT(is_ex_of_type(*self, indexed));
+ GINAC_ASSERT(is_ex_of_type(*other, indexed));
+ GINAC_ASSERT(self->nops() == 4);
+ GINAC_ASSERT(is_ex_of_type(self->op(0), su3f));
+
+ if (is_ex_exactly_of_type(other->op(0), su3f)) { // f*d is handled by su3d class
+
+ // Find the dummy indices of the contraction
+ exvector dummy_indices;
+ dummy_indices = ex_to_indexed(*self).get_dummy_indices(ex_to_indexed(*other));
+
+ // f.abc*f.abc=24
+ if (dummy_indices.size() == 3) {
+ *self = 24;
+ *other = _ex1();
+ return true;
+
+ // f.akl*f.bkl=3*delta.ab
+ } else if (dummy_indices.size() == 2) {
+ int sign1, sign2;
+ ex a = permute_free_index_to_front(ex_to_indexed(*self).get_indices(), dummy_indices, sign1);
+ ex b = permute_free_index_to_front(ex_to_indexed(*other).get_indices(), dummy_indices, sign2);
+ *self = sign1 * sign2 * 3 * delta_tensor(a, b);
+ *other = _ex1();
+ return true;
+ }
+ }
+
+ return false;
+}
+
//////////
// global functions
//////////
ex color_T(const ex & a, unsigned rl)
{
+ if (!is_ex_of_type(a, idx))
+ throw(std::invalid_argument("indices of color_T must be of type idx"));
+ if (!ex_to_idx(a).get_dim().is_equal(8))
+ throw(std::invalid_argument("index dimension for color_T must be 8"));
+
return color(su3t(), a, rl);
}
ex color_f(const ex & a, const ex & b, const ex & c)
{
+ if (!is_ex_of_type(a, idx) || !is_ex_of_type(b, idx) || !is_ex_of_type(c, idx))
+ throw(std::invalid_argument("indices of color_f must be of type idx"));
+ if (!ex_to_idx(a).get_dim().is_equal(8) || !ex_to_idx(b).get_dim().is_equal(8) || !ex_to_idx(c).get_dim().is_equal(8))
+ throw(std::invalid_argument("index dimension for color_f must be 8"));
+
return indexed(su3f(), indexed::antisymmetric, a, b, c);
}
ex color_d(const ex & a, const ex & b, const ex & c)
{
+ if (!is_ex_of_type(a, idx) || !is_ex_of_type(b, idx) || !is_ex_of_type(c, idx))
+ throw(std::invalid_argument("indices of color_d must be of type idx"));
+ if (!ex_to_idx(a).get_dim().is_equal(8) || !ex_to_idx(b).get_dim().is_equal(8) || !ex_to_idx(c).get_dim().is_equal(8))
+ throw(std::invalid_argument("index dimension for color_d must be 8"));
+
return indexed(su3d(), indexed::symmetric, a, b, c);
}
* elements from different Lie algebra representations (only objects with
* the same label "interact" with each other). These objects implement an
* abstract representation of the group, not a specific matrix
- * representation. */
+ * representation. The indices used for color objects should not have a
+ * variance. */
class color : public indexed
{
GINAC_DECLARE_REGISTERED_CLASS(color, indexed)
// functions overriding virtual functions from bases classes
public:
void print(std::ostream & os, unsigned upper_precedence=0) const;
-// ex eval_indexed(const basic & i) const;
-// bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
+ ex eval_indexed(const basic & i) const;
+ bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
};
/** This class represents the tensor of symmetric su(3) structure constants. */
// functions overriding virtual functions from bases classes
public:
void print(std::ostream & os, unsigned upper_precedence=0) const;
-// ex eval_indexed(const basic & i) const;
-// bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
+ ex eval_indexed(const basic & i) const;
+ bool contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const;
};
return is_dummy_pair(ex_to_idx(e1), ex_to_idx(e2));
}
+/** Bring a vector of indices into a canonic order. Dummy indices will lie
+ * next to each other after the sorting. */
+static void sort_index_vector(exvector &v)
+{
+ // Nothing to sort if less than 2 elements
+ if (v.size() < 2)
+ return;
+
+ // Simple bubble sort algorithm should be sufficient for the small
+ // number of indices expected
+ exvector::iterator it1 = v.begin(), itend = v.end(), next_to_last_idx = itend - 1;
+ while (it1 != next_to_last_idx) {
+ exvector::iterator it2 = it1 + 1;
+ while (it2 != itend) {
+ if (it1->compare(*it2) > 0)
+ it1->swap(*it2);
+ it2++;
+ }
+ it1++;
+ }
+}
+
+
+void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator itend, exvector & out_free, exvector & out_dummy)
+{
+ out_free.clear();
+ out_dummy.clear();
+
+ // No indices? Then do nothing
+ if (it == itend)
+ return;
+
+ // Only one index? Then it is a free one if it's not numeric
+ if (itend - it == 1) {
+ if (ex_to_idx(*it).is_symbolic())
+ out_free.push_back(*it);
+ return;
+ }
+
+ // Sort index vector. This will cause dummy indices come to lie next
+ // to each other (because the sort order is defined to guarantee this).
+ exvector v(it, itend);
+ sort_index_vector(v);
+
+ // Find dummy pairs and free indices
+ it = v.begin(); itend = v.end();
+ exvector::const_iterator last = it++;
+ while (it != itend) {
+ if (is_dummy_pair(*it, *last)) {
+ out_dummy.push_back(*last);
+ it++;
+ if (it == itend)
+ return;
+ } else {
+ if (!it->is_equal(*last) && ex_to_idx(*last).is_symbolic())
+ out_free.push_back(*last);
+ }
+ last = it++;
+ }
+ if (ex_to_idx(*last).is_symbolic())
+ out_free.push_back(*last);
+}
+
+exvector index_set_difference(const exvector & set1, const exvector & set2)
+{
+ exvector ret;
+
+ exvector::const_iterator ait = set1.begin(), aitend = set1.end();
+ while (ait != aitend) {
+ exvector::const_iterator bit = set2.begin(), bitend = set2.end();
+ bool found = false;
+ while (bit != bitend) {
+ if (ait->is_equal(*bit)) {
+ found = true;
+ break;
+ }
+ bit++;
+ }
+ if (!found)
+ ret.push_back(*ait);
+ ait++;
+ }
+
+ return ret;
+}
+
} // namespace GiNaC
/** Check whether two expressions form a dummy index pair. */
bool is_dummy_pair(const ex & e1, const ex & e2);
+/** Given a vector of indices, split them into two vectors, one containing
+ * the free indices, the other containing the dummy indices (numeric
+ * indices are neither free nor dummy ones).
+ *
+ * @param it Pointer to start of index vector
+ * @param itend Pointer to end of index vector
+ * @param out_free Vector of free indices (returned, sorted)
+ * @param out_dummy Vector of dummy indices (returned, sorted) */
+void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator itend, exvector & out_free, exvector & out_dummy);
+
+/** Given a vector of indices, split them into two vectors, one containing
+ * the free indices, the other containing the dummy indices (numeric
+ * indices are neither free nor dummy ones).
+ *
+ * @param v Index vector
+ * @param out_free Vector of free indices (returned, sorted)
+ * @param out_dummy Vector of dummy indices (returned, sorted) */
+inline void find_free_and_dummy(const exvector & v, exvector & out_free, exvector & out_dummy)
+{
+ find_free_and_dummy(v.begin(), v.end(), out_free, out_dummy);
+}
+
+/** Given a vector of indices, find the dummy indices.
+ *
+ * @param v Index vector
+ * @param out_dummy Vector of dummy indices (returned, sorted) */
+inline void find_dummy_indices(const exvector & v, exvector & out_dummy)
+{
+ exvector free_indices;
+ find_free_and_dummy(v.begin(), v.end(), free_indices, out_dummy);
+}
+
+/** Count the number of dummy index pairs in an index vector. */
+inline unsigned count_dummy_indices(const exvector & v)
+{
+ exvector free_indices, dummy_indices;
+ find_free_and_dummy(v.begin(), v.end(), free_indices, dummy_indices);
+ return dummy_indices.size();
+}
+
+/** Count the number of dummy index pairs in an index vector. */
+inline unsigned count_free_indices(const exvector & v)
+{
+ exvector free_indices, dummy_indices;
+ find_free_and_dummy(v.begin(), v.end(), free_indices, dummy_indices);
+ return free_indices.size();
+}
+
+/** Given two index vectors, find those indices that appear in the first
+ * vector but not in the second one (asymmetric set difference). */
+exvector index_set_difference(const exvector & set1, const exvector & set2);
} // namespace GiNaC
// global functions
//////////
-/** Given a vector of indices, split them into two vectors, one containing
- * the free indices, the other containing the dummy indices. */
-static void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator itend, exvector & out_free, exvector & out_dummy)
-{
- out_free.clear();
- out_dummy.clear();
-
- // No indices? Then do nothing
- if (it == itend)
- return;
-
- // Only one index? Then it is a free one if it's not numeric
- if (itend - it == 1) {
- if (ex_to_idx(*it).is_symbolic())
- out_free.push_back(*it);
- return;
- }
-
- // Sort index vector. This will cause dummy indices come to lie next
- // to each other (because the sort order is defined to guarantee this).
- exvector v(it, itend);
- sort_index_vector(v);
-
- // Find dummy pairs and free indices
- it = v.begin(); itend = v.end();
- exvector::const_iterator last = it++;
- while (it != itend) {
- if (is_dummy_pair(*it, *last)) {
- out_dummy.push_back(*last);
- it++;
- if (it == itend)
- return;
- } else {
- if (!it->is_equal(*last) && ex_to_idx(*last).is_symbolic())
- out_free.push_back(*last);
- }
- last = it++;
- }
- if (ex_to_idx(*last).is_symbolic())
- out_free.push_back(*last);
-}
-
/** Check whether two sorted index vectors are consistent (i.e. equal). */
static bool indices_consistent(const exvector & v1, const exvector & v2)
{
return true;
}
+exvector indexed::get_indices(void) const
+{
+ GINAC_ASSERT(seq.size() >= 1);
+ return exvector(seq.begin() + 1, seq.end());
+}
+
exvector indexed::get_dummy_indices(void) const
{
exvector free_indices, dummy_indices;
return dummy_indices;
}
+exvector indexed::get_dummy_indices(const indexed & other) const
+{
+ exvector indices = get_free_indices();
+ exvector other_indices = other.get_free_indices();
+ indices.insert(indices.end(), other_indices.begin(), other_indices.end());
+ exvector dummy_indices;
+ find_dummy_indices(indices, dummy_indices);
+ return dummy_indices;
+}
+
exvector indexed::get_free_indices(void) const
{
exvector free_indices, dummy_indices;
// And remove the dummy indices
exvector free_indices, dummy_indices;
- find_free_and_dummy(un.begin(), un.end(), free_indices, dummy_indices);
+ find_free_and_dummy(un, free_indices, dummy_indices);
return free_indices;
}
// And remove the dummy indices
exvector free_indices, dummy_indices;
- find_free_and_dummy(un.begin(), un.end(), free_indices, dummy_indices);
+ find_free_and_dummy(un, free_indices, dummy_indices);
return free_indices;
}
} else if (is_ex_exactly_of_type(f, ncmul)) {
// Noncommutative factor found, split it as well
non_commutative = true; // everything becomes noncommutative, ncmul will sort out the commutative factors later
- for (int j=0; j<f.nops(); i++)
+ for (int j=0; j<f.nops(); j++)
v.push_back(f.op(j));
} else
v.push_back(f);
exvector un(ex_to_indexed(*it1).seq.begin() + 1, ex_to_indexed(*it1).seq.end());
un.insert(un.end(), ex_to_indexed(*it2).seq.begin() + 1, ex_to_indexed(*it2).seq.end());
exvector free, dummy;
- find_free_and_dummy(un.begin(), un.end(), free, dummy);
+ find_free_and_dummy(un, free, dummy);
if (dummy.size() == 0)
continue;
}
it1++;
}
- find_free_and_dummy(un.begin(), un.end(), free_indices, dummy_indices);
+ find_free_and_dummy(un, free_indices, dummy_indices);
ex r;
if (something_changed) {
* @see class info_flags */
bool all_index_values_are(unsigned inf) const;
+ /** Return a vector containing the object's indices. */
+ exvector get_indices(void) const;
+
/** Return a vector containing the dummy indices of the object, if any. */
exvector get_dummy_indices(void) const;
+ /** Return a vector containing the dummy indices in the contraction with
+ * another indexed object. */
+ exvector get_dummy_indices(const indexed & other) const;
+
protected:
void printrawindices(std::ostream & os) const;
void printtreeindices(std::ostream & os, unsigned indent) const;
if (is_dummy_pair(i1, i2))
return i1.get_dim();
+ // Numeric evaluation
+ if (static_cast<const indexed &>(i).all_index_values_are(info_flags::integer)) {
+ int n1 = ex_to_numeric(i1.get_value()).to_int(), n2 = ex_to_numeric(i2.get_value()).to_int();
+ if (n1 == n2)
+ return _ex1();
+ else
+ return _ex0();
+ }
+
// No further simplifications
return i.hold();
}
const unsigned TINFO_su3f = 0x000e100aU;
const unsigned TINFO_su3d = 0x000e100bU;
const unsigned TINFO_diracgamma = 0x000e100cU;
+const unsigned TINFO_diracone = 0x000e100dU;
} // namespace GiNaC