diff --git a/dynare++/kord/decision_rule.hweb b/dynare++/kord/decision_rule.hweb index f79b6f803..bc96bb130 100644 --- a/dynare++/kord/decision_rule.hweb +++ b/dynare++/kord/decision_rule.hweb @@ -217,7 +217,7 @@ void fillTensors(const _Tg& g, double sigma) _Ttensym* g_yud = new _Ttensym(ypart.ny(), ypart.nys()+nu, d); g_yud->zeros(); @; - insert(g_yud); + this->insert(g_yud); } } @@ -274,7 +274,7 @@ void centralize(const DecisionRuleImpl& dr) pol.derivative(d-1); _Ttensym* der = pol.evalPartially(d, dstate); der->mult(1.0/dfac); - insert(der); + this->insert(der); } } @@ -556,7 +556,7 @@ void fillTensors(const _Tg& g, double sigma) g_yd->add(mult, *ten); } } - insert(g_yd); + this->insert(g_yd); } } diff --git a/dynare++/kord/first_order.hweb b/dynare++/kord/first_order.hweb index 3b5e78ca7..a110e2091 100644 --- a/dynare++/kord/first_order.hweb +++ b/dynare++/kord/first_order.hweb @@ -74,10 +74,10 @@ public:@; nvs[0] = fo.ypart.nys(); nvs[1] = fo.nu; nvs[2] = fo.nu; nvs[3] = 1; _Ttensor* ten = new _Ttensor(fo.ypart.ny(), TensorDimens(Symmetry(1,0,0,0),nvs)); ten->zeros(); ten->add(1.0, fo.gy); - insert(ten); + this->insert(ten); ten = new _Ttensor(fo.ypart.ny(), TensorDimens(Symmetry(0,1,0,0), nvs)); ten->zeros(); ten->add(1.0, fo.gu); - insert(ten); + this->insert(ten); } }; diff --git a/dynare++/kord/korder_stoch.hweb b/dynare++/kord/korder_stoch.hweb index ff66e9149..83d7cd6f4 100644 --- a/dynare++/kord/korder_stoch.hweb +++ b/dynare++/kord/korder_stoch.hweb @@ -115,7 +115,7 @@ IntegDerivs(int r, const IntSequence& nvs, const _Tgss& g, const __Tm& mom, Symmetry sym(i,0,0,p); _Ttensor* ten = new _Ttensor(r, TensorDimens(sym, nvs)); @; - insert(ten); + this->insert(ten); } } } @@ -256,7 +256,7 @@ symmetric polynomial. Note that the derivative get the true |nvs|. IntSequence coor(sym, pp); _Ttensor* ten = new _Ttensor(*(g_int_cent.get(Symmetry(d))), ss, coor, TensorDimens(sym, true_nvs)); - insert(ten); + this->insert(ten); } } } diff --git a/dynare++/tl/cc/sthread.hweb b/dynare++/tl/cc/sthread.hweb index 678d4b633..a8331ca5e 100644 --- a/dynare++/tl/cc/sthread.hweb +++ b/dynare++/tl/cc/sthread.hweb @@ -340,7 +340,7 @@ void remove(const void* c, const char* id) { iterator it = _Tparent::find(mmkey(c, id)); if (it != _Tparent::end()) - erase(it); + this->erase(it); } @ This is the |synchro| class. The constructor of this class tries to diff --git a/mex/sources/estimation/libmat/Matrix.hh b/mex/sources/estimation/libmat/Matrix.hh index 1024ee1e5..860af9507 100644 --- a/mex/sources/estimation/libmat/Matrix.hh +++ b/mex/sources/estimation/libmat/Matrix.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Dynare Team + * Copyright (C) 2010-2012 Dynare Team * * This file is part of Dynare. * @@ -426,107 +426,6 @@ namespace mat } return nrm; } - // emulates Matlab command A(a,b)=B(c,d) where a,b,c,d are size_t vectors or nullVec as a proxy for ":") - // i.e. zero sized vector (or mat::nullVec) is interpreted as if one supplied ":" in matlab - template - void - assignByVectors(Mat1 &a, const std::vector &vToRows, const std::vector &vToCols, - const Mat2 &b, const std::vector &vrows, const std::vector &vcols) - { - size_t nrows = 0, ncols = 0, tonrows = 0, toncols = 0; - const std::vector *vpToCols = 0, *vpToRows = 0, *vpRows = 0, *vpCols = 0; - std::vector tmpvpToCols(0), tmpvpToRows(0), tmpvpRows(0), tmpvpCols(0); - - if (vToRows.size() == 0 && vToCols.size() == 0 && vrows.size() == 0 && vcols.size() == 0) - a = b; - else if (vToRows.size() == 0 && vrows.size() == 0) // just reorder columns - reorderColumnsByVectors(a, vToCols, b, vcols); - else if (vToCols.size() == 0 && vcols.size() == 0) // just reorder rows - reorderRowsByVectors(a, vToRows, b, vrows); - else - { - if (vToRows.size() == 0) - { - tonrows = a.getRows(); - tmpvpToRows.reserve(tonrows); - for (size_t i = 0; i < tonrows; ++i) - tmpvpToRows[i] = i; - vpToRows = (const std::vector *)&tmpvpToRows; - } - else - { - for (size_t i = 0; i < vToRows.size(); ++i) - { - assert(vToRows[i] < a.getRows()); //Negative or too large indices - tonrows++; - } - assert(tonrows <= a.getRows()); // check wrong dimensions for assignment by vector - vpToRows = &vToRows; - } - - if (vToCols.size() == 0) - { - toncols = a.getCols(); - tmpvpToCols.reserve(toncols); - for (size_t i = 0; i < toncols; ++i) - tmpvpToCols[i] = i; - vpToCols = (const std::vector *)&tmpvpToCols; - } - else - { - for (size_t i = 0; i < vToCols.size(); ++i) - { - assert(vToCols[i] < a.getCols()); //Negative or too large indices - toncols++; - } - assert(toncols <= a.getCols()); // check wrong dimensions for assignment by vector - vpToCols = &vToCols; - } - - if (vrows.size() == 0) - { - nrows = b.getRows(); - tmpvpRows.reserve(nrows); - for (size_t i = 0; i < nrows; ++i) - tmpvpRows[i] = i; - vpRows = (const std::vector *)&tmpvpRows; - } - else - { - for (size_t i = 0; i < vrows.size(); ++i) - { - assert(vrows[i] < b.getRows()); //Negative or too large indices - nrows++; - } - assert(nrows <= b.getRows()); // check wrong dimensions for assignment by vector - vpRows = &vrows; - } - - if (vcols.size() == 0) - { - ncols = b.getCols(); - tmpvpCols.reserve(ncols); - for (size_t i = 0; i < ncols; ++i) - tmpvpCols[i] = i; - vpCols = (const std::vector *)&tmpvpCols; - } - else - { - for (size_t i = 0; i < vcols.size(); ++i) - { - assert(vcols[i] < b.getCols()); //Negative or too large indices - ncols++; - } - assert(ncols <= b.getCols()); // check wrong dimensions for assignment by vector - vpCols = &vcols; - } - - assert(tonrows == nrows && toncols == ncols && nrows * ncols > 0); - for (size_t i = 0; i < nrows; ++i) - for (size_t j = 0; j < ncols; ++j) - a((*vpToRows)[i], (*vpToCols)[j]) = b((*vpRows)[i], (*vpCols)[j]); - } - } // emulates Matlab command A(:,b)=B(:,d) where b,d are size_t vectors or nullVec as a proxy for ":") // i.e. zero sized vector (or mat::nullVec) is interpreted as if one supplied ":" in matlab @@ -649,6 +548,108 @@ namespace mat } } + // emulates Matlab command A(a,b)=B(c,d) where a,b,c,d are size_t vectors or nullVec as a proxy for ":") + // i.e. zero sized vector (or mat::nullVec) is interpreted as if one supplied ":" in matlab + template + void + assignByVectors(Mat1 &a, const std::vector &vToRows, const std::vector &vToCols, + const Mat2 &b, const std::vector &vrows, const std::vector &vcols) + { + size_t nrows = 0, ncols = 0, tonrows = 0, toncols = 0; + const std::vector *vpToCols = 0, *vpToRows = 0, *vpRows = 0, *vpCols = 0; + std::vector tmpvpToCols(0), tmpvpToRows(0), tmpvpRows(0), tmpvpCols(0); + + if (vToRows.size() == 0 && vToCols.size() == 0 && vrows.size() == 0 && vcols.size() == 0) + a = b; + else if (vToRows.size() == 0 && vrows.size() == 0) // just reorder columns + reorderColumnsByVectors(a, vToCols, b, vcols); + else if (vToCols.size() == 0 && vcols.size() == 0) // just reorder rows + reorderRowsByVectors(a, vToRows, b, vrows); + else + { + if (vToRows.size() == 0) + { + tonrows = a.getRows(); + tmpvpToRows.reserve(tonrows); + for (size_t i = 0; i < tonrows; ++i) + tmpvpToRows[i] = i; + vpToRows = (const std::vector *)&tmpvpToRows; + } + else + { + for (size_t i = 0; i < vToRows.size(); ++i) + { + assert(vToRows[i] < a.getRows()); //Negative or too large indices + tonrows++; + } + assert(tonrows <= a.getRows()); // check wrong dimensions for assignment by vector + vpToRows = &vToRows; + } + + if (vToCols.size() == 0) + { + toncols = a.getCols(); + tmpvpToCols.reserve(toncols); + for (size_t i = 0; i < toncols; ++i) + tmpvpToCols[i] = i; + vpToCols = (const std::vector *)&tmpvpToCols; + } + else + { + for (size_t i = 0; i < vToCols.size(); ++i) + { + assert(vToCols[i] < a.getCols()); //Negative or too large indices + toncols++; + } + assert(toncols <= a.getCols()); // check wrong dimensions for assignment by vector + vpToCols = &vToCols; + } + + if (vrows.size() == 0) + { + nrows = b.getRows(); + tmpvpRows.reserve(nrows); + for (size_t i = 0; i < nrows; ++i) + tmpvpRows[i] = i; + vpRows = (const std::vector *)&tmpvpRows; + } + else + { + for (size_t i = 0; i < vrows.size(); ++i) + { + assert(vrows[i] < b.getRows()); //Negative or too large indices + nrows++; + } + assert(nrows <= b.getRows()); // check wrong dimensions for assignment by vector + vpRows = &vrows; + } + + if (vcols.size() == 0) + { + ncols = b.getCols(); + tmpvpCols.reserve(ncols); + for (size_t i = 0; i < ncols; ++i) + tmpvpCols[i] = i; + vpCols = (const std::vector *)&tmpvpCols; + } + else + { + for (size_t i = 0; i < vcols.size(); ++i) + { + assert(vcols[i] < b.getCols()); //Negative or too large indices + ncols++; + } + assert(ncols <= b.getCols()); // check wrong dimensions for assignment by vector + vpCols = &vcols; + } + + assert(tonrows == nrows && toncols == ncols && nrows * ncols > 0); + for (size_t i = 0; i < nrows; ++i) + for (size_t j = 0; j < ncols; ++j) + a((*vpToRows)[i], (*vpToCols)[j]) = b((*vpRows)[i], (*vpCols)[j]); + } + } + //emulates Matlab repmat: Mat2 = multv*multh tiled [Mat1] template void diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index e19ff0af0..e36c43f2f 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -22,6 +22,10 @@ #include #include #include +#ifndef _WIN32 +# include +#endif + #include "ModFile.hh" #include "ConfigFile.hh" #include "ComputingTasks.hh"