Dynare++: drop remaining "using namespace std"

time-shift
Sébastien Villemot 2019-02-06 15:50:01 +01:00
parent 798cecd879
commit af722f438f
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
37 changed files with 140 additions and 147 deletions

View File

@ -184,9 +184,9 @@ public:
/* Just for debugging. */ /* Just for debugging. */
void void
savePoints(const string &fname, int level) const savePoints(const std::string &fname, int level) const
{ {
ofstream fd{fname, std::ios::out | std::ios::trunc}; std::ofstream fd{fname, std::ios::out | std::ios::trunc};
if (fd.fail()) if (fd.fail())
{ {
// todo: raise // todo: raise

View File

@ -83,7 +83,7 @@ private:
protected: protected:
int num; int num;
int maxn; int maxn;
vector<RadicalInverse> ri; std::vector<RadicalInverse> ri;
const PermutationScheme &per; const PermutationScheme &per;
Vector pt; Vector pt;
public: public:

View File

@ -101,9 +101,9 @@ class SmolyakQuadrature : public QuadratureImpl<smolpit>
friend class smolpit; friend class smolpit;
int level; int level;
const OneDQuadrature &uquad; const OneDQuadrature &uquad;
vector<IntSequence> levels; std::vector<IntSequence> levels;
vector<IntSequence> levpoints; std::vector<IntSequence> levpoints;
vector<int> cumevals; std::vector<int> cumevals;
PascalTriangle psc; PascalTriangle psc;
public: public:
SmolyakQuadrature(int d, int l, const OneDQuadrature &uq); SmolyakQuadrature(int d, int l, const OneDQuadrature &uq);

View File

@ -22,8 +22,8 @@
struct QuadParams struct QuadParams
{ {
string outname; std::string outname;
string vcovname; std::string vcovname;
int max_level{3}; int max_level{3};
double discard_weight{0.0}; double discard_weight{0.0};
QuadParams(int argc, char **argv); QuadParams(int argc, char **argv);
@ -60,7 +60,7 @@ QuadParams::QuadParams(int argc, char **argv)
case opt_max_level: case opt_max_level:
try try
{ {
max_level = std::stoi(string{optarg}); max_level = std::stoi(std::string{optarg});
} }
catch (const std::invalid_argument &e) catch (const std::invalid_argument &e)
{ {
@ -70,7 +70,7 @@ QuadParams::QuadParams(int argc, char **argv)
case opt_discard_weight: case opt_discard_weight:
try try
{ {
discard_weight = std::stod(string{optarg}); discard_weight = std::stod(std::string{optarg});
} }
catch (const std::invalid_argument &e) catch (const std::invalid_argument &e)
{ {

View File

@ -165,11 +165,11 @@ Function1Trans::eval(const Vector &point, const ParameterSignal &sig, Vector &ou
// with time information // with time information
class WallTimer class WallTimer
{ {
string mes; std::string mes;
std::chrono::time_point<std::chrono::high_resolution_clock> start; std::chrono::time_point<std::chrono::high_resolution_clock> start;
bool new_line; bool new_line;
public: public:
WallTimer(string m, bool nl = true) WallTimer(std::string m, bool nl = true)
: mes{m}, start{std::chrono::high_resolution_clock::now()}, new_line{nl} : mes{m}, start{std::chrono::high_resolution_clock::now()}, new_line{nl}
{ {
} }
@ -189,10 +189,10 @@ public:
class TestRunnable class TestRunnable
{ {
public: public:
const string name; const std::string name;
int dim; // dimension of the solved problem int dim; // dimension of the solved problem
int nvar; // number of variable of the solved problem int nvar; // number of variable of the solved problem
TestRunnable(string name_arg, int d, int nv) TestRunnable(std::string name_arg, int d, int nv)
: name{move(name_arg)}, dim(d), nvar(nv) : name{move(name_arg)}, dim(d), nvar(nv)
{ {
} }
@ -211,7 +211,7 @@ protected:
bool bool
TestRunnable::test() const TestRunnable::test() const
{ {
cout << "Running test <" << name << ">" << endl; std::cout << "Running test <" << name << ">" << std::endl;
bool passed; bool passed;
{ {
WallTimer tim("Wall clock time ", false); WallTimer tim("Wall clock time ", false);
@ -286,7 +286,7 @@ TestRunnable::product_normal_moments(const GeneralMatrix &m, int imom, int level
// check against theoretical moments // check against theoretical moments
UNormalMoments moments(imom, msq); UNormalMoments moments(imom, msq);
prod_out.add(-1.0, (moments.get(Symmetry(imom)))->getData()); prod_out.add(-1.0, (moments.get(Symmetry(imom)))->getData());
std::cout << "\tError: " << std::setw(16) << std::setprecision(12) << prod_out.getMax() << endl; std::cout << "\tError: " << std::setw(16) << std::setprecision(12) << prod_out.getMax() << std::endl;
return prod_out.getMax() < 1.e-7; return prod_out.getMax() < 1.e-7;
} }

View File

@ -437,7 +437,7 @@ RTSimResultsStats::writeMat(mat_t *fd, const char *lname)
} }
IRFResults::IRFResults(const DynamicModel &mod, const DecisionRule &dr, IRFResults::IRFResults(const DynamicModel &mod, const DecisionRule &dr,
const SimResults &control, vector<int> ili, const SimResults &control, std::vector<int> ili,
Journal &journal) Journal &journal)
: model(mod), irf_list_ind(std::move(ili)) : model(mod), irf_list_ind(std::move(ili))
{ {
@ -639,6 +639,6 @@ GenShockRealization::get(int n, Vector &out)
Vector r(numShocks()); Vector r(numShocks());
RandomShockRealization::get(n, r); RandomShockRealization::get(n, r);
for (int j = 0; j < numShocks(); j++) for (int j = 0; j < numShocks(); j++)
if (!isfinite(out[j])) if (!std::isfinite(out[j]))
out[j] = r[j]; out[j] = r[j];
} }

View File

@ -728,9 +728,9 @@ protected:
int num_y; int num_y;
int num_per; int num_per;
int num_burn; int num_burn;
vector<TwoDMatrix *> data; std::vector<TwoDMatrix *> data;
vector<ExplicitShockRealization *> shocks; std::vector<ExplicitShockRealization *> shocks;
vector<ConstVector> start; std::vector<ConstVector> start;
public: public:
SimResults(int ny, int nper, int nburn = 0) SimResults(int ny, int nper, int nburn = 0)
: num_y(ny), num_per(nper), num_burn(nburn) : num_y(ny), num_per(nper), num_burn(nburn)
@ -902,12 +902,12 @@ public:
class DynamicModel; class DynamicModel;
class IRFResults class IRFResults
{ {
vector<SimResultsIRF *> irf_res; std::vector<SimResultsIRF *> irf_res;
const DynamicModel &model; const DynamicModel &model;
vector<int> irf_list_ind; std::vector<int> irf_list_ind;
public: public:
IRFResults(const DynamicModel &mod, const DecisionRule &dr, IRFResults(const DynamicModel &mod, const DecisionRule &dr,
const SimResults &control, vector<int> ili, const SimResults &control, std::vector<int> ili,
Journal &journal); Journal &journal);
~IRFResults(); ~IRFResults();
void writeMat(mat_t *fd, const char *prefix) const; void writeMat(mat_t *fd, const char *prefix) const;

View File

@ -204,7 +204,7 @@ JournalRecordPair::~JournalRecordPair()
writePrefixForEnd(flash); writePrefixForEnd(flash);
journal << prefix_end; journal << prefix_end;
journal << mes; journal << mes;
journal << endl; journal << std::endl;
journal.flush(); journal.flush();
} }
@ -213,7 +213,7 @@ endrec(JournalRecord &rec)
{ {
rec.journal << rec.prefix; rec.journal << rec.prefix;
rec.journal << rec.mes; rec.journal << rec.mes;
rec.journal << endl; rec.journal << std::endl;
rec.journal.flush(); rec.journal.flush();
rec.journal.incrementOrd(); rec.journal.incrementOrd();
return rec; return rec;

View File

@ -39,13 +39,13 @@ struct SystemResourcesFlash
void diff(const SystemResourcesFlash &pre); void diff(const SystemResourcesFlash &pre);
}; };
class Journal : public ofstream class Journal : public std::ofstream
{ {
int ord; int ord;
int depth; int depth;
public: public:
Journal(const char *fname) Journal(const char *fname)
: ofstream(fname), ord(0), depth(0) : std::ofstream(fname), ord(0), depth(0)
{ {
printHeader(); printHeader();
} }

View File

@ -19,10 +19,10 @@
/**************************************************************************************/ /**************************************************************************************/
/* DynareNameList class */ /* DynareNameList class */
/**************************************************************************************/ /**************************************************************************************/
vector<int> std::vector<int>
DynareNameList::selectIndices(const vector<const char *> &ns) const DynareNameList::selectIndices(const std::vector<const char *> &ns) const
{ {
vector<int> res; std::vector<int> res;
for (auto n : ns) for (auto n : ns)
{ {
int j = 0; int j = 0;
@ -30,7 +30,7 @@ DynareNameList::selectIndices(const vector<const char *> &ns) const
j++; j++;
if (j == getNum()) if (j == getNum())
throw DynareException(__FILE__, __LINE__, throw DynareException(__FILE__, __LINE__,
string("Couldn't find name for ") + n std::string("Couldn't find name for ") + n
+" in DynareNameList::selectIndices"); +" in DynareNameList::selectIndices");
res.push_back(j); res.push_back(j);
} }
@ -47,7 +47,7 @@ Dynare::Dynare(const char *modname, int ord, double sstol, Journal &jr)
{ {
std::ifstream f{modname}; std::ifstream f{modname};
if (f.fail()) if (f.fail())
throw DynareException(__FILE__, __LINE__, string{"Could not open model file "}+modname); throw DynareException(__FILE__, __LINE__, std::string{"Could not open model file "}+modname);
std::ostringstream buffer; std::ostringstream buffer;
buffer << f.rdbuf(); buffer << f.rdbuf();

View File

@ -20,7 +20,7 @@ class Dynare;
class DynareNameList : public NameList class DynareNameList : public NameList
{ {
vector<const char *> names; std::vector<const char *> names;
public: public:
DynareNameList(const Dynare &dynare); DynareNameList(const Dynare &dynare);
int int
@ -36,12 +36,12 @@ public:
/** This for each string of the input vector calculates its index /** This for each string of the input vector calculates its index
* in the names. And returns the resulting vector of indices. If * in the names. And returns the resulting vector of indices. If
* the name cannot be found, then an exception is raised. */ * the name cannot be found, then an exception is raised. */
vector<int> selectIndices(const vector<const char *> &ns) const; std::vector<int> selectIndices(const std::vector<const char *> &ns) const;
}; };
class DynareExogNameList : public NameList class DynareExogNameList : public NameList
{ {
vector<const char *> names; std::vector<const char *> names;
public: public:
DynareExogNameList(const Dynare &dynare); DynareExogNameList(const Dynare &dynare);
int int
@ -58,7 +58,7 @@ public:
class DynareStateNameList : public NameList class DynareStateNameList : public NameList
{ {
vector<const char *> names; std::vector<const char *> names;
public: public:
DynareStateNameList(const Dynare &dynare, const DynareNameList &dnl, DynareStateNameList(const Dynare &dynare, const DynareNameList &dnl,
const DynareExogNameList &denl); const DynareExogNameList &denl);

View File

@ -43,7 +43,7 @@ main(int argc, char **argv)
// make dynare object // make dynare object
Dynare dynare(params.modname, params.order, params.ss_tol, journal); Dynare dynare(params.modname, params.order, params.ss_tol, journal);
// make list of shocks for which we will do IRFs // make list of shocks for which we will do IRFs
vector<int> irf_list_ind; std::vector<int> irf_list_ind;
if (params.do_irfs_all) if (params.do_irfs_all)
for (int i = 0; i < dynare.nexog(); i++) for (int i = 0; i < dynare.nexog(); i++)
irf_list_ind.push_back(i); irf_list_ind.push_back(i);

View File

@ -313,7 +313,7 @@ EquivalenceSet::EquivalenceSet(int num)
: n(num), : n(num),
equis() equis()
{ {
list<Equivalence> added; std::list<Equivalence> added;
Equivalence first(n); Equivalence first(n);
equis.push_back(first); equis.push_back(first);
addParents(first, added); addParents(first, added);
@ -359,7 +359,7 @@ EquivalenceSet::has(const Equivalence &e) const
void void
EquivalenceSet::addParents(const Equivalence &e, EquivalenceSet::addParents(const Equivalence &e,
list<Equivalence> &added) std::list<Equivalence> &added)
{ {
if (e.numClasses() == 2 || e.numClasses() == 1) if (e.numClasses() == 2 || e.numClasses() == 1)
return; return;
@ -396,7 +396,7 @@ EquivalenceSet::print(const char *prefix) const
/* Construct the bundle. |nmax| is a maximum size of underlying set. */ /* Construct the bundle. |nmax| is a maximum size of underlying set. */
EquivalenceBundle::EquivalenceBundle(int nmax) EquivalenceBundle::EquivalenceBundle(int nmax)
{ {
nmax = max(nmax, 1); nmax = std::max(nmax, 1);
generateUpTo(nmax); generateUpTo(nmax);
} }

View File

@ -44,8 +44,6 @@
#include <vector> #include <vector>
#include <list> #include <list>
using namespace std;
/* Here is the abstraction for an equivalence class. We implement it as /* Here is the abstraction for an equivalence class. We implement it as
|vector<int>|. We have a constructor for empty class, copy |vector<int>|. We have a constructor for empty class, copy
constructor. What is important here is the ordering operator constructor. What is important here is the ordering operator
@ -55,7 +53,7 @@ using namespace std;
class OrdSequence class OrdSequence
{ {
vector<int> data; std::vector<int> data;
public: public:
OrdSequence() : data() OrdSequence() : data()
{ {
@ -68,7 +66,7 @@ public:
bool operator==(const OrdSequence &s) const; bool operator==(const OrdSequence &s) const;
int operator[](int i) const; int operator[](int i) const;
bool operator<(const OrdSequence &s) const; bool operator<(const OrdSequence &s) const;
const vector<int> & const std::vector<int> &
getData() const getData() const
{ {
return data; return data;
@ -97,10 +95,10 @@ class Equivalence
{ {
private: private:
int n; int n;
list<OrdSequence> classes; std::list<OrdSequence> classes;
public: public:
using const_seqit = list<OrdSequence>::const_iterator; using const_seqit = std::list<OrdSequence>::const_iterator;
using seqit = list<OrdSequence>::iterator; using seqit = std::list<OrdSequence>::iterator;
/* The first constructor constructs $\{\{0\},\{1\},\ldots,\{n-1\}\}$. /* The first constructor constructs $\{\{0\},\{1\},\ldots,\{n-1\}\}$.
@ -183,9 +181,9 @@ protected:
class EquivalenceSet class EquivalenceSet
{ {
int n; int n;
list<Equivalence> equis; std::list<Equivalence> equis;
public: public:
using const_iterator = list<Equivalence>::const_iterator; using const_iterator = std::list<Equivalence>::const_iterator;
EquivalenceSet(int num); EquivalenceSet(int num);
void print(const char *prefix) const; void print(const char *prefix) const;
const_iterator const_iterator
@ -200,7 +198,7 @@ public:
} }
private: private:
bool has(const Equivalence &e) const; bool has(const Equivalence &e) const;
void addParents(const Equivalence &e, list<Equivalence> &added); void addParents(const Equivalence &e, std::list<Equivalence> &added);
}; };
/* The equivalence bundle class only encapsulates |EquivalenceSet|s /* The equivalence bundle class only encapsulates |EquivalenceSet|s
@ -212,7 +210,7 @@ private:
class EquivalenceBundle class EquivalenceBundle
{ {
vector<EquivalenceSet> bundle; std::vector<EquivalenceSet> bundle;
public: public:
EquivalenceBundle(int nmax); EquivalenceBundle(int nmax);
~EquivalenceBundle() = default; ~EquivalenceBundle() = default;

View File

@ -39,8 +39,8 @@
class SizeRefinement class SizeRefinement
{ {
vector<int> rsizes; std::vector<int> rsizes;
vector<int> ind_map; std::vector<int> ind_map;
int new_nc; int new_nc;
public: public:
SizeRefinement(const IntSequence &s, int nc, int max); SizeRefinement(const IntSequence &s, int nc, int max);

View File

@ -29,7 +29,7 @@ IntSequence::IntSequence(const Symmetry &sy, const IntSequence &se)
constructed sequence must be $(1,1)$, meaning that we picked one $y$ constructed sequence must be $(1,1)$, meaning that we picked one $y$
and one $u$. */ and one $u$. */
IntSequence::IntSequence(const Symmetry &sy, const vector<int> &se) IntSequence::IntSequence(const Symmetry &sy, const std::vector<int> &se)
: data(new int[sy.num()]), length(sy.num()), destroy(true) : data(new int[sy.num()]), length(sy.num()), destroy(true)
{ {
TL_RAISE_IF(sy.dimen() <= se[se.size()-1], TL_RAISE_IF(sy.dimen() <= se[se.size()-1],
@ -102,7 +102,7 @@ IntSequence::operator==(const IntSequence &s) const
bool bool
IntSequence::operator<(const IntSequence &s) const IntSequence::operator<(const IntSequence &s) const
{ {
int len = min(size(), s.size()); int len = std::min(size(), s.size());
int i = 0; int i = 0;
while (i < len && operator[](i) == s[i]) while (i < len && operator[](i) == s[i])

View File

@ -28,7 +28,6 @@
#include <cstring> #include <cstring>
#include <vector> #include <vector>
using namespace std;
/* The implementation of |IntSequence| is straightforward. It has a /* The implementation of |IntSequence| is straightforward. It has a
pointer |data|, a |length| of the data, and a flag |destroy|, whether pointer |data|, a |length| of the data, and a flag |destroy|, whether
@ -74,7 +73,7 @@ public:
{ {
memcpy(data, s.data+i1, sizeof(int)*length); memcpy(data, s.data+i1, sizeof(int)*length);
} }
IntSequence(const Symmetry &sy, const vector<int> &se); IntSequence(const Symmetry &sy, const std::vector<int> &se);
IntSequence(const Symmetry &sy, const IntSequence &se); IntSequence(const Symmetry &sy, const IntSequence &se);
IntSequence(int i, const IntSequence &s); IntSequence(int i, const IntSequence &s);
IntSequence(int i, const IntSequence &s, int pos); IntSequence(int i, const IntSequence &s, int pos);

View File

@ -340,7 +340,7 @@ KronProdAll::multRows(const IntSequence &irows) const
Vector *last = nullptr; Vector *last = nullptr;
ConstVector *row; ConstVector *row;
vector<Vector *> to_delete; std::vector<Vector *> to_delete;
for (int i = 0; i < dimen(); i++) for (int i = 0; i < dimen(); i++)
{ {
int j = dimen()-1-i; int j = dimen()-1-i;

View File

@ -103,13 +103,13 @@ PermutationSet::~PermutationSet()
delete [] pers; delete [] pers;
} }
vector<const Permutation *> std::vector<const Permutation *>
PermutationSet::getPreserving(const IntSequence &s) const PermutationSet::getPreserving(const IntSequence &s) const
{ {
TL_RAISE_IF(s.size() != order, TL_RAISE_IF(s.size() != order,
"Wrong sequence length in PermutationSet::getPreserving"); "Wrong sequence length in PermutationSet::getPreserving");
vector<const Permutation *> res; std::vector<const Permutation *> res;
IntSequence tmp(s.size()); IntSequence tmp(s.size());
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
@ -125,7 +125,7 @@ PermutationSet::getPreserving(const IntSequence &s) const
PermutationBundle::PermutationBundle(int nmax) PermutationBundle::PermutationBundle(int nmax)
{ {
nmax = max(nmax, 1); nmax = std::max(nmax, 1);
generateUpTo(nmax); generateUpTo(nmax);
} }

View File

@ -155,7 +155,7 @@ public:
{ {
return *(pers[i]); return *(pers[i]);
} }
vector<const Permutation *> getPreserving(const IntSequence &s) const; std::vector<const Permutation *> getPreserving(const IntSequence &s) const;
}; };
/* The permutation bundle encapsulates all permutations sets up to some /* The permutation bundle encapsulates all permutations sets up to some
@ -163,7 +163,7 @@ public:
class PermutationBundle class PermutationBundle
{ {
vector<PermutationSet *> bundle; std::vector<PermutationSet *> bundle;
public: public:
PermutationBundle(int nmax); PermutationBundle(int nmax);
~PermutationBundle(); ~PermutationBundle();

View File

@ -215,7 +215,7 @@ UPSTensor::fillFromSparseTwo(const FSSparseTensor &t, const IntSequence &ss,
} }
const PermutationSet &pset = tls.pbundle->get(coor.size()); const PermutationSet &pset = tls.pbundle->get(coor.size());
vector<const Permutation *> pp = pset.getPreserving(coor); std::vector<const Permutation *> pp = pset.getPreserving(coor);
Permutation unsort(coor); Permutation unsort(coor);
zeros(); zeros();

View File

@ -19,7 +19,7 @@
USubTensor::USubTensor(const TensorDimens &bdims, USubTensor::USubTensor(const TensorDimens &bdims,
const TensorDimens &hdims, const TensorDimens &hdims,
const FGSContainer &cont, const FGSContainer &cont,
const vector<IntSequence> &lst) const std::vector<IntSequence> &lst)
: URTensor(lst.size(), hdims.getNVX()[0], hdims.dimen()) : URTensor(lst.size(), hdims.getNVX()[0], hdims.dimen())
{ {
TL_RAISE_IF(!hdims.getNVX().isConstant(), TL_RAISE_IF(!hdims.getNVX().isConstant(),
@ -31,7 +31,7 @@ USubTensor::USubTensor(const TensorDimens &bdims,
if (it.numClasses() == hdims.dimen()) if (it.numClasses() == hdims.dimen())
{ {
Permutation per(it); Permutation per(it);
vector<const FGSTensor *> ts std::vector<const FGSTensor *> ts
= cont.fetchTensors(bdims.getSym(), it); = cont.fetchTensors(bdims.getSym(), it);
for (int i = 0; i < (int) lst.size(); i++) for (int i = 0; i < (int) lst.size(); i++)
{ {
@ -58,10 +58,10 @@ USubTensor::USubTensor(const TensorDimens &bdims,
|i|-th column. */ |i|-th column. */
void void
USubTensor::addKronColumn(int i, const vector<const FGSTensor *> &ts, USubTensor::addKronColumn(int i, const std::vector<const FGSTensor *> &ts,
const IntSequence &pindex) const IntSequence &pindex)
{ {
vector<ConstVector> tmpcols; std::vector<ConstVector> tmpcols;
int lastdim = 0; int lastdim = 0;
for (auto t : ts) for (auto t : ts)
{ {

View File

@ -54,8 +54,6 @@
#include <vector> #include <vector>
using namespace std;
/* Here we define the new tensor for representing /* Here we define the new tensor for representing
$[G]_S^{\gamma_1\ldots\gamma_l}$. It allows a construction from $[G]_S^{\gamma_1\ldots\gamma_l}$. It allows a construction from
container of folded general symmetry tensors |cont|, and set of container of folded general symmetry tensors |cont|, and set of
@ -66,8 +64,8 @@ class USubTensor : public URTensor
{ {
public: public:
USubTensor(const TensorDimens &bdims, const TensorDimens &hdims, USubTensor(const TensorDimens &bdims, const TensorDimens &hdims,
const FGSContainer &cont, const vector<IntSequence> &lst); const FGSContainer &cont, const std::vector<IntSequence> &lst);
void addKronColumn(int i, const vector<const FGSTensor *> &ts, void addKronColumn(int i, const std::vector<const FGSTensor *> &ts,
const IntSequence &pindex); const IntSequence &pindex);
}; };

View File

@ -115,7 +115,7 @@ URTensor::getOffset(const IntSequence &v) const
/* Here we construct $v_1\otimes v_2\otimes\ldots\otimes v_n$, where /* Here we construct $v_1\otimes v_2\otimes\ldots\otimes v_n$, where
$v_1,v_2,\ldots,v_n$ are stored in |vector<ConstVector>|. */ $v_1,v_2,\ldots,v_n$ are stored in |vector<ConstVector>|. */
URSingleTensor::URSingleTensor(const vector<ConstVector> &cols) URSingleTensor::URSingleTensor(const std::vector<ConstVector> &cols)
: URTensor(1, cols[0].length(), cols.size()) : URTensor(1, cols[0].length(), cols.size())
{ {
if (dimen() == 1) if (dimen() == 1)

View File

@ -131,7 +131,7 @@ public:
: URTensor(1, nvar, d) : URTensor(1, nvar, d)
{ {
} }
URSingleTensor(const vector<ConstVector> &cols); URSingleTensor(const std::vector<ConstVector> &cols);
URSingleTensor(const ConstVector &v, int d); URSingleTensor(const ConstVector &v, int d);
URSingleTensor(const URSingleTensor &ut) URSingleTensor(const URSingleTensor &ut)

View File

@ -31,8 +31,6 @@
#include <map> #include <map>
using namespace std;
// |ltseq| predicate // |ltseq| predicate
struct ltseq struct ltseq
{ {
@ -50,8 +48,8 @@ struct ltseq
class SparseTensor class SparseTensor
{ {
public: public:
using Item = pair<int, double>; using Item = std::pair<int, double>;
using Map = multimap<IntSequence, Item, ltseq>; using Map = std::multimap<IntSequence, Item, ltseq>;
using const_iterator = Map::const_iterator; using const_iterator = Map::const_iterator;
protected: protected:
using iterator = Map::iterator; using iterator = Map::iterator;

View File

@ -215,7 +215,7 @@ public:
symmetries from the given equivalence and outer symmetry. A symmetries from the given equivalence and outer symmetry. A
permutation might optionally permute the classes of the equivalence. */ permutation might optionally permute the classes of the equivalence. */
class InducedSymmetries : public vector<Symmetry> class InducedSymmetries : public std::vector<Symmetry>
{ {
public: public:
InducedSymmetries(const Equivalence &e, const Symmetry &s); InducedSymmetries(const Equivalence &e, const Symmetry &s);

View File

@ -41,7 +41,7 @@ UGSContainer::multAndAdd(const UGSTensor &t, UGSTensor &out) const
{ {
if (it.numClasses() == l) if (it.numClasses() == l)
{ {
vector<const UGSTensor *> ts std::vector<const UGSTensor *> ts
= fetchTensors(out.getSym(), it); = fetchTensors(out.getSym(), it);
KronProdAllOptim kp(l); KronProdAllOptim kp(l);
for (int i = 0; i < l; i++) for (int i = 0; i < l; i++)
@ -89,7 +89,7 @@ FGSContainer::multAndAdd(const UGSTensor &t, FGSTensor &out) const
{ {
if (it.numClasses() == l) if (it.numClasses() == l)
{ {
vector<const FGSTensor *> ts std::vector<const FGSTensor *> ts
= fetchTensors(out.getSym(), it); = fetchTensors(out.getSym(), it);
KronProdAllOptim kp(l); KronProdAllOptim kp(l);
for (int i = 0; i < l; i++) for (int i = 0; i < l; i++)
@ -106,7 +106,7 @@ FGSContainer::multAndAdd(const UGSTensor &t, FGSTensor &out) const
(excluding). If there are not |num| of such indices, the shorter vector (excluding). If there are not |num| of such indices, the shorter vector
is returned. */ is returned. */
Tensor::index Tensor::index
FGSContainer::getIndices(int num, vector<IntSequence> &out, FGSContainer::getIndices(int num, std::vector<IntSequence> &out,
const Tensor::index &start, const Tensor::index &start,
const Tensor::index &end) const Tensor::index &end)
{ {

View File

@ -96,7 +96,7 @@ class TensorContainer
protected: protected:
using _const_ptr = const _Ttype *; using _const_ptr = const _Ttype *;
using _ptr = _Ttype *; using _ptr = _Ttype *;
using _Map = map<Symmetry, _ptr, ltsym>; using _Map = std::map<Symmetry, _ptr, ltsym>;
using _mvtype = typename _Map::value_type; using _mvtype = typename _Map::value_type;
public: public:
using iterator = typename _Map::iterator; using iterator = typename _Map::iterator;
@ -262,9 +262,9 @@ public:
/* Output to the Memory Map. */ /* Output to the Memory Map. */
void void
writeMMap(map<string, ConstTwoDMatrix> &mm, const string &prefix) const writeMMap(std::map<std::string, ConstTwoDMatrix> &mm, const std::string &prefix) const
{ {
ostringstream lname; std::ostringstream lname;
for (const_iterator it = begin(); it != end(); ++it) for (const_iterator it = begin(); it != end(); ++it)
{ {
lname.str(prefix); lname.str(prefix);
@ -280,10 +280,10 @@ public:
through all equivalence classes, calculate implied symmetry, and through all equivalence classes, calculate implied symmetry, and
fetch its tensor storing it in the same order to the vector. */ fetch its tensor storing it in the same order to the vector. */
vector<_const_ptr> std::vector<_const_ptr>
fetchTensors(const Symmetry &rsym, const Equivalence &e) const fetchTensors(const Symmetry &rsym, const Equivalence &e) const
{ {
vector<_const_ptr> res(e.numClasses()); std::vector<_const_ptr> res(e.numClasses());
int i = 0; int i = 0;
for (auto it = e.begin(); for (auto it = e.begin();
it != e.end(); ++it, i++) it != e.end(); ++it, i++)
@ -377,7 +377,7 @@ public:
void multAndAdd(const FGSTensor &t, FGSTensor &out) const; void multAndAdd(const FGSTensor &t, FGSTensor &out) const;
void multAndAdd(const UGSTensor &t, FGSTensor &out) const; void multAndAdd(const UGSTensor &t, FGSTensor &out) const;
private: private:
static Tensor::index getIndices(int num, vector<IntSequence> &out, static Tensor::index getIndices(int num, std::vector<IntSequence> &out,
const Tensor::index &start, const Tensor::index &start,
const Tensor::index &end); const Tensor::index &end);
}; };

View File

@ -340,7 +340,7 @@ public:
if (_Tparent::check(Symmetry(d))) if (_Tparent::check(Symmetry(d)))
{ {
_Ttype *ten = _Tparent::get(Symmetry(d)); _Ttype *ten = _Tparent::get(Symmetry(d));
ten->mult((double) max((d-k), 0)); ten->mult((double) std::max((d-k), 0));
} }
} }
} }

View File

@ -21,9 +21,9 @@
#include <sstream> #include <sstream>
DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false) DynamicModelDLL::DynamicModelDLL(const std::string &modName) noexcept(false)
{ {
string fName; std::string fName;
#if !defined(__CYGWIN32__) && !defined(_WIN32) #if !defined(__CYGWIN32__) && !defined(_WIN32)
fName = "./"; fName = "./";
#endif #endif
@ -57,7 +57,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false)
dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW); dynamicHinstance = dlopen(fName.c_str(), RTLD_NOW);
if (dynamicHinstance == nullptr) if (dynamicHinstance == nullptr)
{ {
cerr << dlerror() << endl; std::cerr << dlerror() << std::endl;
throw 1; throw 1;
} }
ntt = (int *) dlsym(dynamicHinstance, "ntt"); ntt = (int *) dlsym(dynamicHinstance, "ntt");
@ -76,7 +76,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false)
|| dynamic_g3_tt == nullptr || dynamic_g3 == nullptr) || dynamic_g3_tt == nullptr || dynamic_g3 == nullptr)
{ {
dlclose(dynamicHinstance); // Free the library dlclose(dynamicHinstance); // Free the library
cerr << dlerror() << endl; std::cerr << dlerror() << std::endl;
throw 2; throw 2;
} }
#endif #endif
@ -84,7 +84,7 @@ DynamicModelDLL::DynamicModelDLL(const string &modName) noexcept(false)
} }
catch (int i) catch (int i)
{ {
ostringstream msg; std::ostringstream msg;
msg << "Error when loading " << fName << " ("; msg << "Error when loading " << fName << " (";
if (i == 1) if (i == 1)
msg << "can't dynamically load the file"; msg << "can't dynamically load the file";
@ -105,7 +105,7 @@ DynamicModelDLL::~DynamicModelDLL()
auto result = FreeLibrary(dynamicHinstance); auto result = FreeLibrary(dynamicHinstance);
if (result == 0) if (result == 0)
{ {
cerr << "Can't free the *_dynamic DLL" << endl; std::cerr << "Can't free the *_dynamic DLL" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#else #else

View File

@ -61,7 +61,7 @@ private:
public: public:
// construct and load Dynamic model DLL // construct and load Dynamic model DLL
explicit DynamicModelDLL(const string &fname) noexcept(false); explicit DynamicModelDLL(const std::string &fname) noexcept(false);
virtual ~DynamicModelDLL(); virtual ~DynamicModelDLL();
void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady, void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady,

View File

@ -19,7 +19,7 @@
#include "dynamic_m.hh" #include "dynamic_m.hh"
DynamicModelMFile::DynamicModelMFile(const string &modName) noexcept(false) : DynamicModelMFile::DynamicModelMFile(const std::string &modName) noexcept(false) :
DynamicMFilename{modName + ".dynamic"} DynamicMFilename{modName + ".dynamic"}
{ {
} }

View File

@ -32,11 +32,11 @@
class DynamicModelMFile : public DynamicModelAC class DynamicModelMFile : public DynamicModelAC
{ {
private: private:
const string DynamicMFilename; const std::string DynamicMFilename;
const static int nlhs_dynamic = 4; const static int nlhs_dynamic = 4;
const static int nrhs_dynamic = 5; const static int nrhs_dynamic = 5;
public: public:
explicit DynamicModelMFile(const string &modName) noexcept(false); explicit DynamicModelMFile(const std::string &modName) noexcept(false);
virtual ~DynamicModelMFile() = default; virtual ~DynamicModelMFile() = default;
void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady, void eval(const Vector &y, const Vector &x, const Vector &params, const Vector &ySteady,
Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false); Vector &residual, TwoDMatrix *g1, TwoDMatrix *g2, TwoDMatrix *g3) noexcept(false);

View File

@ -33,13 +33,13 @@
/* Dynare DynamicModel class */ /* Dynare DynamicModel class */
/**************************************************************************************/ /**************************************************************************************/
KordpDynare::KordpDynare(const vector<string> &endo, int num_endo, KordpDynare::KordpDynare(const std::vector<std::string> &endo, int num_endo,
const vector<string> &exo, int nexog, int npar, const std::vector<std::string> &exo, int nexog, int npar,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder, const int nsteps, int norder,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol, Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium) noexcept(false) : const std::vector<int> &var_order, const TwoDMatrix &llincidence, double criterium) noexcept(false) :
nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar}, nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar},
nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps}, nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps},
nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov}, nOrder{norder}, journal{jr}, ySteady{ysteady}, params{inParams}, vCov{vcov},
@ -54,13 +54,13 @@ KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
md.insert(new FSSparseTensor(iord, nY+nYs+nYss+nExog, nY)); md.insert(new FSSparseTensor(iord, nY+nYs+nYss+nExog, nY));
} }
KordpDynare::KordpDynare(const vector<string> &endo, int num_endo, KordpDynare::KordpDynare(const std::vector<std::string> &endo, int num_endo,
const vector<string> &exo, int nexog, int npar, const std::vector<std::string> &exo, int nexog, int npar,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat, Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd, int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder, const int nsteps, int norder,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol, Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium, const std::vector<int> &var_order, const TwoDMatrix &llincidence, double criterium,
TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false) : TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false) :
nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar}, nStat{nstat}, nBoth{nboth}, nPred{npred}, nForw{nforw}, nExog{nexog}, nPar{npar},
nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps}, nYs{npred + nboth}, nYss{nboth + nforw}, nY{num_endo}, nJcols{jcols}, NNZD{nnzd}, nSteps{nsteps},
@ -159,7 +159,7 @@ KordpDynare::calcDerivativesAtSteady()
* populateDerivatives to sparse Tensor and fit it in the Derivatives Container * populateDerivatives to sparse Tensor and fit it in the Derivatives Container
*******************************************************************************/ *******************************************************************************/
void void
KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const vector<int> &vOrder) KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const std::vector<int> &vOrder)
{ {
// model derivatives FSSparseTensor instance // model derivatives FSSparseTensor instance
FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY)); FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY));
@ -186,7 +186,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve
else if (ord == 2) else if (ord == 2)
{ {
int nJcols1 = nJcols-nExog; int nJcols1 = nJcols-nExog;
vector<int> revOrder(nJcols1); std::vector<int> revOrder(nJcols1);
for (int i = 0; i < nJcols1; i++) for (int i = 0; i < nJcols1; i++)
revOrder[vOrder[i]] = i; revOrder[vOrder[i]] = i;
for (int i = 0; i < g.nrows(); i++) for (int i = 0; i < g.nrows(); i++)
@ -216,7 +216,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve
{ {
int nJcols1 = nJcols-nExog; int nJcols1 = nJcols-nExog;
int nJcols2 = nJcols*nJcols; int nJcols2 = nJcols*nJcols;
vector<int> revOrder(nJcols1); std::vector<int> revOrder(nJcols1);
for (int i = 0; i < nJcols1; i++) for (int i = 0; i < nJcols1; i++)
revOrder[vOrder[i]] = i; revOrder[vOrder[i]] = i;
for (int i = 0; i < g.nrows(); i++) for (int i = 0; i < g.nrows(); i++)
@ -311,7 +311,7 @@ KordpDynare::ReorderDynareJacobianIndices() noexcept(false)
// create temporary square 2D matrix size nEndo x nEndo (sparse) // create temporary square 2D matrix size nEndo x nEndo (sparse)
// for the lag, current and lead blocks of the jacobian // for the lag, current and lead blocks of the jacobian
JacobianIndices.resize(nJcols); JacobianIndices.resize(nJcols);
vector <int> tmp(nY); std::vector<int> tmp(nY);
int i, j, rjoff = nJcols-nExog-1; int i, j, rjoff = nJcols-nExog-1;
for (int ll_row = 0; ll_row < ll_Incidence.nrows(); ll_row++) for (int ll_row = 0; ll_row < ll_Incidence.nrows(); ll_row++)
@ -341,7 +341,7 @@ KordpDynare::ReorderDynareJacobianIndices() noexcept(false)
/* DynareNameList class */ /* DynareNameList class */
/**************************************************************************************/ /**************************************************************************************/
DynareNameList::DynareNameList(const KordpDynare &dynare, const vector<string> &names_arg) : names(names_arg) DynareNameList::DynareNameList(const KordpDynare &dynare, const std::vector<std::string> &names_arg) : names(names_arg)
{ {
} }
@ -349,7 +349,7 @@ DynareStateNameList::DynareStateNameList(const KordpDynare &dynare, const Dynare
const DynareNameList &denl) const DynareNameList &denl)
{ {
for (int i = 0; i < dynare.nys(); i++) for (int i = 0; i < dynare.nys(); i++)
names.push_back(string{dnl.getName(i+dynare.nstat())}); names.push_back(std::string{dnl.getName(i+dynare.nstat())});
for (int i = 0; i < dynare.nexog(); i++) for (int i = 0; i < dynare.nexog(); i++)
names.push_back(string{denl.getName(i)}); names.push_back(std::string{denl.getName(i)});
} }

View File

@ -42,9 +42,9 @@ class KordpDynare;
/*////////////////////////////////////////////*/ /*////////////////////////////////////////////*/
class DynareNameList : public NameList class DynareNameList : public NameList
{ {
vector<string> names; std::vector<std::string> names;
public: public:
DynareNameList(const KordpDynare &dynare, const vector<string> &names_arg); DynareNameList(const KordpDynare &dynare, const std::vector<std::string> &names_arg);
int int
getNum() const getNum() const
{ {
@ -59,7 +59,7 @@ public:
class DynareStateNameList : public NameList class DynareStateNameList : public NameList
{ {
vector<string> names; std::vector<std::string> names;
public: public:
DynareStateNameList(const KordpDynare &dynare, const DynareNameList &dnl, DynareStateNameList(const KordpDynare &dynare, const DynareNameList &dnl,
const DynareNameList &denl); const DynareNameList &denl);
@ -110,30 +110,30 @@ class KordpDynare : public DynamicModel
DynareNameList dnl, denl; DynareNameList dnl, denl;
DynareStateNameList dsnl; DynareStateNameList dsnl;
const double ss_tol; const double ss_tol;
const vector<int> &varOrder; const std::vector<int> &varOrder;
const TwoDMatrix &ll_Incidence; const TwoDMatrix &ll_Incidence;
double qz_criterium; double qz_criterium;
vector<int> JacobianIndices; std::vector<int> JacobianIndices;
TwoDMatrix *g1p; TwoDMatrix *g1p;
TwoDMatrix *g2p; TwoDMatrix *g2p;
TwoDMatrix *g3p; TwoDMatrix *g3p;
public: public:
KordpDynare(const vector<string> &endo, int num_endo, KordpDynare(const std::vector<std::string> &endo, int num_endo,
const vector<string> &exo, int num_exo, int num_par, const std::vector<std::string> &exo, int num_exo, int num_par,
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred, Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD, int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord, const int nSteps, const int ord,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol, Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence, const std::vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium) noexcept(false); double qz_criterium) noexcept(false);
KordpDynare(const vector<string> &endo, int num_endo, KordpDynare(const std::vector<std::string> &endo, int num_endo,
const vector<string> &exo, int num_exo, int num_par, const std::vector<std::string> &exo, int num_exo, int num_par,
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred, Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD, int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord, const int nSteps, const int ord,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol, Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence, const std::vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false); double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false);
virtual ~KordpDynare(); virtual ~KordpDynare();
@ -234,7 +234,7 @@ public:
void evaluateSystem(Vector &out, const ConstVector &yym, const ConstVector &yy, void evaluateSystem(Vector &out, const ConstVector &yym, const ConstVector &yy,
const ConstVector &yyp, const Vector &xx) noexcept(false); const ConstVector &yyp, const Vector &xx) noexcept(false);
void calcDerivativesAtSteady(); void calcDerivativesAtSteady();
unique_ptr<DynamicModelAC> dynamicModelFile; std::unique_ptr<DynamicModelAC> dynamicModelFile;
DynamicModel * DynamicModel *
clone() const clone() const
{ {
@ -245,7 +245,7 @@ public:
private: private:
void ReorderDynareJacobianIndices() noexcept(false); void ReorderDynareJacobianIndices() noexcept(false);
void populateDerivativesContainer(const TwoDMatrix &g, int ord, const vector<int> &vOrder); void populateDerivativesContainer(const TwoDMatrix &g, int ord, const std::vector<int> &vOrder);
}; };
#endif #endif

View File

@ -49,7 +49,7 @@
// hence a rather low level approach is needed // hence a rather low level approach is needed
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
void void
DynareMxArrayToString(const mxArray *mxFldp, const int len, const int width, vector<string> &out) DynareMxArrayToString(const mxArray *mxFldp, const int len, const int width, std::vector<std::string> &out)
{ {
char *cNamesCharStr = mxArrayToString(mxFldp); char *cNamesCharStr = mxArrayToString(mxFldp);
@ -91,7 +91,7 @@ extern "C" {
if (!mxIsChar(mFname)) if (!mxIsChar(mFname))
DYN_MEX_FUNC_ERR_MSG_TXT("Input must be of type char."); DYN_MEX_FUNC_ERR_MSG_TXT("Input must be of type char.");
string fName = mxArrayToString(mFname); std::string fName = mxArrayToString(mFname);
int kOrder; int kOrder;
mxArray *mxFldp = mxGetField(options_, 0, "order"); mxArray *mxFldp = mxGetField(options_, 0, "order");
@ -152,7 +152,7 @@ extern "C" {
if (npar != nEndo) if (npar != nEndo)
DYN_MEX_FUNC_ERR_MSG_TXT("Incorrect number of input var_order vars."); DYN_MEX_FUNC_ERR_MSG_TXT("Incorrect number of input var_order vars.");
vector<int> var_order_vp(nEndo); std::vector<int> var_order_vp(nEndo);
for (int v = 0; v < nEndo; v++) for (int v = 0; v < nEndo; v++)
var_order_vp[v] = (int) (*(dparams++)); var_order_vp[v] = (int) (*(dparams++));
@ -164,7 +164,7 @@ extern "C" {
TwoDMatrix llincidence(nrows, npar, Vector{mxFldp}); TwoDMatrix llincidence(nrows, npar, Vector{mxFldp});
if (npar != nEndo) if (npar != nEndo)
{ {
ostringstream strstrm; std::ostringstream strstrm;
strstrm << "dynare:k_order_perturbation " << "Incorrect length of lead lag incidences: ncol=" << npar << " != nEndo=" << nEndo; strstrm << "dynare:k_order_perturbation " << "Incorrect length of lead lag incidences: ncol=" << npar << " != nEndo=" << nEndo;
DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str()); DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str());
} }
@ -179,13 +179,13 @@ extern "C" {
mxFldp = mxGetField(M_, 0, "var_order_endo_names"); mxFldp = mxGetField(M_, 0, "var_order_endo_names");
const int nendo = (int) mxGetM(mxFldp); const int nendo = (int) mxGetM(mxFldp);
const int widthEndo = (int) mxGetN(mxFldp); const int widthEndo = (int) mxGetN(mxFldp);
vector<string> endoNames; std::vector<std::string> endoNames;
DynareMxArrayToString(mxFldp, nendo, widthEndo, endoNames); DynareMxArrayToString(mxFldp, nendo, widthEndo, endoNames);
mxFldp = mxGetField(M_, 0, "exo_names"); mxFldp = mxGetField(M_, 0, "exo_names");
const int nexo = (int) mxGetM(mxFldp); const int nexo = (int) mxGetM(mxFldp);
const int widthExog = (int) mxGetN(mxFldp); const int widthExog = (int) mxGetN(mxFldp);
vector<string> exoNames; std::vector<std::string> exoNames;
DynareMxArrayToString(mxFldp, nexo, widthExog, exoNames); DynareMxArrayToString(mxFldp, nexo, widthExog, exoNames);
if ((nEndo != nendo) || (nExog != nexo)) if ((nEndo != nendo) || (nExog != nexo))
@ -227,11 +227,11 @@ extern "C" {
jName += ".jnl"; jName += ".jnl";
Journal journal(jName.c_str()); Journal journal(jName.c_str());
unique_ptr<DynamicModelAC> dynamicModelFile; std::unique_ptr<DynamicModelAC> dynamicModelFile;
if (use_dll == 1) if (use_dll == 1)
dynamicModelFile = make_unique<DynamicModelDLL>(fName); dynamicModelFile = std::make_unique<DynamicModelDLL>(fName);
else else
dynamicModelFile = make_unique<DynamicModelMFile>(fName); dynamicModelFile = std::make_unique<DynamicModelMFile>(fName);
// intiate tensor library // intiate tensor library
tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog); tls.init(kOrder, nStat+2*nPred+3*nBoth+2*nForw+nExog);
@ -239,7 +239,7 @@ extern "C" {
// make KordpDynare object // make KordpDynare object
KordpDynare dynare(endoNames, nEndo, exoNames, nExog, nPar, KordpDynare dynare(endoNames, nEndo, exoNames, nExog, nPar,
ySteady, vCov, modParams, nStat, nPred, nForw, nBoth, ySteady, vCov, modParams, nStat, nPred, nForw, nBoth,
jcols, NNZD, nSteps, kOrder, journal, move(dynamicModelFile), jcols, NNZD, nSteps, kOrder, journal, std::move(dynamicModelFile),
sstol, var_order_vp, llincidence, qz_criterium, sstol, var_order_vp, llincidence, qz_criterium,
g1m, g2m, g3m); g1m, g2m, g3m);
@ -250,8 +250,8 @@ extern "C" {
app.walkStochSteady(); app.walkStochSteady();
/* Write derivative outputs into memory map */ /* Write derivative outputs into memory map */
map<string, ConstTwoDMatrix> mm; std::map<std::string, ConstTwoDMatrix> mm;
app.getFoldDecisionRule().writeMMap(mm, string()); app.getFoldDecisionRule().writeMMap(mm, std::string());
// get latest ysteady // get latest ysteady
ySteady = dynare.getSteady(); ySteady = dynare.getSteady();
@ -259,7 +259,7 @@ extern "C" {
if (kOrder == 1) if (kOrder == 1)
{ {
/* Set the output pointer to the output matrix ysteady. */ /* Set the output pointer to the output matrix ysteady. */
map<string, ConstTwoDMatrix>::const_iterator cit = mm.begin(); auto cit = mm.begin();
++cit; ++cit;
plhs[1] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL); plhs[1] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL);
@ -271,7 +271,7 @@ extern "C" {
if (kOrder >= 2) if (kOrder >= 2)
{ {
int ii = 1; int ii = 1;
for (map<string, ConstTwoDMatrix>::const_iterator cit = mm.begin(); for (auto cit = mm.begin();
((cit != mm.end()) && (ii < nlhs)); ++cit) ((cit != mm.end()) && (ii < nlhs)); ++cit)
{ {
plhs[ii] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL); plhs[ii] = mxCreateDoubleMatrix((*cit).second.numRows(), (*cit).second.numCols(), mxREAL);
@ -312,7 +312,7 @@ extern "C" {
catch (const KordException &e) catch (const KordException &e)
{ {
e.print(); e.print();
ostringstream strstrm; std::ostringstream strstrm;
strstrm << "dynare:k_order_perturbation: Caught Kord exception: " << e.get_message(); strstrm << "dynare:k_order_perturbation: Caught Kord exception: " << e.get_message();
DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str()); DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str());
} }
@ -328,13 +328,13 @@ extern "C" {
} }
catch (const DynareException &e) catch (const DynareException &e)
{ {
ostringstream strstrm; std::ostringstream strstrm;
strstrm << "dynare:k_order_perturbation: Caught KordDynare exception: " << e.message(); strstrm << "dynare:k_order_perturbation: Caught KordDynare exception: " << e.message();
DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str()); DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str());
} }
catch (const ogu::Exception &e) catch (const ogu::Exception &e)
{ {
ostringstream strstrm; std::ostringstream strstrm;
strstrm << "dynare:k_order_perturbation: Caught general exception: " << e.message(); strstrm << "dynare:k_order_perturbation: Caught general exception: " << e.message();
DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str()); DYN_MEX_FUNC_ERR_MSG_TXT(strstrm.str().c_str());
} }