X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fidx.cpp;h=67d23c5b1b9592af8da3b10bba9cccb0c10e0dc7;hp=f57a5ae4bdc6ac71067d888d37c1ddead3ca59f4;hb=d11acf2982b74cca5c0f4dc58c72832530957cd9;hpb=24fe247f9ed16114a765a01c593fec5c4a2f591c diff --git a/ginac/idx.cpp b/ginac/idx.cpp index f57a5ae4..67d23c5b 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's indices. */ /* - * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2000 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 @@ -29,7 +29,9 @@ #include "utils.h" #include "debugmsg.h" +#ifndef NO_GINAC_NAMESPACE namespace GiNaC { +#endif // ndef NO_GINAC_NAMESPACE ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -50,13 +52,13 @@ idx::~idx() destroy(0); } -idx::idx(idx const & other) +idx::idx(const idx & other) { debugmsg("idx copy constructor",LOGLEVEL_CONSTRUCT); copy(other); } -idx const & idx::operator=(idx const & other) +const idx & idx::operator=(const idx & other) { debugmsg("idx operator=",LOGLEVEL_ASSIGNMENT); if (this != &other) { @@ -68,7 +70,7 @@ idx const & idx::operator=(idx const & other) // protected -void idx::copy(idx const & other) +void idx::copy(const idx & other) { basic::copy(other); serial=other.serial; @@ -96,21 +98,21 @@ idx::idx(bool cov) : basic(TINFO_idx), symbolic(true), covariant(cov) name="index"+ToString(serial); } -idx::idx(string const & n, bool cov) : basic(TINFO_idx), +idx::idx(const string & n, bool cov) : basic(TINFO_idx), symbolic(true), name(n), covariant(cov) { debugmsg("idx constructor from string,bool",LOGLEVEL_CONSTRUCT); serial=next_serial++; } -idx::idx(char const * n, bool cov) : basic(TINFO_idx), +idx::idx(const char * n, bool cov) : basic(TINFO_idx), symbolic(true), name(n), covariant(cov) { debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT); serial=next_serial++; } -idx::idx(unsigned const v, bool cov) : basic(TINFO_idx), +idx::idx(unsigned v, bool cov) : basic(TINFO_idx), symbolic(false), value(v), covariant(cov) { debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); @@ -198,17 +200,17 @@ bool idx::info(unsigned inf) const return basic::info(inf); } -ex idx::subs(lst const & ls, lst const & lr) const +ex idx::subs(const lst & ls, const lst & lr) const { GINAC_ASSERT(ls.nops()==lr.nops()); #ifdef DO_GINAC_ASSERT - for (int i=0; i + const idx & o=static_cast (const_cast(other)); if (covariant!=o.covariant) { @@ -246,10 +248,10 @@ int idx::compare_same_type(basic const & other) const return o.symbolic ? -1 : 1; } -bool idx::is_equal_same_type(basic const & other) const +bool idx::is_equal_same_type(const basic & other) const { GINAC_ASSERT(is_of_type(other,idx)); - idx const & o=static_cast + const idx & o=static_cast (const_cast(other)); if (covariant!=o.covariant) return false; @@ -271,11 +273,11 @@ unsigned idx::calchash(void) const // public -bool idx::is_co_contra_pair(basic const & other) const +bool idx::is_co_contra_pair(const basic & other) const { // like is_equal_same_type(), but tests for different covariant status GINAC_ASSERT(is_of_type(other,idx)); - idx const & o=static_cast + const idx & o=static_cast (const_cast(other)); if (covariant==o.covariant) return false; @@ -326,7 +328,7 @@ unsigned idx::next_serial=0; ////////// const idx some_idx; -type_info const & typeid_idx=typeid(some_idx); +const type_info & typeid_idx=typeid(some_idx); ////////// // other functions @@ -360,7 +362,7 @@ int canonicalize_indices(exvector & iv, bool antisymmetric) return something_changed ? sig : INT_MAX; } -exvector idx_intersect(exvector const & iv1, exvector const & iv2) +exvector idx_intersect(const exvector & iv1, const exvector & iv2) { // build a vector of symbolic indices contained in iv1 and iv2 simultaneously // assumes (but does not test) that each index occurs at most twice @@ -386,7 +388,7 @@ exvector idx_intersect(exvector const & iv1, exvector const & iv2) return iv3[A]; \ } -ex permute_free_index_to_front(exvector const & iv3, exvector const & iv2, +ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, bool antisymmetric, int * sig) { // match (return value,iv2) to iv3 by permuting indices @@ -406,7 +408,7 @@ ex permute_free_index_to_front(exvector const & iv3, exvector const & iv2, throw(std::logic_error("permute_free_index_to_front(): no valid permutation found")); } -unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir) +unsigned subs_index_in_exvector(exvector & v, const ex & is, const ex & ir) { exvector::iterator it; unsigned replacements=0; @@ -425,7 +427,7 @@ unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir) return replacements; } -unsigned count_index(ex const & e, ex const & i) +unsigned count_index(const ex & e, const ex & i) { exvector idxv=e.get_indices(); unsigned count=0; @@ -435,8 +437,8 @@ unsigned count_index(ex const & e, ex const & i) return count; } -ex subs_indices(ex const & e, exvector const & idxv_subs, - exvector const & idxv_repl) +ex subs_indices(const ex & e, const exvector & idxv_subs, + const exvector & idxv_repl) { GINAC_ASSERT(idxv_subs.size()==idxv_repl.size()); ex res=e; @@ -446,4 +448,6 @@ ex subs_indices(ex const & e, exvector const & idxv_subs, return res; } +#ifndef NO_GINAC_NAMESPACE } // namespace GiNaC +#endif // ndef NO_GINAC_NAMESPACE