X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Futils.h;h=dd39d42ec2f5e412d1a54f8acbb11aca5caf9709;hb=c814fb2991fc9d44c7466da5bbf20e58c0f4238f;hp=3c293ea8c5e2e3f7b42391e701f780d3e064acdd;hpb=a3009dfc5402f6253e9219201f48d972dd46984b;p=ginac.git diff --git a/ginac/utils.h b/ginac/utils.h index 3c293ea8..dd39d42e 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -4,7 +4,7 @@ * of any interest to the user of the library. */ /* - * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2015 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 @@ -21,20 +21,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __GINAC_UTILS_H__ -#define __GINAC_UTILS_H__ +#ifndef GINAC_UTILS_H +#define GINAC_UTILS_H +#include "assertion.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include #include #ifdef HAVE_STDINT_H #include // for uintptr_t #endif - -#include "assertion.h" +#include namespace GiNaC { @@ -129,7 +128,9 @@ int permutation_sign(It first, It last) sign = -sign; } else if (!(*other < *i)) return 0; - --i; --other; + --i; + if (i != first) + --other; } if (!swapped) return sign; @@ -148,7 +149,9 @@ int permutation_sign(It first, It last) sign = -sign; } else if (!(*i < *other)) return 0; - ++i; ++other; + ++i; + if (i != last) + ++other; } if (!swapped) return sign; @@ -182,7 +185,9 @@ int permutation_sign(It first, It last, Cmp comp, Swap swapit) sign = -sign; } else if (!comp(*other, *i)) return 0; - --i; --other; + --i; + if (i != first) + --other; } if (!swapped) return sign; @@ -201,7 +206,9 @@ int permutation_sign(It first, It last, Cmp comp, Swap swapit) sign = -sign; } else if (!comp(*i, *other)) return 0; - ++i; ++other; + ++i; + if (i != last) + ++other; } if (!swapped) return sign; @@ -233,7 +240,9 @@ void shaker_sort(It first, It last, Cmp comp, Swap swapit) flag = other; swapped = true; } - --i; --other; + --i; + if (i != first) + --other; } if (!swapped) return; @@ -250,7 +259,9 @@ void shaker_sort(It first, It last, Cmp comp, Swap swapit) flag = other; swapped = true; } - ++i; ++other; + ++i; + if (i != last) + ++other; } if (!swapped) return; @@ -405,21 +416,7 @@ extern const ex _ex120; // Helper macros for class implementations (mostly useful for trivial classes) #define DEFAULT_CTOR(classname) \ -classname::classname() : inherited(&classname::tinfo_static) { setflag(status_flags::evaluated | status_flags::expanded); } - -#define DEFAULT_UNARCHIVE(classname) \ -ex classname::unarchive(const archive_node &n, lst &sym_lst) \ -{ \ - return (new classname(n, sym_lst))->setflag(status_flags::dynallocated); \ -} - -#define DEFAULT_ARCHIVING(classname) \ -classname::classname(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) {} \ -DEFAULT_UNARCHIVE(classname) \ -void classname::archive(archive_node &n) const \ -{ \ - inherited::archive(n); \ -} +classname::classname() { setflag(status_flags::evaluated | status_flags::expanded); } #define DEFAULT_COMPARE(classname) \ int classname::compare_same_type(const basic & other) const \ @@ -443,5 +440,4 @@ void classname::do_print_latex(const print_latex & c, unsigned level) const \ } // namespace GiNaC - -#endif // ndef __GINAC_UTILS_H__ +#endif // ndef GINAC_UTILS_H