X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=c76fff234cf57bbbc24b9797c2bc96e1637a0f75;hp=b7501f78e72a1be1c5109a31a108454b9dc8080b;hb=4a9f6c276daf54acbb2f5951f0435bfb6f014809;hpb=26c31eb89fe38c4d232f90b62c8acbeaaa0454f4 diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index b7501f78..c76fff23 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -716,6 +716,17 @@ ex dirac_ONE(unsigned char rl) return clifford(ONE, rl); } +static unsigned get_dim_uint(const ex& e) +{ + if (!is_a(e)) + throw std::invalid_argument("get_dim_uint: argument is not an index"); + ex dim = ex_to(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(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); @@ -737,10 +748,10 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) // 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(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; } } @@ -1175,7 +1186,7 @@ ex lst_to_clifford(const ex & v, const ex & e) { ex mu = e.op(1); ex mu_toggle = is_a(mu) ? ex_to(mu).toggle_variance() : mu; - unsigned dim = (ex_to(ex_to(mu).get_dim())).to_int(); + unsigned dim = get_dim_uint(mu); if (is_a(v)) { if (ex_to(v).cols() > ex_to(v).rows()) {