1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

code cleaning

This commit is contained in:
Antonin Portelli 2014-03-03 14:21:37 +00:00
parent a66a2d8c5c
commit 15fa3f0354
27 changed files with 63 additions and 113 deletions

View File

@ -41,12 +41,6 @@ AsciiFile::AsciiParserState::~AsciiParserState(void)
}
// constructor /////////////////////////////////////////////////////////////////
AsciiFile::AsciiFile(void)
: File(), fileStream_()
, isParsed_(false)
, state_(nullptr)
{}
AsciiFile::AsciiFile(const string &name, const unsigned int mode)
{
open(name, mode);

View File

@ -25,6 +25,7 @@
#include <latan/Mat.hpp>
#include <latan/RandGen.hpp>
#include <latan/Sample.hpp>
#include <fstream>
BEGIN_NAMESPACE
@ -38,8 +39,8 @@ public:
{
public:
// constructor
explicit AsciiParserState(std::istream *stream, std::string *name,
IoDataTable *data);
AsciiParserState(std::istream *stream, std::string *name,
IoDataTable *data);
// destructor
virtual ~AsciiParserState(void);
// first element reference
@ -58,7 +59,7 @@ public:
};
public:
// constructors
AsciiFile(void);
AsciiFile(void) = default;
AsciiFile(const std::string &name, const unsigned int mode);
// destructor
virtual ~AsciiFile(void);
@ -78,8 +79,8 @@ private:
void parse(void);
private:
std::fstream fileStream_;
bool isParsed_;
std::unique_ptr<AsciiParserState> state_;
bool isParsed_{false};
std::unique_ptr<AsciiParserState> state_{nullptr};
};
END_NAMESPACE

View File

@ -18,16 +18,15 @@
*/
%{
#include <iostream>
#include <memory>
#include <sstream>
#include <utility>
#include <cstring>
#include <latan/Global.hpp>
#include <latan/AsciiFile.hpp>
#include <latan/Mat.hpp>
#include <latan/RandGen.hpp>
#include <latan/Sample.hpp>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstring>
using namespace std;
using namespace Latan;

View File

@ -23,7 +23,6 @@
#include <latan/Global.hpp>
#include <latan/Function.hpp>
#include <latan/Model.hpp>
#include <memory>
BEGIN_NAMESPACE
@ -45,7 +44,7 @@ private:
};
public:
// constructor
Chi2Function(const XYStatData &data);
explicit Chi2Function(const XYStatData &data);
Chi2Function(const XYStatData &data,
const std::vector<const DoubleModel *> &modelVector);
// destructor

View File

@ -23,10 +23,8 @@
#include <latan/Global.hpp>
#include <latan/Function.hpp>
#include <latan/MathInterpreter.hpp>
#include <memory>
#include <stack>
#include <vector>
#include <cstdarg>
BEGIN_NAMESPACE
@ -37,7 +35,7 @@ class CompiledDoubleFunction: public DoubleFunction
{
public:
// constructors
CompiledDoubleFunction(const unsigned nArg);
explicit CompiledDoubleFunction(const unsigned nArg);
CompiledDoubleFunction(const unsigned nArg, const std::string &code);
// destructor
virtual ~CompiledDoubleFunction(void) = default;

View File

@ -39,10 +39,10 @@ private:
typedef StatArray<T> Base;
public:
// constructors
using Base::Base;
Dataset(void);
Dataset(void) = default;
template <typename FileType>
Dataset(const std::string &listFileName, const std::string &dataName);
using Base::Base;
// destructor
virtual ~Dataset(void) = default;
// IO
@ -59,10 +59,6 @@ private:
* Dataset template implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
template <typename T>
Dataset<T>::Dataset(void)
{}
template <typename T>
template <typename FileType>
Dataset<T>::Dataset(const std::string &listFileName,

View File

@ -36,7 +36,7 @@ std::cerr << Env::msgPrefix << "warning: " << msg\
class name: public base\
{\
public:\
explicit name(std::string msg, std::string loc);\
name(std::string msg, std::string loc);\
}
BEGIN_NAMESPACE

View File

@ -27,16 +27,9 @@ using namespace Latan;
* File implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
File::File(void)
: name_("")
, mode_(Mode::null)
, data_()
{}
File::File(const string &name, const unsigned int mode)
: name_(name)
, mode_(mode)
, data_()
{}
// destructor //////////////////////////////////////////////////////////////////

View File

@ -20,15 +20,11 @@
#ifndef Latan_Io_hpp_
#define Latan_Io_hpp_
#include <fstream>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <unordered_map>
#include <latan/Global.hpp>
#include <latan/IoObject.hpp>
#include <latan/ParserState.hpp>
#include <queue>
#include <unordered_map>
BEGIN_NAMESPACE
@ -59,7 +55,7 @@ public:
};
public:
// constructors
File(void);
File(void) = default;
File(const std::string &name, const unsigned int mode);
// destructor
virtual ~File(void);
@ -93,8 +89,8 @@ private:
// IO
virtual std::string load(const std::string &name = "") = 0;
protected:
std::string name_;
unsigned int mode_;
std::string name_{""};
unsigned int mode_{Mode::null};
IoDataTable data_;
};

View File

@ -23,7 +23,6 @@
#include <latan/Global.hpp>
#include <latan/Mat.hpp>
#include <functional>
#include <memory>
#include <stack>
#include <vector>
@ -38,7 +37,8 @@ private:
typedef std::function<double(const double *)> vecFunc;
public:
// constructor
DoubleFunction(const Index nArg = 0, const vecFunc &f = nullFunction_);
explicit DoubleFunction(const Index nArg = 0,
const vecFunc &f = nullFunction_);
// destructor
virtual ~DoubleFunction(void) = default;
// access

View File

@ -21,7 +21,7 @@
#define Latan_Global_hpp_
#include <latan/Eigen/Dense>
#include <map>
#include <memory>
#include <string>
#include <sstream>
#include <type_traits>

View File

@ -27,10 +27,6 @@ using namespace Latan;
* DMat class *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
DMat::DMat(void)
: Base()
{}
DMat::DMat(const Index nRow, const Index nCol)
: Base(nRow, nCol)
{}

View File

@ -35,7 +35,7 @@ private:
typedef DMatBase Base;
public:
// constructors
DMat(void);
DMat(void) = default;
DMat(const Index nRow, const Index nCol);
EIGEN_EXPR_CTOR(DMat, DMat, Base, MatrixBase)
// destructor

View File

@ -23,7 +23,6 @@
#include <latan/Global.hpp>
#include <latan/Function.hpp>
#include <latan/MathInterpreter.hpp>
#include <vector>
BEGIN_NAMESPACE

View File

@ -382,20 +382,8 @@ MathInterpreter::MathParserState::~MathParserState(void)
}
// constructors ////////////////////////////////////////////////////////////////
MathInterpreter::MathInterpreter(void)
: code_(nullptr)
, codeName_("<no_code>")
, state_(nullptr)
, root_(nullptr)
, status_(Status::none)
{}
MathInterpreter::MathInterpreter(const std::string &code)
: code_(nullptr)
, codeName_("<string>")
, state_(nullptr)
, root_(nullptr)
, status_(Status::none)
: codeName_("<string>")
{
setCode(code);
}

View File

@ -84,8 +84,8 @@ private:
virtual void print(std::ostream& out) const;
private:
ArgType type_;
double val_;
std::string name_;
double val_;
std::string name_;
};
// Pop
@ -135,7 +135,7 @@ private:
class name: public Instruction\
{\
public:\
virtual void operator()(RunContext &context) const;\
virtual void operator()(RunContext &context) const;\
private:\
virtual void print(std::ostream &out) const;\
}
@ -154,7 +154,7 @@ class ExprNode
{
public:
// constructors
ExprNode(const std::string &name);
explicit ExprNode(const std::string &name);
// destructor
virtual ~ExprNode() = default;
// access
@ -205,7 +205,6 @@ DECL_NODE(KeywordNode, ReturnNode);
******************************************************************************/
class MathInterpreter
{
public:
// parser state
class MathParserState: public ParserState<std::unique_ptr<ExprNode>>
@ -236,7 +235,7 @@ private:
};
public:
// constructors
MathInterpreter(void);
MathInterpreter(void) = default;
MathInterpreter(const std::string &code);
// destructor
~MathInterpreter(void) = default;
@ -264,12 +263,12 @@ private:
// execution
void execute(RunContext &context) const;
private:
std::unique_ptr<std::istream> code_;
std::string codeName_;
std::unique_ptr<MathParserState> state_;
std::unique_ptr<ExprNode> root_;
std::unique_ptr<std::istream> code_{nullptr};
std::string codeName_{"<no_code>"};
std::unique_ptr<MathParserState> state_{nullptr};
std::unique_ptr<ExprNode> root_{nullptr};
Program program_;
unsigned int status_;
unsigned int status_{Status::none};
};
std::ostream & operator<<(std::ostream &out, const MathInterpreter &program);

View File

@ -41,7 +41,7 @@ public:
};
public:
// constructor
Minimizer(Verbosity verbosity = Verbosity::Silent);
explicit Minimizer(Verbosity verbosity = Verbosity::Silent);
// destructor
virtual ~Minimizer(void) = default;
// access

View File

@ -22,7 +22,6 @@
#include <latan/Global.hpp>
#include <latan/Mat.hpp>
#include <memory>
#include <vector>
BEGIN_NAMESPACE

View File

@ -22,7 +22,6 @@
#include <latan/Global.hpp>
#include <iostream>
#include <string>
BEGIN_NAMESPACE
@ -31,8 +30,7 @@ class ParserState
{
public:
// constructor
explicit ParserState(std::istream *streamPt, std::string *namePt,
DataObj *dataPt);
ParserState(std::istream *streamPt, std::string *namePt, DataObj *dataPt);
// destructor
virtual ~ParserState(void) = default;
private:

View File

@ -143,10 +143,6 @@ void PlotRange::operator()(PlotOptions &option) const
/******************************************************************************
* Plot implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
Plot::Plot(void)
{}
// destructor //////////////////////////////////////////////////////////////////
Plot::~Plot(void)
{

View File

@ -20,11 +20,11 @@
#ifndef Latan_Plot_hpp_
#define Latan_Plot_hpp_
#include <latan/Global.hpp>
#include <latan/XYStatData.hpp>
#include <sstream>
#include <stack>
#include <vector>
#include <latan/Global.hpp>
#include <latan/XYStatData.hpp>
// gnuplot default parameters
#ifndef GNUPLOT_BIN
@ -144,7 +144,7 @@ class PlotRange: public PlotModifier
{
public:
// constructor
explicit PlotRange(const Axis axis, const double min, const double max);
PlotRange(const Axis axis, const double min, const double max);
// destructor
virtual ~PlotRange(void) = default;
// modifier
@ -172,7 +172,7 @@ public:
};
public:
// constructor/destructor
Plot(void);
Plot(void) = default;
virtual ~Plot(void);
// plot operations
Plot & operator<<(PlotObject &&command);

View File

@ -41,7 +41,6 @@ IoObject::IoType RandGenState::getType(void) const
******************************************************************************/
// RanLxd implementation ///////////////////////////////////////////////////////
RandGen::RanLxd::RanLxd(void)
: init(0)
{
// avoid a warning in the SSE case
one_bit = 0.0;

View File

@ -50,14 +50,14 @@ private:
class RanLxd
{
private:
typedef struct
typedef struct alignas(16)
{
float c1,c2,c3,c4;
} rlxd_vec_t __attribute__ ((aligned (16)));
typedef struct
} rlxd_vec_t;
typedef struct alignas(16)
{
rlxd_vec_t c1,c2;
} rlxd_dble_vec_t __attribute__ ((aligned (16)));
} rlxd_dble_vec_t;
public:
RanLxd(void);
~RanLxd(void) = default;
@ -71,20 +71,20 @@ private:
void update(void);
void define_constants(void);
private:
int init, rlxd_pr, prm, ir, jr, is, is_old, next[96];
int init{0}, rlxd_pr, prm, ir, jr, is, is_old, next[96];
rlxd_vec_t one_sse, one_bit_sse, carry;
double one_bit;
union
union alignas(16)
{
rlxd_dble_vec_t vec[12];
float num[96];
} rlxd_x __attribute__ ((aligned (16)));
} rlxd_x;
};
public:
// constructors
RandGen(void);
RandGen(const int seed);
RandGen(const RandGenState &state);
explicit RandGen(const int seed);
explicit RandGen(const RandGenState &state);
// destructor
virtual ~RandGen(void) = default;
// state management

View File

@ -27,10 +27,6 @@ using namespace std;
* DMatSample implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
DMatSample::DMatSample(void)
: Sample<DMat>()
{}
DMatSample::DMatSample(const Index nSample, const Index nRow,
const Index nCol)
: Sample<DMat>(nSample)
@ -41,7 +37,10 @@ DMatSample::DMatSample(const Index nSample, const Index nRow,
// resize all matrices /////////////////////////////////////////////////////////
void DMatSample::resizeMat(const Index nRow, const Index nCol)
{
this->unaryExpr([nRow, nCol](DMat &m){m.resize(nRow, nCol);});
FOR_VEC(*this, s)
{
(*this)[s].resize(nRow, nCol);
}
}
// IO type /////////////////////////////////////////////////////////////////////

View File

@ -41,6 +41,7 @@ private:
typedef StatArray<T, SAMPLE_OFFSET> Base;
public:
// constructors
Sample(void) = default;
using Base::Base;
// destructor
virtual ~Sample(void) = default;
@ -53,7 +54,7 @@ class DMatSample: public Sample<DMat>, public IoObject
{
public:
// constructors
DMatSample(void);
DMatSample(void) = default;
DMatSample(const Index nSample, const Index nRow, const Index nCol);
using Sample<DMat>::Sample;
// destructor

View File

@ -37,7 +37,7 @@ private:
public:
// constructors
StatArray(void);
StatArray(const Index size);
explicit StatArray(const Index size);
EIGEN_EXPR_CTOR(StatArray, unique_arg(StatArray<T, offset>), Base,
ArrayBase)
// destructor

View File

@ -26,7 +26,6 @@
#include <latan/Mat.hpp>
#include <latan/Minimizer.hpp>
#include <latan/Model.hpp>
#include <memory>
BEGIN_NAMESPACE
@ -38,7 +37,8 @@ class FitResult: public DVec
friend class XYStatData;
public:
// constructors
using DVec::DVec;
FitResult(void) = default;
EIGEN_EXPR_CTOR(FitResult, FitResult, Base, MatrixBase)
// destructor
virtual ~FitResult(void) = default;
// access
@ -108,10 +108,10 @@ public:
const DVec &init, const bool reinitChi2 = true,
const FitVerbosity verbosity = FitVerbosity::Silent);
private:
DMat x_, y_;
Mat<DMat> var_[3];
IVec isXExact_, isFitPoint_;
Chi2Function chi2_;
DMat x_, y_;
Mat<DMat> var_[3];
IVec isXExact_, isFitPoint_;
Chi2Function chi2_;
};
/******************************************************************************