X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Futils.h;h=2aff369f9165e3eebbdff17b01f5bb7736463484;hb=1c288c22278ea56673eaf96c3c9885a7b5d854a8;hp=13fa2c8b956bafc17d8ca33640b8575467b9ba44;hpb=b7c15cf3731d4b3d4f9bcd7b95b42982e91a69bd;p=ginac.git diff --git a/ginac/utils.h b/ginac/utils.h index 13fa2c8b..2aff369f 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -26,6 +26,7 @@ #include #include +#include #include "config.h" #include "assertion.h" @@ -33,19 +34,29 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC +// This should be obsoleted once is widely available. template -string ToString(const T & t) +std::string ToString(const T & t) { char buf[256]; - ostrstream(buf,sizeof(buf)) << t << ends; + std::ostrstream(buf,sizeof(buf)) << t << std::ends; return buf; } -/** Exception thrown by classes which provide their own series expansion to - * signal that ordinary Taylor expansion is safe. */ +/** Exception class thrown by classes which provide their own series expansion + * to signal that ordinary Taylor expansion is safe. */ class do_taylor {}; -// cygwin defines a macro log2, causing confusion +/** Exception class thrown when a singularity is encountered. */ +class pole_error : public std::domain_error { +public: + explicit pole_error(const std::string& what_arg, int degree); + int degree(void) const; +private: + int deg; +}; + +// some compilers (e.g. cygwin) define a macro log2, causing confusion #ifndef log2 unsigned log2(unsigned n); #endif @@ -143,13 +154,13 @@ OutputIterator mymerge3(InputIterator1 first1, InputIterator1 last1, // Compute the sign of a permutation of a vector of things. template -int permutation_sign(vector s) +int permutation_sign(std::vector s) { if (s.size() < 2) return 0; int sigma = 1; - for (typename vector::iterator i=s.begin(); i!=s.end()-1; ++i) { - for (typename vector::iterator j=i+1; j!=s.end(); ++j) { + for (typename std::vector::iterator i=s.begin(); i!=s.end()-1; ++i) { + for (typename std::vector::iterator j=i+1; j!=s.end(); ++j) { if (*i == *j) return 0; if (*i > *j) { @@ -174,6 +185,8 @@ const numeric & _num_120(void); // -120 const ex & _ex_120(void); const numeric & _num_60(void); // -60 const ex & _ex_60(void); +const numeric & _num_48(void); // -48 +const ex & _ex_48(void); const numeric & _num_30(void); // -30 const ex & _ex_30(void); const numeric & _num_25(void); // -25 @@ -260,6 +273,8 @@ const numeric & _num25(void); // 25 const ex & _ex25(void); const numeric & _num30(void); // 30 const ex & _ex30(void); +const numeric & _num48(void); // 48 +const ex & _ex48(void); const numeric & _num60(void); // 60 const ex & _ex60(void); const numeric & _num120(void); // 120