X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Findexed.cpp;h=765a07c8bf4c7a1f8be7a17411a55dbcb64311b9;hp=5759b24d4c93e6f21e64a07e9ed392145e62db70;hb=35287d4fef8dc61a10966091ff662eeb9444f87a;hpb=d448856f20cb58f939ddbf636e7f72e3599b1468 diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 5759b24d..765a07c8 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's indexed expressions. */ /* - * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2002 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 @@ -20,8 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include -#include #include "indexed.h" #include "idx.h" @@ -34,19 +34,17 @@ #include "print.h" #include "archive.h" #include "utils.h" -#include "debugmsg.h" namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS(indexed, exprseq) ////////// -// default constructor, destructor, copy constructor assignment operator and helpers +// default ctor, dtor, copy ctor, assignment operator and helpers ////////// indexed::indexed() : symtree(sy_none()) { - debugmsg("indexed default constructor", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; } @@ -64,63 +62,54 @@ DEFAULT_DESTROY(indexed) indexed::indexed(const ex & b) : inherited(b), symtree(sy_none()) { - debugmsg("indexed constructor from ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const ex & i1) : inherited(b, i1), symtree(sy_none()) { - debugmsg("indexed constructor from ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(sy_none()) { - debugmsg("indexed constructor from ex,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(sy_none()) { - debugmsg("indexed constructor from ex,ex,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(sy_none()) { - debugmsg("indexed constructor from ex,ex,ex,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(symm) { - debugmsg("indexed constructor from ex,symmetry,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(symm) { - debugmsg("indexed constructor from ex,symmetry,ex,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(symm) { - debugmsg("indexed constructor from ex,symmetry,ex,ex,ex,ex", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; validate(); } indexed::indexed(const ex & b, const exvector & v) : inherited(b), symtree(sy_none()) { - debugmsg("indexed constructor from ex,exvector", LOGLEVEL_CONSTRUCT); seq.insert(seq.end(), v.begin(), v.end()); tinfo_key = TINFO_indexed; validate(); @@ -128,7 +117,6 @@ indexed::indexed(const ex & b, const exvector & v) : inherited(b), symtree(sy_no indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inherited(b), symtree(symm) { - debugmsg("indexed constructor from ex,symmetry,exvector", LOGLEVEL_CONSTRUCT); seq.insert(seq.end(), v.begin(), v.end()); tinfo_key = TINFO_indexed; validate(); @@ -136,19 +124,16 @@ indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inhe indexed::indexed(const symmetry & symm, const exprseq & es) : inherited(es), symtree(symm) { - debugmsg("indexed constructor from symmetry,exprseq", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; } indexed::indexed(const symmetry & symm, const exvector & v, bool discardable) : inherited(v, discardable), symtree(symm) { - debugmsg("indexed constructor from symmetry,exvector", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; } indexed::indexed(const symmetry & symm, exvector * vp) : inherited(vp), symtree(symm) { - debugmsg("indexed constructor from symmetry,exvector *", LOGLEVEL_CONSTRUCT); tinfo_key = TINFO_indexed; } @@ -158,7 +143,6 @@ indexed::indexed(const symmetry & symm, exvector * vp) : inherited(vp), symtree( indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("indexed constructor from archive_node", LOGLEVEL_CONSTRUCT); if (!n.find_ex("symmetry", symtree, sym_lst)) { // GiNaC versions <= 0.9.0 had an unsigned "symmetry" property unsigned symm = 0; @@ -192,7 +176,6 @@ DEFAULT_UNARCHIVE(indexed) void indexed::print(const print_context & c, unsigned level) const { - debugmsg("indexed print", LOGLEVEL_PRINT); GINAC_ASSERT(seq.size() > 0); if (is_of_type(c, print_tree)) { @@ -264,7 +247,7 @@ ex indexed::eval(int level) const // If the base object is 0, the whole object is 0 if (base.is_zero()) - return _ex0(); + return _ex0; // If the base object is a product, pull out the numeric factor if (is_ex_exactly_of_type(base, mul) && is_ex_exactly_of_type(base.op(base.nops() - 1), numeric)) { @@ -282,7 +265,7 @@ ex indexed::eval(int level) const if (sig != INT_MAX) { // Something has changed while sorting indices, more evaluations later if (sig == 0) - return _ex0(); + return _ex0; return ex(sig) * thisexprseq(v); } } @@ -291,24 +274,6 @@ ex indexed::eval(int level) const return ex_to(base).eval_indexed(*this); } -int indexed::degree(const ex & s) const -{ - return is_equal(ex_to(s)) ? 1 : 0; -} - -int indexed::ldegree(const ex & s) const -{ - return is_equal(ex_to(s)) ? 1 : 0; -} - -ex indexed::coeff(const ex & s, int n) const -{ - if (is_equal(ex_to(s))) - return n==1 ? _ex1() : _ex0(); - else - return n==0 ? ex(*this) : _ex0(); -} - ex indexed::thisexprseq(const exvector & v) const { return indexed(ex_to(symtree), v); @@ -327,7 +292,7 @@ ex indexed::expand(unsigned options) const // expand_indexed expands (a+b).i -> a.i + b.i const ex & base = seq[0]; - ex sum = _ex0(); + ex sum = _ex0; for (unsigned i=0; i(*it).is_covariant() : true); - if (first || cur_covariant != covariant) { + if (first || cur_covariant != covariant) { // Variance changed + // The empty {} prevents indices from ending up on top of each other if (!first) - c.s << "}"; + c.s << "}{}"; covariant = cur_covariant; if (covariant) c.s << "_{"; @@ -415,7 +381,7 @@ void indexed::validate(void) const * @see ex::diff */ ex indexed::derivative(const symbol & s) const { - return _ex0(); + return _ex0; } ////////// @@ -556,7 +522,6 @@ static ex rename_dummy_indices(const ex & e, exvector & global_dummy_indices, ex } it++; } - shaker_sort(global_dummy_indices.begin(), global_dummy_indices.end(), ex_is_less(), ex_swap()); // If this is the first set of local indices, do nothing if (old_global_size == 0) @@ -571,6 +536,7 @@ static ex rename_dummy_indices(const ex & e, exvector & global_dummy_indices, ex shaker_sort(local_syms.begin(), local_syms.end(), ex_is_less(), ex_swap()); for (unsigned i=0; i a*a - GINAC_ASSERT(e.op(1).is_equal(_ex2())); + GINAC_ASSERT(e.op(1).is_equal(_ex2)); v.push_back(e.op(0)); v.push_back(e.op(0)); } else { for (unsigned i=0; i