From: Richard Kreckel Date: Thu, 3 Feb 2011 22:48:21 +0000 (+0100) Subject: Merge branch 'master.msvc.support' of git://github.com/AlexeiSheplyakov/GiNaC X-Git-Tag: release_1-6-0~19 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=5375260fd145e474246b7a3cce0fc2e667bd4ec8;hp=c0fcba137d26486085ed5d4104b34d2c44978693 Merge branch 'master.msvc.support' of git://github.com/AlexeiSheplyakov/GiNaC * 'master.msvc.support' of git://github.com/AlexeiSheplyakov/GiNaC: Omit extra qualification (as in struct foo f() vs foo f()). [msvc] msvc cannot handle string constants above 16k [msvc] Yet another compiler bug work around. [msvc] Work around strange scoping and name mangling rules. Add few defines for msvc (__func__, __alignof__). symmetry::compare_same_type(): const-correctness fix clifford: fix a few GCCisms (or, not). --- diff --git a/check/time_uvar_gcd.cpp b/check/time_uvar_gcd.cpp index 5e5b5967..b8f69a1e 100644 --- a/check/time_uvar_gcd.cpp +++ b/check/time_uvar_gcd.cpp @@ -89,7 +89,7 @@ static const std::string p2_srep("\ +11039962159*x^11+20714527103*x^31+29530802947*x^30+4813620791*x^29 \ +8841198971*x^6-4237029618*x^5-1135211878*x^4"); -static const std::string q1_srep("\ +static const std::string q1_srep_1("\ -96986421453*x^426-75230349764*x^425+128202397899*x^424+67687797741*x^423 \ +3024931260*x^422+43589211963*x^421+17028560437*x^420+9502389896*x^419 \ +4613252773*x^418+12194328527*x^417-57222260166*x^416+40667752907*x^415 \ @@ -316,7 +316,8 @@ static const std::string q1_srep("\ +20489525484*x^893-34750326173*x^894-26930924040*x^895+28807856566*x^896 \ -67232744129*x^897+21557992547*x^898-7466474096*x^899-29460379882*x^900 \ +11599719084*x^901+67152781205*x^902+8214925141*x^903-36941792660*x^904 \ -+53285909119*x^905+25945946437*x^906-50737201760*x^907-3797518282*x^908 \ ++53285909119*x^905+25945946437*x^906-50737201760*x^907-3797518282*x^908"); +static const std::string q1_srep_2("\ -14516581381*x^909+17052064867*x^910+49668098832*x^911-25564508274*x^912 \ -27386697676*x^913-11774383518*x^914-493156372*x^915+13331359952*x^916 \ +18215828822*x^917-1703765835*x^918-25637155270*x^919+16201914729*x^920 \ @@ -342,7 +343,7 @@ static const std::string q1_srep("\ +4503145470*x^997+91649222*x^998+3092691860*x^999+2111130448*x^1000 \ +7931022064"); -static const std::string q2_srep("\ +static const std::string q2_srep_1("\ 13695560229*x^426 \ +16181971852*x^425-90237548124*x^424-71238644589*x^423-54046636289*x^422 \ -56977010004*x^421+24652773038*x^420+20598565048*x^419+91475303480*x^418 \ @@ -570,7 +571,9 @@ static const std::string q2_srep("\ +32866462223*x^893+75548504697*x^894-48026152317*x^895-33748968072*x^896 \ -1682061382*x^897+8180943332*x^898+19356108993*x^899+7145333263*x^900 \ +22433305927*x^901+18401298176*x^902-46765206984*x^903-19742304183*x^904 \ --48845002624*x^905-27099816961*x^906+23031415252*x^907-4460429941*x^908 \ +-48845002624*x^905-27099816961*x^906+23031415252*x^907-4460429941*x^908"); + +static const std::string q2_srep_2("\ -14418681720*x^909-41227198785*x^910-10148524063*x^911+18686856429*x^912 \ -97172567422*x^913-9574103314*x^914-18076030731*x^915-28358519392*x^916 \ -16581350003*x^917+12090038057*x^918+44243258246*x^919-3986576854*x^920 \ @@ -595,7 +598,7 @@ static const std::string q2_srep("\ -2336834864*x^993+2482449646*x^994-23487081*x^995+41345539*x^996 \ -1908649318*x^997-1563161986*x^998-3391442566*x^999-1975737484*x^1000"); -static const std::string r1_srep("\ +static const std::string r1_srep_1("\ 138233755629*x^426-22168686741*x^425-65314032186*x^424+46713467112*x^423 \ +54066842891*x^422+82543269656*x^421+176235947107*x^420+23156315980*x^419 \ -8714217205*x^418-7917439564*x^417-20923895097*x^416-96817317174*x^415 \ @@ -815,7 +818,9 @@ static const std::string r1_srep("\ +68191968832*x^1574-2532739610*x^1575+182827386055*x^1576+88816579011*x^1577 \ -89385510567*x^1578+66143786656*x^1579+126309891941*x^1580+5804094044*x^1581 \ +97890664428*x^1582+85726994348*x^1583-23154770060*x^1584-117108787907*x^1585 \ -+13971227562*x^1586+38219978507*x^1587-29292257027*x^1588-45584106398*x^1589 \ ++13971227562*x^1586+38219978507*x^1587-29292257027*x^1588-45584106398*x^1589"); + +static const std::string r1_srep_2("\ +226543786384*x^1590-123525218087*x^1591-106279675553*x^1592+59009279185*x^1593 \ -21501846244*x^1594-58215906325*x^1595+10168443133*x^1596+14253963923*x^1597 \ -103607933374*x^1598-23820552704*x^1599+73298115017*x^1600-76073336462*x^1601 \ @@ -1033,7 +1038,9 @@ static const std::string r1_srep("\ -63339878187*x^898-74519679962*x^899-45764977904*x^900+17864107983*x^901 \ +10133013854*x^902-144667843119*x^903+33769537229*x^904+116016157352*x^905 \ -109345484017*x^906+104654868950*x^907-961106931*x^908+31965621838*x^909 \ --6900915942*x^910+39708679388*x^911+165967464883*x^912-13498312464*x^913 \ +-6900915942*x^910+39708679388*x^911+165967464883*x^912-13498312464*x^913"); + +static const std::string r1_srep_3("\ -167799799320*x^914-131936289889*x^915+89614618044*x^916+85016248695*x^917 \ -79954038780*x^918-209591894768*x^919-71794807620*x^920-23283477500*x^921 \ +12638220555*x^922-95752230735*x^923-116899891043*x^924-101215036532*x^925 \ @@ -1099,7 +1106,7 @@ static const std::string r1_srep("\ -149308311610*x^1195 \ "); -static const std::string r2_srep("\ +static const std::string r2_srep_1("\ -12298243395*x^426-33246261919*x^425+14881216216*x^424+100717315398*x^423 \ +32435341799*x^422+11306102069*x^421-42857343048*x^420-23027068074*x^419 \ -121525059139*x^418+41062828633*x^417-9120088623*x^416+38127915034*x^415 \ @@ -1319,7 +1326,9 @@ static const std::string r2_srep("\ +36592332602*x^1574-49900527049*x^1575+109450983286*x^1576+87454580007*x^1577 \ -22429929394*x^1578-90955942668*x^1579-52085998619*x^1580+7542444291*x^1581 \ -129095640958*x^1582-116117273631*x^1583-15362293016*x^1584-75422573875*x^1585 \ -+104080240756*x^1586+29567135838*x^1587-85533231646*x^1588-14007407713*x^1589 \ ++104080240756*x^1586+29567135838*x^1587-85533231646*x^1588-14007407713*x^1589"); + +static const std::string r2_srep_2("\ -72167537141*x^1590+15578436550*x^1591+37099609795*x^1592+5366651746*x^1593 \ -80006924851*x^1594+21429342288*x^1595+30269096496*x^1596-56303168087*x^1597 \ -32192045909*x^1598-24090181314*x^1599-91201040971*x^1600-90424483245*x^1601 \ @@ -1537,7 +1546,9 @@ static const std::string r2_srep("\ -151229340489*x^898-79365642073*x^899+89379856502*x^900+180727114848*x^901 \ +19745037556*x^902+20006492259*x^903-68966001684*x^904+130265998317*x^905 \ -117371414201*x^906-7030328681*x^907-56677471592*x^908+19528257927*x^909 \ -+44475269947*x^910+3470169206*x^911+22467959607*x^912+98656618915*x^913 \ ++44475269947*x^910+3470169206*x^911+22467959607*x^912+98656618915*x^913"); + +static const std::string r2_srep_3("\ -13743860146*x^914+23552943848*x^915-138242276800*x^916-88277644417*x^917 \ +47255373796*x^918-31977886816*x^919-115363640056*x^920+25243901225*x^921 \ -105295249154*x^922-36136467784*x^923+52453236830*x^924+80777038439*x^925 \ @@ -1879,9 +1890,9 @@ int main(int argc, char** argv) bool tolerant_p = (run_expensive_timings_p() >= 1); bool masochist_p = (run_expensive_timings_p() >= 2); // By default PRS gcd tests are disabled, they are way too slow - run_test(q1_srep, q2_srep, tolerant_p, masochist_p); + run_test(q1_srep_1 + q1_srep_2, q2_srep_1 + q2_srep_2, tolerant_p, masochist_p); // ditto - run_test(r1_srep, r2_srep, masochist_p, masochist_p); + run_test(r1_srep_1 + r1_srep_2 + r1_srep_3, r2_srep_1 + r2_srep_2 + r2_srep_3, masochist_p, masochist_p); std::cout << ". " << std::flush; return 0; } diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index d70f0f50..e5ebb401 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -1291,11 +1291,11 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic) if (algebraic) // check if algebraic method is applicable for (unsigned int i = 0; i < D; i++) if (pow(c.subs(mu == i, subs_options::no_pattern), 2).is_zero() - or (not is_a(pow(c.subs(mu == i, subs_options::no_pattern), 2)))) + || (! is_a(pow(c.subs(mu == i, subs_options::no_pattern), 2)))) algebraic = false; lst V; ex v0 = remove_dirac_ONE(canonicalize_clifford(e+clifford_prime(e)).normal())/2; - if (not v0.is_zero()) + if (! v0.is_zero()) V.append(v0); ex e1 = canonicalize_clifford(e - v0 * dirac_ONE(ex_to(c).get_representation_label())); if (algebraic) { @@ -1312,7 +1312,7 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic) e1 = canonicalize_clifford(expand_dummy_sum(e, true)); V.remove_all(); v0 = remove_dirac_ONE(canonicalize_clifford(e1+clifford_prime(e1)).normal())/2; - if (not v0.is_zero()) { + if (! v0.is_zero()) { V.append(v0); e1 = canonicalize_clifford(e1 - v0 * dirac_ONE(ex_to(c).get_representation_label())); } diff --git a/ginac/compiler.h b/ginac/compiler.h index 6c94150c..f0ac685f 100644 --- a/ginac/compiler.h +++ b/ginac/compiler.h @@ -31,4 +31,9 @@ #define likely(cond) (cond) #endif +#ifdef _MSC_VER +#define __func__ __FUNCTION__ +#define __alignof__ __alignof +#endif + #endif // ndef GINAC_COMPILER_DEP_H diff --git a/ginac/ex.h b/ginac/ex.h index f0e6db51..d7bbf6df 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -32,6 +32,11 @@ #include namespace GiNaC { +#ifdef _MSC_VER + // MSVC produces a different symbol for _ex0 when it is declared inside + // ex::is_zero() than when it is declared at top level as follows + extern const ex _ex0; +#endif /** Helper class to initialize the library. There must be one static object * of this class in every object file that makes use of our flyweights in @@ -204,7 +209,12 @@ public: // comparison int compare(const ex & other) const; bool is_equal(const ex & other) const; - bool is_zero() const { extern const ex _ex0; return is_equal(_ex0); } + bool is_zero() const { +#ifndef _MSC_VER + extern const ex _ex0; +#endif + return is_equal(_ex0); + } bool is_zero_matrix() const; // symmetry diff --git a/ginac/exprseq.cpp b/ginac/exprseq.cpp index 2b17e8a6..947d32bd 100644 --- a/ginac/exprseq.cpp +++ b/ginac/exprseq.cpp @@ -37,4 +37,10 @@ template <> bool exprseq::info(unsigned inf) const return inherited::info(inf); } +#ifdef _MSC_VER + // MSVC does not include exprseq::info() in the library without + // defining some kind of dummy function here + basic* dummy_func(void) { return new exprseq(); } +#endif + } // namespace GiNaC diff --git a/ginac/parser/parse_binop_rhs.cpp b/ginac/parser/parse_binop_rhs.cpp index f114c2e2..a0ca4cd3 100644 --- a/ginac/parser/parse_binop_rhs.cpp +++ b/ginac/parser/parse_binop_rhs.cpp @@ -114,7 +114,7 @@ ex parser::parse_binop_rhs(int expr_prec, ex& lhs) } } -extern numeric* _num_1_p; +extern const numeric* _num_1_p; static ex make_minus_expr(const exvector& args) { diff --git a/ginac/parser/parser.cpp b/ginac/parser/parser.cpp index a3284fa4..6c4ebea6 100644 --- a/ginac/parser/parser.cpp +++ b/ginac/parser/parser.cpp @@ -120,8 +120,7 @@ ex parser::parse_paren_expr() return e; } -extern numeric* _num_1_p; -extern ex _ex0; +extern const ex _ex0; /// unary_expr: [+-] expression ex parser::parse_unary_expr() diff --git a/ginac/polynomial/collect_vargs.cpp b/ginac/polynomial/collect_vargs.cpp index c4368fb2..acae53e6 100644 --- a/ginac/polynomial/collect_vargs.cpp +++ b/ginac/polynomial/collect_vargs.cpp @@ -69,7 +69,7 @@ struct compare_terms }; template -static struct compare_terms +static compare_terms make_compare_terms(const T& dummy, const CoeffCMP& coeff_cmp) { return compare_terms(coeff_cmp); diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp index 23f9df90..5dd974c2 100644 --- a/ginac/symmetry.cpp +++ b/ginac/symmetry.cpp @@ -160,7 +160,7 @@ int symmetry::compare_same_type(const basic & other) const return 1; if (this_size < that_size) return -1; - typedef std::set::iterator set_it; + typedef std::set::const_iterator set_it; set_it end = indices.end(); for (set_it i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) { if(*i < *j)