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

Merge branch 'release/3.1' into develop

This commit is contained in:
Antonin Portelli 2016-04-13 12:47:07 +01:00
commit b25cfdc308
9 changed files with 116 additions and 23 deletions

74
Readme.md Normal file
View File

@ -0,0 +1,74 @@
# LatAnalyze
Contributors: Antonin Portelli, Matt Spraggs
License: GNU General Public License v3
<table>
<tr>
<td>Last stable release</td>
<td><a href="https://travis-ci.org/aportelli/LatAnalyze">
<img src="https://travis-ci.org/aportelli/LatAnalyze.svg?branch=master"></a>
</td>
</tr>
<tr>
<td>Development branch</td>
<td><a href="https://travis-ci.org/aportelli/LatAnalyze">
<img src="https://travis-ci.org/aportelli/LatAnalyze.svg?branch=develop"></a>
</td>
</tr>
</table>
## Description
LatAnalyze is a C++11 library for statistical data analysis based on bootstrap
resampling. It has been written with lattice QCD data analysis in mind (hence
the name), but its features are not lattice specific and can be used more general statistical context.
Sadly a proper documentation was never written, but some comprehensive examples covering most features can be found in the `examples` directory.
The main features are the following:
* Array and matrix types with fast arithmetic operations based on [Eigen](http://eigen.tuxfamily.org).
* High-level types for bootstrap sample manipulation (including various statistical estimators and histogramming).
* Mathematical expression parser for runtime defined functions.
* Data I/O in ASCII and HDF5 (optional).
* High-level wrappers to minimisation routines from the [GSL](http://www.gnu.org/software/gsl/), [Minuit](http://seal.web.cern.ch/seal/snapshot/work-packages/mathlibs/minuit/) (optional) and [NLopt](http://ab-initio.mit.edu/wiki/index.php/NLopt).
* Non-linear regression with error on independent variables (through total least squares).
* High-level wrappers to numerical integrator and non-linear solver from the [GSL](http://www.gnu.org/software/gsl/).
* High-level functional types for function of model. General functions can be defined from C pointers, C++ objects, strings of mathematical expressions or tabulated data.
* High-level plotting functions based on [gnuplot](http://www.gnuplot.info), with the possibility of generating and saving plot scripts.
## Installation
The head of the `master` branch always points to the latest stable release. The `develop` branch is the main unstable branch of LatAnalyze.
LatAnalyze is written in C++11 and requires a rather recent C++ compiler to be built. It has been successfully built on various Linux and OS X platforms using clang (from 3.7), GCC (from 4.9) and the Intel C++ compiler (2016).
The strict dependencies are the [GSL](http://www.gnu.org/software/gsl/) and [LatCore](https://github.com/aportelli/LatCore).
Additionally, autoconf, automake (from 1.11), libtool, bison (from 3.0) and flex are necessary to build the library. Unless you use a very exotic system, these tools are standard on any Unix platform and should be already present or easy to install through a package manager.
Optional dependencies are [HDF5](https://www.hdfgroup.org/HDF5/) (built with C++ support), [Minuit](http://seal.web.cern.ch/seal/snapshot/work-packages/mathlibs/minuit/) and [NLopt](http://ab-initio.mit.edu/wiki/index.php/NLopt).
For a quick installation with all possible extensions execute:
```
./install-latan.sh <prefix> {osx|linux}
```
in the `ci-scripts` directory where `<prefix>` is where you want LatAnalyze (and its dependencies) to be installed and `{osx|linux}` should be the name of your OS. This script will automatically download, build and install LatCore, HDF5, Minuit and NLopt. It is assumed that the GSL can be found in a standard location (_e.g._ it has been installed through a package manager for Linux and is present in `/usr/local` for OS X).
For a more customised installation, one first needs to generate the build system by running `./bootstrap.sh` in the root directory. Then the library can be built and installed through the usual GNU mantra `./configure <options> && make && make install`. Use `./configure --help` to obtain a list of possible options for `./configure`. Because Eigen expressions rely a lot on inlining and compiler optimisations it is strongly recommended to set the `CXXFLAGS` variable to `-O3 -march=native -mtune=native`.
## History
#### v3.1
Additions:
* Wrappers to NLopt and GSL minimisers.
* Command-line tool to plot the correlation heatmap of a boostrap sample file.
* I/O functions for `DSample` type.
Changes:
* Internal random generator removed (obsolete because of C++11 pseudo-random generators).
* Fit interface and `XY*Data` classes rewritten from scratch for improved flexibility and performance.
Fixes:
* **Loads** of portability and compatibility fixes and [CI with Travis](https://travis-ci.org/aportelli/LatAnalyze).
#### v3.0
Commit `7b4f2884a5e99bbfab4d4bd7623f609a55403c39`.
First 'stable' version of LatAnalyze in C++. The v2.0 refers to the [C version](https://github.com/aportelli/LatAnalyze-legacy) and v1.0 to an old undistributed version.
**This version compiles fine on OS X with clang but does have many portability issues to other platforms/compilers, v3.1 is the first real release.**

View File

@ -133,3 +133,18 @@ AC_SUBST([AM_LDFLAGS])
AC_CONFIG_FILES([Makefile lib/Makefile utils/Makefile examples/Makefile])
AC_OUTPUT
echo "*********************************************"
echo "* ${PACKAGE_NAME} v${VERSION}" build options
echo "*********************************************"
echo "* C++ compiler : $CXX"
echo "* HDF5 support : `test x$HAVE_HDF5_TRUE = 'x' && echo yes \
|| echo no`"
echo "* Minuit minimizers: `test x$HAVE_MINUIT_TRUE = 'x' && echo yes \
|| echo no`"
echo "* NLopt minimizers : `test x$HAVE_NLOPT_TRUE = 'x' && echo yes \
|| echo no`"
echo "*********************************************"

View File

@ -9,18 +9,17 @@ endif
noinst_PROGRAMS = \
exCompiledDoubleFunction\
exDerivative \
exFit \
exFitSample \
exIntegrator \
exInterp \
exMat \
exMathInterpreter \
exMin \
exPlot \
exRand \
exRootFinder
if HAVE_MINUIT
noinst_PROGRAMS += exFit exFitSample exMin
endif
exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp
exCompiledDoubleFunction_CXXFLAGS = $(COM_CXXFLAGS)
exCompiledDoubleFunction_LDFLAGS = -L../lib/.libs -lLatAnalyze
@ -29,7 +28,6 @@ exDerivative_SOURCES = exDerivative.cpp
exDerivative_CXXFLAGS = $(COM_CXXFLAGS)
exDerivative_LDFLAGS = -L../lib/.libs -lLatAnalyze
if HAVE_MINUIT
exFit_SOURCES = exFit.cpp
exFit_CXXFLAGS = $(COM_CXXFLAGS)
exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze
@ -37,7 +35,6 @@ exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze
exFitSample_SOURCES = exFitSample.cpp
exFitSample_CXXFLAGS = $(COM_CXXFLAGS)
exFitSample_LDFLAGS = -L../lib/.libs -lLatAnalyze
endif
exInterp_SOURCES = exInterp.cpp
exInterp_CXXFLAGS = $(COM_CXXFLAGS)
@ -51,11 +48,9 @@ exMat_SOURCES = exMat.cpp
exMat_CXXFLAGS = $(COM_CXXFLAGS)
exMat_LDFLAGS = -L../lib/.libs -lLatAnalyze
if HAVE_MINUIT
exMin_SOURCES = exMin.cpp
exMin_CXXFLAGS = $(COM_CXXFLAGS)
exMin_LDFLAGS = -L../lib/.libs -lLatAnalyze
endif
exMathInterpreter_SOURCES = exMathInterpreter.cpp
exMathInterpreter_CXXFLAGS = $(COM_CXXFLAGS)

View File

@ -8,7 +8,7 @@ using namespace Latan;
int main(void)
{
DMat A(2, 3), B(3, 2), C = DMat::Random(6, 6);
const string fileName = "exMat.h5";
const string fileName = "exMat.dat";
A << 1, 2, 3,
4, 5, 6;

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/MinuitMinimizer.hpp>
#include <LatAnalyze/GslMinimizer.hpp>
using namespace std;
using namespace Latan;
@ -16,8 +16,8 @@ int main(int argc, char* argv[])
}
source = argv[1];
DoubleFunction f = compile(source, 1);
MinuitMinimizer minimize;
DoubleFunction f = compile(source, 1);
GslMinimizer minimize;
DVec init(1);
double min;

View File

@ -356,4 +356,6 @@ string GslMinimizer::getAlgorithmName(const Algorithm algorithm)
return "improved Nelder-Mead simplex with random start";
break;
}
return "";
}

View File

@ -19,6 +19,10 @@
#include <LatAnalyze/Io.hpp>
#include <LatAnalyze/includes.hpp>
#include <LatAnalyze/AsciiFile.hpp>
#ifdef HAVE_HDF5
#include <LatAnalyze/Hdf5File.hpp>
#endif
using namespace std;
using namespace Latan;
@ -34,14 +38,16 @@ unique_ptr<File> Io::open(const std::string &fileName, const unsigned int mode)
{
string ext = extension(fileName);
if (ext == "h5")
{
return unique_ptr<File>(new Hdf5File(fileName, mode));
}
else if ((ext == "dat")||(ext == "sample")||(ext == "seed"))
if ((ext == "dat")||(ext == "sample")||(ext == "seed"))
{
return unique_ptr<File>(new AsciiFile(fileName, mode));
}
#ifdef HAVE_HDF5
else if (ext == "h5")
{
return unique_ptr<File>(new Hdf5File(fileName, mode));
}
#endif
else
{
LATAN_ERROR(Io, "unknown file extension '" + ext + "'");

View File

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

View File

@ -32,9 +32,8 @@ libLatAnalyze_la_SOURCES = \
Function.cpp \
Global.cpp \
GslHybridRootFinder.cpp\
GslMinimizer.cpp \
GslMinimizer.cpp \
GslQagsIntegrator.cpp \
Hdf5File.cpp \
Histogram.cpp \
includes.hpp \
Io.cpp \
@ -65,9 +64,8 @@ libLatAnalyze_la_HEADERS = \
FitInterface.hpp \
Global.hpp \
GslHybridRootFinder.hpp\
GslMinimizer.hpp \
GslMinimizer.hpp \
GslQagsIntegrator.hpp \
Hdf5File.hpp \
Histogram.hpp \
Integrator.hpp \
Io.hpp \
@ -86,6 +84,10 @@ libLatAnalyze_la_HEADERS = \
StatArray.hpp \
XYSampleData.hpp \
XYStatData.hpp
if HAVE_HDF5
libLatAnalyze_la_SOURCES += Hdf5File.cpp
libLatAnalyze_la_HEADERS += Hdf5File.hpp
endif
if HAVE_MINUIT
libLatAnalyze_la_SOURCES += MinuitMinimizer.cpp
libLatAnalyze_la_HEADERS += MinuitMinimizer.hpp