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. */
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())
{
// todo: raise

View File

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

View File

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

View File

@ -22,8 +22,8 @@
struct QuadParams
{
string outname;
string vcovname;
std::string outname;
std::string vcovname;
int max_level{3};
double discard_weight{0.0};
QuadParams(int argc, char **argv);
@ -60,7 +60,7 @@ QuadParams::QuadParams(int argc, char **argv)
case opt_max_level:
try
{
max_level = std::stoi(string{optarg});
max_level = std::stoi(std::string{optarg});
}
catch (const std::invalid_argument &e)
{
@ -70,7 +70,7 @@ QuadParams::QuadParams(int argc, char **argv)
case opt_discard_weight:
try
{
discard_weight = std::stod(string{optarg});
discard_weight = std::stod(std::string{optarg});
}
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
class WallTimer
{
string mes;
std::string mes;
std::chrono::time_point<std::chrono::high_resolution_clock> start;
bool new_line;
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}
{
}
@ -189,10 +189,10 @@ public:
class TestRunnable
{
public:
const string name;
const std::string name;
int dim; // dimension 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)
{
}
@ -211,7 +211,7 @@ protected:
bool
TestRunnable::test() const
{
cout << "Running test <" << name << ">" << endl;
std::cout << "Running test <" << name << ">" << std::endl;
bool passed;
{
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
UNormalMoments moments(imom, msq);
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;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class Dynare;
class DynareNameList : public NameList
{
vector<const char *> names;
std::vector<const char *> names;
public:
DynareNameList(const Dynare &dynare);
int
@ -36,12 +36,12 @@ public:
/** This for each string of the input vector calculates its index
* in the names. And returns the resulting vector of indices. If
* 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
{
vector<const char *> names;
std::vector<const char *> names;
public:
DynareExogNameList(const Dynare &dynare);
int
@ -58,7 +58,7 @@ public:
class DynareStateNameList : public NameList
{
vector<const char *> names;
std::vector<const char *> names;
public:
DynareStateNameList(const Dynare &dynare, const DynareNameList &dnl,
const DynareExogNameList &denl);

View File

@ -43,7 +43,7 @@ main(int argc, char **argv)
// make dynare object
Dynare dynare(params.modname, params.order, params.ss_tol, journal);
// 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)
for (int i = 0; i < dynare.nexog(); i++)
irf_list_ind.push_back(i);

View File

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

View File

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

View File

@ -39,8 +39,8 @@
class SizeRefinement
{
vector<int> rsizes;
vector<int> ind_map;
std::vector<int> rsizes;
std::vector<int> ind_map;
int new_nc;
public:
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$
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)
{
TL_RAISE_IF(sy.dimen() <= se[se.size()-1],
@ -102,7 +102,7 @@ IntSequence::operator==(const IntSequence &s) const
bool
IntSequence::operator<(const IntSequence &s) const
{
int len = min(size(), s.size());
int len = std::min(size(), s.size());
int i = 0;
while (i < len && operator[](i) == s[i])

View File

@ -28,7 +28,6 @@
#include <cstring>
#include <vector>
using namespace std;
/* The implementation of |IntSequence| is straightforward. It has a
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);
}
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(int i, const IntSequence &s);
IntSequence(int i, const IntSequence &s, int pos);

View File

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

View File

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

View File

@ -155,7 +155,7 @@ public:
{
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
@ -163,7 +163,7 @@ public:
class PermutationBundle
{
vector<PermutationSet *> bundle;
std::vector<PermutationSet *> bundle;
public:
PermutationBundle(int nmax);
~PermutationBundle();

View File

@ -215,7 +215,7 @@ UPSTensor::fillFromSparseTwo(const FSSparseTensor &t, const IntSequence &ss,
}
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);
zeros();

View File

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

View File

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

View File

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

View File

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

View File

@ -215,7 +215,7 @@ public:
symmetries from the given equivalence and outer symmetry. A
permutation might optionally permute the classes of the equivalence. */
class InducedSymmetries : public vector<Symmetry>
class InducedSymmetries : public std::vector<Symmetry>
{
public:
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)
{
vector<const UGSTensor *> ts
std::vector<const UGSTensor *> ts
= fetchTensors(out.getSym(), it);
KronProdAllOptim kp(l);
for (int i = 0; i < l; i++)
@ -89,7 +89,7 @@ FGSContainer::multAndAdd(const UGSTensor &t, FGSTensor &out) const
{
if (it.numClasses() == l)
{
vector<const FGSTensor *> ts
std::vector<const FGSTensor *> ts
= fetchTensors(out.getSym(), it);
KronProdAllOptim kp(l);
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
is returned. */
Tensor::index
FGSContainer::getIndices(int num, vector<IntSequence> &out,
FGSContainer::getIndices(int num, std::vector<IntSequence> &out,
const Tensor::index &start,
const Tensor::index &end)
{

View File

@ -96,7 +96,7 @@ class TensorContainer
protected:
using _const_ptr = const _Ttype *;
using _ptr = _Ttype *;
using _Map = map<Symmetry, _ptr, ltsym>;
using _Map = std::map<Symmetry, _ptr, ltsym>;
using _mvtype = typename _Map::value_type;
public:
using iterator = typename _Map::iterator;
@ -262,9 +262,9 @@ public:
/* Output to the Memory Map. */
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)
{
lname.str(prefix);
@ -280,10 +280,10 @@ public:
through all equivalence classes, calculate implied symmetry, and
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
{
vector<_const_ptr> res(e.numClasses());
std::vector<_const_ptr> res(e.numClasses());
int i = 0;
for (auto it = e.begin();
it != e.end(); ++it, i++)
@ -377,7 +377,7 @@ public:
void multAndAdd(const FGSTensor &t, FGSTensor &out) const;
void multAndAdd(const UGSTensor &t, FGSTensor &out) const;
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 &end);
};

View File

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

View File

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

View File

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

View File

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

View File

@ -33,13 +33,13 @@
/* Dynare DynamicModel class */
/**************************************************************************************/
KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
const vector<string> &exo, int nexog, int npar,
KordpDynare::KordpDynare(const std::vector<std::string> &endo, int num_endo,
const std::vector<std::string> &exo, int nexog, int npar,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium) noexcept(false) :
Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
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},
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},
@ -54,13 +54,13 @@ KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
md.insert(new FSSparseTensor(iord, nY+nYs+nYss+nExog, nY));
}
KordpDynare::KordpDynare(const vector<string> &endo, int num_endo,
const vector<string> &exo, int nexog, int npar,
KordpDynare::KordpDynare(const std::vector<std::string> &endo, int num_endo,
const std::vector<std::string> &exo, int nexog, int npar,
Vector &ysteady, TwoDMatrix &vcov, Vector &inParams, int nstat,
int npred, int nforw, int nboth, const int jcols, const Vector &nnzd,
const int nsteps, int norder,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &var_order, const TwoDMatrix &llincidence, double criterium,
Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const std::vector<int> &var_order, const TwoDMatrix &llincidence, double criterium,
TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false) :
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},
@ -159,7 +159,7 @@ KordpDynare::calcDerivativesAtSteady()
* populateDerivatives to sparse Tensor and fit it in the Derivatives Container
*******************************************************************************/
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
FSSparseTensor *mdTi = (new FSSparseTensor(ord, nJcols, nY));
@ -186,7 +186,7 @@ KordpDynare::populateDerivativesContainer(const TwoDMatrix &g, int ord, const ve
else if (ord == 2)
{
int nJcols1 = nJcols-nExog;
vector<int> revOrder(nJcols1);
std::vector<int> revOrder(nJcols1);
for (int i = 0; i < nJcols1; i++)
revOrder[vOrder[i]] = 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 nJcols2 = nJcols*nJcols;
vector<int> revOrder(nJcols1);
std::vector<int> revOrder(nJcols1);
for (int i = 0; i < nJcols1; i++)
revOrder[vOrder[i]] = 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)
// for the lag, current and lead blocks of the jacobian
JacobianIndices.resize(nJcols);
vector <int> tmp(nY);
std::vector<int> tmp(nY);
int i, j, rjoff = nJcols-nExog-1;
for (int ll_row = 0; ll_row < ll_Incidence.nrows(); ll_row++)
@ -341,7 +341,7 @@ KordpDynare::ReorderDynareJacobianIndices() noexcept(false)
/* 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)
{
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++)
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
{
vector<string> names;
std::vector<std::string> names;
public:
DynareNameList(const KordpDynare &dynare, const vector<string> &names_arg);
DynareNameList(const KordpDynare &dynare, const std::vector<std::string> &names_arg);
int
getNum() const
{
@ -59,7 +59,7 @@ public:
class DynareStateNameList : public NameList
{
vector<string> names;
std::vector<std::string> names;
public:
DynareStateNameList(const KordpDynare &dynare, const DynareNameList &dnl,
const DynareNameList &denl);
@ -110,30 +110,30 @@ class KordpDynare : public DynamicModel
DynareNameList dnl, denl;
DynareStateNameList dsnl;
const double ss_tol;
const vector<int> &varOrder;
const std::vector<int> &varOrder;
const TwoDMatrix &ll_Incidence;
double qz_criterium;
vector<int> JacobianIndices;
std::vector<int> JacobianIndices;
TwoDMatrix *g1p;
TwoDMatrix *g2p;
TwoDMatrix *g3p;
public:
KordpDynare(const vector<string> &endo, int num_endo,
const vector<string> &exo, int num_exo, int num_par,
KordpDynare(const std::vector<std::string> &endo, int num_endo,
const std::vector<std::string> &exo, int num_exo, int num_par,
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const std::vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium) noexcept(false);
KordpDynare(const vector<string> &endo, int num_endo,
const vector<string> &exo, int num_exo, int num_par,
KordpDynare(const std::vector<std::string> &endo, int num_endo,
const std::vector<std::string> &exo, int num_exo, int num_par,
Vector &ySteady, TwoDMatrix &vCov, Vector &params, int nstat, int nPred,
int nforw, int nboth, const int nJcols, const Vector &NNZD,
const int nSteps, const int ord,
Journal &jr, unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
Journal &jr, std::unique_ptr<DynamicModelAC> dynamicModelFile_arg, double sstol,
const std::vector<int> &varOrder, const TwoDMatrix &ll_Incidence,
double qz_criterium, TwoDMatrix *g1_arg, TwoDMatrix *g2_arg, TwoDMatrix *g3_arg) noexcept(false);
virtual ~KordpDynare();
@ -234,7 +234,7 @@ public:
void evaluateSystem(Vector &out, const ConstVector &yym, const ConstVector &yy,
const ConstVector &yyp, const Vector &xx) noexcept(false);
void calcDerivativesAtSteady();
unique_ptr<DynamicModelAC> dynamicModelFile;
std::unique_ptr<DynamicModelAC> dynamicModelFile;
DynamicModel *
clone() const
{
@ -245,7 +245,7 @@ public:
private:
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

View File

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