Port to C++11 nullptr keyword

Performed using modernize-use-nullptr from clang-tidy.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
time-shift
Sébastien Villemot 2019-01-09 16:25:31 +01:00
parent 7df31f68d9
commit 9656904d41
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
47 changed files with 180 additions and 180 deletions

View File

@ -4,8 +4,8 @@
#include "symmetry.hh"
prodpit::prodpit()
: prodq(NULL), jseq(NULL),
sig(NULL), p(NULL)
: prodq(nullptr), jseq(nullptr),
sig(nullptr), p(nullptr)
{
}
@ -33,15 +33,15 @@ prodpit::prodpit(const prodpit &ppit)
if (ppit.jseq)
jseq = new IntSequence(*(ppit.jseq));
else
jseq = NULL;
jseq = nullptr;
if (ppit.sig)
sig = new ParameterSignal(*(ppit.sig));
else
sig = NULL;
sig = nullptr;
if (ppit.p)
p = new Vector(*(ppit.p));
else
p = NULL;
p = nullptr;
}
prodpit::~prodpit()
@ -60,8 +60,8 @@ prodpit::operator==(const prodpit &ppit) const
bool ret = true;
ret = ret & prodq == ppit.prodq;
ret = ret & end_flag == ppit.end_flag;
ret = ret & ((jseq == NULL && ppit.jseq == NULL)
|| (jseq != NULL && ppit.jseq != NULL && *jseq == *(ppit.jseq)));
ret = ret & ((jseq == nullptr && ppit.jseq == nullptr)
|| (jseq != nullptr && ppit.jseq != nullptr && *jseq == *(ppit.jseq)));
return ret;
}
@ -82,15 +82,15 @@ prodpit::operator=(const prodpit &ppit)
if (ppit.jseq)
jseq = new IntSequence(*(ppit.jseq));
else
jseq = NULL;
jseq = nullptr;
if (ppit.sig)
sig = new ParameterSignal(*(ppit.sig));
else
sig = NULL;
sig = nullptr;
if (ppit.p)
p = new Vector(*(ppit.p));
else
p = NULL;
p = nullptr;
return *this;
}

View File

@ -188,7 +188,7 @@ public:
savePoints(const char *fname, int level) const
{
FILE *fd;
if (NULL == (fd = fopen(fname, "w")))
if (nullptr == (fd = fopen(fname, "w")))
{
// todo: raise
fprintf(stderr, "Cannot open file %s for writing.\n", fname);

View File

@ -162,7 +162,7 @@ HaltonSequence::print() const
}
qmcpit::qmcpit()
: spec(NULL), halton(NULL), sig(NULL)
: spec(nullptr), halton(nullptr), sig(nullptr)
{
}
@ -173,7 +173,7 @@ qmcpit::qmcpit(const QMCSpecification &s, int n)
}
qmcpit::qmcpit(const qmcpit &qpit)
: spec(qpit.spec), halton(NULL), sig(NULL)
: spec(qpit.spec), halton(nullptr), sig(nullptr)
{
if (qpit.halton)
halton = new HaltonSequence(*(qpit.halton));
@ -193,8 +193,8 @@ bool
qmcpit::operator==(const qmcpit &qpit) const
{
return (spec == qpit.spec)
&& ((halton == NULL && qpit.halton == NULL)
|| (halton != NULL && qpit.halton != NULL && halton->getNum() == qpit.halton->getNum()));
&& ((halton == nullptr && qpit.halton == nullptr)
|| (halton != nullptr && qpit.halton != nullptr && halton->getNum() == qpit.halton->getNum()));
}
const qmcpit &
@ -206,7 +206,7 @@ qmcpit::operator=(const qmcpit &qpit)
if (qpit.halton)
halton = new HaltonSequence(*(qpit.halton));
else
halton = NULL;
halton = nullptr;
return *this;
}
@ -225,7 +225,7 @@ qmcpit::weight() const
}
qmcnpit::qmcnpit()
: qmcpit(), pnt(NULL)
: qmcpit(), pnt(nullptr)
{
}
@ -235,7 +235,7 @@ qmcnpit::qmcnpit(const QMCSpecification &s, int n)
}
qmcnpit::qmcnpit(const qmcnpit &qpit)
: qmcpit(qpit), pnt(NULL)
: qmcpit(qpit), pnt(nullptr)
{
if (qpit.pnt)
pnt = new Vector(*(qpit.pnt));
@ -256,7 +256,7 @@ qmcnpit::operator=(const qmcnpit &qpit)
if (qpit.pnt)
pnt = new Vector(*(qpit.pnt));
else
pnt = NULL;
pnt = nullptr;
return *this;
}

View File

@ -4,7 +4,7 @@
#include "symmetry.hh"
smolpit::smolpit()
: smolq(NULL), jseq(NULL), sig(NULL), p(NULL)
: smolq(nullptr), jseq(nullptr), sig(nullptr), p(nullptr)
{
}
@ -28,15 +28,15 @@ smolpit::smolpit(const smolpit &spit)
if (spit.jseq)
jseq = new IntSequence(*(spit.jseq));
else
jseq = NULL;
jseq = nullptr;
if (spit.sig)
sig = new ParameterSignal(*(spit.sig));
else
sig = NULL;
sig = nullptr;
if (spit.p)
p = new Vector(*(spit.p));
else
p = NULL;
p = nullptr;
}
smolpit::~smolpit()
@ -55,8 +55,8 @@ smolpit::operator==(const smolpit &spit) const
bool ret = true;
ret = ret & smolq == spit.smolq;
ret = ret & isummand == spit.isummand;
ret = ret & ((jseq == NULL && spit.jseq == NULL)
|| (jseq != NULL && spit.jseq != NULL && *jseq == *(spit.jseq)));
ret = ret & ((jseq == nullptr && spit.jseq == nullptr)
|| (jseq != nullptr && spit.jseq != nullptr && *jseq == *(spit.jseq)));
return ret;
}
@ -77,15 +77,15 @@ smolpit::operator=(const smolpit &spit)
if (spit.jseq)
jseq = new IntSequence(*(spit.jseq));
else
jseq = NULL;
jseq = nullptr;
if (spit.sig)
sig = new ParameterSignal(*(spit.sig));
else
sig = NULL;
sig = nullptr;
if (spit.p)
p = new Vector(*(spit.p));
else
p = NULL;
p = nullptr;
return *this;
}

View File

@ -29,7 +29,7 @@ private:
};
QuadParams::QuadParams(int argc, char **argv)
: outname(NULL), vcovname(NULL), max_level(3), discard_weight(0.0)
: outname(nullptr), vcovname(nullptr), max_level(3), discard_weight(0.0)
{
if (argc == 1)
{
@ -41,10 +41,10 @@ QuadParams::QuadParams(int argc, char **argv)
argc--;
struct option const opts [] = {
{"max-level", required_argument, NULL, opt_max_level},
{"discard-weight", required_argument, NULL, opt_discard_weight},
{"vcov", required_argument, NULL, opt_vcov},
{NULL, 0, NULL, 0}
{"max-level", required_argument, nullptr, opt_max_level},
{"discard-weight", required_argument, nullptr, opt_discard_weight},
{"vcov", required_argument, nullptr, opt_vcov},
{nullptr, 0, nullptr, 0}
};
int ret;
@ -73,13 +73,13 @@ QuadParams::QuadParams(int argc, char **argv)
void
QuadParams::check_consistency() const
{
if (outname == NULL)
if (outname == nullptr)
{
fprintf(stderr, "Error: output name not set\n");
exit(1);
}
if (vcovname == NULL)
if (vcovname == nullptr)
{
fprintf(stderr, "Error: vcov file name not set\n");
exit(1);
@ -104,7 +104,7 @@ main(int argc, char **argv)
// open output file for writing
FILE *fout;
if (NULL == (fout = fopen(params.outname, "w")))
if (nullptr == (fout = fopen(params.outname, "w")))
{
fprintf(stderr, "Could not open %s for writing\n", params.outname);
exit(1);

View File

@ -172,12 +172,12 @@ class WallTimer
public:
WallTimer(const char *m, bool nl = true)
{
strcpy(mes, m); new_line = nl; gettimeofday(&start, NULL);
strcpy(mes, m); new_line = nl; gettimeofday(&start, nullptr);
}
~WallTimer()
{
struct timeval end;
gettimeofday(&end, NULL);
gettimeofday(&end, nullptr);
printf("%s%8.4g", mes,
end.tv_sec-start.tv_sec + (end.tv_usec-start.tv_usec)*1.0e-6);
if (new_line)

View File

@ -30,7 +30,7 @@ ZAuxContainer::getType(int i, const Symmetry &s) const
}
Approximation::Approximation(DynamicModel &m, Journal &j, int ns, bool dr_centr, double qz_crit)
: model(m), journal(j), rule_ders(NULL), rule_ders_ss(NULL), fdr(NULL), udr(NULL),
: model(m), journal(j), rule_ders(nullptr), rule_ders_ss(nullptr), fdr(nullptr), udr(nullptr),
ypart(model.nstat(), model.npred(), model.nboth(), model.nforw()),
mom(UNormalMoments(model.order(), model.getVcov())), nvs(4), steps(ns),
dr_centralize(dr_centr), qz_criterium(qz_crit), ss(ypart.ny(), steps+1)
@ -57,7 +57,7 @@ Approximation::~Approximation()
const FoldDecisionRule &
Approximation::getFoldDecisionRule() const
{
KORD_RAISE_IF(fdr == NULL,
KORD_RAISE_IF(fdr == nullptr,
"Folded decision rule has not been created in Approximation::getFoldDecisionRule");
return *fdr;
}
@ -66,7 +66,7 @@ Approximation::getFoldDecisionRule() const
const UnfoldDecisionRule &
Approximation::getUnfoldDecisionRule() const
{
KORD_RAISE_IF(udr == NULL,
KORD_RAISE_IF(udr == nullptr,
"Unfolded decision rule has not been created in Approximation::getUnfoldDecisionRule");
return *udr;
}
@ -208,12 +208,12 @@ Approximation::walkStochSteady()
if (fdr)
{
delete fdr;
fdr = NULL;
fdr = nullptr;
}
if (udr)
{
delete udr;
udr = NULL;
udr = nullptr;
}
fdr = new FoldDecisionRule(*rule_ders, ypart, model.nexog(),

View File

@ -132,8 +132,8 @@ SimResults::writeMat(const char *base, const char *lname) const
{
char matfile_name[100];
sprintf(matfile_name, "%s.mat", base);
mat_t *matfd = Mat_Create(matfile_name, NULL);
if (matfd != NULL)
mat_t *matfd = Mat_Create(matfile_name, nullptr);
if (matfd != nullptr)
{
writeMat(matfd, lname);
Mat_Close(matfd);

View File

@ -534,7 +534,7 @@ template <int t>
DRFixPoint<t>::DRFixPoint(const _Tg &g, const PartitionY &yp,
const Vector &ys, double sigma)
: ctraits<t>::Tpol(yp.ny(), yp.nys()),
ysteady(ys), ypart(yp), bigf(NULL), bigfder(NULL)
ysteady(ys), ypart(yp), bigf(nullptr), bigfder(nullptr)
{
fillTensors(g, sigma);
_Tparent yspol(ypart.nstat, ypart.nys(), *this);

View File

@ -16,13 +16,13 @@
ResidFunction::ResidFunction(const Approximation &app)
: VectorFunction(app.getModel().nexog(), app.getModel().numeq()), approx(app),
model(app.getModel().clone()),
yplus(NULL), ystar(NULL), u(NULL), hss(NULL)
yplus(nullptr), ystar(nullptr), u(nullptr), hss(nullptr)
{
}
ResidFunction::ResidFunction(const ResidFunction &rf)
: VectorFunction(rf), approx(rf.approx), model(rf.model->clone()),
yplus(NULL), ystar(NULL), u(NULL), hss(NULL)
yplus(nullptr), ystar(nullptr), u(nullptr), hss(nullptr)
{
if (rf.yplus)
yplus = new Vector(*(rf.yplus));

View File

@ -67,7 +67,7 @@ sysconf(int name)
SystemResources::SystemResources()
{
gettimeofday(&start, NULL);
gettimeofday(&start, nullptr);
}
long int
@ -103,7 +103,7 @@ SystemResources::getRUS(double &load_avg, long int &pg_avail,
long int &idrss, long int &majflt)
{
struct timeval now;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
elapsed = now.tv_sec-start.tv_sec + (now.tv_usec-start.tv_usec)*1.0e-6;
#if !defined(__MINGW32__)
@ -239,7 +239,7 @@ Journal::printHeader()
(*this)<< "\n\nStart time: ";
char ts[100];
time_t curtime = time(NULL);
time_t curtime = time(nullptr);
tm loctime;
localtime_r(&curtime, &loctime);
asctime_r(&loctime, ts);

View File

@ -29,7 +29,7 @@ KOrderStoch::KOrderStoch(const PartitionY &yp, int nu,
const FGSContainer &hh, Journal &jr)
: nvs(4), ypart(yp), journal(jr),
_ug(4), _fg(4), _ugs(4), _fgs(4), _uG(4), _fG(4),
_uh(NULL), _fh(&hh),
_uh(nullptr), _fh(&hh),
_uZstack(&_uG, ypart.nyss(), &_ug, ypart.ny(), ypart.nys(), nu),
_fZstack(&_fG, ypart.nyss(), &_fg, ypart.ny(), ypart.nys(), nu),
_uGstack(&_ugs, ypart.nys(), nu),
@ -50,7 +50,7 @@ KOrderStoch::KOrderStoch(const PartitionY &yp, int nu,
const UGSContainer &hh, Journal &jr)
: nvs(4), ypart(yp), journal(jr),
_ug(4), _fg(4), _ugs(4), _fgs(4), _uG(4), _fG(4),
_uh(&hh), _fh(NULL),
_uh(&hh), _fh(nullptr),
_uZstack(&_uG, ypart.nyss(), &_ug, ypart.ny(), ypart.nys(), nu),
_fZstack(&_fG, ypart.nyss(), &_fg, ypart.ny(), ypart.nys(), nu),
_uGstack(&_ugs, ypart.nys(), nu),

View File

@ -35,7 +35,7 @@ AtomSubstitutions::add_substitution(const char *newname, const char *oldname, in
// make sure the storage is from the new_atoms
newname = new_atoms.get_name_storage().query(newname);
oldname = new_atoms.get_name_storage().query(oldname);
if (newname == NULL || oldname == NULL)
if (newname == nullptr || oldname == nullptr)
throw ogu::Exception(__FILE__, __LINE__,
"Bad newname or oldname in AtomSubstitutions::add_substitution");
@ -88,7 +88,7 @@ AtomSubstitutions::get_new4old(const char *oldname, int tshift) const
if (itt.second == -tshift)
return itt.first;
}
return NULL;
return nullptr;
}
void
@ -114,19 +114,19 @@ SAtoms::substituteAllLagsAndLeads(FormulaParser &fp, AtomSubstitutions &as)
endovarspan(mlead, mlag);
// substitute all endo lagged more than 1
while (NULL != (name = findEndoWithLeadInInterval(mlag, -2)))
while (nullptr != (name = findEndoWithLeadInInterval(mlag, -2)))
makeAuxVariables(name, -1, -2, mlag, fp, as);
// substitute all endo leaded more than 1
while (NULL != (name = findEndoWithLeadInInterval(2, mlead)))
while (nullptr != (name = findEndoWithLeadInInterval(2, mlead)))
makeAuxVariables(name, 1, 2, mlead, fp, as);
exovarspan(mlead, mlag);
// substitute all lagged exo
while (NULL != (name = findExoWithLeadInInterval(mlag, -1)))
while (nullptr != (name = findExoWithLeadInInterval(mlag, -1)))
makeAuxVariables(name, -1, -1, mlag, fp, as);
// substitute all leaded exo
while (NULL != (name = findExoWithLeadInInterval(1, mlead)))
while (nullptr != (name = findExoWithLeadInInterval(1, mlead)))
makeAuxVariables(name, 1, 1, mlead, fp, as);
// notify that substitution have been finished
@ -142,16 +142,16 @@ SAtoms::substituteAllLagsAndExo1Leads(FormulaParser &fp, AtomSubstitutions &as)
endovarspan(mlead, mlag);
// substitute all endo lagged more than 1
while (NULL != (name = findEndoWithLeadInInterval(mlag, -2)))
while (nullptr != (name = findEndoWithLeadInInterval(mlag, -2)))
makeAuxVariables(name, -1, -2, mlag, fp, as);
exovarspan(mlead, mlag);
// substitute all lagged exo
while (NULL != (name = findExoWithLeadInInterval(mlag, -1)))
while (nullptr != (name = findExoWithLeadInInterval(mlag, -1)))
makeAuxVariables(name, -1, -1, mlag, fp, as);
// substitute all leaded exo by 1
while (NULL != (name = findExoWithLeadInInterval(1, 1)))
while (nullptr != (name = findExoWithLeadInInterval(1, 1)))
makeAuxVariables(name, 1, 1, 1, fp, as);
// notify that substitution have been finished
@ -175,7 +175,7 @@ SAtoms::findNameWithLeadInInterval(const vector<const char *> &names,
}
// nothing found
return NULL;
return nullptr;
}
void
@ -242,7 +242,7 @@ SAtoms::makeAuxVariables(const char *name, int step, int start, int limit_lead,
const char *newname;
string newname_str;
int taux;
if (NULL == (newname = as.get_new4old(name, ll-step)))
if (nullptr == (newname = as.get_new4old(name, ll-step)))
{
attemptAuxName(name, ll-step, newname_str);
newname = newname_str.c_str();

View File

@ -40,5 +40,5 @@ CSVParser::csv_parse(int length, const char *str)
::csv_parse();
delete [] buffer;
csv__destroy_buffer(p);
parsed_string = NULL;
parsed_string = nullptr;
}

View File

@ -25,7 +25,7 @@ namespace ogp
const char *parsed_string;
public:
CSVParser(CSVParserPeer &p)
: peer(p), row(0), col(0), parsed_string(0)
: peer(p), row(0), col(0), parsed_string(nullptr)
{
}
CSVParser(const CSVParser &csvp)

View File

@ -32,7 +32,7 @@ NameStorage::query(const char *name) const
{
auto it = name_set.find(name);
if (it == name_set.end())
return NULL;
return nullptr;
else
return (*it);
}

View File

@ -76,7 +76,7 @@ AllvarOuterOrdering::AllvarOuterOrdering(const AllvarOuterOrdering &avo,
FineAtoms::FineAtoms(const FineAtoms &fa)
: DynamicAtoms(fa), params(), endovars(), exovars(),
endo_order(NULL), exo_order(NULL), allvar_order(NULL),
endo_order(nullptr), exo_order(nullptr), allvar_order(nullptr),
der_atoms(fa.der_atoms),
endo_atoms_map(fa.endo_atoms_map),
exo_atoms_map(fa.exo_atoms_map)

View File

@ -229,7 +229,7 @@ namespace ogp
vector<int> exo_atoms_map;
public:
FineAtoms()
: endo_order(NULL), exo_order(NULL), allvar_order(NULL)
: endo_order(nullptr), exo_order(nullptr), allvar_order(nullptr)
{
}
FineAtoms(const FineAtoms &fa);

View File

@ -91,7 +91,7 @@ namespace ogp
int r{0};
public:
MPIterator() : p(NULL)
MPIterator() : p(nullptr)
{
}
/** Constructs an iterator pointing to the beginning of the

View File

@ -48,7 +48,7 @@ ParserException::ParserException(const string &m, const char *dum, int i1, int i
}
ParserException::ParserException(const ParserException &m, int plus_offset)
: mes(NULL),
: mes(nullptr),
aux_i1(-1), aux_i2(-1), aux_i3(-1)
{
copy(m);
@ -56,7 +56,7 @@ ParserException::ParserException(const ParserException &m, int plus_offset)
}
ParserException::ParserException(const ParserException &m, const char *dum, int i)
: mes(NULL),
: mes(nullptr),
aux_i1(-1), aux_i2(-1), aux_i3(-1)
{
copy(m);
@ -66,7 +66,7 @@ ParserException::ParserException(const ParserException &m, const char *dum, int
}
ParserException::ParserException(const ParserException &m, const char *dum, int i1, int i2)
: mes(NULL),
: mes(nullptr),
aux_i1(-1), aux_i2(-1), aux_i3(-1)
{
copy(m);
@ -76,7 +76,7 @@ ParserException::ParserException(const ParserException &m, const char *dum, int
}
ParserException::ParserException(const ParserException &m, const char *dum, int i1, int i2, int i3)
: mes(NULL),
: mes(nullptr),
aux_i1(-1), aux_i2(-1), aux_i3(-1)
{
copy(m);
@ -86,7 +86,7 @@ ParserException::ParserException(const ParserException &m, const char *dum, int
}
ParserException::ParserException(const ParserException &e)
: mes(NULL),
: mes(nullptr),
aux_i1(-1), aux_i2(-1), aux_i3(-1)
{
copy(e);

View File

@ -84,7 +84,7 @@ StaticAtoms::inv_index(int t) const
{
auto it = indices.find(t);
if (it == indices.end())
return NULL;
return nullptr;
else
return (*it).second;
}

View File

@ -97,7 +97,7 @@ int
StaticFineAtoms::check_variable(const char *name) const
{
const char *ss = varnames.query(name);
if (ss == NULL)
if (ss == nullptr)
throw ParserException(string("Variable <")+name+"> not declared.", 0);
return index(name);
}
@ -208,7 +208,7 @@ void
StaticFineAtoms::register_endo(const char *name)
{
const char *ss = varnames.query(name);
if (ss == NULL)
if (ss == nullptr)
throw ogp::ParserException(string("Endogenous variable <")
+name+"> not found in storage.", 0);
endovars.push_back(ss);
@ -219,7 +219,7 @@ void
StaticFineAtoms::register_exo(const char *name)
{
const char *ss = varnames.query(name);
if (ss == NULL)
if (ss == nullptr)
throw ogp::ParserException(string("Exogenous variable <")
+name+"> not found in storage.", 0);
exovars.push_back(ss);
@ -230,7 +230,7 @@ void
StaticFineAtoms::register_param(const char *name)
{
const char *ss = varnames.query(name);
if (ss == NULL)
if (ss == nullptr)
throw ogp::ParserException(string("Parameter <")+name+"> not found in storage.", 0);
params.push_back(ss);
param_outer_map.insert(Tvarintmap::value_type(ss, params.size()-1));

View File

@ -40,8 +40,8 @@ DynareNameList::selectIndices(const vector<const char *> &ns) const
/**************************************************************************************/
Dynare::Dynare(const char *modname, int ord, double sstol, Journal &jr)
: journal(jr), model(NULL), ysteady(NULL), md(1), dnl(NULL), denl(NULL), dsnl(NULL),
fe(NULL), fde(NULL), ss_tol(sstol)
: journal(jr), model(nullptr), ysteady(nullptr), md(1), dnl(nullptr), denl(nullptr), dsnl(nullptr),
fe(nullptr), fde(nullptr), ss_tol(sstol)
{
// make memory file
ogu::MemoryFile mf(modname);
@ -77,8 +77,8 @@ Dynare::Dynare(const char **endo, int num_endo,
const char **par, int num_par,
const char *equations, int len, int ord,
double sstol, Journal &jr)
: journal(jr), model(NULL), ysteady(NULL), md(1), dnl(NULL), denl(NULL), dsnl(NULL),
fe(NULL), fde(NULL), ss_tol(sstol)
: journal(jr), model(nullptr), ysteady(nullptr), md(1), dnl(nullptr), denl(nullptr), dsnl(nullptr),
fe(nullptr), fde(nullptr), ss_tol(sstol)
{
try
{
@ -99,9 +99,9 @@ Dynare::Dynare(const char **endo, int num_endo,
}
Dynare::Dynare(const Dynare &dynare)
: journal(dynare.journal), model(NULL),
ysteady(NULL), md(dynare.md),
dnl(NULL), denl(NULL), dsnl(NULL), fe(NULL), fde(NULL),
: journal(dynare.journal), model(nullptr),
ysteady(nullptr), md(dynare.md),
dnl(nullptr), denl(nullptr), dsnl(nullptr), fe(nullptr), fde(nullptr),
ss_tol(dynare.ss_tol)
{
model = dynare.model->clone();

View File

@ -24,7 +24,7 @@ DynareStaticAtoms::register_name(const char *name)
int
DynareStaticAtoms::check_variable(const char *name) const
{
if (0 == varnames.query(name))
if (nullptr == varnames.query(name))
throw ogp::ParserException(std::string("Unknown name <")+name+">", 0);
auto it = vars.find(name);
if (it == vars.end())

View File

@ -27,18 +27,18 @@ ParsedMatrix::ParsedMatrix(const ogp::MatrixParser &mp)
DynareModel::DynareModel()
: atoms(), eqs(atoms),
pbuilder(NULL), fbuilder(NULL),
atom_substs(NULL), old_atoms(NULL)
pbuilder(nullptr), fbuilder(nullptr),
atom_substs(nullptr), old_atoms(nullptr)
{
}
DynareModel::DynareModel(const DynareModel &dm)
: atoms(dm.atoms), eqs(dm.eqs, atoms), order(dm.order),
param_vals(0), init_vals(0), vcov_mat(0),
param_vals(nullptr), init_vals(nullptr), vcov_mat(nullptr),
t_plobjective(dm.t_plobjective),
t_pldiscount(dm.t_pldiscount),
pbuilder(NULL), fbuilder(NULL),
atom_substs(NULL), old_atoms(NULL)
pbuilder(nullptr), fbuilder(nullptr),
atom_substs(nullptr), old_atoms(nullptr)
{
if (dm.param_vals)
param_vals = new Vector((const Vector &) *(dm.param_vals));
@ -79,7 +79,7 @@ DynareModel::get_planner_info() const
{
if (pbuilder)
return &(pbuilder->get_info());
return NULL;
return nullptr;
}
const ForwSubstInfo *
@ -87,7 +87,7 @@ DynareModel::get_forw_subst_info() const
{
if (fbuilder)
return &(fbuilder->get_info());
return NULL;
return nullptr;
}
const ogp::SubstInfo *
@ -95,7 +95,7 @@ DynareModel::get_subst_info() const
{
if (atom_substs)
return &(atom_substs->get_info());
return NULL;
return nullptr;
}
void

View File

@ -84,12 +84,12 @@ namespace ogdyn
/** A vector of parameters values created by a subclass. It
* is stored with natural ordering (outer) of the parameters
* given by atoms. */
Vector *param_vals{0};
Vector *param_vals{nullptr};
/** A vector of initial values created by a subclass. It is
* stored with internal ordering given by atoms. */
Vector *init_vals{0};
Vector *init_vals{nullptr};
/** A matrix for vcov. It is created by a subclass. */
TwoDMatrix *vcov_mat{0};
TwoDMatrix *vcov_mat{nullptr};
/** Tree index of the planner objective. If there was no
* planner objective keyword, the value is set to -1. */
int t_plobjective{-1};

View File

@ -46,7 +46,7 @@ const char *help_str
const char *dyn_basename(const char *str);
DynareParams::DynareParams(int argc, char **argv)
: modname(NULL), num_per(100), num_burn(0), num_sim(80),
: modname(nullptr), num_per(100), num_burn(0), num_sim(80),
num_rtper(0), num_rtsim(0),
num_condper(0), num_condsim(0),
num_threads(2), num_steps(0),
@ -71,37 +71,37 @@ DynareParams::DynareParams(int argc, char **argv)
argc--;
struct option const opts [] = {
{"periods", required_argument, NULL, opt_per},
{"per", required_argument, NULL, opt_per},
{"burn", required_argument, NULL, opt_burn},
{"simulations", required_argument, NULL, opt_sim},
{"sim", required_argument, NULL, opt_sim},
{"rtperiods", required_argument, NULL, opt_rtper},
{"rtper", required_argument, NULL, opt_rtper},
{"rtsimulations", required_argument, NULL, opt_rtsim},
{"rtsim", required_argument, NULL, opt_rtsim},
{"condperiods", required_argument, NULL, opt_condper},
{"condper", required_argument, NULL, opt_condper},
{"condsimulations", required_argument, NULL, opt_condsim},
{"condsim", required_argument, NULL, opt_condsim},
{"prefix", required_argument, NULL, opt_prefix},
{"threads", required_argument, NULL, opt_threads},
{"steps", required_argument, NULL, opt_steps},
{"seed", required_argument, NULL, opt_seed},
{"order", required_argument, NULL, opt_order},
{"ss-tol", required_argument, NULL, opt_ss_tol},
{"check", required_argument, NULL, opt_check},
{"check-scale", required_argument, NULL, opt_check_scale},
{"check-evals", required_argument, NULL, opt_check_evals},
{"check-num", required_argument, NULL, opt_check_num},
{"qz-criterium", required_argument, NULL, opt_qz_criterium},
{"no-irfs", no_argument, NULL, opt_noirfs},
{"irfs", no_argument, NULL, opt_irfs},
{"centralize", no_argument, NULL, opt_centralize},
{"no-centralize", no_argument, NULL, opt_no_centralize},
{"help", no_argument, NULL, opt_help},
{"version", no_argument, NULL, opt_version},
{NULL, 0, NULL, 0}
{"periods", required_argument, nullptr, opt_per},
{"per", required_argument, nullptr, opt_per},
{"burn", required_argument, nullptr, opt_burn},
{"simulations", required_argument, nullptr, opt_sim},
{"sim", required_argument, nullptr, opt_sim},
{"rtperiods", required_argument, nullptr, opt_rtper},
{"rtper", required_argument, nullptr, opt_rtper},
{"rtsimulations", required_argument, nullptr, opt_rtsim},
{"rtsim", required_argument, nullptr, opt_rtsim},
{"condperiods", required_argument, nullptr, opt_condper},
{"condper", required_argument, nullptr, opt_condper},
{"condsimulations", required_argument, nullptr, opt_condsim},
{"condsim", required_argument, nullptr, opt_condsim},
{"prefix", required_argument, nullptr, opt_prefix},
{"threads", required_argument, nullptr, opt_threads},
{"steps", required_argument, nullptr, opt_steps},
{"seed", required_argument, nullptr, opt_seed},
{"order", required_argument, nullptr, opt_order},
{"ss-tol", required_argument, nullptr, opt_ss_tol},
{"check", required_argument, nullptr, opt_check},
{"check-scale", required_argument, nullptr, opt_check_scale},
{"check-evals", required_argument, nullptr, opt_check_evals},
{"check-num", required_argument, nullptr, opt_check_num},
{"qz-criterium", required_argument, nullptr, opt_qz_criterium},
{"no-irfs", no_argument, nullptr, opt_noirfs},
{"irfs", no_argument, nullptr, opt_irfs},
{"centralize", no_argument, nullptr, opt_centralize},
{"no-centralize", no_argument, nullptr, opt_no_centralize},
{"help", no_argument, nullptr, opt_help},
{"version", no_argument, nullptr, opt_version},
{nullptr, 0, nullptr, 0}
};
int ret;

View File

@ -54,7 +54,7 @@ main(int argc, char **argv)
FILE *mfd;
std::string mfile1(params.basename);
mfile1 += "_f.m";
if (NULL == (mfd = fopen(mfile1.c_str(), "w")))
if (nullptr == (mfd = fopen(mfile1.c_str(), "w")))
{
fprintf(stderr, "Couldn't open %s for writing.\n", mfile1.c_str());
exit(1);
@ -65,7 +65,7 @@ main(int argc, char **argv)
std::string mfile2(params.basename);
mfile2 += "_ff.m";
if (NULL == (mfd = fopen(mfile2.c_str(), "w")))
if (nullptr == (mfd = fopen(mfile2.c_str(), "w")))
{
fprintf(stderr, "Couldn't open %s for writing.\n", mfile2.c_str());
exit(1);
@ -77,8 +77,8 @@ main(int argc, char **argv)
// open mat file
std::string matfile(params.basename);
matfile += ".mat";
mat_t *matfd = Mat_Create(matfile.c_str(), NULL);
if (matfd == NULL)
mat_t *matfd = Mat_Create(matfile.c_str(), nullptr);
if (matfd == nullptr)
{
fprintf(stderr, "Couldn't open %s for writing.\n", matfile.c_str());
exit(1);

View File

@ -16,7 +16,7 @@ protected:
int n{0};
int depth{0};
public:
KronVector() : Vector((double *) 0, 0)
KronVector() : Vector((double *) nullptr, 0)
{
}
KronVector(int mm, int nn, int dp); // new instance

View File

@ -87,7 +87,7 @@ Diagonal::Diagonal(double *data, int d_size)
else
{
// it is last column or we have zero below diagonal
DiagonalBlock b(jbar, true, &data[id], &data[id], NULL, NULL);
DiagonalBlock b(jbar, true, &data[id], &data[id], nullptr, nullptr);
blocks.push_back(b);
}
jbar++;
@ -102,8 +102,8 @@ Diagonal::Diagonal(double *data, const Diagonal &d)
int d_size = d.getSize();
for (const auto & dit : d)
{
double *beta1 = NULL;
double *beta2 = NULL;
double *beta1 = nullptr;
double *beta2 = nullptr;
int id = dit.getIndex()*(d_size+1);
int idd = id;
if (!dit.isReal())
@ -157,7 +157,7 @@ Diagonal::changeBase(double *p)
if (b.isReal())
{
DiagonalBlock bnew(jbar, true, &p[base], &p[base],
NULL, NULL);
nullptr, nullptr);
it = bnew;
}
else
@ -243,8 +243,8 @@ Diagonal::checkConsistency(diag_iter it)
double *d2 = (*it).alpha.a2;
(*it).alpha.a2 = (*it).alpha.a1;
(*it).real = true;
(*it).beta1 = 0;
(*it).beta2 = 0;
(*it).beta1 = nullptr;
(*it).beta2 = nullptr;
DiagonalBlock b(jbar+1, d2);
blocks.insert((++it).iter(), b);
num_real += 2;

View File

@ -96,8 +96,8 @@ public:
{
jbar = jb;
real = true;
beta1 = 0;
beta2 = 0;
beta1 = nullptr;
beta2 = nullptr;
}
DiagonalBlock(const DiagonalBlock &b)
{

View File

@ -18,9 +18,9 @@ SchurDecomp::SchurDecomp(const SqSylvMatrix &m)
lapack_int lwork = 6*rows;
auto *const work = new double[lwork];
lapack_int info;
dgees("V", "N", 0, &rows, auxt.base(), &rows, &sdim,
dgees("V", "N", nullptr, &rows, auxt.base(), &rows, &sdim,
wr, wi, q->base(), &rows,
work, &lwork, 0, &info);
work, &lwork, nullptr, &info);
delete [] work;
delete [] wi;
delete [] wr;

View File

@ -16,7 +16,7 @@ SylvException::SylvException(const char *f, int l, const SylvException *s)
SylvException::~SylvException()
{
if (source != NULL)
if (source != nullptr)
{
delete source;
}
@ -35,7 +35,7 @@ int
SylvException::printMessage(char *str, int maxlen) const
{
int remain = maxlen;
if (source != NULL)
if (source != nullptr)
{
remain = source->printMessage(str, maxlen);
}
@ -53,7 +53,7 @@ SylvException::printMessage(char *str, int maxlen) const
SylvExceptionMessage::SylvExceptionMessage(const char *f, int i,
const char *mes)
: SylvException(f, i, NULL)
: SylvException(f, i, nullptr)
{
strcpy(message, mes);
}

View File

@ -29,7 +29,7 @@ void operator delete[](void *p);
class SylvMemoryPool
{
char *base{0};
char *base{nullptr};
size_t length{0};
size_t allocated{0};
bool stack_mode{false};

View File

@ -19,7 +19,7 @@ class Vector
protected:
int len{0};
int s{1};
double *data{0};
double *data{nullptr};
bool destroy{false};
public:
Vector()

View File

@ -10,7 +10,7 @@
MMMatrixIn::MMMatrixIn(const char *fname)
{
FILE *fd;
if (NULL == (fd = fopen(fname, "r")))
if (nullptr == (fd = fopen(fname, "r")))
throw MMException(string("Cannot open file ")+fname+" for reading\n");
char buffer[1000];
@ -51,7 +51,7 @@ void
MMMatrixOut::write(const char *fname, int rows, int cols, const double *data)
{
FILE *fd;
if (NULL == (fd = fopen(fname, "w")))
if (nullptr == (fd = fopen(fname, "w")))
throw MMException(string("Cannot open file ")+fname+" for writing\n");
if (0 > fprintf(fd, "%%%%MatrixMarket matrix array real general\n"))

View File

@ -106,7 +106,7 @@ KronProdAll::setMat(int i, const TwoDMatrix &m)
void
KronProdAll::setUnit(int i, int n)
{
matlist[i] = NULL;
matlist[i] = nullptr;
kpd.setRC(i, n, n);
}
@ -114,7 +114,7 @@ bool
KronProdAll::isUnit() const
{
int i = 0;
while (i < dimen() && matlist[i] == NULL)
while (i < dimen() && matlist[i] == nullptr)
i++;
return i == dimen();
}
@ -279,7 +279,7 @@ KronProdAll::mult(const ConstTwoDMatrix &in, TwoDMatrix &out) const
}
int c;
TwoDMatrix *last = NULL;
TwoDMatrix *last = nullptr;
// perform first multiplication AI
/* Here we have to construct $A_1\otimes I$, allocate intermediate
@ -338,7 +338,7 @@ KronProdAll::multRows(const IntSequence &irows) const
TL_RAISE_IF(irows.size() != dimen(),
"Wrong length of row indices in KronProdAll::multRows");
Vector *last = NULL;
Vector *last = nullptr;
ConstVector *row;
vector<Vector *> to_delete;
for (int i = 0; i < dimen(); i++)

View File

@ -80,7 +80,7 @@ PermutationSet::PermutationSet(const PermutationSet &sp, int n)
pers(new const Permutation *[size])
{
for (int i = 0; i < size; i++)
pers[i] = NULL;
pers[i] = nullptr;
TL_RAISE_IF(n != sp.order+1,
"Wrong new order in PermutationSet constructor");

View File

@ -22,7 +22,7 @@ namespace sthread
void
thread_traits<posix>::run(_Ctype *c)
{
pthread_create(&(c->getThreadIden()), NULL, posix_thread_function, (void *) c);
pthread_create(&(c->getThreadIden()), nullptr, posix_thread_function, (void *) c);
}
void *posix_detach_thread_function(void *c);
@ -42,21 +42,21 @@ namespace sthread
void
thread_traits<posix>::exit()
{
pthread_exit(NULL);
pthread_exit(nullptr);
}
template <>
void
thread_traits<posix>::join(_Ctype *c)
{
pthread_join(c->getThreadIden(), NULL);
pthread_join(c->getThreadIden(), nullptr);
}
template <>
void
mutex_traits<posix>::init(pthread_mutex_t &m)
{
pthread_mutex_init(&m, NULL);
pthread_mutex_init(&m, nullptr);
}
template <>
@ -77,7 +77,7 @@ namespace sthread
void
cond_traits<posix>::init(_Tcond &cond)
{
pthread_cond_init(&cond, NULL);
pthread_cond_init(&cond, nullptr);
}
template <>
@ -127,7 +127,7 @@ namespace sthread
{
ct->exit();
}
return NULL;
return nullptr;
}
void *
@ -146,7 +146,7 @@ namespace sthread
}
if (counter)
counter->decrease();
return NULL;
return nullptr;
}
}
#else

View File

@ -302,7 +302,7 @@ namespace sthread
{
auto it = _Tparent::find(mmkey(c, id));
if (it == _Tparent::end())
return NULL;
return nullptr;
return &((*it).second);
}
@ -502,7 +502,7 @@ namespace sthread
{
public:
condition_counter<thread_impl> *counter;
detach_thread() : counter(NULL)
detach_thread() : counter(nullptr)
{
}
void

View File

@ -57,7 +57,7 @@ Symmetry::isFull() const
beginning as subordinal |symiterator|. */
symiterator::symiterator(SymmetrySet &ss)
: s(ss), subit(NULL), subs(NULL), end_flag(false)
: s(ss), subit(nullptr), subs(nullptr), end_flag(false)
{
s.sym()[0] = 0;
if (s.size() == 2)

View File

@ -144,7 +144,7 @@ public:
if (it == m.end())
{
TL_RAISE("Symmetry not found in TensorContainer::get");
return NULL;
return nullptr;
}
else
{
@ -161,7 +161,7 @@ public:
if (it == m.end())
{
TL_RAISE("Symmetry not found in TensorContainer::get");
return NULL;
return nullptr;
}
else
{

View File

@ -65,7 +65,7 @@ class PowerProvider
int nv;
public:
PowerProvider(const ConstVector &v)
: origv(v), ut(NULL), ft(NULL), nv(v.length())
: origv(v), ut(nullptr), ft(nullptr), nv(v.length())
{
}
~PowerProvider();
@ -165,7 +165,7 @@ public:
PowerProvider pwp(xval);
for (int i = 1; i <= tp.maxdim; i++)
{
const _Stype &xpow = pwp.getNext((const _Stype *) NULL);
const _Stype &xpow = pwp.getNext((const _Stype *) nullptr);
for (int j = 0; j <= tp.maxdim-i; j++)
{
if (tp.check(Symmetry(i+j)))
@ -255,7 +255,7 @@ public:
PowerProvider pp(v);
for (int d = 1; d <= maxdim; d++)
{
const _Stype &p = pp.getNext((const _Stype *) NULL);
const _Stype &p = pp.getNext((const _Stype *) nullptr);
Symmetry cs(d);
if (_Tparent::check(cs))
{

View File

@ -10,9 +10,9 @@ TLStatic tls;
TLStatic::TLStatic()
{
ebundle = NULL;
pbundle = NULL;
ptriang = NULL;
ebundle = nullptr;
pbundle = nullptr;
ptriang = nullptr;
}
TLStatic::~TLStatic()

View File

@ -104,7 +104,7 @@ void
TwoDMatrix::save(const char *fname) const
{
FILE *fd;
if (NULL == (fd = fopen(fname, "w")))
if (nullptr == (fd = fopen(fname, "w")))
{
TL_RAISE("Cannot open file for writing in TwoDMatrix::save");
}

View File

@ -505,11 +505,11 @@ DenseDerivGenerator::DenseDerivGenerator(int ng, int nx, int ny, int nu,
Monom2Vector r(g, x);
xcont = x.deriv(maxdimen);
rcont = r.deriv(maxdimen);
uxcont = NULL;
uxcont = nullptr;
for (int d = 1; d <= maxdimen; d++)
{
ts[d-1] = g.deriv(d);
uts[d-1] = NULL;
uts[d-1] = nullptr;
}
}

View File

@ -49,7 +49,7 @@ ogu::calc_pos_line_and_col(int length, const char *str, int offset,
}
MemoryFile::MemoryFile(const char *fname)
: len(-1), data(NULL)
: len(-1), data(nullptr)
{
FILE *fd = fopen(fname, "rb");
if (fd)