print_func<print_dflt>(&clifford::do_print_dflt).
print_func<print_latex>(&clifford::do_print_latex))
-const tinfo_static_t clifford::return_type_tinfo_static[256] = {{}};
-
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracone, tensor,
print_func<print_dflt>(&diracone::do_print).
print_func<print_latex>(&diracone::do_print_latex))
tinfo_key = &clifford::tinfo_static;
}
+return_type_t clifford::return_type_tinfo() const
+{
+ return make_return_type_t<clifford>(representation_label);
+}
+
//////////
// archiving
//////////
return clifford(ONE, rl);
}
+static unsigned get_dim_uint(const ex& e)
+{
+ if (!is_a<idx>(e))
+ throw std::invalid_argument("get_dim_uint: argument is not an index");
+ ex dim = ex_to<idx>(e).get_dim();
+ if (!dim.info(info_flags::posint))
+ throw std::invalid_argument("get_dim_uint: dimension of index should be a positive integer");
+ unsigned d = ex_to<numeric>(dim).to_int();
+ return d;
+}
+
ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl)
{
- static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated);
+ //static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated);
+ ex unit = (new cliffordunit)->setflag(status_flags::dynallocated);
if (!is_a<idx>(mu))
throw(std::invalid_argument("clifford_unit(): index of Clifford unit must be of type idx or varidx"));
unsigned n = M.rows();
bool symmetric = true;
- static idx xi((new symbol)->setflag(status_flags::dynallocated), n),
+ //static idx xi((new symbol)->setflag(status_flags::dynallocated), n),
+ // chi((new symbol)->setflag(status_flags::dynallocated), n);
+ idx xi((new symbol)->setflag(status_flags::dynallocated), n),
chi((new symbol)->setflag(status_flags::dynallocated), n);
- if ((n == M.cols()) && (n == ex_to<idx>(mu).get_dim())) {
+ if ((n == M.cols()) && (n == get_dim_uint(mu))) {
for (unsigned i = 0; i < n; i++) {
for (unsigned j = i+1; j < n; j++) {
- if (M(i, j) != M(j, i)) {
+ if (!M(i, j).is_equal(M(j, i))) {
symmetric = false;
}
}
throw(std::invalid_argument("clifford_unit(): metric for Clifford unit must be a square matrix with the same dimensions as index"));
}
} else if (indices.size() == 0) { // a tensor or other expression without indices
- static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim()),
+ //static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim()),
+ // chi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim());
+ varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim()),
chi((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(mu).get_dim());
return clifford(unit, mu, indexed(metr, xi, chi), rl);
} else
return clifford(e, varidx(0, dim), indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl);
}
-/** Check whether a given tinfo key (as returned by return_type_tinfo()
- * is that of a clifford object (with an arbitrary representation label). */
-bool is_clifford_tinfo(tinfo_t ti)
-{
- p_int start_loc=(p_int)&clifford::return_type_tinfo_static;
- return (p_int)ti>=start_loc && (p_int)ti<start_loc+256;
-}
-
/** Extract representation label from tinfo key (as returned by
* return_type_tinfo()). */
-static unsigned char get_representation_label(tinfo_t ti)
+static unsigned char get_representation_label(const return_type_t& ti)
{
- return (unsigned char)((p_int)ti-(p_int)&clifford::return_type_tinfo_static);
+ return (unsigned char)ti.rl;
}
/** Take trace of a string of an even number of Dirac gammas given a vector
ex mu = e.op(1);
ex mu_toggle
= is_a<varidx>(mu) ? ex_to<varidx>(mu).toggle_variance() : mu;
- unsigned dim = (ex_to<numeric>(ex_to<idx>(mu).get_dim())).to_int();
+ unsigned dim = get_dim_uint(mu);
if (is_a<matrix>(v)) {
if (ex_to<matrix>(v).cols() > ex_to<matrix>(v).rows()) {