1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-13 01:35:35 +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 ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
AsciiFile::AsciiFile(void)
: File(), fileStream_()
, isParsed_(false)
, state_(nullptr)
{}
AsciiFile::AsciiFile(const string &name, const unsigned int mode) AsciiFile::AsciiFile(const string &name, const unsigned int mode)
{ {
open(name, mode); open(name, mode);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,14 +50,14 @@ private:
class RanLxd class RanLxd
{ {
private: private:
typedef struct typedef struct alignas(16)
{ {
float c1,c2,c3,c4; float c1,c2,c3,c4;
} rlxd_vec_t __attribute__ ((aligned (16))); } rlxd_vec_t;
typedef struct typedef struct alignas(16)
{ {
rlxd_vec_t c1,c2; rlxd_vec_t c1,c2;
} rlxd_dble_vec_t __attribute__ ((aligned (16))); } rlxd_dble_vec_t;
public: public:
RanLxd(void); RanLxd(void);
~RanLxd(void) = default; ~RanLxd(void) = default;
@ -71,20 +71,20 @@ private:
void update(void); void update(void);
void define_constants(void); void define_constants(void);
private: 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; rlxd_vec_t one_sse, one_bit_sse, carry;
double one_bit; double one_bit;
union union alignas(16)
{ {
rlxd_dble_vec_t vec[12]; rlxd_dble_vec_t vec[12];
float num[96]; float num[96];
} rlxd_x __attribute__ ((aligned (16))); } rlxd_x;
}; };
public: public:
// constructors // constructors
RandGen(void); RandGen(void);
RandGen(const int seed); explicit RandGen(const int seed);
RandGen(const RandGenState &state); explicit RandGen(const RandGenState &state);
// destructor // destructor
virtual ~RandGen(void) = default; virtual ~RandGen(void) = default;
// state management // state management

View File

@ -27,10 +27,6 @@ using namespace std;
* DMatSample implementation * * DMatSample implementation *
******************************************************************************/ ******************************************************************************/
// constructors //////////////////////////////////////////////////////////////// // constructors ////////////////////////////////////////////////////////////////
DMatSample::DMatSample(void)
: Sample<DMat>()
{}
DMatSample::DMatSample(const Index nSample, const Index nRow, DMatSample::DMatSample(const Index nSample, const Index nRow,
const Index nCol) const Index nCol)
: Sample<DMat>(nSample) : Sample<DMat>(nSample)
@ -41,7 +37,10 @@ DMatSample::DMatSample(const Index nSample, const Index nRow,
// resize all matrices ///////////////////////////////////////////////////////// // resize all matrices /////////////////////////////////////////////////////////
void DMatSample::resizeMat(const Index nRow, const Index nCol) 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 ///////////////////////////////////////////////////////////////////// // IO type /////////////////////////////////////////////////////////////////////

View File

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

View File

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

View File

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