1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-19 13:15:37 +01:00

reintegration of LatCore & folder restructuration

This commit is contained in:
Antonin Portelli 2019-02-10 00:23:36 +00:00
parent 6addec5e14
commit 83d5428c3a
111 changed files with 6974 additions and 315 deletions

5
.gitignore vendored
View File

@ -31,11 +31,6 @@ lib/eigen_files.mk
# CI builds
ci-scripts/local/*
# CLion stuff
.idea/*
CMakeLists.txt
cmake-build-debug/*
# VS Code Studio stuff
.vscode
*.code-workspace

View File

@ -2,4 +2,5 @@
rm -rf .buildutils
mkdir -p .buildutils/m4
./update_eigen.sh eigen-3.3.4.tar.bz2
autoreconf -fvi

View File

@ -13,4 +13,3 @@ for d in nlopt minuit hdf5; do
./install-${d}.sh ${PREFIX}
fi
done
./install-latcore.sh ${PREFIX}

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
if (( $# != 1 )); then
echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1
fi
PREFIX=$1
set -ex
INITDIR=`pwd`
cd local/build
if [ -d LatCore ]; then
cd LatCore
git pull origin master
else
git clone https://github.com/aportelli/LatCore.git
mkdir LatCore/build
cd LatCore
./bootstrap.sh
fi
cd build
../configure --prefix=${PREFIX}
make -j4
make install
cd ${INITDIR}

View File

@ -8,7 +8,7 @@ AC_CONFIG_SRCDIR([lib/Global.cpp])
AC_CONFIG_SRCDIR([utils/sample_read.cpp])
AC_CONFIG_SRCDIR([examples/exMathInterpreter.cpp])
AC_CONFIG_MACRO_DIR([.buildutils/m4])
AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign])
AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign subdir-objects])
AM_SILENT_RULES([yes])
AC_CONFIG_HEADERS([config.h])
AM_CONDITIONAL([HAVE_AM_MINOR_LE_11],
@ -48,11 +48,6 @@ AC_ARG_WITH([hdf5],
[try this for a non-standard install prefix of the HDF5 library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_hdf5/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_hdf5/lib"])
AC_ARG_WITH([latcore],
[AS_HELP_STRING([--with-latcore=prefix],
[use this option for a non-standard install prefix of the LatCore library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_latcore/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_latcore/lib"])
# Get compilers informations
AX_COMPILER_VENDOR
@ -109,17 +104,6 @@ AC_LINK_IFELSE(
[AC_MSG_RESULT([no])])
AM_CONDITIONAL([HAVE_MINUIT], [test x$have_minuit = xtrue])
LDFLAGS=$SAVED_LDFLAGS
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -lLatCore"
AC_MSG_CHECKING([for LatCore::XmlReader in -lLatCore]);
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <LatCore/XmlReader.hpp>],
[LatCore::XmlReader dummy()])],
[LIBS="$LIBS -lLatCore"]
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
[AC_MSG_ERROR([LatCore library not found])])
LDFLAGS=$SAVED_LDFLAGS
CXXFLAGS=$CXXFLAGS_CPY
LDFLAGS=$LDFLAGS_CPY

BIN
eigen-3.3.4.tar.bz2 Normal file

Binary file not shown.

View File

@ -1,4 +1,4 @@
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,6 +1,6 @@
#include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Numerical/Derivative.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,10 +1,10 @@
#include <iostream>
#include <cmath>
#include <LatAnalyze/CompiledModel.hpp>
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/GslMinimizer.hpp>
#include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/Functional/CompiledModel.hpp>
#include <LatAnalyze/Io/Io.hpp>
#include <LatAnalyze/Numerical/GslMinimizer.hpp>
#include <LatAnalyze/Core/Plot.hpp>
#include <LatAnalyze/Statistics/XYStatData.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,7 +1,7 @@
#include <LatAnalyze/CompiledModel.hpp>
#include <LatAnalyze/GslMinimizer.hpp>
#include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/XYSampleData.hpp>
#include <LatAnalyze/Functional/CompiledModel.hpp>
#include <LatAnalyze/Numerical/GslMinimizer.hpp>
#include <LatAnalyze/Core/Plot.hpp>
#include <LatAnalyze/Statistics/XYSampleData.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/GslQagsIntegrator.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Numerical/GslQagsIntegrator.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,4 +1,4 @@
#include <LatAnalyze/TabFunction.hpp>
#include <LatAnalyze/Functional/TabFunction.hpp>
int main(void)
{

View File

@ -1,6 +1,6 @@
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Io/Io.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/GslMinimizer.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Numerical/GslMinimizer.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,7 +1,7 @@
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/TabFunction.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/Core/Plot.hpp>
#include <LatAnalyze/Functional/TabFunction.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,6 +1,6 @@
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/Io/Io.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Core/Plot.hpp>
using namespace std;
using namespace Latan;

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/GslHybridRootFinder.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/GslHybridRootFinder.hpp>
using namespace std;
using namespace Latan;

123
lib/Core/Eigen.hpp Normal file
View File

@ -0,0 +1,123 @@
/*
* Eigen.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2016 Antonin Portelli
*
* LatAnalyze 3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze 3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
// Eigen inclusion
#define EIGEN_DONT_PARALLELIZE
#define EIGEN_MATRIXBASE_PLUGIN <LatAnalyze/Core/EigenPlugin.hpp>
#include <LatAnalyze/Eigen/Dense>
// copy/assignement from Eigen expression
#define EIGEN_EXPR_CTOR(ctorName, Class, Base, ExprType) \
template <typename Derived>\
ctorName(const ExprType<Derived> &m): Base(m) {}\
template<typename Derived>\
Class & operator=(const ExprType<Derived> &m)\
{\
this->Base::operator=(m);\
return *this;\
}
#define FOR_MAT(mat, i, j) \
for (Latan::Index j = 0; j < mat.cols(); ++j)\
for (Latan::Index i = 0; i < mat.rows(); ++i)
BEGIN_LATAN_NAMESPACE
const int dynamic = Eigen::Dynamic;
// array types
template <typename Derived>
using ArrayExpr = Eigen::ArrayBase<Derived>;
template <typename T, int nRow = dynamic, int nCol = dynamic>
using Array = Eigen::Array<T, nRow, nCol>;
// matrix types
template <typename Derived>
using MatExpr = Eigen::MatrixBase<Derived>;
template <typename T, int nRow = dynamic, int nCol = dynamic>
using MatBase = Eigen::Matrix<T, nRow, nCol>;
template <int nRow, int nCol>
using SFMat = Eigen::Matrix<float, nRow, nCol>;
template <int nRow, int nCol>
using SDMat = Eigen::Matrix<double, nRow, nCol>;
template <int nRow, int nCol>
using SCMat = Eigen::Matrix<std::complex<double>, nRow, nCol>;
// vector types
template <typename T, int size = dynamic>
using Vec = MatBase<T, size, 1>;
template <int size>
using SIVec = Vec<int, size>;
template <int size>
using SUVec = Vec<unsigned int, size>;
template <int size>
using SFVec = Vec<float, size>;
template <int size>
using SDVec = Vec<double, size>;
template <int size>
using SCVec = Vec<std::complex<double>, size>;
typedef SIVec<dynamic> IVec;
typedef SUVec<dynamic> UVec;
typedef SDVec<dynamic> DVec;
typedef SCVec<dynamic> CVec;
// block types
template <typename Derived>
using Block = Eigen::Block<Derived>;
template <typename Derived>
using ConstBlock = const Eigen::Block<const Derived>;
template <typename Derived>
using Row = typename Derived::RowXpr;
template <typename Derived>
using ConstRow = typename Derived::ConstRowXpr;
template <typename Derived>
using Col = typename Derived::ColXpr;
template <typename Derived>
using ConstCol = typename Derived::ConstColXpr;
// map type
template <int stride>
using InnerStride = Eigen::InnerStride<stride>;
template <int rowStride, int colStride>
using Stride = Eigen::Stride<rowStride, colStride>;
template <typename Derived, typename StrideType = Stride<0, 0>>
using Map = Eigen::Map<Derived, Eigen::Unaligned, StrideType>;
template <typename Derived, typename StrideType = Stride<0, 0>>
using ConstMap = Eigen::Map<const Derived, Eigen::Unaligned, StrideType>;
// Index type //////////////////////////////////////////////////////////////////
typedef MatBase<int>::Index Index;
#define FOR_VEC(vec, i) for (Latan::Index i = 0; i < (vec).size(); ++i)
#define FOR_ARRAY(ar, i) FOR_VEC(ar, i)
END_LATAN_NAMESPACE

60
lib/Core/EigenPlugin.hpp Normal file
View File

@ -0,0 +1,60 @@
/*
* EigenPlugin.hpp, part of LatAnalyze
*
* Copyright (C) 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
Derived pInverse(const double tolerance = 1.0e-10)
{
auto svd = jacobiSvd(Eigen::ComputeThinU|Eigen::ComputeThinV);
const auto u = svd.matrixU();
const auto v = svd.matrixV();
auto s = svd.singularValues();
double maxsv = 0.;
unsigned int elim = 0;
for (Index i = 0; i < s.rows(); ++i)
{
if (fabs(s(i)) > maxsv) maxsv = fabs(s(i));
}
for (Index i = 0; i < s.rows(); ++i)
{
if (fabs(s(i)) > maxsv*tolerance)
{
s(i) = 1./s(i);
}
else
{
elim++;
s(i) = 0.;
}
}
if (elim)
{
std::cerr << "warning: pseudoinverse: " << elim << "/";
std::cerr << s.rows() << " singular value(s) eliminated (tolerance= ";
std::cerr << tolerance << ")" << std::endl;
}
return v*s.asDiagonal()*u.transpose();
}
Derived singularValues(void)
{
auto svd = jacobiSvd();
return svd.singularValues();
}

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Exceptions.hpp>
#include <LatAnalyze/Core/Exceptions.hpp>
#include <LatAnalyze/includes.hpp>
#ifndef ERR_SUFF

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,11 +21,7 @@
#define Latan_Mat_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/IoObject.hpp>
#define FOR_MAT(mat, i, j) \
for (Latan::Index j = 0; j < mat.cols(); ++j)\
for (Latan::Index i = 0; i < mat.rows(); ++i)
#include <LatAnalyze/Io/IoObject.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/includes.hpp>
#include <gsl/gsl_cdf.h>

View File

@ -21,8 +21,8 @@
#define Latan_Math_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -20,9 +20,9 @@
#ifndef Latan_MathInterpreter_hpp_
#define Latan_MathInterpreter_hpp_
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/ParserState.hpp>
#include <LatAnalyze/Core/ParserState.hpp>
#define MAXIDLENGTH 256

View File

@ -25,7 +25,7 @@
%option yylineno
%{
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
#include "MathParser.hpp"
using namespace std;

View File

@ -19,7 +19,7 @@
%{
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
using namespace std;
using namespace Latan;

272
lib/Core/OptParser.cpp Normal file
View File

@ -0,0 +1,272 @@
/*
* OptParser.cpp, part of LatAnalyze
*
* Copyright (C) 2016 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Core/OptParser.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
static char optRegex[] = "(-([a-zA-Z])(.+)?)|(--([a-zA-Z_-]+)=?(.+)?)";
/******************************************************************************
* OptParser implementation *
******************************************************************************/
// regular expressions /////////////////////////////////////////////////////////
const regex OptParser::optRegex_(optRegex);
// access //////////////////////////////////////////////////////////////////////
void OptParser::addOption(const std::string shortName,
const std::string longName,
const OptType type, const bool optional,
const std::string helpMessage,
const std::string defaultVal)
{
OptPar par;
par.shortName = shortName;
par.longName = longName;
par.defaultVal = defaultVal;
par.helpMessage = helpMessage;
par.type = type;
par.optional = optional;
opt_.push_back(par);
}
bool OptParser::gotOption(const std::string name) const
{
int i = optIndex(name);
if (result_.size() != opt_.size())
{
throw(runtime_error("options not parsed"));
}
if (i >= 0)
{
return result_[i].present;
}
else
{
throw(out_of_range("no option with name '" + name + "'"));
}
}
const vector<string> & OptParser::getArgs(void) const
{
return arg_;
}
// parse ///////////////////////////////////////////////////////////////////////
bool OptParser::parse(int argc, char *argv[])
{
smatch sm;
queue<string> arg;
int expectVal = -1;
bool isCorrect = true;
for (int i = 1; i < argc; ++i)
{
arg.push(argv[i]);
}
result_.clear();
result_.resize(opt_.size());
arg_.clear();
for (unsigned int i = 0; i < opt_.size(); ++i)
{
result_[i].value = opt_[i].defaultVal;
}
while (!arg.empty())
{
// option
if (regex_match(arg.front(), sm, optRegex_))
{
// should it be a value?
if (expectVal >= 0)
{
cerr << "warning: expected value for option ";
cerr << optName(opt_[expectVal]);
cerr << ", got option '" << arg.front() << "' instead" << endl;
expectVal = -1;
isCorrect = false;
}
// short option
if (sm[1].matched)
{
string optName = sm[2].str();
// find option
auto it = find_if(opt_.begin(), opt_.end(),
[&optName](const OptPar &p)
{
return (p.shortName == optName);
});
// parse if found
if (it != opt_.end())
{
unsigned int i = it - opt_.begin();
result_[i].present = true;
if (opt_[i].type == OptType::value)
{
if (sm[3].matched)
{
result_[i].value = sm[3].str();
}
else
{
expectVal = i;
}
}
}
// warning if not found
else
{
cerr << "warning: unknown option '" << arg.front() << "'";
cerr << endl;
}
}
// long option
else if (sm[4].matched)
{
string optName = sm[5].str();
// find option
auto it = find_if(opt_.begin(), opt_.end(),
[&optName](const OptPar &p)
{
return (p.longName == optName);
});
// parse if found
if (it != opt_.end())
{
unsigned int i = it - opt_.begin();
result_[i].present = true;
if (opt_[i].type == OptType::value)
{
if (sm[6].matched)
{
result_[i].value = sm[6].str();
}
else
{
expectVal = i;
}
}
}
// warning if not found
else
{
cerr << "warning: unknown option '" << arg.front() << "'";
cerr << endl;
}
}
}
else if (expectVal >= 0)
{
result_[expectVal].value = arg.front();
expectVal = -1;
}
else
{
arg_.push_back(arg.front());
}
arg.pop();
}
if (expectVal >= 0)
{
cerr << "warning: expected value for option ";
cerr << optName(opt_[expectVal]) << endl;
expectVal = -1;
isCorrect = false;
}
for (unsigned int i = 0; i < opt_.size(); ++i)
{
if (!opt_[i].optional and !result_[i].present)
{
cerr << "warning: mandatory option " << optName(opt_[i]);
cerr << " is missing" << endl;
isCorrect = false;
}
}
return isCorrect;
}
// find option index ///////////////////////////////////////////////////////////
int OptParser::optIndex(const string name) const
{
auto it = find_if(opt_.begin(), opt_.end(), [&name](const OptPar &p)
{
return (p.shortName == name) or (p.longName == name);
});
if (it != opt_.end())
{
return static_cast<int>(it - opt_.begin());
}
else
{
return -1;
}
}
// option name for messages ////////////////////////////////////////////////////
std::string OptParser::optName(const OptPar &opt)
{
std::string res = "";
if (!opt.shortName.empty())
{
res += "-" + opt.shortName;
if (!opt.longName.empty())
{
res += "/";
}
}
if (!opt.longName.empty())
{
res += "--" + opt.longName;
if (opt.type == OptParser::OptType::value)
{
res += "=";
}
}
return res;
}
// print option list ///////////////////////////////////////////////////////////
std::ostream & Latan::operator<<(std::ostream &out, const OptParser &parser)
{
for (auto &o: parser.opt_)
{
out << setw(20) << OptParser::optName(o);
out << ": " << o.helpMessage;
if (!o.defaultVal.empty())
{
out << " (default: " << o.defaultVal << ")";
}
out << endl;
}
return out;
}

103
lib/Core/OptParser.hpp Normal file
View File

@ -0,0 +1,103 @@
/*
* OptParser.hpp, part of LatAnalyze
*
* Copyright (C) 2016 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LatAnalyze_OptParser_hpp_
#define LatAnalyze_OptParser_hpp_
#include <LatAnalyze/Global.hpp>
BEGIN_LATAN_NAMESPACE
/******************************************************************************
* command-line option parser *
******************************************************************************/
class OptParser
{
public:
enum class OptType {value, trigger};
private:
struct OptPar
{
std::string shortName, longName, defaultVal, helpMessage;
OptType type;
bool optional;
};
struct OptRes
{
std::string value;
bool present;
};
public:
// constructor
OptParser(void) = default;
// destructor
virtual ~OptParser(void) = default;
// access
void addOption(const std::string shortName, const std::string longName,
const OptType type, const bool optional = false,
const std::string helpMessage = "",
const std::string defaultVal = "");
bool gotOption(const std::string name) const;
template <typename T = std::string>
T optionValue(const std::string name) const;
const std::vector<std::string> & getArgs(void) const;
// parse
bool parse(int argc, char *argv[]);
// print option list
friend std::ostream & operator<<(std::ostream &out,
const OptParser &parser);
private:
// find option index
int optIndex(const std::string name) const;
// option name for messages
static std::string optName(const OptPar &opt);
private:
std::vector<OptPar> opt_;
std::vector<OptRes> result_;
std::vector<std::string> arg_;
static const std::regex optRegex_;
};
std::ostream & operator<<(std::ostream &out, const OptParser &parser);
/******************************************************************************
* OptParser template implementation *
******************************************************************************/
template <typename T>
T OptParser::optionValue(const std::string name) const
{
int i = optIndex(name);
if (result_.size() != opt_.size())
{
throw(std::runtime_error("options not parsed"));
}
if (i >= 0)
{
return strTo<T>(result_[i].value);
}
else
{
throw(std::out_of_range("no option with name '" + name + "'"));
}
}
END_LATAN_NAMESPACE
#endif // LatAnalyze_OptParser_hpp_

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/Core/Plot.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Core/Mat.hpp>
using namespace std;
using namespace Latan;

View File

@ -21,11 +21,11 @@
#define Latan_Plot_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Histogram.hpp>
#include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
#include <LatAnalyze/Statistics/Histogram.hpp>
#include <LatAnalyze/Statistics/XYStatData.hpp>
// gnuplot default parameters
#ifndef GNUPLOT_BIN

137
lib/Core/Utilities.cpp Normal file
View File

@ -0,0 +1,137 @@
/*
* Utilities.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Core/Utilities.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
void Latan::testFunction(void)
{}
ostream & Latan::operator<<(ostream &out, const ProgressBar &&bar)
{
const Index nTick = bar.nCol_*bar.current_/bar.total_;
out << "[";
for (Index i = 0; i < nTick; ++i)
{
out << "=";
}
for (Index i = nTick; i < bar.nCol_; ++i)
{
out << " ";
}
out << "] " << bar.current_ << "/" << bar.total_;
out.flush();
return out;
}
int Latan::mkdir(const std::string dirName)
{
if (access(dirName.c_str(), R_OK|W_OK|X_OK))
{
mode_t mode755;
char tmp[MAX_PATH_LENGTH];
char *p = NULL;
size_t len;
mode755 = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
snprintf(tmp, sizeof(tmp), "%s", dirName.c_str());
len = strlen(tmp);
if(tmp[len - 1] == '/')
{
tmp[len - 1] = 0;
}
for(p = tmp + 1; *p; p++)
{
if(*p == '/')
{
*p = 0;
::mkdir(tmp, mode755);
*p = '/';
}
}
return ::mkdir(tmp, mode755);
}
else
{
return 0;
}
}
string Latan::basename(const string &s)
{
constexpr char sep = '/';
size_t i = s.rfind(sep, s.length());
if (i != string::npos)
{
return s.substr(i+1, s.length() - i);
}
else
{
return s;
}
}
std::string Latan::dirname(const std::string &s)
{
constexpr char sep = '/';
size_t i = s.rfind(sep, s.length());
if (i != std::string::npos)
{
return s.substr(0, i);
}
else
{
return "";
}
}
VarName::VarName(const string defName)
: defName_(defName)
{}
string VarName::getName(const Index i) const
{
if (hasName(i))
{
return name_.at(i);
}
else
{
return defName_ + "_" + strFrom(i);
}
}
void VarName::setName(const Index i, const string name)
{
name_[i] = name;
}
bool VarName::hasName(const Index i) const
{
return (name_.find(i) != name_.end());
}

250
lib/Core/Utilities.hpp Normal file
View File

@ -0,0 +1,250 @@
/*
* Utilities.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LatAnalyze_Utilities_hpp_
#define LatAnalyze_Utilities_hpp_
#ifndef LATAN_GLOBAL_HPP_
#include <LatAnalyze/Global.hpp>
#endif
BEGIN_LATAN_NAMESPACE
// Random seed type ////////////////////////////////////////////////////////////
typedef std::random_device::result_type SeedType;
// Type utilities //////////////////////////////////////////////////////////////
// pointer type test
template <typename Derived, typename Base>
inline bool isDerivedFrom(const Base *pt)
{
return (dynamic_cast<const Derived *>(pt) != nullptr);
}
// static logical or
template <bool... b>
struct static_or;
template <bool... tail>
struct static_or<true, tail...> : static_or<tail...> {};
template <bool... tail>
struct static_or<false, tail...> : std::false_type {};
template <>
struct static_or<> : std::true_type {};
// Environment /////////////////////////////////////////////////////////////////
void testFunction(void);
// String utilities ////////////////////////////////////////////////////////////
inline std::string extension(const std::string fileName)
{
return fileName.substr(fileName.find_last_of(".") + 1);
}
template <typename T>
inline T strTo(const std::string &str)
{
T buf;
std::istringstream stream(str);
stream >> buf;
return buf;
}
// optimized specializations
template <>
inline float strTo<float>(const std::string &str)
{
return strtof(str.c_str(), (char **)NULL);
}
template <>
inline double strTo<double>(const std::string &str)
{
return strtod(str.c_str(), (char **)NULL);
}
template <>
inline int strTo<int>(const std::string &str)
{
return (int)(strtol(str.c_str(), (char **)NULL, 10));
}
template <>
inline long strTo<long>(const std::string &str)
{
return strtol(str.c_str(), (char **)NULL, 10);
}
template <>
inline std::string strTo<std::string>(const std::string &str)
{
return str;
}
template <typename T>
inline std::string strFrom(const T x)
{
std::ostringstream stream;
stream << x;
return stream.str();
}
// specialization for vectors
template<>
inline DVec strTo<DVec>(const std::string &str)
{
DVec res;
std::vector<double> vbuf;
double buf;
std::istringstream stream(str);
while (!stream.eof())
{
stream >> buf;
vbuf.push_back(buf);
}
res = Map<DVec>(vbuf.data(), static_cast<Index>(vbuf.size()));
return res;
}
template<>
inline IVec strTo<IVec>(const std::string &str)
{
IVec res;
std::vector<int> vbuf;
int buf;
std::istringstream stream(str);
while (!stream.eof())
{
stream >> buf;
vbuf.push_back(buf);
}
res = Map<IVec>(vbuf.data(), static_cast<Index>(vbuf.size()));
return res;
}
template<>
inline UVec strTo<UVec>(const std::string &str)
{
UVec res;
std::vector<unsigned int> vbuf;
unsigned int buf;
std::istringstream stream(str);
while (!stream.eof())
{
stream >> buf;
vbuf.push_back(buf);
}
res = Map<UVec>(vbuf.data(), static_cast<Index>(vbuf.size()));
return res;
}
template <typename T>
void tokenReplace(std::string &str, const std::string token,
const T &x, const std::string mark = "@")
{
std::string fullToken = mark + token + mark;
auto pos = str.find(fullToken);
if (pos != std::string::npos)
{
str.replace(pos, fullToken.size(), strFrom(x));
}
}
// Manifest file reader ////////////////////////////////////////////////////////
inline std::vector<std::string> readManifest(const std::string manFileName)
{
std::vector<std::string> list;
std::ifstream manFile;
char buf[MAX_PATH_LENGTH];
manFile.open(manFileName);
while (!manFile.eof())
{
manFile.getline(buf, MAX_PATH_LENGTH);
if (!std::string(buf).empty())
{
list.push_back(buf);
}
}
manFile.close();
return list;
}
// Recursive directory creation ////////////////////////////////////////////////
int mkdir(const std::string dirName);
// C++ version of basename/dirname /////////////////////////////////////////////
std::string basename(const std::string& s);
std::string dirname(const std::string& s);
// Progress bar class //////////////////////////////////////////////////////////
class ProgressBar
{
public:
// constructor
template <typename A, typename B>
ProgressBar(const A current, const B total, const Index nCol = 60);
// IO
friend std::ostream & operator<<(std::ostream &out,
const ProgressBar &&bar);
private:
Index current_, total_, nCol_;
};
template <typename A, typename B>
ProgressBar::ProgressBar(const A current, const B total, const Index nCol)
: current_(static_cast<Index>(current))
, total_(static_cast<Index>(total))
, nCol_(nCol)
{}
std::ostream & operator<<(std::ostream &out, const ProgressBar &&bar);
// named variable interface ////////////////////////////////////////////////////
// FIXME: check redundant names and variable number limit
class VarName
{
public:
// constructor
VarName(const std::string defName);
// destructor
virtual ~VarName(void) = default;
// access
std::string getName(const Index i) const;
void setName(const Index i, const std::string name);
// test
bool hasName(const Index i) const;
private:
std::string defName_;
std::unordered_map<Index, std::string> name_;
};
END_LATAN_NAMESPACE
#endif // LatAnalyze_Utilities_hpp_

56
lib/Core/stdincludes.hpp Normal file
View File

@ -0,0 +1,56 @@
/*
* stdincludes.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2016 Antonin Portelli
*
* LatAnalyze 3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze 3 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef Latan_stdincludes_hpp_
#define Latan_stdincludes_hpp_
#include <algorithm>
#include <array>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sys/stat.h>
#include <unistd.h>
#endif // Latan_stdincludes_hpp_

View File

@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_CompiledFunction_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/CompiledModel.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Functional/CompiledModel.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_CompiledModel_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Model.hpp>
#include <LatAnalyze/MathInterpreter.hpp>
#include <LatAnalyze/Functional/Model.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_Function_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Model.hpp>
#include <LatAnalyze/Functional/Model.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_Model_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/Mat.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/TabFunction.hpp>
#include <LatAnalyze/Functional/TabFunction.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,9 +21,9 @@
#define Latan_TabFunction_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <LatAnalyze/Statistics/XYStatData.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -20,13 +20,27 @@
#ifndef Latan_Global_hpp_
#define Latan_Global_hpp_
#include <LatCore/LatCore.hpp>
#include <LatAnalyze/Core/stdincludes.hpp>
#define BEGIN_LATAN_NAMESPACE \
namespace Latan {\
using namespace LatCore;
namespace Latan {
#define END_LATAN_NAMESPACE }
// macro utilities
#define unique_arg(...) __VA_ARGS__
#define DEBUG_VAR(x) std::cout << #x << "= " << x << std::endl
#define DEBUG_MAT(m) std::cout << #m << "=\n" << m << std::endl
// attribute to switch off unused warnings with gcc
#ifdef __GNUC__
#define __dumb __attribute__((unused))
#else
#define __dumb
#endif
// max length for paths
#define MAX_PATH_LENGTH 512u
BEGIN_LATAN_NAMESPACE
// Placeholder type ////////////////////////////////////////////////////////////
@ -47,6 +61,8 @@ namespace Env
END_LATAN_NAMESPACE
#include <LatAnalyze/Exceptions.hpp>
#include <LatAnalyze/Core/Eigen.hpp>
#include <LatAnalyze/Core/Exceptions.hpp>
#include <LatAnalyze/Core/Utilities.hpp>
#endif // Latan_Global_hpp_

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,10 +21,10 @@
#define Latan_AsciiFile_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/File.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/ParserState.hpp>
#include <LatAnalyze/Io/File.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
#include <LatAnalyze/Core/ParserState.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -25,7 +25,7 @@
%option yylineno
%{
#include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp>
#include "AsciiParser.hpp"
using namespace std;

View File

@ -19,9 +19,9 @@
%{
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
using namespace std;
using namespace Latan;

81
lib/Io/BinReader.cpp Normal file
View File

@ -0,0 +1,81 @@
/*
* BinReader.cpp, part of LatAnalyze
*
* Copyright (C) 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Io/BinReader.hpp>
#include <LatAnalyze/includes.hpp>
#if (defined __GNUC__)||(defined __clang__)
#pragma GCC diagnostic ignored "-Wunreachable-code"
#endif
using namespace std;
using namespace Latan;
BinIO::BinIO(string msg, string loc)
: runtime_error("Binary reader error: " + msg + " (" + loc + ")")
{}
/******************************************************************************
* BinReader implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
BinReader::BinReader(const string fileName, const uint32_t endianness,
const bool isColMaj)
{
open(fileName, endianness, isColMaj);
}
// I/O /////////////////////////////////////////////////////////////////////////
void BinReader::open(const string fileName, const uint32_t endianness,
const bool isColMaj)
{
fileName_ = fileName;
endianness_ = endianness;
isColMaj_ = isColMaj;
file_.reset(new ifstream(fileName_, ios::in|ios::binary|ios::ate));
if (!file_->is_open())
{
LATAN_ERROR(Io, "impossible to open file '" + fileName_ + "'");
}
size_ = static_cast<size_t>(file_->tellg());
file_->seekg(0, ios::beg);
}
void BinReader::close(void)
{
file_.reset(nullptr);
}
template <>
std::string BinReader::read(void)
{
std::string s;
char c = 'a';
while (c != '\n')
{
c = read<char>();
if (c != '\n')
{
s.push_back(c);
}
}
return s;
}

196
lib/Io/BinReader.hpp Normal file
View File

@ -0,0 +1,196 @@
/*
* BinReader.hpp, part of LatAnalyze
*
* Copyright (C) 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LatAnalyze_BinReader_hpp_
#define LatAnalyze_BinReader_hpp_
#include <LatAnalyze/Global.hpp>
BEGIN_LATAN_NAMESPACE
// I/O exception
class BinIO: public std::runtime_error
{
public:
BinIO(std::string msg, std::string loc);
};
/******************************************************************************
* Byte manipulation utilities *
******************************************************************************/
class Endianness
{
public:
enum: uint32_t
{
little = 0x00000001,
big = 0x01000000,
unknown = 0xffffffff
};
};
class ByteManip
{
public:
static constexpr uint32_t getHostEndianness(void)
{
return ((0xffffffff & 1) == Endianness::little) ? Endianness::little
: (((0xffffffff & 1) == Endianness::big) ? Endianness::big
: Endianness::unknown);
}
template <typename T>
static T swapBytes(const T);
};
/******************************************************************************
* template implementation *
******************************************************************************/
template <typename T>
T ByteManip::swapBytes(const T u)
{
static_assert (CHAR_BIT == 8, "CHAR_BIT != 8");
union
{
T u;
unsigned char u8[sizeof(T)];
} source, dest;
source.u = u;
for (size_t k = 0; k < sizeof(T); ++k)
{
dest.u8[k] = source.u8[sizeof(T) - k - 1];
}
return dest.u;
}
/******************************************************************************
* Utility to read binary files *
******************************************************************************/
class BinReader
{
public:
// constructor
BinReader(void) = default;
BinReader(const std::string fileName,
const uint32_t endianness = ByteManip::getHostEndianness(),
const bool isColMaj = false);
// destructor
virtual ~BinReader(void) = default;
// I/O
void open(const std::string fileName,
const uint32_t endianness = ByteManip::getHostEndianness(),
const bool isColMaj = false);
void close(void);
template <typename T>
void read(T *pt, Index size);
template <typename T>
T read(void);
template <typename T>
MatBase<T> read(const Index nRow, const Index nCol);
private:
std::unique_ptr<std::ifstream> file_{nullptr};
std::string fileName_;
size_t size_;
uint32_t endianness_;
bool isColMaj_;
};
/******************************************************************************
* template implementation *
******************************************************************************/
template <typename T>
void BinReader::read(T *pt, Index n)
{
if (file_ != nullptr)
{
file_->read(reinterpret_cast<char *>(pt),
static_cast<long>(sizeof(T))*n);
if (endianness_ != ByteManip::getHostEndianness())
{
for (Index i = 0; i < n; ++i)
{
pt[i] = ByteManip::swapBytes(pt[i]);
}
}
}
else
{
LATAN_ERROR(Io, "file is not opened");
}
}
template <typename T>
T BinReader::read(void)
{
T x;
if (file_ != nullptr)
{
read(&x, 1);
}
else
{
LATAN_ERROR(Io, "file is not opened");
}
return x;
}
template <>
std::string BinReader::read(void);
template <typename T>
MatBase<T> BinReader::read(const Index nRow, const Index nCol)
{
MatBase<T> m;
// Eigen matrices use column-major ordering
if (isColMaj_)
{
m.resize(nRow, nCol);
}
else
{
m.resize(nCol, nRow);
}
if (file_ != nullptr)
{
read(m.data(), nRow*nCol);
}
else
{
LATAN_ERROR(Io, "file is not opened");
}
if (isColMaj_)
{
return m;
}
else
{
return m.transpose();
}
}
END_LATAN_NAMESPACE
#endif // LatAnalyze_BinReader_hpp_

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/File.hpp>
#include <LatAnalyze/Io/File.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,9 +21,9 @@
#define Latan_File_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/IoObject.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Io/IoObject.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Hdf5File.hpp>
#include <LatAnalyze/IoObject.hpp>
#include <LatAnalyze/Io/Hdf5File.hpp>
#include <LatAnalyze/Io/IoObject.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,9 +21,9 @@
#define Latan_Hdf5File_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/File.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Io/File.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
#include <H5Cpp.h>
BEGIN_LATAN_NAMESPACE

View File

@ -17,10 +17,10 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/Io/Io.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Hdf5File.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp>
#include <LatAnalyze/Io/Hdf5File.hpp>
using namespace std;
using namespace Latan;

View File

@ -21,7 +21,7 @@
#define Latan_Io_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/File.hpp>
#include <LatAnalyze/Io/File.hpp>
BEGIN_LATAN_NAMESPACE

2791
lib/Io/Xml/tinyxml2.cpp Normal file

File diff suppressed because it is too large Load Diff

2272
lib/Io/Xml/tinyxml2.hpp Normal file

File diff suppressed because it is too large Load Diff

84
lib/Io/XmlReader.cpp Normal file
View File

@ -0,0 +1,84 @@
/*
* XmlReader.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2014 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Io/XmlReader.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
XmlParsing::XmlParsing(string msg, string loc)
: runtime_error("XML reader error: " + msg + " (" + loc + ")")
{}
/******************************************************************************
* XmlReader implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
XmlReader::XmlReader(const string &fileName)
{
open(fileName);
}
// IO //////////////////////////////////////////////////////////////////////////
void XmlReader::open(const string &fileName)
{
name_ = fileName;
doc_.LoadFile(name_.c_str());
if (doc_.Error())
{
string errMsg;
if (doc_.ErrorStr())
{
errMsg = doc_.ErrorStr();
}
LATAN_ERROR(Io, "cannot open file " + fileName + " [tinyxml2 code "
+ strFrom(doc_.ErrorID()) + ": " + errMsg + "]");
}
root_ = doc_.RootElement();
}
// XML structure access ////////////////////////////////////////////////////////
const XmlNode * XmlReader::getNextNode(const XmlNode *node,
const string &nodeName)
{
const char *pt = (nodeName.empty()) ? nullptr : nodeName.c_str();
if (node)
{
return node->NextSiblingElement(pt);
}
else
{
return nullptr;
}
}
const XmlNode * XmlReader::getNextSameNode(const XmlNode *node)
{
if (node)
{
return getNextNode(node, node->Name());
}
else
{
return nullptr;
}
}

235
lib/Io/XmlReader.hpp Normal file
View File

@ -0,0 +1,235 @@
/*
* XmlReader.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2015 Antonin Portelli
*
* LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LatAnalyze is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LatAnalyze_XmlReader_hpp_
#define LatAnalyze_XmlReader_hpp_
#include <LatAnalyze/Global.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#include <LatAnalyze/Io/Xml/tinyxml2.hpp>
#pragma GCC diagnostic pop
BEGIN_LATAN_NAMESPACE
// parsing exception
class XmlParsing: public std::runtime_error
{
public:
XmlParsing(std::string msg, std::string loc);
};
/******************************************************************************
* XML parameter file reader *
******************************************************************************/
typedef tinyxml2::XMLElement XmlNode;
class XmlReader
{
public:
// constructor
XmlReader(void) = default;
explicit XmlReader(const std::string &fileName);
// destructor
virtual ~XmlReader(void) = default;
// IO
void open(const std::string &fileName);
// XML structure access
template <typename... Strs>
static const XmlNode * getFirstNode(const XmlNode *startNode,
const std::string &nodeName,
Strs... nodeNames);
template <typename... Strs>
const XmlNode * getFirstNode(const std::string &nodeName,
Strs... nodeNames) const;
static const XmlNode * getNextNode(const XmlNode *node,
const std::string &nodeName = "");
static const XmlNode * getNextSameNode(const XmlNode *node);
template <typename T>
static T getValue(const XmlNode *node);
template <typename T, typename... Strs>
static T getFirstValue(const XmlNode *startNode,
const std::string &nodeName, Strs... nodeNames);
template <typename T, typename... Strs>
T getFirstValue(const std::string &nodeName, Strs... nodeNames) const;
template <typename T, typename... Strs>
static std::vector<T> getAllValues(const XmlNode *startNode,
const std::string &nodeName,
Strs... nodeNames);
template <typename T, typename... Strs>
std::vector<T> getAllValues(const std::string &nodeName,
Strs... nodeNames) const;
// XML structure test
template <typename... Strs>
static bool hasNode(const XmlNode *startNode, const std::string &nodeName,
Strs... nodeNames);
template <typename... Strs>
bool hasNode(const std::string &nodeName, Strs... nodeNames) const;
private:
std::string name_;
tinyxml2::XMLDocument doc_;
XmlNode *root_{nullptr};
};
/******************************************************************************
* XmlReader template implementation *
******************************************************************************/
// XML structure access ////////////////////////////////////////////////////////
template <typename... Strs>
const XmlNode * XmlReader::getFirstNode(const XmlNode *startNode,
const std::string &nodeName,
Strs... nodeNames)
{
static_assert(static_or<std::is_assignable<std::string, Strs>::value...>::value,
"getFirstNode arguments are not compatible with std::string");
const unsigned int nName = sizeof...(nodeNames) + 1;
const std::string name[] = {nodeName, nodeNames...};
const XmlNode *node = startNode;
if (!node)
{
LATAN_ERROR(Io, "root node is null, no XML file opened");
}
for (unsigned int i = 0; i < nName; ++i)
{
node = node->FirstChildElement(name[i].c_str());
if (!node)
{
LATAN_ERROR(Io, "XML node " + name[i] + " not found");
}
}
return node;
}
template <typename... Strs>
const XmlNode * XmlReader::getFirstNode(const std::string &nodeName,
Strs... nodeNames) const
{
if (!root_)
{
LATAN_ERROR(Io, "root node is null, no XML file opened");
}
return getFirstNode(root_, nodeName, nodeNames...);
}
template <typename T>
T XmlReader::getValue(const XmlNode *node)
{
if (node)
{
if (node->GetText())
{
return Latan::strTo<T>(node->GetText());
}
else
{
return T();
}
}
else
{
return T();
}
}
template <typename T, typename... Strs>
T XmlReader::getFirstValue(const XmlNode *startNode,
const std::string &nodeName, Strs... nodeNames)
{
const XmlNode *node = getFirstNode(startNode, nodeName, nodeNames...);
return getValue<T>(node);
}
template <typename T, typename... Strs>
T XmlReader::getFirstValue(const std::string &nodeName, Strs... nodeNames) const
{
return getFirstValue<T>(root_, nodeName, nodeNames...);
}
template <typename T, typename... Strs>
std::vector<T> XmlReader::getAllValues(const XmlNode *startNode,
const std::string &nodeName,
Strs... nodeNames)
{
const XmlNode *node = getFirstNode(startNode, nodeName, nodeNames...);
std::vector<T> value;
while (node)
{
value.push_back(getValue<T>(node));
node = getNextSameNode(node);
}
return value;
}
template <typename T, typename... Strs>
std::vector<T> XmlReader::getAllValues(const std::string &nodeName,
Strs... nodeNames) const
{
return getAllValues<T>(root_, nodeName, nodeNames...);
}
// XML structure test //////////////////////////////////////////////////////////
template <typename... Strs>
bool XmlReader::hasNode(const XmlNode *startNode, const std::string &nodeName,
Strs... nodeNames)
{
static_assert(static_or<std::is_assignable<std::string, Strs>::value...>::value,
"hasNode arguments are not compatible with std::string");
const unsigned int nName = sizeof...(nodeNames) + 1;
const std::string name[] = {nodeName, nodeNames...};
const XmlNode *node = startNode;
if (!node)
{
LATAN_ERROR(Io, "root node is null, no XML file opened");
}
for (unsigned int i = 0; i < nName; ++i)
{
node = node->FirstChildElement(name[i].c_str());
if (!node)
{
return false;
}
}
return true;
}
template <typename... Strs>
bool XmlReader::hasNode(const std::string &nodeName, Strs... nodeNames) const
{
if (!root_)
{
LATAN_ERROR(Io, "root node is null, no XML file opened");
}
return hasNode(root_, nodeName, nodeNames...);
}
END_LATAN_NAMESPACE
#endif // LatAnalyze_XmlReader_hpp_

View File

@ -7,115 +7,129 @@ if CXX_INTEL
endif
endif
include eigen_files.mk
AM_LFLAGS = -olex.yy.c
AM_YFLAGS = -d
lib_LTLIBRARIES = libLatAnalyze.la
noinst_LTLIBRARIES = libLexers.la
libLexers_la_SOURCES = AsciiLexer.lpp MathLexer.lpp
libLexers_la_SOURCES = Io/AsciiLexer.lpp Core/MathLexer.lpp
if CXX_GNU
libLexers_la_CXXFLAGS = $(COM_CXXFLAGS) -Wno-unused-parameter -Wno-unused-function -Wno-deprecated-register
else
libLexers_la_CXXFLAGS = $(COM_CXXFLAGS)
endif
libLatAnalyze_la_SOURCES = \
AsciiFile.cpp \
AsciiParser.ypp \
CompiledFunction.cpp \
CompiledModel.cpp \
Derivative.cpp \
Exceptions.cpp \
File.cpp \
FitInterface.cpp \
Function.cpp \
Global.cpp \
GslFFT.cpp \
GslHybridRootFinder.cpp\
GslMinimizer.cpp \
GslQagsIntegrator.cpp \
Hdf5File.cpp \
Histogram.cpp \
includes.hpp \
Io.cpp \
Mat.cpp \
Math.cpp \
MathInterpreter.cpp \
MathParser.ypp \
Minimizer.cpp \
Model.cpp \
Plot.cpp \
RootFinder.cpp \
Solver.cpp \
StatArray.cpp \
TabFunction.cpp \
XYSampleData.cpp \
XYStatData.cpp \
libLatAnalyze_la_SOURCES = \
includes.hpp \
Global.cpp \
Core/Exceptions.cpp \
Core/Mat.cpp \
Core/Math.cpp \
Core/MathInterpreter.cpp \
Core/MathParser.ypp \
Core/OptParser.cpp \
Core/Plot.cpp \
Core/Utilities.cpp \
Functional/CompiledFunction.cpp \
Functional/CompiledModel.cpp \
Functional/Function.cpp \
Functional/Model.cpp \
Functional/TabFunction.cpp \
Io/AsciiFile.cpp \
Io/AsciiParser.ypp \
Io/BinReader.cpp \
Io/File.cpp \
Io/Hdf5File.cpp \
Io/Io.cpp \
Io/XmlReader.cpp \
Io/Xml/tinyxml2.cpp \
Numerical/Derivative.cpp \
Numerical/GslFFT.cpp \
Numerical/GslHybridRootFinder.cpp\
Numerical/GslMinimizer.cpp \
Numerical/GslQagsIntegrator.cpp \
Numerical/Minimizer.cpp \
Numerical/RootFinder.cpp \
Numerical/Solver.cpp \
Statistics/FitInterface.cpp \
Statistics/Histogram.cpp \
Statistics/StatArray.cpp \
Statistics/XYSampleData.cpp \
Statistics/XYStatData.cpp \
../config.h
libLatAnalyze_ladir = $(pkgincludedir)
libLatAnalyze_la_HEADERS = \
AsciiFile.hpp \
CompiledFunction.hpp \
CompiledModel.hpp \
Dataset.hpp \
Derivative.hpp \
Exceptions.hpp \
FFT.hpp \
Function.hpp \
File.hpp \
FitInterface.hpp \
Global.hpp \
GslFFT.hpp \
GslHybridRootFinder.hpp\
GslMinimizer.hpp \
GslQagsIntegrator.hpp \
Hdf5File.hpp \
Histogram.hpp \
Integrator.hpp \
Io.hpp \
IoObject.hpp \
Mat.hpp \
Math.hpp \
MathInterpreter.hpp \
MatSample.hpp \
Minimizer.hpp \
Model.hpp \
ParserState.hpp \
Plot.hpp \
RootFinder.hpp \
TabFunction.hpp \
Solver.hpp \
StatArray.hpp \
XYSampleData.hpp \
XYStatData.hpp
HPPFILES = \
Global.hpp \
Core/Exceptions.hpp \
Core/Mat.hpp \
Core/Math.hpp \
Core/MathInterpreter.hpp \
Core/OptParser.hpp \
Core/ParserState.hpp \
Core/Plot.hpp \
Core/stdincludes.hpp \
Core/Utilities.hpp \
Functional/CompiledFunction.hpp \
Functional/CompiledModel.hpp \
Functional/Function.hpp \
Functional/Model.hpp \
Functional/TabFunction.hpp \
Io/AsciiFile.hpp \
Io/BinReader.hpp \
Io/File.hpp \
Io/Hdf5File.hpp \
Io/Io.hpp \
Io/IoObject.hpp \
Io/XmlReader.hpp \
Numerical/Derivative.hpp \
Numerical/FFT.hpp \
Numerical/GslFFT.hpp \
Numerical/GslHybridRootFinder.hpp\
Numerical/GslMinimizer.hpp \
Numerical/GslQagsIntegrator.hpp \
Numerical/Integrator.hpp \
Numerical/Minimizer.hpp \
Numerical/RootFinder.hpp \
Numerical/Solver.hpp \
Statistics/Dataset.hpp \
Statistics/FitInterface.hpp \
Statistics/Histogram.hpp \
Statistics/MatSample.hpp \
Statistics/StatArray.hpp \
Statistics/XYSampleData.hpp \
Statistics/XYStatData.hpp
if HAVE_MINUIT
libLatAnalyze_la_SOURCES += MinuitMinimizer.cpp
libLatAnalyze_la_HEADERS += MinuitMinimizer.hpp
libLatAnalyze_la_SOURCES += Numerical/MinuitMinimizer.cpp
HPPFILES += Numerical/MinuitMinimizer.hpp
endif
if HAVE_NLOPT
libLatAnalyze_la_SOURCES += NloptMinimizer.cpp
libLatAnalyze_la_HEADERS += NloptMinimizer.hpp
libLatAnalyze_la_SOURCES += Numerical/NloptMinimizer.cpp
HPPFILES += Numerical/NloptMinimizer.hpp
endif
libLatAnalyze_la_CXXFLAGS = $(COM_CXXFLAGS)
libLatAnalyze_la_LIBADD = libLexers.la
if HAVE_AM_MINOR_LE_11
AsciiParser.hpp: AsciiParser.ypp
$(AM_V_YACC) $(YACC) -o AsciiParser.cpp --defines=AsciiParser.hpp $<
Io/AsciiParser.hpp: Io/AsciiParser.ypp
$(AM_V_YACC) $(YACC) -o Io/AsciiParser.cpp --defines=Io/AsciiParser.hpp $<
MathParser.hpp: MathParser.ypp
$(AM_V_YACC) $(YACC) -o MathParser.cpp --defines=MathParser.hpp $<
Core/MathParser.hpp: Core/MathParser.ypp
$(AM_V_YACC) $(YACC) -o Core/MathParser.cpp --defines=Core/MathParser.hpp $<
endif
BUILT_SOURCES = AsciiParser.hpp MathParser.hpp
BUILT_SOURCES = Io/AsciiParser.hpp Core/MathParser.hpp
CLEANFILES = \
MathLexer.cpp \
AsciiLexer.cpp \
AsciiParser.cpp\
AsciiParser.hpp\
MathParser.cpp \
MathParser.hpp
CLEANFILES = \
Core/MathLexer.cpp \
Core/MathParser.cpp\
Core/MathParser.hpp\
Io/AsciiLexer.cpp \
Io/AsciiParser.cpp \
Io/AsciiParser.hpp
nobase_dist_pkginclude_HEADERS = $(HPPFILES) $(eigen_files) Io/Xml/tinyxml2.hpp
ACLOCAL_AMFLAGS = -I .buildutils/m4

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/Numerical/Derivative.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -21,7 +21,7 @@
#define Latan_Derivative_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Functional/Function.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/GslFFT.hpp>
#include <LatAnalyze/Numerical/GslFFT.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_GslFFT_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/FFT.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Numerical/FFT.hpp>
#include <gsl/gsl_fft_complex.h>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/GslHybridRootFinder.hpp>
#include <LatAnalyze/Numerical/GslHybridRootFinder.hpp>
#include <LatAnalyze/includes.hpp>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_multiroots.h>

View File

@ -21,7 +21,7 @@
#define Latan_GslHybridRootFinder_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/RootFinder.hpp>
#include <LatAnalyze/Numerical/RootFinder.hpp>
#include <gsl/gsl_multiroots.h>
BEGIN_LATAN_NAMESPACE

View File

@ -17,9 +17,9 @@
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/GslMinimizer.hpp>
#include <LatAnalyze/Numerical/GslMinimizer.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_blas.h>

View File

@ -21,9 +21,9 @@
#define Latan_GslMinimizer_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Minimizer.hpp>
#include <LatAnalyze/Numerical/Derivative.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
#include <gsl/gsl_vector.h>
BEGIN_LATAN_NAMESPACE

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/GslQagsIntegrator.hpp>
#include <LatAnalyze/Numerical/GslQagsIntegrator.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -21,8 +21,8 @@
#define Latan_GslQagsIntegrator_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Integrator.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Integrator.hpp>
#include <gsl/gsl_integration.h>
BEGIN_LATAN_NAMESPACE

View File

@ -21,7 +21,7 @@
#define Latan_Integrator_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Functional/Function.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Minimizer.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,9 +21,9 @@
#define Latan_Minimizer_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Solver.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Numerical/Solver.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/MinuitMinimizer.hpp>
#include <LatAnalyze/Numerical/MinuitMinimizer.hpp>
#include <LatAnalyze/includes.hpp>
#include <Minuit2/Minuit2Minimizer.h>
#include <Math/Functor.h>

View File

@ -21,8 +21,8 @@
#define Latan_MinuitMinimizer_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Minimizer.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/NloptMinimizer.hpp>
#include <LatAnalyze/Numerical/NloptMinimizer.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,9 +21,9 @@
#define Latan_NloptMinimizer_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Minimizer.hpp>
#include <LatAnalyze/Numerical/Derivative.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
#include <nlopt.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/RootFinder.hpp>
#include <LatAnalyze/Numerical/RootFinder.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_RootFinder_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Solver.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Solver.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Solver.hpp>
#include <LatAnalyze/Numerical/Solver.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,8 +21,8 @@
#define Latan_Dataset_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/File.hpp>
#include <LatAnalyze/StatArray.hpp>
#include <LatAnalyze/Io/File.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/FitInterface.hpp>
#include <LatAnalyze/Statistics/FitInterface.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,7 +21,7 @@
#define Latan_FitInterface_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Core/Mat.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/Histogram.hpp>
#include <LatAnalyze/Statistics/Histogram.hpp>
#include <LatAnalyze/includes.hpp>
#include <gsl/gsl_histogram.h>
#include <gsl/gsl_sf.h>

View File

@ -21,7 +21,7 @@
#define Latan_Histogram_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/StatArray.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -21,8 +21,8 @@
#define Latan_MatSample_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/StatArray.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/StatArray.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;

View File

@ -21,7 +21,7 @@
#define Latan_StatArray_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Core/Mat.hpp>
#define FOR_STAT_ARRAY(ar, i) \
for (Latan::Index i = -(ar).offset; i < (ar).size(); ++i)

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/XYSampleData.hpp>
#include <LatAnalyze/Statistics/XYSampleData.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

View File

@ -21,11 +21,11 @@
#define Latan_XYSampleData_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/FitInterface.hpp>
#include <LatAnalyze/Minimizer.hpp>
#include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Model.hpp>
#include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/Statistics/FitInterface.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
#include <LatAnalyze/Functional/Model.hpp>
#include <LatAnalyze/Statistics/XYStatData.hpp>
BEGIN_LATAN_NAMESPACE

View File

@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/
#include <LatAnalyze/XYStatData.hpp>
#include <LatAnalyze/Statistics/XYStatData.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Math.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;

Some files were not shown because too many files have changed in this diff Show More