Global reindentation of Dynare++

parent 24a2aa2a
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -109,10 +109,10 @@ public:
See QuadratureImpl class declaration for details. */
template <typename _Tpit>
template<typename _Tpit>
class QuadratureImpl;
template <typename _Tpit>
template<typename _Tpit>
class IntegrationWorker : public sthread::detach_thread
{
const QuadratureImpl<_Tpit> &quad;
......@@ -168,7 +168,7 @@ public:
In addition, we define a method which saves all the points to a given file.
Only for debugging purposes. */
template <typename _Tpit>
template<typename _Tpit>
class QuadratureImpl : public Quadrature
{
friend class IntegrationWorker<_Tpit>;
......@@ -257,7 +257,7 @@ class OneDPrecalcQuadrature : public OneDQuadrature
public:
OneDPrecalcQuadrature(int nlevels, const int *npoints,
const double *wts, const double *pts)
: num_levels(nlevels), num_points(npoints),
: num_levels(nlevels), num_points(npoints),
weights(wts), points(pts), offsets(num_levels)
{
calcOffsets();
......
......@@ -106,25 +106,26 @@ RadicalInverse::print() const
/* Here we have the first 170 primes. This means that we are not able to
integrate dimensions greater than 170. */
std::array<int, 170> HaltonSequence::primes = {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013
};
std::array<int, 170> HaltonSequence::primes =
{
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013
};
/* This takes first ‘dim’ primes and constructs ‘dim’ radical inverses and
calls eval(). */
......@@ -145,7 +146,7 @@ HaltonSequence::HaltonSequence(int n, int mxn, int dim, const PermutationScheme
void
HaltonSequence::increase()
{
for (auto & i : ri)
for (auto &i : ri)
i.increase();
num++;
if (num <= maxn)
......@@ -165,7 +166,7 @@ void
HaltonSequence::print() const
{
auto ff = std::cout.flags();
for (const auto & i : ri)
for (const auto &i : ri)
i.print();
std::cout << "point=[ "
<< std::fixed << std::setprecision(6);
......
......@@ -70,7 +70,6 @@ VectorFunctionSet::VectorFunctionSet(VectorFunction &f, int n)
}
}
/* Here we construct the object from the given function f and given
variance-covariance matrix Σ=vcov. The matrix A is calculated as lower
triangular and yields Σ=AAᵀ. */
......
......@@ -47,7 +47,7 @@ struct QuadParams
QuadParams(int argc, char **argv);
void check_consistency() const;
private:
enum class opt {max_level, discard_weight, vcov};
enum class opt { max_level, discard_weight, vcov };
};
QuadParams::QuadParams(int argc, char **argv)
......@@ -62,11 +62,11 @@ QuadParams::QuadParams(int argc, char **argv)
outname = argv[argc-1];
argc--;
struct option const opts [] = {
{"max-level", required_argument, nullptr, static_cast<int>(opt::max_level)},
{"discard-weight", required_argument, nullptr, static_cast<int>(opt::discard_weight)},
{"vcov", required_argument, nullptr, static_cast<int>(opt::vcov)},
{nullptr, 0, nullptr, 0}
struct option const opts[] = {
{"max-level", required_argument, nullptr, static_cast<int>(opt::max_level)},
{"discard-weight", required_argument, nullptr, static_cast<int>(opt::discard_weight)},
{"vcov", required_argument, nullptr, static_cast<int>(opt::vcov)},
{nullptr, 0, nullptr, 0}
};
int ret;
......@@ -188,7 +188,7 @@ main(int argc, char **argv)
// Calculate weights and mass
double mass = 0.0;
std::vector<double> weights;
for (auto & point : points)
for (auto &point : points)
{
weights.push_back(std::exp(-point->dot(*point)));
mass += weights.back();
......
......@@ -177,7 +177,7 @@ Function1Trans::eval(const Vector &point, const ParameterSignal &sig, Vector &ou
}
/* WallTimer class. Constructor saves the wall time, destructor cancels the
current time from the saved, and prints the message with time information */
current time from the saved, and prints the message with time information */
class WallTimer
{
std::string mes;
......
......@@ -51,7 +51,7 @@ Approximation::Approximation(DynamicModel &m, Journal &j, int ns, bool dr_centr,
: model(m), journal(j),
ypart(model.nstat(), model.npred(), model.nboth(), model.nforw()),
mom(UNormalMoments(model.order(), model.getVcov())),
nvs{ypart.nys(), model.nexog(), model.nexog(), 1 },
nvs{ypart.nys(), model.nexog(), model.nexog(), 1},
steps(ns),
dr_centralize(dr_centr), qz_criterium(qz_crit), ss(ypart.ny(), steps+1)
{
......@@ -184,7 +184,7 @@ Approximation::walkStochSteady()
dy.add(-1.0, last_steady);
StochForwardDerivs<Storage::fold> hh(ypart, model.nexog(), *rule_ders_ss, mom, dy,
dsigma, sigma_so_far);
dsigma, sigma_so_far);
JournalRecord rec1(journal);
rec1 << "Calculation of g** expectations done" << endrec;
......
......@@ -34,7 +34,7 @@
// FoldDecisionRule conversion from UnfoldDecisionRule
FoldDecisionRule::FoldDecisionRule(const UnfoldDecisionRule &udr)
: DecisionRuleImpl<Storage::fold>(ctraits<Storage::fold>::Tpol(udr.nrows(), udr.nvars()),
udr.ypart, udr.nu, udr.ysteady)
udr.ypart, udr.nu, udr.ysteady)
{
for (const auto &it : udr)
insert(std::make_unique<ctraits<Storage::fold>::Ttensym>(*(it.second)));
......@@ -43,7 +43,7 @@ FoldDecisionRule::FoldDecisionRule(const UnfoldDecisionRule &udr)
// UnfoldDecisionRule conversion from FoldDecisionRule
UnfoldDecisionRule::UnfoldDecisionRule(const FoldDecisionRule &fdr)
: DecisionRuleImpl<Storage::unfold>(ctraits<Storage::unfold>::Tpol(fdr.nrows(), fdr.nvars()),
fdr.ypart, fdr.nu, fdr.ysteady)
fdr.ypart, fdr.nu, fdr.ysteady)
{
for (const auto &it : fdr)
insert(std::make_unique<ctraits<Storage::unfold>::Ttensym>(*(it.second)));
......
......@@ -75,7 +75,7 @@ public:
virtual void eval(emethod em, Vector &out, const ConstVector &v) const = 0;
/* makes only one step of simulation (in terms of absolute values, not
deviations) */
deviations) */
virtual void evaluate(emethod em, Vector &out, const ConstVector &ys,
const ConstVector &u) const = 0;
......@@ -120,7 +120,7 @@ public:
Storage::unfold. So, there are two implementations of the DecisionRule
interface. */
template <Storage t>
template<Storage t>
class DecisionRuleImpl : public ctraits<t>::Tpol, public DecisionRule
{
protected:
......@@ -220,7 +220,7 @@ public:
So we go through i+j=d=0…q and in each loop we form the fully symmetric
tensor [g_(yu)ᵈ] and insert it to the container. */
template <Storage t>
template<Storage t>
void
DecisionRuleImpl<t>::fillTensors(const _Tg &g, double sigma)
{
......@@ -277,7 +277,7 @@ DecisionRuleImpl<t>::fillTensors(const _Tg &g, double sigma)
where ȳ is the steady state of the original rule ‘dr’. */
template <Storage t>
template<Storage t>
void
DecisionRuleImpl<t>::centralize(const DecisionRuleImpl &dr)
{
......@@ -310,7 +310,7 @@ DecisionRuleImpl<t>::centralize(const DecisionRuleImpl &dr)
canceled from ‘ystart’, we simulate, and at the end ‘ysteady’ is added to
all columns of the result. */
template <Storage t>
template<Storage t>
TwoDMatrix
DecisionRuleImpl<t>::simulate(emethod em, int np, const ConstVector &ystart,
ShockRealization &sr) const
......@@ -378,7 +378,7 @@ DecisionRuleImpl<t>::simulate(emethod em, int np, const ConstVector &ystart,
steady state (fix point) is cancelled and added once. Hence we have two
special methods. */
template <Storage t>
template<Storage t>
void
DecisionRuleImpl<t>::evaluate(emethod em, Vector &out, const ConstVector &ys,
const ConstVector &u) const
......@@ -401,7 +401,7 @@ DecisionRuleImpl<t>::evaluate(emethod em, Vector &out, const ConstVector &ys,
/* This is easy. We just return the newly created copy using the centralized
constructor. */
template <Storage t>
template<Storage t>
std::unique_ptr<DecisionRule>
DecisionRuleImpl<t>::centralizedClone(const Vector &fixpoint) const
{
......@@ -411,7 +411,7 @@ DecisionRuleImpl<t>::centralizedClone(const Vector &fixpoint) const
/* Here we only encapsulate two implementations to one, deciding according to
the parameter. */
template <Storage t>
template<Storage t>
void
DecisionRuleImpl<t>::eval(emethod em, Vector &out, const ConstVector &v) const
{
......@@ -423,7 +423,7 @@ DecisionRuleImpl<t>::eval(emethod em, Vector &out, const ConstVector &v) const
/* Write the decision rule and steady state to the MAT file. */
template <Storage t>
template<Storage t>
void
DecisionRuleImpl<t>::writeMat(mat_t *fd, const std::string &prefix) const
{
......@@ -506,7 +506,7 @@ public:
F is given by its derivatives ‘bigf’. The Jacobian of the solved system is
given by derivatives stored in ‘bigfder’. */
template <Storage t>
template<Storage t>
class DRFixPoint : public ctraits<t>::Tpol
{
using _Tpol = typename ctraits<t>::Tpol;
......@@ -557,7 +557,7 @@ private:
first derivative (Symmetry{1}). Then the derivative of the F polynomial is
calculated. */
template <Storage t>
template<Storage t>
DRFixPoint<t>::DRFixPoint(const _Tg &g, const PartitionY &yp,
const Vector &ys, double sigma)
: ctraits<t>::Tpol(yp.ny(), yp.nys()),
......@@ -577,7 +577,7 @@ DRFixPoint<t>::DRFixPoint(const _Tg &g, const PartitionY &yp,
such that ‘d+k’ is between the maximum dimension and ‘d’, and add
σᵏ/(d!k!)[g_yᵈσᵏ] to the tensor [g_yᵈ]. */
template <Storage t>
template<Storage t>
void
DRFixPoint<t>::fillTensors(const _Tg &g, double sigma)
{
......@@ -612,7 +612,7 @@ DRFixPoint<t>::fillTensors(const _Tg &g, double sigma)
underrelaxation parameter ‘urelax’, which improves the residual. If ‘urelax’
is less that ‘urelax_threshold’, we stop searching and stop the Newton. */
template <Storage t>
template<Storage t>
bool
DRFixPoint<t>::solveNewton(Vector &y)
{
......@@ -666,7 +666,7 @@ DRFixPoint<t>::solveNewton(Vector &y)
flastnorm = fnorm;
}
while (!converged && newton_iter_last < max_newton_iter
&&urelax > urelax_threshold);
&& urelax > urelax_threshold);
newton_iter_total += newton_iter_last;
if (!converged)
......@@ -688,7 +688,7 @@ DRFixPoint<t>::solveNewton(Vector &y)
The ‘out’ vector is not touched if the algorithm has not convered. */
template <Storage t>
template<Storage t>
bool
DRFixPoint<t>::calcFixPoint(emethod em, Vector &out)
{
......
......@@ -18,7 +18,6 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
// Dynamic model abstraction
/* This file only defines a generic interface to a DSGE model. The model
......
......@@ -57,7 +57,7 @@ public:
void calculate(const UnfoldedStackContainer &cont, const UGSContainer &g,
UGSTensor &out);
protected:
std::tuple<int,int,int> estimRefinement(const TensorDimens &tdims, int nr, int l);
std::tuple<int, int, int> estimRefinement(const TensorDimens &tdims, int nr, int l);
// See FaaDiBruno::calculate() folded sparse code for why we have magic_mult
constexpr static double magic_mult = 1.5;
......
......@@ -178,9 +178,9 @@ FirstOrder::solve(const TwoDMatrix &fd)
std::lock_guard<std::mutex> lk{mut};
qz_criterium_global = qz_criterium;
dgges("N", "V", "S", order_eigs, &n, matE.getData().base(), &lda,
matD.getData().base(), &ldb, &sdim2, alphar.base(), alphai.base(),
beta.base(), vsl.getData().base(), &ldvsl, vsr.getData().base(), &ldvsr,
work.base(), &lwork, bwork.get(), &info);
matD.getData().base(), &ldb, &sdim2, alphar.base(), alphai.base(),
beta.base(), vsl.getData().base(), &ldvsl, vsr.getData().base(), &ldvsr,
work.base(), &lwork, bwork.get(), &info);
}
if (info)
throw KordException(__FILE__, __LINE__,
......
......@@ -31,7 +31,7 @@ template<Storage>
class FirstOrderDerivs;
class FirstOrder
{
template <Storage>
template<Storage>
friend class FirstOrderDerivs;
PartitionY ypart;
int nu;
......@@ -89,7 +89,7 @@ protected:
/* This class only converts the derivatives g_y* and gᵤ to a folded or unfolded
container. */
template <Storage t>
template<Storage t>
class FirstOrderDerivs : public ctraits<t>::Tg
{
public:
......
......@@ -90,7 +90,7 @@ protected:
public:
ResidFunction(const Approximation &app);
ResidFunction(const ResidFunction &rf);
std::unique_ptr<VectorFunction>
clone() const override
{
......
......@@ -145,7 +145,7 @@ JournalRecord::writePrefix(const SystemResources &f)
std::ostringstream s;
s << std::setfill('0');
writeFloatTabular(s, f.elapsed, 7);
s << u8"│" << recChar << std::setw(5) << ord << u8"│";
s << u8"│" << recChar << std::setw(5) << ord << u8"│";
writeFloatTabular(s, f.load_avg, 3);
s << u8"│";
writeFloatTabular(s, f.mem_avail/mb, 5);
......
......@@ -26,18 +26,18 @@
#include <iostream>
#ifndef KORD_EXCEPTION_H
#define KORD_EXCEPTION_H
# define KORD_EXCEPTION_H
#define KORD_RAISE(mes) \
# define KORD_RAISE(mes) \
throw KordException(__FILE__, __LINE__, mes);
#define KORD_RAISE_IF(expr, mes) \
# define KORD_RAISE_IF(expr, mes) \
if (expr) throw KordException(__FILE__, __LINE__, mes);
#define KORD_RAISE_X(mes, c) \
# define KORD_RAISE_X(mes, c) \
throw KordException(__FILE__, __LINE__, mes, c);
#define KORD_RAISE_IF_X(expr, mes, c) \
# define KORD_RAISE_IF_X(expr, mes, c) \
if (expr) throw KordException(__FILE__, __LINE__, mes, c);
class KordException
......
......@@ -112,117 +112,173 @@ MatrixS::MatrixS(const FSSparseTensor &f, const IntSequence &ss,
interesting here. */
template<>
ctraits<Storage::unfold>::Tg& KOrder::g<Storage::unfold>()
ctraits<Storage::unfold>::Tg &
KOrder::g<Storage::unfold>()
{
return _ug;
}
template<>
const ctraits<Storage::unfold>::Tg& KOrder::g<Storage::unfold>() const
{ return _ug;}
const ctraits<Storage::unfold>::Tg &
KOrder::g<Storage::unfold>() const
{
return _ug;
}
template<>
ctraits<Storage::fold>::Tg& KOrder::g<Storage::fold>()
ctraits<Storage::fold>::Tg &
KOrder::g<Storage::fold>()
{
return _fg;
}
template<>
const ctraits<Storage::fold>::Tg& KOrder::g<Storage::fold>() const
{ return _fg;}
const ctraits<Storage::fold>::Tg &
KOrder::g<Storage::fold>() const
{
return _fg;
}
template<>
ctraits<Storage::unfold>::Tgs& KOrder::gs<Storage::unfold>()
ctraits<Storage::unfold>::Tgs &
KOrder::gs<Storage::unfold>()
{
return _ugs;
}
template<>
const ctraits<Storage::unfold>::Tgs& KOrder::gs<Storage::unfold>() const
{ return _ugs;}
const ctraits<Storage::unfold>::Tgs &
KOrder::gs<Storage::unfold>() const
{
return _ugs;
}
template<>
ctraits<Storage::fold>::Tgs& KOrder::gs<Storage::fold>()
ctraits<Storage::fold>::Tgs &
KOrder::gs<Storage::fold>()
{
return _fgs;
}
template<>
const ctraits<Storage::fold>::Tgs& KOrder::gs<Storage::fold>() const
{ return _fgs;}
const ctraits<Storage::fold>::Tgs &
KOrder::gs<Storage::fold>() const
{
return _fgs;
}
template<>
ctraits<Storage::unfold>::Tgss& KOrder::gss<Storage::unfold>()
ctraits<Storage::unfold>::Tgss &
KOrder::gss<Storage::unfold>()
{
return _ugss;
}
template<>
const ctraits<Storage::unfold>::Tgss& KOrder::gss<Storage::unfold>() const
{ return _ugss;}
const ctraits<Storage::unfold>::Tgss &
KOrder::gss<Storage::unfold>() const
{
return _ugss;
}
template<>
ctraits<Storage::fold>::Tgss& KOrder::gss<Storage::fold>()
ctraits<Storage::fold>::Tgss &
KOrder::gss<Storage::fold>()
{
return _fgss;
}
template<>
const ctraits<Storage::fold>::Tgss& KOrder::gss<Storage::fold>() const
{ return _fgss;}
const ctraits<Storage::fold>::Tgss &
KOrder::gss<Storage::fold>() const
{
return _fgss;
}
template<>
ctraits<Storage::unfold>::TG& KOrder::G<Storage::unfold>()
ctraits<Storage::unfold>::TG &
KOrder::G<Storage::unfold>()
{
return _uG;
}
template<>
const ctraits<Storage::unfold>::TG& KOrder::G<Storage::unfold>() const
{ return _uG;}
const ctraits<Storage::unfold>::TG &
KOrder::G<Storage::unfold>() const
{
return _uG;
}
template<>
ctraits<Storage::fold>::TG& KOrder::G<Storage::fold>()
ctraits<Storage::fold>::TG &
KOrder::G<Storage::fold>()
{
return _fG;
}
template<>
const ctraits<Storage::fold>::TG& KOrder::G<Storage::fold>() const
{ return _fG;}
const ctraits<Storage::fold>::TG &
KOrder::G<Storage::fold>() const
{
return _fG;
}
template<>
ctraits<Storage::unfold>::TZstack& KOrder::Zstack<Storage::unfold>()
ctraits<Storage::unfold>::TZstack &
KOrder::Zstack<Storage::unfold>()
{
return _uZstack;
}
template<>
const ctraits<Storage::unfold>::TZstack& KOrder::Zstack<Storage::unfold>() const
{ return _uZstack;}
const ctraits<Storage::unfold>::TZstack &
KOrder::Zstack<Storage::unfold>() const
{
return _uZstack;
}
template<>
ctraits<Storage::fold>::TZstack& KOrder::Zstack<Storage::fold>()
ctraits<Storage::fold>::TZstack &
KOrder::Zstack<Storage::fold>()
{
return _fZstack;
}
template<>
const ctraits<Storage::fold>::TZstack& KOrder::Zstack<Storage::fold>() const
{ return _fZstack;}
const ctraits<Storage::fold>::TZstack &
KOrder::Zstack<Storage::fold>() const
{
return _fZstack;
}
template<>
ctraits<Storage::unfold>::TGstack& KOrder::Gstack<Storage::unfold>()
ctraits<Storage::unfold>::TGstack &
KOrder::Gstack<Storage::unfold>()
{
return _uGstack;
}
template<>
const ctraits<Storage::unfold>::TGstack& KOrder::Gstack<Storage::unfold>() const
{ return _uGstack;}
const ctraits<Storage::unfold>::TGstack &
KOrder::Gstack<Storage::unfold>() const
{
return _uGstack;
}
template<>
ctraits<Storage::fold>::TGstack& KOrder::Gstack<Storage::fold>()
ctraits<Storage::fold>::TGstack &
KOrder::Gstack<Storage::fold>()
{
return _fGstack;
}
template<>
const ctraits<Storage::fold>::TGstack& KOrder::Gstack<Storage::fold>() const
{ return _fGstack;}
const ctraits<Storage::fold>::TGstack &
KOrder::Gstack<Storage::fold>() const
{
return _fGstack;
}
template<>
ctraits<Storage::unfold>::Tm& KOrder::m<Storage::unfold>()
ctraits<Storage::unfold>::Tm &
KOrder::m<Storage::unfold>()
{
return _um;
}
template<>
const ctraits<Storage::unfold>::Tm& KOrder::m<Storage::unfold>() const
{ return _um;}
const ctraits<Storage::unfold>::Tm &
KOrder::m<Storage::unfold>() const
{
return _um;
}
template<>
ctraits<Storage::fold>::Tm& KOrder::m<Storage::fold>()
ctraits<Storage::fold>::Tm &
KOrder::m<Storage::fold>()
{
return _fm;
}
template<>
const ctraits<Storage::fold>::Tm& KOrder::m<Storage::fold>() const
{ return _fm;}
const ctraits<Storage::fold>::Tm &
KOrder::m<Storage::fold>() const
{
return _fm;
}
/* Here is the constructor of the KOrder class. We pass what we have to. The
partitioning of the y vector, a sparse container with model derivatives,
......
......@@ -72,7 +72,7 @@ class UnfoldedZXContainer;
class FoldedGXContainer;
class UnfoldedGXContainer;
template <Storage type>
template<Storage type>
class ctraits
{
public:
......@@ -296,15 +296,15 @@ public:
/* Performs k-order step provided that k=2 or the k−1-th step has been
run, this is the core method */
template <Storage t>
template<Storage t>
void performStep(int order);