* Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
/*
- * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
ex clifford::get_metric(const ex & i, const ex & j) const
{
- return indexed(metric, symmetric2(), i, j);
+ return indexed(metric, i, j);
}
bool clifford::same_metric(const ex & other) const
c.s << "{";
seq[0].print(c, level);
c.s << "\\hspace{-1.0ex}/}";
- } else
+ } else {
+ c.s << "\\clifford[" << int(representation_label) << "]";
this->print_dispatch<inherited>(c, level);
+ }
}
DEFAULT_COMPARE(diracone)
DEFAULT_COMPARE(diracgammaL)
DEFAULT_COMPARE(diracgammaR)
-DEFAULT_PRINT_LATEX(diracone, "ONE", "\\mathbb{1}")
+DEFAULT_PRINT_LATEX(diracone, "ONE", "\\mathbf{1}")
DEFAULT_PRINT_LATEX(cliffordunit, "e", "e")
DEFAULT_PRINT_LATEX(diracgamma, "gamma", "\\gamma")
DEFAULT_PRINT_LATEX(diracgamma5, "gamma5", "{\\gamma^5}")
}
}
+/** Predicate for finding non-clifford objects. */
+struct is_not_a_clifford : public std::unary_function<ex, bool> {
+ bool operator()(const ex & e)
+ {
+ return !is_a<clifford>(e);
+ }
+};
+
/** Contraction of a gamma matrix with something else. */
bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
{
if (ex_to<clifford>(*other).get_representation_label() != rl)
return false;
+ size_t num = other - self;
+
// gamma~mu gamma.mu = dim ONE
- if (other - self == 1) {
+ if (num == 1) {
*self = dim;
*other = dirac_ONE(rl);
return true;
// gamma~mu gamma~alpha gamma.mu = (2-dim) gamma~alpha
- } else if (other - self == 2
+ } else if (num == 2
&& is_a<clifford>(self[1])) {
*self = 2 - dim;
*other = _ex1;
return true;
// gamma~mu gamma~alpha gamma~beta gamma.mu = 4 g~alpha~beta + (dim-4) gamam~alpha gamma~beta
- } else if (other - self == 3
+ } else if (num == 3
&& is_a<clifford>(self[1])
&& is_a<clifford>(self[2])) {
ex b1, i1, b2, i2;
return true;
// gamma~mu gamma~alpha gamma~beta gamma~delta gamma.mu = -2 gamma~delta gamma~beta gamma~alpha - (dim-4) gamam~alpha gamma~beta gamma~delta
- } else if (other - self == 4
+ } else if (num == 4
&& is_a<clifford>(self[1])
&& is_a<clifford>(self[2])
&& is_a<clifford>(self[3])) {
*other = _ex1;
return true;
+ // gamma~mu Sodd gamma.mu = -2 Sodd_R
+ // (Chisholm identity in 4 dimensions)
+ } else if (!((other - self) & 1) && dim.is_equal(4)) {
+ if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
+ return false;
+
+ *self = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(other), std::reverse_iterator<exvector::const_iterator>(self + 1)), true);
+ std::fill(self + 1, other, _ex1);
+ *other = _ex_2;
+ return true;
+
+ // gamma~mu Sodd gamma~alpha gamma.mu = 2 gamma~alpha Sodd + 2 Sodd_R gamma~alpha
+ // (commutate contracted indices towards each other, then use
+ // Chisholm identity in 4 dimensions)
+ } else if (((other - self) & 1) && dim.is_equal(4)) {
+ if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
+ return false;
+
+ exvector::iterator next_to_last = other - 1;
+ ex S = ncmul(exvector(self + 1, next_to_last), true);
+ ex SR = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(next_to_last), std::reverse_iterator<exvector::const_iterator>(self + 1)), true);
+
+ *self = (*next_to_last) * S + SR * (*next_to_last);
+ std::fill(self + 1, other, _ex1);
+ *other = _ex2;
+ return true;
+
// gamma~mu S gamma~alpha gamma.mu = 2 gamma~alpha S - gamma~mu S gamma.mu gamma~alpha
// (commutate contracted indices towards each other, simplify_indexed()
// will re-expand and re-run the simplification)
} else {
- exvector::iterator it = self + 1, next_to_last = other - 1;
- while (it != other) {
- if (!is_a<clifford>(*it))
- return false;
- ++it;
- }
+ if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
+ return false;
- it = self + 1;
- ex S = _ex1;
- while (it != next_to_last) {
- S *= *it;
- *it++ = _ex1;
- }
+ exvector::iterator next_to_last = other - 1;
+ ex S = ncmul(exvector(self + 1, next_to_last), true);
*self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
- *next_to_last = _ex1;
- *other = _ex1;
+ std::fill(self + 1, other + 1, _ex1);
return true;
}
// Find if a previous contraction produces the square of self
int prev_square = find_same_metric(v, self[0]);
- varidx d((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(ex_to<idx>(self->op(1)).get_dim()));
+ varidx d((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(self->op(1)).get_dim());
ex squared_metric = unit.get_metric(self->op(1), d) * unit.get_metric(d.toggle_variance(), other->op(1));
// e~mu e.mu = Tr ONE
if (!is_a<varidx>(mu))
throw(std::invalid_argument("index of Clifford unit must be of type varidx"));
- return clifford(unit, mu, metr, rl);
+ if (is_a<indexed>(metr))
+ return clifford(unit, mu, metr.op(0), rl);
+ else if(is_a<tensmetric>(metr) || is_a<matrix>(metr))
+ return clifford(unit, mu, metr, rl);
+ else
+ throw(std::invalid_argument("metric for Clifford unit must be of type indexed, tensormetric or matrix"));
}
ex dirac_gamma(const ex & mu, unsigned char rl)
return (ti & ~0xff) == TINFO_clifford;
}
+/** Extract representation label from tinfo key (as returned by
+ * return_type_tinfo()). */
+static unsigned char get_representation_label(unsigned ti)
+{
+ return ti & 0xff;
+}
+
/** Take trace of a string of an even number of Dirac gammas given a vector
* of indices. */
static ex trace_string(exvector::const_iterator ix, size_t num)
return result;
}
-ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
+ex dirac_trace(const ex & e, const std::set<unsigned char> & rls, const ex & trONE)
{
if (is_a<clifford>(e)) {
- if (!ex_to<clifford>(e).get_representation_label() == rl)
- return _ex0;
+ unsigned char rl = ex_to<clifford>(e).get_representation_label();
+
+ // Are we taking the trace over this object's representation label?
+ if (rls.find(rl) == rls.end())
+ return e;
+
+ // Yes, all elements are traceless, except for dirac_ONE and dirac_L/R
const ex & g = e.op(0);
if (is_a<diracone>(g))
return trONE;
ex prod = _ex1;
for (size_t i=0; i<e.nops(); i++) {
const ex &o = e.op(i);
- if (is_clifford_tinfo(o.return_type_tinfo(), rl))
- prod *= dirac_trace(o, rl, trONE);
+ if (is_clifford_tinfo(o.return_type_tinfo()))
+ prod *= dirac_trace(o, rls, trONE);
else
prod *= o;
}
} else if (is_exactly_a<ncmul>(e)) {
- if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
- return _ex0;
+ unsigned char rl = get_representation_label(e.return_type_tinfo());
+
+ // Are we taking the trace over this string's representation label?
+ if (rls.find(rl) == rls.end())
+ return e;
// Substitute gammaL/R and expand product, if necessary
ex e_expanded = e.subs(lst(
dirac_gammaR(rl) == (dirac_ONE(rl)+dirac_gamma5(rl))/2
), subs_options::no_pattern).expand();
if (!is_a<ncmul>(e_expanded))
- return dirac_trace(e_expanded, rl, trONE);
+ return dirac_trace(e_expanded, rls, trONE);
// gamma5 gets moved to the front so this check is enough
bool has_gamma5 = is_a<diracgamma5>(e.op(0).op(0));
} else if (e.nops() > 0) {
// Trace maps to all other container classes (this includes sums)
- pointer_to_map_function_2args<unsigned char, const ex &> fcn(dirac_trace, rl, trONE);
+ pointer_to_map_function_2args<const std::set<unsigned char> &, const ex &> fcn(dirac_trace, rls, trONE);
return e.map(fcn);
} else
return _ex0;
}
-ex canonicalize_clifford(const ex & e)
+ex dirac_trace(const ex & e, const lst & rll, const ex & trONE)
{
- // Scan for any ncmul objects
- exmap srl;
- ex aux = e.to_rational(srl);
- for (exmap::iterator i = srl.begin(); i != srl.end(); ++i) {
-
- ex lhs = i->first;
- ex rhs = i->second;
+ // Convert list to set
+ std::set<unsigned char> rls;
+ for (lst::const_iterator i = rll.begin(); i != rll.end(); ++i) {
+ if (i->info(info_flags::nonnegint))
+ rls.insert(ex_to<numeric>(*i).to_int());
+ }
- if (is_exactly_a<ncmul>(rhs)
- && rhs.return_type() == return_types::noncommutative
- && is_clifford_tinfo(rhs.return_type_tinfo())) {
+ return dirac_trace(e, rls, trONE);
+}
- // Expand product, if necessary
- ex rhs_expanded = rhs.expand();
- if (!is_a<ncmul>(rhs_expanded)) {
- i->second = canonicalize_clifford(rhs_expanded);
- continue;
+ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE)
+{
+ // Convert label to set
+ std::set<unsigned char> rls;
+ rls.insert(rl);
- } else if (!is_a<clifford>(rhs.op(0)))
- continue;
+ return dirac_trace(e, rls, trONE);
+}
- exvector v;
- v.reserve(rhs.nops());
- for (size_t j=0; j<rhs.nops(); j++)
- v.push_back(rhs.op(j));
- // Stupid recursive bubble sort because we only want to swap adjacent gammas
- exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
- if (is_a<diracgamma5>(it->op(0)) || is_a<diracgammaL>(it->op(0)) || is_a<diracgammaR>(it->op(0)))
- ++it;
- while (it != next_to_last) {
- if (it[0].compare(it[1]) > 0) {
- ex save0 = it[0], save1 = it[1];
- ex b1, i1, b2, i2;
- base_and_index(it[0], b1, i1);
- base_and_index(it[1], b2, i2);
- it[0] = (ex_to<clifford>(save0).get_metric(i1, i2) * b1 * b2).simplify_indexed();
- it[1] = v.size() == 2 ? _ex2 * dirac_ONE(ex_to<clifford>(it[1]).get_representation_label()) : _ex2;
- ex sum = ncmul(v);
- it[0] = save1;
- it[1] = save0;
- sum -= ncmul(v, true);
- i->second = canonicalize_clifford(sum);
- goto next_sym;
+ex canonicalize_clifford(const ex & e_)
+{
+ pointer_to_map_function fcn(canonicalize_clifford);
+
+ if (is_a<matrix>(e_) // || is_a<pseries>(e) || is_a<integral>(e)
+ || is_a<lst>(e_)) {
+ return e_.map(fcn);
+ } else {
+ ex e=simplify_indexed(e_);
+ // Scan for any ncmul objects
+ exmap srl;
+ ex aux = e.to_rational(srl);
+ for (exmap::iterator i = srl.begin(); i != srl.end(); ++i) {
+
+ ex lhs = i->first;
+ ex rhs = i->second;
+
+ if (is_exactly_a<ncmul>(rhs)
+ && rhs.return_type() == return_types::noncommutative
+ && is_clifford_tinfo(rhs.return_type_tinfo())) {
+
+ // Expand product, if necessary
+ ex rhs_expanded = rhs.expand();
+ if (!is_a<ncmul>(rhs_expanded)) {
+ i->second = canonicalize_clifford(rhs_expanded);
+ continue;
+
+ } else if (!is_a<clifford>(rhs.op(0)))
+ continue;
+
+ exvector v;
+ v.reserve(rhs.nops());
+ for (size_t j=0; j<rhs.nops(); j++)
+ v.push_back(rhs.op(j));
+
+ // Stupid recursive bubble sort because we only want to swap adjacent gammas
+ exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
+ if (is_a<diracgamma5>(it->op(0)) || is_a<diracgammaL>(it->op(0)) || is_a<diracgammaR>(it->op(0)))
+ ++it;
+ while (it != next_to_last) {
+ if (it[0].compare(it[1]) > 0) {
+ ex save0 = it[0], save1 = it[1];
+ ex b1, i1, b2, i2;
+ base_and_index(it[0], b1, i1);
+ base_and_index(it[1], b2, i2);
+ it[0] = (ex_to<clifford>(save0).get_metric(i1, i2) * b1 * b2).simplify_indexed();
+ it[1] = v.size() == 2 ? _ex2 * dirac_ONE(ex_to<clifford>(it[1]).get_representation_label()) : _ex2;
+ ex sum = ncmul(v);
+ it[0] = save1;
+ it[1] = save0;
+ sum -= ncmul(v, true);
+ i->second = canonicalize_clifford(sum);
+ goto next_sym;
+ }
+ ++it;
}
- ++it;
- }
next_sym: ;
+ }
}
+ return aux.subs(srl, subs_options::no_pattern).simplify_indexed();
}
- return aux.subs(srl, subs_options::no_pattern).simplify_indexed();
}
-ex clifford_prime(const ex &e)
+ex clifford_prime(const ex & e)
{
pointer_to_map_function fcn(clifford_prime);
if (is_a<clifford>(e) && is_a<cliffordunit>(e.op(0))) {
return -e;
- } else if (is_a<add>(e)) {
- return e.map(fcn);
- } else if (is_a<ncmul>(e)) {
+ } else if (is_a<add>(e) || is_a<ncmul>(e) || is_a<mul>(e) //|| is_a<pseries>(e) || is_a<integral>(e)
+ || is_a<matrix>(e) || is_a<lst>(e)) {
return e.map(fcn);
} else if (is_a<power>(e)) {
return pow(clifford_prime(e.op(0)), e.op(1));
return e;
}
-ex delete_ONE(const ex &e)
+ex remove_dirac_ONE(const ex & e, unsigned char rl)
{
- pointer_to_map_function fcn(delete_ONE);
- if (is_a<clifford>(e) && is_a<diracone>(e.op(0))) {
- return 1;
- } else if (is_a<add>(e)) {
- return e.map(fcn);
- } else if (is_a<ncmul>(e)) {
- return e.map(fcn);
- } else if (is_a<mul>(e)) {
+ pointer_to_map_function_1arg<unsigned char> fcn(remove_dirac_ONE, rl);
+ if (is_a<clifford>(e) && ex_to<clifford>(e).get_representation_label() >= rl) {
+ if (is_a<diracone>(e.op(0)))
+ return 1;
+ else
+ throw(std::invalid_argument("Expression is a non-scalar Clifford number!"));
+ } else if (is_a<add>(e) || is_a<ncmul>(e) || is_a<mul>(e) // || is_a<pseries>(e) || is_a<integral>(e)
+ || is_a<matrix>(e) || is_a<lst>(e)) {
return e.map(fcn);
} else if (is_a<power>(e)) {
- return pow(delete_ONE(e.op(0)), e.op(1));
+ return pow(remove_dirac_ONE(e.op(0)), e.op(1));
} else
return e;
}
-ex clifford_norm(const ex &e)
+ex clifford_norm(const ex & e)
{
- return sqrt(delete_ONE((e * clifford_bar(e)).simplify_indexed()));
+ return sqrt(remove_dirac_ONE(canonicalize_clifford(e * clifford_bar(e)).simplify_indexed()));
}
-ex clifford_inverse(const ex &e)
+ex clifford_inverse(const ex & e)
{
ex norm = clifford_norm(e);
if (!norm.is_zero())
return clifford_bar(e) / pow(norm, 2);
+ else
+ throw(std::invalid_argument("Cannot find inverse of Clifford number with zero norm!"));
}
ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl)
{
- unsigned min, max;
if (!ex_to<idx>(mu).is_dim_numeric())
throw(std::invalid_argument("Index should have a numeric dimension"));
- unsigned dim = (ex_to<numeric>(ex_to<idx>(mu).get_dim())).to_int();
- ex c = clifford_unit(mu, metr, rl);
+ ex e = clifford_unit(mu, metr, rl);
+ return lst_to_clifford(v, e);
+}
- if (is_a<matrix>(v)) {
- if (ex_to<matrix>(v).cols() > ex_to<matrix>(v).rows()) {
- min = ex_to<matrix>(v).rows();
- max = ex_to<matrix>(v).cols();
- } else {
- min = ex_to<matrix>(v).cols();
- max = ex_to<matrix>(v).rows();
- }
- if (min == 1) {
- if (dim == max)
- if (is_a<varidx>(mu)) // need to swap variance
- return indexed(v, ex_to<varidx>(mu).toggle_variance()) * c;
+ex lst_to_clifford(const ex & v, const ex & e) {
+ unsigned min, max;
+
+ if (is_a<clifford>(e)) {
+ varidx mu = ex_to<varidx>(e.op(1));
+ unsigned dim = (ex_to<numeric>(mu.get_dim())).to_int();
+
+ if (is_a<matrix>(v)) {
+ if (ex_to<matrix>(v).cols() > ex_to<matrix>(v).rows()) {
+ min = ex_to<matrix>(v).rows();
+ max = ex_to<matrix>(v).cols();
+ } else {
+ min = ex_to<matrix>(v).cols();
+ max = ex_to<matrix>(v).rows();
+ }
+ if (min == 1) {
+ if (dim == max)
+ return indexed(v, ex_to<varidx>(mu).toggle_variance()) * e;
else
- return indexed(v, mu) * c;
+ throw(std::invalid_argument("Dimensions of vector and clifford unit mismatch"));
+ } else
+ throw(std::invalid_argument("First argument should be a vector vector"));
+ } else if (is_a<lst>(v)) {
+ if (dim == ex_to<lst>(v).nops())
+ return indexed(matrix(dim, 1, ex_to<lst>(v)), ex_to<varidx>(mu).toggle_variance()) * e;
else
- throw(std::invalid_argument("Dimensions of vector and clifford unit mismatch"));
+ throw(std::invalid_argument("List length and dimension of clifford unit mismatch"));
} else
- throw(std::invalid_argument("First argument should be a vector vector"));
- } else if (is_a<lst>(v)) {
- if (dim == ex_to<lst>(v).nops())
- return indexed(matrix(dim, 1, ex_to<lst>(v)), ex_to<varidx>(mu).toggle_variance()) * c;
- else
- throw(std::invalid_argument("List length and dimension of clifford unit mismatch"));
+ throw(std::invalid_argument("Cannot construct from anything but list or vector"));
} else
- throw(std::invalid_argument("Cannot construct from anything but list or vector"));
+ throw(std::invalid_argument("The second argument should be a Clifford unit"));
}
-
+
+/** Auxiliary structure to define a function for striping one Clifford unit
+ * from vectors. Used in clifford_to_lst(). */
+static ex get_clifford_comp(const ex & e, const ex & c)
+{
+ pointer_to_map_function_1arg<const ex &> fcn(get_clifford_comp, c);
+ int ival = ex_to<numeric>(ex_to<varidx>(c.op(1)).get_value()).to_int();
+
+ if (is_a<add>(e) || is_a<lst>(e) // || is_a<pseries>(e) || is_a<integral>(e)
+ || is_a<matrix>(e))
+ return e.map(fcn);
+ else if (is_a<ncmul>(e) || is_a<mul>(e)) {
+ // find a Clifford unit with the same metric, delete it and substitute its index
+ size_t ind = e.nops() + 1;
+ for (size_t j = 0; j < e.nops(); j++)
+ if (is_a<clifford>(e.op(j)) && ex_to<clifford>(c).same_metric(e.op(j)))
+ if (ind > e.nops())
+ ind = j;
+ else
+ throw(std::invalid_argument("Expression is a Clifford multi-vector"));
+ if (ind < e.nops()) {
+ ex S = 1;
+ bool same_value_index, found_dummy;
+ same_value_index = ( ex_to<varidx>(e.op(ind).op(1)).is_numeric()
+ && (ival == ex_to<numeric>(ex_to<varidx>(e.op(ind).op(1)).get_value()).to_int()) );
+ found_dummy = same_value_index;
+ for(size_t j=0; j < e.nops(); j++)
+ if (j != ind)
+ if (same_value_index)
+ S = S * e.op(j);
+ else {
+ exvector ind_vec = ex_to<indexed>(e.op(j)).get_dummy_indices(ex_to<indexed>(e.op(ind)));
+ if (ind_vec.size() > 0) {
+ found_dummy = true;
+ exvector::const_iterator it = ind_vec.begin(), itend = ind_vec.end();
+ while (it != itend) {
+ S = S * e.op(j).subs(lst(ex_to<varidx>(*it) == ival, ex_to<varidx>(*it).toggle_variance() == ival), subs_options::no_pattern);
+ ++it;
+ }
+ } else
+ S = S * e.op(j);
+ }
+ return (found_dummy ? S : 0);
+ } else
+ throw(std::invalid_argument("Expression is not a Clifford vector to the given units"));
+ } else if (e.is_zero())
+ return e;
+ else if (is_a<clifford>(e) && ex_to<clifford>(e).same_metric(c))
+ if ( ex_to<varidx>(e.op(1)).is_numeric() &&
+ (ival != ex_to<numeric>(ex_to<varidx>(e.op(1)).get_value()).to_int()) )
+ return 0;
+ else
+ return 1;
+ else
+ throw(std::invalid_argument("Expression is not usable as a Clifford vector"));
+}
+
+
+lst clifford_to_lst(const ex & e, const ex & c, bool algebraic)
+{
+ GINAC_ASSERT(is_a<clifford>(c));
+ varidx mu = ex_to<varidx>(c.op(1));
+ if (! mu.is_dim_numeric())
+ throw(std::invalid_argument("Index should have a numeric dimension"));
+ unsigned int D = ex_to<numeric>(mu.get_dim()).to_int();
+
+ if (algebraic) // check if algebraic method is applicable
+ for (unsigned int i = 0; i < D; i++)
+ if (pow(c.subs(mu == i), 2).is_zero()
+ or (not is_a<numeric>(pow(c.subs(mu == i), 2))))
+ algebraic = false;
+ lst V;
+ if (algebraic)
+ for (unsigned int i = 0; i < D; i++)
+ V.append(remove_dirac_ONE(
+ simplify_indexed(canonicalize_clifford(e * c.subs(mu == i) + c.subs(mu == i) * e))
+ / (2*pow(c.subs(mu == i), 2))));
+ else {
+ ex e1 = canonicalize_clifford(e);
+ for (unsigned int i = 0; i < D; i++)
+ V.append(get_clifford_comp(e1, c.subs(c.op(1) == i)));
+ }
+ return V;
+}
+
+
+ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl)
+{
+ ex x, D, cu;
+
+ if (! is_a<matrix>(v) && ! is_a<lst>(v))
+ throw(std::invalid_argument("parameter v should be either vector or list"));
+
+ if (is_a<clifford>(G)) {
+ cu = G;
+ } else {
+ if (is_a<indexed>(G))
+ D = ex_to<varidx>(G.op(1)).get_dim();
+ else if (is_a<matrix>(G))
+ D = ex_to<matrix>(G).rows();
+ else throw(std::invalid_argument("metric should be an indexed object, matrix, or a Clifford unit"));
+
+ varidx mu((new symbol)->setflag(status_flags::dynallocated), D);
+ cu = clifford_unit(mu, G, rl);
+ }
+
+ x = lst_to_clifford(v, cu);
+ ex e = simplify_indexed(canonicalize_clifford((a * x + b) * clifford_inverse(c * x + d)));
+ return clifford_to_lst(e, cu, false);
+}
+
+ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl)
+{
+ if (is_a<matrix>(M))
+ return clifford_moebius_map(ex_to<matrix>(M)(0,0), ex_to<matrix>(M)(0,1),
+ ex_to<matrix>(M)(1,0), ex_to<matrix>(M)(1,1), v, G, rl);
+ else
+ throw(std::invalid_argument("parameter M should be a matrix"));
+}
+
} // namespace GiNaC