mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-06-15 14:17:04 +01:00
Compare commits
44 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f101686fa | |||
8f52731513 | |||
b378f2fe6d | |||
7a087944ff | |||
64d2616e24 | |||
281663230d | |||
545a146f49 | |||
f8ad5c4da0 | |||
6dd82f33dc | |||
7993a1a7f7 | |||
86f7f89106 | |||
005158e2ed | |||
8b9494029c | |||
b4ad61406f | |||
c62f3a4b69 | |||
8a229ec0b0 | |||
0735cd54ce | |||
d5b743b985 | |||
e0e4bd327b | |||
07bbdca089 | |||
28a036ca9c | |||
260c70cbeb | |||
5e96db7b24 | |||
6b624186cd | |||
839159831f | |||
98cf39efda | |||
3d514ef026 | |||
a498a836ce | |||
6906b0c00d | |||
e43a7c6d0b | |||
92822348f6 | |||
810c860256 | |||
5641f3b481 | |||
76dffb7775 | |||
769dfd2e05 | |||
4576d73379 | |||
d80b160521 | |||
c6bc8c9af2 | |||
005ffeea5f | |||
af78c201e6 | |||
91cdfa9f8b | |||
582528f243 | |||
ba8056d9b0 | |||
01672cef99 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -3,7 +3,7 @@ build/*
|
|||||||
build_debug/*
|
build_debug/*
|
||||||
sandbox/*
|
sandbox/*
|
||||||
|
|
||||||
# Apple stuffs
|
# Apple stuff
|
||||||
*.xcodeproj
|
*.xcodeproj
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
@ -30,3 +30,12 @@ lib/eigen_files.mk
|
|||||||
|
|
||||||
# CI builds
|
# CI builds
|
||||||
ci-scripts/local/*
|
ci-scripts/local/*
|
||||||
|
|
||||||
|
# CLion stuff
|
||||||
|
.idea/*
|
||||||
|
CMakeLists.txt
|
||||||
|
cmake-build-debug/*
|
||||||
|
|
||||||
|
# VS Code Studio stuff
|
||||||
|
.vscode
|
||||||
|
*.code-workspace
|
||||||
|
43
.travis.yml
43
.travis.yml
@ -1,9 +1,5 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
||||||
slack: ukqcd:mQLXCtz8D2cg89xT8j1a4wku
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- ci-scripts/local
|
- ci-scripts/local
|
||||||
@ -12,56 +8,34 @@ cache:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode7.2
|
osx_image: xcode10.1
|
||||||
compiler: clang
|
compiler: clang
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode7.2
|
osx_image: xcode10.1
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: VERSION=-5
|
env: VERSION=-7
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
packages:
|
packages:
|
||||||
- g++-4.9
|
- g++-7
|
||||||
- libgsl0-dev
|
- libgsl0-dev
|
||||||
- flex
|
- flex
|
||||||
- bison
|
- bison
|
||||||
env: VERSION=-4.9
|
env: VERSION=-7
|
||||||
- compiler: gcc
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-5
|
|
||||||
- libgsl0-dev
|
|
||||||
- flex
|
|
||||||
- bison
|
|
||||||
env: VERSION=-5
|
|
||||||
- compiler: clang
|
- compiler: clang
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
- ubuntu-toolchain-r-test
|
- ubuntu-toolchain-r-test
|
||||||
packages:
|
packages:
|
||||||
- g++-4.8
|
- g++-7
|
||||||
- libgsl0-dev
|
- libgsl0-dev
|
||||||
- flex
|
- flex
|
||||||
- bison
|
- bison
|
||||||
env: CLANG_LINK=http://llvm.org/releases/3.6.0/clang+llvm-3.6.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
env: CLANG_LINK=http://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
||||||
- compiler: clang
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
packages:
|
|
||||||
- g++-4.8
|
|
||||||
- libgsl0-dev
|
|
||||||
- flex
|
|
||||||
- bison
|
|
||||||
env: CLANG_LINK=http://llvm.org/releases/3.7.0/clang+llvm-3.7.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export LATDIR=`pwd`
|
- export LATDIR=`pwd`
|
||||||
@ -72,7 +46,7 @@ before_install:
|
|||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gsl; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gsl; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bison flex; export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bison flex; export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc5; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc@${VERSION#-}; fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- export CC=$CC$VERSION
|
- export CC=$CC$VERSION
|
||||||
@ -85,6 +59,7 @@ install:
|
|||||||
- ./install-deps.sh `pwd`/local
|
- ./install-deps.sh `pwd`/local
|
||||||
- cd ..
|
- cd ..
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=${LATDIR}/ci-scripts/local/lib:$LD_LIBRARY_PATH; fi
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=${LATDIR}/ci-scripts/local/lib:$LD_LIBRARY_PATH; fi
|
||||||
|
- if [[ "$CC" == "gcc-7" ]]; then export CXXFLAGS='-Wno-int-in-bool-context'; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd ci-scripts
|
- cd ci-scripts
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
SUBDIRS = lib utils physics examples
|
SUBDIRS = lib utils physics examples
|
||||||
|
|
||||||
|
bin_SCRIPTS=latan-config
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I .buildutils/m4
|
ACLOCAL_AMFLAGS = -I .buildutils/m4
|
||||||
|
37
Readme.md
37
Readme.md
@ -55,6 +55,43 @@ in the `ci-scripts` directory where `<prefix>` is where you want LatAnalyze (and
|
|||||||
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`.
|
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
|
## History
|
||||||
|
#### v3.4
|
||||||
|
Additions:
|
||||||
|
* `latan-config` utility to easily compile LatAnalyze-based programs
|
||||||
|
* Linear and constant models to the 2-point fitter
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
* HDF5 is now a compulsory dependency
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
* Variance matrix computation fix.
|
||||||
|
|
||||||
|
#### v3.3
|
||||||
|
Additions:
|
||||||
|
* Sample plot CL utility.
|
||||||
|
* Infinity as a math constant.
|
||||||
|
* Option to dump bootstrap sequence while resampling.
|
||||||
|
* FFT through the GSL.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
* GSL integrator accepts infinite bounds.
|
||||||
|
* `latan-sample-combine` accepts mixes of `DSample` and `DMatSample`.
|
||||||
|
* More general `latan-sample-element` command.
|
||||||
|
|
||||||
|
#### v3.2.2
|
||||||
|
Additions:
|
||||||
|
* The math interpreter supports `inf` for infinity.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
* Vector version of `setUnidimData`.
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
* Variance matrix computation fix.
|
||||||
|
|
||||||
|
#### v3.2.1
|
||||||
|
Fixes:
|
||||||
|
* Wrong argument number check in `latan-resample`
|
||||||
|
|
||||||
#### v3.2 (needs LatCore 1.1)
|
#### v3.2 (needs LatCore 1.1)
|
||||||
Additions:
|
Additions:
|
||||||
* 2-pt function fitter `latan-2pt-fit`
|
* 2-pt function fitter `latan-2pt-fit`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
NAME='hdf5-1.8.16'
|
NAME='hdf5-1.10.1'
|
||||||
|
|
||||||
if (( $# != 1 )); then
|
if (( $# != 1 )); then
|
||||||
echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
|
echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
|
||||||
@ -11,7 +11,7 @@ PREFIX=$1
|
|||||||
set -ex
|
set -ex
|
||||||
INITDIR=`pwd`
|
INITDIR=`pwd`
|
||||||
cd local/build
|
cd local/build
|
||||||
wget http://www.hdfgroup.org/ftp/HDF5/releases/${NAME}/src/${NAME}.tar.gz
|
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/${NAME}/src/${NAME}.tar.gz
|
||||||
tar -xzvf ${NAME}.tar.gz
|
tar -xzvf ${NAME}.tar.gz
|
||||||
mkdir ${NAME}/build
|
mkdir ${NAME}/build
|
||||||
cd ${NAME}/build
|
cd ${NAME}/build
|
||||||
|
@ -14,6 +14,6 @@ cd ..
|
|||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
if [[ "$OS" == "osx" ]]; then EXTRA_FLAGS='--with-gsl=/usr/local'; fi
|
if [[ "$OS" == "osx" ]]; then EXTRA_FLAGS='--with-gsl=/usr/local'; fi
|
||||||
../configure --prefix=$PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS CXXFLAGS='-O3 -march=native -mtune=native'
|
../configure --prefix=$PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS CXXFLAGS="${CXXFLAGS} -O3 -march=native -mtune=native"
|
||||||
make -j4
|
make -j4
|
||||||
make install
|
make install
|
||||||
|
47
configure.ac
47
configure.ac
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Initialization
|
# Initialization
|
||||||
AC_PREREQ([2.63])
|
AC_PREREQ([2.63])
|
||||||
AC_INIT([LatAnalyze],[3.2],[antonin.portelli@me.com],[LatAnalyze])
|
AC_INIT([LatAnalyze],[3.4],[antonin.portelli@me.com],[LatAnalyze])
|
||||||
AC_CONFIG_AUX_DIR([.buildutils])
|
AC_CONFIG_AUX_DIR([.buildutils])
|
||||||
AC_CONFIG_SRCDIR([lib/Global.cpp])
|
AC_CONFIG_SRCDIR([lib/Global.cpp])
|
||||||
AC_CONFIG_SRCDIR([utils/sample_read.cpp])
|
AC_CONFIG_SRCDIR([utils/sample_read.cpp])
|
||||||
@ -53,9 +53,6 @@ AC_ARG_WITH([latcore],
|
|||||||
[use this option for a non-standard install prefix of the LatCore library])],
|
[use this option for a non-standard install prefix of the LatCore library])],
|
||||||
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_latcore/include"]
|
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_latcore/include"]
|
||||||
[AM_LDFLAGS="$AM_LDFLAGS -L$with_latcore/lib"])
|
[AM_LDFLAGS="$AM_LDFLAGS -L$with_latcore/lib"])
|
||||||
CFLAGS="$AM_CFLAGS $CFLAGS"
|
|
||||||
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
|
|
||||||
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
|
|
||||||
|
|
||||||
# Get compilers informations
|
# Get compilers informations
|
||||||
AX_COMPILER_VENDOR
|
AX_COMPILER_VENDOR
|
||||||
@ -78,6 +75,10 @@ AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"],
|
|||||||
[version of g++ that will compile the code])
|
[version of g++ that will compile the code])
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
|
CXXFLAGS_CPY=$CXXFLAGS
|
||||||
|
LDFLAGS_CPY=$LDFLAGS
|
||||||
|
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
|
||||||
|
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
|
||||||
AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([libm library not found])])
|
AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([libm library not found])])
|
||||||
AC_CHECK_LIB([gslcblas],[cblas_dgemm],[],
|
AC_CHECK_LIB([gslcblas],[cblas_dgemm],[],
|
||||||
[AC_MSG_ERROR([GSL CBLAS library not found])])
|
[AC_MSG_ERROR([GSL CBLAS library not found])])
|
||||||
@ -90,12 +91,8 @@ AC_CHECK_LIB([nlopt_cxx],[nlopt_create],
|
|||||||
[LIBS="$LIBS -lnlopt_cxx"],[])
|
[LIBS="$LIBS -lnlopt_cxx"],[])
|
||||||
AM_CONDITIONAL([HAVE_NLOPT], [test x$have_nlopt = xtrue])
|
AM_CONDITIONAL([HAVE_NLOPT], [test x$have_nlopt = xtrue])
|
||||||
AC_CHECK_LIB([hdf5_cpp],[H5Fopen],
|
AC_CHECK_LIB([hdf5_cpp],[H5Fopen],
|
||||||
[AC_DEFINE([HAVE_HDF5],
|
[LIBS="$LIBS -lhdf5_cpp -lhdf5"],
|
||||||
[1],
|
[AC_MSG_ERROR([HDF5 library not found])], [-lhdf5])
|
||||||
[Define to 1 if you have the `HDF5' library (-lhdf5_cpp).])]
|
|
||||||
[have_hdf5=true]
|
|
||||||
[LIBS="$LIBS -lhdf5_cpp -lhdf5"],[],[-lhdf5])
|
|
||||||
AM_CONDITIONAL([HAVE_HDF5], [test x$have_hdf5 = xtrue])
|
|
||||||
SAVED_LDFLAGS=$LDFLAGS
|
SAVED_LDFLAGS=$LDFLAGS
|
||||||
LDFLAGS="$LDFLAGS -lMinuit2"
|
LDFLAGS="$LDFLAGS -lMinuit2"
|
||||||
AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]);
|
AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]);
|
||||||
@ -123,24 +120,44 @@ AC_LINK_IFELSE(
|
|||||||
[AC_MSG_RESULT([no])]
|
[AC_MSG_RESULT([no])]
|
||||||
[AC_MSG_ERROR([LatCore library not found])])
|
[AC_MSG_ERROR([LatCore library not found])])
|
||||||
LDFLAGS=$SAVED_LDFLAGS
|
LDFLAGS=$SAVED_LDFLAGS
|
||||||
|
CXXFLAGS=$CXXFLAGS_CPY
|
||||||
|
LDFLAGS=$LDFLAGS_CPY
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
|
|
||||||
|
cwd=`pwd -P`; cd ${srcdir}; abs_srcdir=`pwd -P`; cd ${cwd}
|
||||||
|
LATAN_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
|
||||||
|
LATAN_LDFLAGS="$AM_LDFLAGS $LDFLAGS"
|
||||||
|
LATAN_LIBS=$LIBS
|
||||||
|
LATAN_SHORT_SHA=`git rev-parse --short HEAD`
|
||||||
|
LATAN_SHA=`git rev-parse HEAD`
|
||||||
|
LATAN_BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
|
AM_CXXFLAGS="-I${abs_srcdir}/lib $AM_CXXFLAGS"
|
||||||
|
AM_CFLAGS="-I${abs_srcdir}/lib $AM_CFLAGS"
|
||||||
|
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
|
||||||
|
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
|
||||||
AC_SUBST([LIBS])
|
AC_SUBST([LIBS])
|
||||||
AC_SUBST([AM_CFLAGS])
|
AC_SUBST([AM_CXXFLAGS])
|
||||||
AC_SUBST([AM_LDFLAGS])
|
AC_SUBST([AM_LDFLAGS])
|
||||||
|
AC_SUBST([LATAN_CXXFLAGS])
|
||||||
|
AC_SUBST([LATAN_LDFLAGS])
|
||||||
|
AC_SUBST([LATAN_LIBS])
|
||||||
|
AC_SUBST([LATAN_SHA])
|
||||||
|
AC_SUBST([LATAN_BRANCH])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile lib/Makefile utils/Makefile physics/Makefile
|
AC_CONFIG_FILES([latan-config], [chmod +x latan-config])
|
||||||
examples/Makefile])
|
AC_CONFIG_FILES([Makefile])
|
||||||
|
AC_CONFIG_FILES([lib/Makefile])
|
||||||
|
AC_CONFIG_FILES([utils/Makefile])
|
||||||
|
AC_CONFIG_FILES([physics/Makefile])
|
||||||
|
AC_CONFIG_FILES([examples/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
echo "*********************************************"
|
echo "*********************************************"
|
||||||
echo "* ${PACKAGE_NAME} v${VERSION}" build options
|
echo "* ${PACKAGE_NAME} v${VERSION}" build options
|
||||||
echo "*********************************************"
|
echo "*********************************************"
|
||||||
echo "* C++ compiler : $CXX"
|
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 "* Minuit minimizers: `test x$HAVE_MINUIT_TRUE = 'x' && echo yes \
|
||||||
|| echo no`"
|
|| echo no`"
|
||||||
echo "* NLopt minimizers : `test x$HAVE_NLOPT_TRUE = 'x' && echo yes \
|
echo "* NLopt minimizers : `test x$HAVE_NLOPT_TRUE = 'x' && echo yes \
|
||||||
|
@ -7,8 +7,8 @@ using namespace Latan;
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
constexpr double a = 1., b = 10.;
|
constexpr double a = 1., b = 10.;
|
||||||
DoubleFunction f1([a](const double *x){return a*(1.-x[0]);}, 2);
|
DoubleFunction f1([](const double *x){return a*(1.-x[0]);}, 2);
|
||||||
DoubleFunction f2([b](const double *x){return b*(x[1]-x[0]*x[0]);}, 2);
|
DoubleFunction f2([](const double *x){return b*(x[1]-x[0]*x[0]);}, 2);
|
||||||
vector<DoubleFunction *> system = {&f1, &f2};
|
vector<DoubleFunction *> system = {&f1, &f2};
|
||||||
GslHybridRootFinder solve;
|
GslHybridRootFinder solve;
|
||||||
DVec init(2), x;
|
DVec init(2), x;
|
||||||
|
79
latan-config.in
Normal file
79
latan-config.in
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
prefix=@prefix@
|
||||||
|
exec_prefix=@exec_prefix@
|
||||||
|
includedir=@includedir@
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
Usage: latan-config [OPTION]
|
||||||
|
|
||||||
|
Known values for OPTION are:
|
||||||
|
|
||||||
|
--prefix show LatAnalyze installation prefix
|
||||||
|
--cxxflags print pre-processor and compiler flags
|
||||||
|
--ldflags print library linking flags
|
||||||
|
--libs print library linking information
|
||||||
|
--help display this help and exit
|
||||||
|
--version output version information
|
||||||
|
--git print git revision
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
usage 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cflags=false
|
||||||
|
libs=false
|
||||||
|
|
||||||
|
while test $# -gt 0; do
|
||||||
|
case "$1" in
|
||||||
|
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||||
|
*) optarg= ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
--prefix)
|
||||||
|
echo $prefix
|
||||||
|
;;
|
||||||
|
|
||||||
|
--version)
|
||||||
|
echo @VERSION@
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
--git)
|
||||||
|
echo "@LATAN_BRANCH@ @LATAN_SHA@"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
--help)
|
||||||
|
usage 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
--cxxflags)
|
||||||
|
echo @LATAN_CXXFLAGS@
|
||||||
|
;;
|
||||||
|
|
||||||
|
--ldflags)
|
||||||
|
echo @LATAN_LDFLAGS@
|
||||||
|
;;
|
||||||
|
|
||||||
|
--libs)
|
||||||
|
echo @LIBS@
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
@ -47,6 +47,8 @@ public:
|
|||||||
// resampling
|
// resampling
|
||||||
Sample<T> bootstrapMean(const Index nSample, const SeedType seed);
|
Sample<T> bootstrapMean(const Index nSample, const SeedType seed);
|
||||||
Sample<T> bootstrapMean(const Index nSample);
|
Sample<T> bootstrapMean(const Index nSample);
|
||||||
|
void dumpBootstrapSeq(std::ostream &out, const Index nSample,
|
||||||
|
const SeedType seed);
|
||||||
private:
|
private:
|
||||||
// mean from pointer vector for resampling
|
// mean from pointer vector for resampling
|
||||||
void ptVectorMean(T &m, const std::vector<const T *> &v);
|
void ptVectorMean(T &m, const std::vector<const T *> &v);
|
||||||
@ -114,6 +116,23 @@ Sample<T> Dataset<T>::bootstrapMean(const Index nSample)
|
|||||||
return bootstrapMean(nSample, rd());
|
return bootstrapMean(nSample, rd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Dataset<T>::dumpBootstrapSeq(std::ostream &out, const Index nSample,
|
||||||
|
const SeedType seed)
|
||||||
|
{
|
||||||
|
std::mt19937 gen(seed);
|
||||||
|
std::uniform_int_distribution<Index> dis(0, this->size() - 1);
|
||||||
|
|
||||||
|
for (Index i = 0; i < nSample; ++i)
|
||||||
|
{
|
||||||
|
for (unsigned int j = 0; j < this->size(); ++j)
|
||||||
|
{
|
||||||
|
out << dis(gen) << " " << std::endl;
|
||||||
|
}
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Dataset<T>::ptVectorMean(T &m, const std::vector<const T *> &v)
|
void Dataset<T>::ptVectorMean(T &m, const std::vector<const T *> &v)
|
||||||
{
|
{
|
||||||
|
53
lib/FFT.hpp
Normal file
53
lib/FFT.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* FFT.hpp, part of LatAnalyze
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 - 2017 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 Latan_FFT_hpp_
|
||||||
|
#define Latan_FFT_hpp_
|
||||||
|
|
||||||
|
#include <LatAnalyze/Global.hpp>
|
||||||
|
|
||||||
|
BEGIN_LATAN_NAMESPACE
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FFT abstract class *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
class FFT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
Forward = 0,
|
||||||
|
Backward = 1
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
FFT(void) = default;
|
||||||
|
FFT(const Index size);
|
||||||
|
// destructor
|
||||||
|
virtual ~FFT(void) = default;
|
||||||
|
// size
|
||||||
|
virtual void resize(const Index size) = 0;
|
||||||
|
// FFT
|
||||||
|
virtual void operator()(CMat &x, const unsigned int dir = FFT::Forward) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
END_LATAN_NAMESPACE
|
||||||
|
|
||||||
|
#endif // Latan_FFT_hpp_
|
@ -200,6 +200,7 @@ double FitInterface::getSvdTolerance(void) const
|
|||||||
void FitInterface::setSvdTolerance(const double &tol)
|
void FitInterface::setSvdTolerance(const double &tol)
|
||||||
{
|
{
|
||||||
svdTol_ = tol;
|
svdTol_ = tol;
|
||||||
|
scheduleLayoutInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
VarName & FitInterface::xName(void)
|
VarName & FitInterface::xName(void)
|
||||||
|
89
lib/GslFFT.cpp
Normal file
89
lib/GslFFT.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* GslFFT.cpp, part of LatAnalyze
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 - 2017 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/GslFFT.hpp>
|
||||||
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Latan;
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* GslFFT implementation *
|
||||||
|
******************************************************************************/
|
||||||
|
// constructor /////////////////////////////////////////////////////////////////
|
||||||
|
GslFFT::GslFFT(const Index size)
|
||||||
|
{
|
||||||
|
resize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor //////////////////////////////////////////////////////////////////
|
||||||
|
GslFFT::~GslFFT(void)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// size ////////////////////////////////////////////////////////////////////////
|
||||||
|
void GslFFT::resize(const Index size)
|
||||||
|
{
|
||||||
|
if (size_ != size)
|
||||||
|
{
|
||||||
|
size_ = size;
|
||||||
|
wavetable_ = gsl_fft_complex_wavetable_alloc(size_);
|
||||||
|
workspace_ = gsl_fft_complex_workspace_alloc(size_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fft /////////////////////////////////////////////////////////////////////////
|
||||||
|
void GslFFT::operator()(CMat &x, const unsigned int dir)
|
||||||
|
{
|
||||||
|
if (x.size() != size_)
|
||||||
|
{
|
||||||
|
LATAN_ERROR(Size, "wrong input vector size");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (dir)
|
||||||
|
{
|
||||||
|
case FFT::Forward:
|
||||||
|
gsl_fft_complex_forward((double *)x.data(), 1, size_,
|
||||||
|
wavetable_, workspace_);
|
||||||
|
break;
|
||||||
|
case FFT::Backward:
|
||||||
|
gsl_fft_complex_backward((double *)x.data(), 1, size_,
|
||||||
|
wavetable_, workspace_);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LATAN_ERROR(Argument, "invalid FT direction");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// destroy GSL objects /////////////////////////////////////////////////////////
|
||||||
|
void GslFFT::clear(void)
|
||||||
|
{
|
||||||
|
if (!wavetable_)
|
||||||
|
{
|
||||||
|
gsl_fft_complex_wavetable_free(wavetable_);
|
||||||
|
}
|
||||||
|
if (!workspace_)
|
||||||
|
{
|
||||||
|
gsl_fft_complex_workspace_free(workspace_);
|
||||||
|
}
|
||||||
|
}
|
57
lib/GslFFT.hpp
Normal file
57
lib/GslFFT.hpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* GslFFT.hpp, part of LatAnalyze
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 - 2017 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 Latan_GslFFT_hpp_
|
||||||
|
#define Latan_GslFFT_hpp_
|
||||||
|
|
||||||
|
#include <LatAnalyze/Global.hpp>
|
||||||
|
#include <LatAnalyze/Mat.hpp>
|
||||||
|
#include <LatAnalyze/FFT.hpp>
|
||||||
|
#include <gsl/gsl_fft_complex.h>
|
||||||
|
|
||||||
|
BEGIN_LATAN_NAMESPACE
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* GSL FFT *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
class GslFFT: public FFT
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructors
|
||||||
|
GslFFT(void) = default;
|
||||||
|
GslFFT(const Index size);
|
||||||
|
// destructor
|
||||||
|
virtual ~GslFFT(void);
|
||||||
|
// size
|
||||||
|
void resize(const Index size);
|
||||||
|
// fft
|
||||||
|
virtual void operator()(CMat &x, const unsigned int dir = FFT::Forward);
|
||||||
|
private:
|
||||||
|
// destroy GSL objects
|
||||||
|
void clear(void);
|
||||||
|
private:
|
||||||
|
Index size_{0};
|
||||||
|
gsl_fft_complex_wavetable *wavetable_{nullptr};
|
||||||
|
gsl_fft_complex_workspace *workspace_{nullptr};
|
||||||
|
};
|
||||||
|
|
||||||
|
END_LATAN_NAMESPACE
|
||||||
|
|
||||||
|
#endif // Latan_GslFFT_hpp_
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <LatAnalyze/GslQagsIntegrator.hpp>
|
#include <LatAnalyze/GslQagsIntegrator.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
|
#include <LatAnalyze/Math.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
@ -55,9 +56,26 @@ double GslQagsIntegrator::operator()(const DoubleFunction &f, const double xMin,
|
|||||||
|
|
||||||
gslF.function = fWrap;
|
gslF.function = fWrap;
|
||||||
gslF.params = reinterpret_cast<void *>(&const_cast<DoubleFunction &>(f));
|
gslF.params = reinterpret_cast<void *>(&const_cast<DoubleFunction &>(f));
|
||||||
|
if ((xMin > -Math::inf) and (xMax < Math::inf))
|
||||||
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_, workspace_,
|
{
|
||||||
&result, &error_);
|
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_,
|
||||||
|
workspace_, &result, &error_);
|
||||||
|
}
|
||||||
|
else if (xMax < Math::inf)
|
||||||
|
{
|
||||||
|
gsl_integration_qagil(&gslF, xMax, 0.0, precision_, limit_,
|
||||||
|
workspace_, &result, &error_);
|
||||||
|
}
|
||||||
|
else if (xMin > -Math::inf)
|
||||||
|
{
|
||||||
|
gsl_integration_qagiu(&gslF, xMin, 0.0, precision_, limit_,
|
||||||
|
workspace_, &result, &error_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gsl_integration_qagi(&gslF, 0.0, precision_, limit_,
|
||||||
|
workspace_, &result, &error_);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
#include <LatAnalyze/Io.hpp>
|
#include <LatAnalyze/Io.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
#include <LatAnalyze/AsciiFile.hpp>
|
#include <LatAnalyze/AsciiFile.hpp>
|
||||||
#ifdef HAVE_HDF5
|
|
||||||
#include <LatAnalyze/Hdf5File.hpp>
|
#include <LatAnalyze/Hdf5File.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
@ -42,12 +40,10 @@ unique_ptr<File> Io::open(const std::string &fileName, const unsigned int mode)
|
|||||||
{
|
{
|
||||||
return unique_ptr<File>(new AsciiFile(fileName, mode));
|
return unique_ptr<File>(new AsciiFile(fileName, mode));
|
||||||
}
|
}
|
||||||
#ifdef HAVE_HDF5
|
|
||||||
else if (ext == "h5")
|
else if (ext == "h5")
|
||||||
{
|
{
|
||||||
return unique_ptr<File>(new Hdf5File(fileName, mode));
|
return unique_ptr<File>(new Hdf5File(fileName, mode));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LATAN_ERROR(Io, "unknown file extension '" + ext + "'");
|
LATAN_ERROR(Io, "unknown file extension '" + ext + "'");
|
||||||
|
@ -31,9 +31,11 @@ libLatAnalyze_la_SOURCES = \
|
|||||||
FitInterface.cpp \
|
FitInterface.cpp \
|
||||||
Function.cpp \
|
Function.cpp \
|
||||||
Global.cpp \
|
Global.cpp \
|
||||||
|
GslFFT.cpp \
|
||||||
GslHybridRootFinder.cpp\
|
GslHybridRootFinder.cpp\
|
||||||
GslMinimizer.cpp \
|
GslMinimizer.cpp \
|
||||||
GslQagsIntegrator.cpp \
|
GslQagsIntegrator.cpp \
|
||||||
|
Hdf5File.cpp \
|
||||||
Histogram.cpp \
|
Histogram.cpp \
|
||||||
includes.hpp \
|
includes.hpp \
|
||||||
Io.cpp \
|
Io.cpp \
|
||||||
@ -59,13 +61,16 @@ libLatAnalyze_la_HEADERS = \
|
|||||||
Dataset.hpp \
|
Dataset.hpp \
|
||||||
Derivative.hpp \
|
Derivative.hpp \
|
||||||
Exceptions.hpp \
|
Exceptions.hpp \
|
||||||
|
FFT.hpp \
|
||||||
Function.hpp \
|
Function.hpp \
|
||||||
File.hpp \
|
File.hpp \
|
||||||
FitInterface.hpp \
|
FitInterface.hpp \
|
||||||
Global.hpp \
|
Global.hpp \
|
||||||
|
GslFFT.hpp \
|
||||||
GslHybridRootFinder.hpp\
|
GslHybridRootFinder.hpp\
|
||||||
GslMinimizer.hpp \
|
GslMinimizer.hpp \
|
||||||
GslQagsIntegrator.hpp \
|
GslQagsIntegrator.hpp \
|
||||||
|
Hdf5File.hpp \
|
||||||
Histogram.hpp \
|
Histogram.hpp \
|
||||||
Integrator.hpp \
|
Integrator.hpp \
|
||||||
Io.hpp \
|
Io.hpp \
|
||||||
@ -84,10 +89,6 @@ libLatAnalyze_la_HEADERS = \
|
|||||||
StatArray.hpp \
|
StatArray.hpp \
|
||||||
XYSampleData.hpp \
|
XYSampleData.hpp \
|
||||||
XYStatData.hpp
|
XYStatData.hpp
|
||||||
if HAVE_HDF5
|
|
||||||
libLatAnalyze_la_SOURCES += Hdf5File.cpp
|
|
||||||
libLatAnalyze_la_HEADERS += Hdf5File.hpp
|
|
||||||
endif
|
|
||||||
if HAVE_MINUIT
|
if HAVE_MINUIT
|
||||||
libLatAnalyze_la_SOURCES += MinuitMinimizer.cpp
|
libLatAnalyze_la_SOURCES += MinuitMinimizer.cpp
|
||||||
libLatAnalyze_la_HEADERS += MinuitMinimizer.hpp
|
libLatAnalyze_la_HEADERS += MinuitMinimizer.hpp
|
||||||
|
@ -228,7 +228,7 @@ Index MatSample<T>::BlockTemplate<S>::getNCol(void) const
|
|||||||
// assignement operators ///////////////////////////////////////////////////////
|
// assignement operators ///////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <class S>
|
template <class S>
|
||||||
MatSample<T>::BlockTemplate<S> &
|
typename MatSample<T>::template BlockTemplate<S> &
|
||||||
MatSample<T>::BlockTemplate<S>::operator=(const S &sample)
|
MatSample<T>::BlockTemplate<S>::operator=(const S &sample)
|
||||||
{
|
{
|
||||||
FOR_STAT_ARRAY(sample_, s)
|
FOR_STAT_ARRAY(sample_, s)
|
||||||
@ -241,7 +241,7 @@ MatSample<T>::BlockTemplate<S>::operator=(const S &sample)
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
template <class S>
|
template <class S>
|
||||||
MatSample<T>::BlockTemplate<S> &
|
typename MatSample<T>::template BlockTemplate<S> &
|
||||||
MatSample<T>::BlockTemplate<S>::operator=(const S &&sample)
|
MatSample<T>::BlockTemplate<S>::operator=(const S &&sample)
|
||||||
{
|
{
|
||||||
*this = sample;
|
*this = sample;
|
||||||
|
@ -72,8 +72,9 @@ namespace MATH_NAMESPACE
|
|||||||
DMat varToCorr(const DMat &var);
|
DMat varToCorr(const DMat &var);
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const double pi = 3.1415926535897932384626433832795028841970;
|
constexpr double pi = 3.1415926535897932384626433832795028841970;
|
||||||
const double e = 2.7182818284590452353602874713526624977572;
|
constexpr double e = 2.7182818284590452353602874713526624977572;
|
||||||
|
constexpr double inf = std::numeric_limits<double>::infinity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -690,6 +690,7 @@ void MathInterpreter::compile(RunContext &context)
|
|||||||
if (root_)
|
if (root_)
|
||||||
{
|
{
|
||||||
context.addVariable("pi", Math::pi);
|
context.addVariable("pi", Math::pi);
|
||||||
|
context.addVariable("inf", Math::inf);
|
||||||
ADD_STDMATH_FUNCS(context);
|
ADD_STDMATH_FUNCS(context);
|
||||||
root_->compile(program_, context);
|
root_->compile(program_, context);
|
||||||
for (unsigned int i = 0; i < program_.size(); ++i)
|
for (unsigned int i = 0; i < program_.size(); ++i)
|
||||||
|
@ -29,18 +29,11 @@ using namespace Latan;
|
|||||||
// constructors ////////////////////////////////////////////////////////////////
|
// constructors ////////////////////////////////////////////////////////////////
|
||||||
TabFunction::TabFunction(const DVec &x, const DVec &y,
|
TabFunction::TabFunction(const DVec &x, const DVec &y,
|
||||||
const InterpType interpType)
|
const InterpType interpType)
|
||||||
: interpType_(interpType)
|
|
||||||
{
|
{
|
||||||
setData(x, y);
|
setData(x, y);
|
||||||
|
setInterpolationType(interpType);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TabFunction::TabFunction(const XYStatData &data, const Index i, const Index j,
|
|
||||||
// const InterpType interpType)
|
|
||||||
//: interpType_(interpType)
|
|
||||||
//{
|
|
||||||
// setData(data, i, j);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// access //////////////////////////////////////////////////////////////////////
|
// access //////////////////////////////////////////////////////////////////////
|
||||||
void TabFunction::setData(const DVec &x, const DVec &y)
|
void TabFunction::setData(const DVec &x, const DVec &y)
|
||||||
{
|
{
|
||||||
@ -54,10 +47,10 @@ void TabFunction::setData(const DVec &x, const DVec &y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void TabFunction::setData(const XYStatData &data, const Index i, const Index j)
|
void TabFunction::setInterpolationType(const InterpType interpType)
|
||||||
//{
|
{
|
||||||
// setData(data.x(i), data.y(j));
|
interpType_ = interpType;
|
||||||
//}
|
}
|
||||||
|
|
||||||
// function call ///////////////////////////////////////////////////////////////
|
// function call ///////////////////////////////////////////////////////////////
|
||||||
double TabFunction::operator()(const double *arg) const
|
double TabFunction::operator()(const double *arg) const
|
||||||
@ -154,12 +147,6 @@ DoubleFunction Latan::interpolate(const DVec &x, const DVec &y,
|
|||||||
return TabFunction(x, y, interpType).makeFunction();
|
return TabFunction(x, y, interpType).makeFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
//DoubleFunction Latan::interpolate(const XYStatData &data, const Index i,
|
|
||||||
// const Index j, const InterpType interpType)
|
|
||||||
//{
|
|
||||||
// return TabFunction(data, i, j, interpType).makeFunction();
|
|
||||||
//}
|
|
||||||
|
|
||||||
map<double, double>::const_iterator TabFunction::nearest(const double x) const
|
map<double, double>::const_iterator TabFunction::nearest(const double x) const
|
||||||
{
|
{
|
||||||
map<double, double>::const_iterator ret;
|
map<double, double>::const_iterator ret;
|
||||||
|
@ -45,13 +45,11 @@ public:
|
|||||||
TabFunction(void) = default;
|
TabFunction(void) = default;
|
||||||
TabFunction(const DVec &x, const DVec &y,
|
TabFunction(const DVec &x, const DVec &y,
|
||||||
const InterpType interpType = InterpType::LINEAR);
|
const InterpType interpType = InterpType::LINEAR);
|
||||||
//TabFunction(const XYStatData &data, const Index i = 0, const Index j = 0,
|
|
||||||
// const InterpType interpType = InterpType::LINEAR);
|
|
||||||
// destructor
|
// destructor
|
||||||
virtual ~TabFunction(void) = default;
|
virtual ~TabFunction(void) = default;
|
||||||
// access
|
// access
|
||||||
void setData(const DVec &x, const DVec &y);
|
void setData(const DVec &x, const DVec &y);
|
||||||
// void setData(const XYStatData &data, const Index i = 0, const Index j = 0);
|
void setInterpolationType(const InterpType interpType);
|
||||||
// function call
|
// function call
|
||||||
double operator()(const double *arg) const;
|
double operator()(const double *arg) const;
|
||||||
// factory
|
// factory
|
||||||
@ -65,9 +63,6 @@ private:
|
|||||||
|
|
||||||
DoubleFunction interpolate(const DVec &x, const DVec &y,
|
DoubleFunction interpolate(const DVec &x, const DVec &y,
|
||||||
const InterpType interpType = InterpType::LINEAR);
|
const InterpType interpType = InterpType::LINEAR);
|
||||||
//DoubleFunction interpolate(const XYStatData &data, const Index i = 0,
|
|
||||||
// const Index j = 0,
|
|
||||||
// const InterpType interpType = InterpType::LINEAR);
|
|
||||||
|
|
||||||
END_LATAN_NAMESPACE
|
END_LATAN_NAMESPACE
|
||||||
|
|
||||||
|
@ -171,6 +171,20 @@ const DSample & XYSampleData::y(const Index k, const Index j) const
|
|||||||
return yData_[j].at(k);
|
return yData_[j].at(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XYSampleData::setUnidimData(const DMatSample &xData,
|
||||||
|
const vector<const DMatSample *> &v)
|
||||||
|
{
|
||||||
|
FOR_STAT_ARRAY(xData, s)
|
||||||
|
FOR_VEC(xData[central], r)
|
||||||
|
{
|
||||||
|
x(r, 0)[s] = xData[s](r);
|
||||||
|
for (unsigned int j = 0; j < v.size(); ++j)
|
||||||
|
{
|
||||||
|
y(r, j)[s] = (*(v[j]))[s](r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const DMat & XYSampleData::getXXVar(const Index i1, const Index i2)
|
const DMat & XYSampleData::getXXVar(const Index i1, const Index i2)
|
||||||
{
|
{
|
||||||
checkXDim(i1);
|
checkXDim(i1);
|
||||||
@ -253,6 +267,7 @@ void XYSampleData::setDataToSample(const Index s)
|
|||||||
const XYStatData & XYSampleData::getData(void)
|
const XYStatData & XYSampleData::getData(void)
|
||||||
{
|
{
|
||||||
setDataToSample(central);
|
setDataToSample(central);
|
||||||
|
computeVarMat();
|
||||||
|
|
||||||
return data_;
|
return data_;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
const DMatSample & x(const Index k);
|
const DMatSample & x(const Index k);
|
||||||
DSample & y(const Index k, const Index j);
|
DSample & y(const Index k, const Index j);
|
||||||
const DSample & y(const Index k, const Index j) const;
|
const DSample & y(const Index k, const Index j) const;
|
||||||
|
void setUnidimData(const DMatSample &xData,
|
||||||
|
const std::vector<const DMatSample *> &v);
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
void setUnidimData(const DMatSample &xData,
|
void setUnidimData(const DMatSample &xData,
|
||||||
const Ts & ...yDatas);
|
const Ts & ...yDatas);
|
||||||
@ -141,17 +143,9 @@ void XYSampleData::setUnidimData(const DMatSample &xData, const Ts & ...yDatas)
|
|||||||
static_assert(static_or<std::is_assignable<DMatSample, Ts>::value...>::value,
|
static_assert(static_or<std::is_assignable<DMatSample, Ts>::value...>::value,
|
||||||
"y data arguments are not compatible with DMatSample");
|
"y data arguments are not compatible with DMatSample");
|
||||||
|
|
||||||
std::vector<const DMatSample *> yData{&yDatas...};
|
std::vector<const DMatSample *> v{&yDatas...};
|
||||||
|
|
||||||
FOR_STAT_ARRAY(xData, s)
|
setUnidimData(xData, v);
|
||||||
FOR_VEC(xData[central], r)
|
|
||||||
{
|
|
||||||
x(r, 0)[s] = xData[s](r);
|
|
||||||
for (unsigned int j = 0; j < yData.size(); ++j)
|
|
||||||
{
|
|
||||||
y(r, j)[s] = (*(yData[j]))[s](r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
|
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
|
|||||||
opt.addOption("s", "shift" , OptParser::OptType::value , true,
|
opt.addOption("s", "shift" , OptParser::OptType::value , true,
|
||||||
"time variable shift", "0");
|
"time variable shift", "0");
|
||||||
opt.addOption("m", "model" , OptParser::OptType::value , true,
|
opt.addOption("m", "model" , OptParser::OptType::value , true,
|
||||||
"fit model (exp|exp2|exp3|cosh|cosh2|cosh3|<interpreter code>)", "cosh");
|
"fit model (exp|exp2|exp3|cosh|cosh2|cosh3|explin|<interpreter code>)", "cosh");
|
||||||
opt.addOption("" , "nPar" , OptParser::OptType::value , true,
|
opt.addOption("" , "nPar" , OptParser::OptType::value , true,
|
||||||
"number of model parameters for custom models "
|
"number of model parameters for custom models "
|
||||||
"(-1 if irrelevant)", "-1");
|
"(-1 if irrelevant)", "-1");
|
||||||
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// make model //////////////////////////////////////////////////////////////
|
// make model //////////////////////////////////////////////////////////////
|
||||||
DoubleModel mod;
|
DoubleModel mod;
|
||||||
bool coshModel = false;
|
bool coshModel = false, linearModel = false;
|
||||||
|
|
||||||
if ((model == "exp") or (model == "exp1"))
|
if ((model == "exp") or (model == "exp1"))
|
||||||
{
|
{
|
||||||
@ -174,6 +174,15 @@ int main(int argc, char *argv[])
|
|||||||
+ p[5]*(exp(-p[2]*x[0])+exp(-p[4]*(nt-x[0])));
|
+ p[5]*(exp(-p[2]*x[0])+exp(-p[4]*(nt-x[0])));
|
||||||
}, 1, nPar);
|
}, 1, nPar);
|
||||||
}
|
}
|
||||||
|
else if (model == "explin")
|
||||||
|
{
|
||||||
|
linearModel = true;
|
||||||
|
nPar = 2;
|
||||||
|
mod.setFunction([](const double *x, const double *p)
|
||||||
|
{
|
||||||
|
return p[1] - p[0]*x[0];
|
||||||
|
}, 1, nPar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (nPar > 0)
|
if (nPar > 0)
|
||||||
@ -210,20 +219,36 @@ int main(int argc, char *argv[])
|
|||||||
mod.parName().setName(p, "E_" + strFrom(p/2));
|
mod.parName().setName(p, "E_" + strFrom(p/2));
|
||||||
mod.parName().setName(p + 1, "Z_" + strFrom(p/2));
|
mod.parName().setName(p + 1, "Z_" + strFrom(p/2));
|
||||||
}
|
}
|
||||||
|
if (linearModel)
|
||||||
|
{
|
||||||
|
init(0) = data.y(nt/4, 0)[central] - data.y(nt/4 + 1, 0)[central];
|
||||||
|
init(1) = data.y(nt/4, 0)[central] + nt/4*init(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
init(0) = log(data.y(nt/4, 0)[central]/data.y(nt/4 + 1, 0)[central]);
|
init(0) = log(data.y(nt/4, 0)[central]/data.y(nt/4 + 1, 0)[central]);
|
||||||
init(1) = data.y(nt/4, 0)[central]/(exp(-init(0)*nt/4));
|
init(1) = data.y(nt/4, 0)[central]/(exp(-init(0)*nt/4));
|
||||||
|
}
|
||||||
for (Index p = 2; p < nPar; p += 2)
|
for (Index p = 2; p < nPar; p += 2)
|
||||||
{
|
{
|
||||||
init(p) = 2*init(p - 2);
|
init(p) = 2*init(p - 2);
|
||||||
init(p + 1) = init(p - 1)/2.;
|
init(p + 1) = init(p - 1)/2.;
|
||||||
}
|
}
|
||||||
for (Index p = 0; p < nPar; p += 2)
|
for (Index p = 0; p < nPar; p += 2)
|
||||||
|
{
|
||||||
|
if (linearModel)
|
||||||
|
{
|
||||||
|
globMin.setLowLimit(p, -10.*fabs(init(p)));
|
||||||
|
globMin.setHighLimit(p, 10.*fabs(init(p)));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
globMin.setLowLimit(p, 0.);
|
globMin.setLowLimit(p, 0.);
|
||||||
globMin.setHighLimit(p, 10.*init(p));
|
|
||||||
globMin.setLowLimit(p + 1, -10.*init(p + 1));
|
|
||||||
globMin.setHighLimit(p + 1, 10.*init(p + 1));
|
|
||||||
locMin.setLowLimit(p, 0.);
|
locMin.setLowLimit(p, 0.);
|
||||||
|
globMin.setHighLimit(p, 10.*init(p));
|
||||||
|
}
|
||||||
|
globMin.setLowLimit(p + 1, -10.*fabs(init(p + 1)));
|
||||||
|
globMin.setHighLimit(p + 1, 10.*fabs(init(p + 1)));
|
||||||
}
|
}
|
||||||
globMin.setPrecision(0.001);
|
globMin.setPrecision(0.001);
|
||||||
globMin.setMaxIteration(100000);
|
globMin.setMaxIteration(100000);
|
||||||
@ -264,7 +289,10 @@ int main(int argc, char *argv[])
|
|||||||
double e0, e0Err;
|
double e0, e0Err;
|
||||||
|
|
||||||
p << PlotRange(Axis::x, 0, nt - 1);
|
p << PlotRange(Axis::x, 0, nt - 1);
|
||||||
|
if (!linearModel)
|
||||||
|
{
|
||||||
p << LogScale(Axis::y);
|
p << LogScale(Axis::y);
|
||||||
|
}
|
||||||
p << Color("rgb 'blue'") << PlotPredBand(fit.getModel(_), 0, nt - 1);
|
p << Color("rgb 'blue'") << PlotPredBand(fit.getModel(_), 0, nt - 1);
|
||||||
p << Color("rgb 'blue'") << PlotFunction(fit.getModel(), 0, nt - 1);
|
p << Color("rgb 'blue'") << PlotFunction(fit.getModel(), 0, nt - 1);
|
||||||
p << Color("rgb 'red'") << PlotData(data.getData());
|
p << Color("rgb 'red'") << PlotData(data.getData());
|
||||||
@ -285,6 +313,16 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (linearModel)
|
||||||
|
{
|
||||||
|
FOR_STAT_ARRAY(effMass, s)
|
||||||
|
{
|
||||||
|
for (Index t = 0; t < nt - 1; ++t)
|
||||||
|
{
|
||||||
|
effMass[s](t) = corr[s](t) - corr[s](t+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FOR_STAT_ARRAY(effMass, s)
|
FOR_STAT_ARRAY(effMass, s)
|
||||||
@ -302,7 +340,6 @@ int main(int argc, char *argv[])
|
|||||||
p << Color("rgb 'blue'") << PlotHLine(e0);
|
p << Color("rgb 'blue'") << PlotHLine(e0);
|
||||||
p << Color("rgb 'red'") << PlotData(effMassT, effMass);
|
p << Color("rgb 'red'") << PlotData(effMassT, effMass);
|
||||||
p.display();
|
p.display();
|
||||||
p.save("test");
|
|
||||||
}
|
}
|
||||||
if (doHeatmap)
|
if (doHeatmap)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,8 @@ bin_PROGRAMS = \
|
|||||||
latan-sample-combine \
|
latan-sample-combine \
|
||||||
latan-sample-element \
|
latan-sample-element \
|
||||||
latan-sample-fake \
|
latan-sample-fake \
|
||||||
|
latan-sample-ft \
|
||||||
|
latan-sample-plot \
|
||||||
latan-sample-plot-corr\
|
latan-sample-plot-corr\
|
||||||
latan-sample-read \
|
latan-sample-read \
|
||||||
latan-resample
|
latan-resample
|
||||||
@ -26,10 +28,18 @@ latan_sample_fake_SOURCES = sample-fake.cpp
|
|||||||
latan_sample_fake_CXXFLAGS = $(COM_CXXFLAGS)
|
latan_sample_fake_CXXFLAGS = $(COM_CXXFLAGS)
|
||||||
latan_sample_fake_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
latan_sample_fake_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||||
|
|
||||||
|
latan_sample_ft_SOURCES = sample-ft.cpp
|
||||||
|
latan_sample_ft_CXXFLAGS = $(COM_CXXFLAGS)
|
||||||
|
latan_sample_ft_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||||
|
|
||||||
latan_sample_plot_corr_SOURCES = sample-plot-corr.cpp
|
latan_sample_plot_corr_SOURCES = sample-plot-corr.cpp
|
||||||
latan_sample_plot_corr_CXXFLAGS = $(COM_CXXFLAGS)
|
latan_sample_plot_corr_CXXFLAGS = $(COM_CXXFLAGS)
|
||||||
latan_sample_plot_corr_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
latan_sample_plot_corr_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||||
|
|
||||||
|
latan_sample_plot_SOURCES = sample-plot.cpp
|
||||||
|
latan_sample_plot_CXXFLAGS = $(COM_CXXFLAGS)
|
||||||
|
latan_sample_plot_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||||
|
|
||||||
latan_sample_read_SOURCES = sample-read.cpp
|
latan_sample_read_SOURCES = sample-read.cpp
|
||||||
latan_sample_read_CXXFLAGS = $(COM_CXXFLAGS)
|
latan_sample_read_CXXFLAGS = $(COM_CXXFLAGS)
|
||||||
latan_sample_read_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
latan_sample_read_LDFLAGS = -L../lib/.libs -lLatAnalyze
|
||||||
|
@ -25,12 +25,7 @@
|
|||||||
#ifndef DEF_NSAMPLE
|
#ifndef DEF_NSAMPLE
|
||||||
#define DEF_NSAMPLE "100"
|
#define DEF_NSAMPLE "100"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_HDF5
|
|
||||||
#define DEF_FMT "h5"
|
#define DEF_FMT "h5"
|
||||||
#else
|
|
||||||
#define DEF_FMT "sample"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
@ -39,7 +34,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
// argument parsing ////////////////////////////////////////////////////////
|
// argument parsing ////////////////////////////////////////////////////////
|
||||||
OptParser opt;
|
OptParser opt;
|
||||||
bool parsed;
|
bool parsed, dumpBoot;
|
||||||
random_device rd;
|
random_device rd;
|
||||||
SeedType seed = rd();
|
SeedType seed = rd();
|
||||||
string manFileName, nameFileName, outDirName;
|
string manFileName, nameFileName, outDirName;
|
||||||
@ -56,10 +51,12 @@ int main(int argc, char *argv[])
|
|||||||
"output directory", ".");
|
"output directory", ".");
|
||||||
opt.addOption("f", "format" , OptParser::OptType::value, true,
|
opt.addOption("f", "format" , OptParser::OptType::value, true,
|
||||||
"output file format", DEF_FMT);
|
"output file format", DEF_FMT);
|
||||||
|
opt.addOption("d", "dump-boot" , OptParser::OptType::trigger, true,
|
||||||
|
"dump bootstrap sequence");
|
||||||
opt.addOption("" , "help" , OptParser::OptType::trigger, true,
|
opt.addOption("" , "help" , OptParser::OptType::trigger, true,
|
||||||
"show this help message and exit");
|
"show this help message and exit");
|
||||||
parsed = opt.parse(argc, argv);
|
parsed = opt.parse(argc, argv);
|
||||||
if (!parsed or (opt.getArgs().size() != 1) or opt.gotOption("help"))
|
if (!parsed or (opt.getArgs().size() != 2) or opt.gotOption("help"))
|
||||||
{
|
{
|
||||||
cerr << "usage: " << argv[0];
|
cerr << "usage: " << argv[0];
|
||||||
cerr << " <datafile list> <name list> <options>" << endl;
|
cerr << " <datafile list> <name list> <options>" << endl;
|
||||||
@ -75,6 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
ext = opt.optionValue("f");
|
ext = opt.optionValue("f");
|
||||||
outDirName = opt.optionValue("o");
|
outDirName = opt.optionValue("o");
|
||||||
|
dumpBoot = opt.gotOption("d");
|
||||||
manFileName = opt.getArgs()[0];
|
manFileName = opt.getArgs()[0];
|
||||||
nameFileName = opt.getArgs()[1];
|
nameFileName = opt.getArgs()[1];
|
||||||
|
|
||||||
@ -124,6 +122,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
cout << '\r' << ProgressBar(i + 1, name.size());
|
cout << '\r' << ProgressBar(i + 1, name.size());
|
||||||
data[name[i]].bin(binSize);
|
data[name[i]].bin(binSize);
|
||||||
|
if ((i == 0) and dumpBoot)
|
||||||
|
{
|
||||||
|
ofstream file(outDirName + "/" + manFileName + ".bootseq");
|
||||||
|
|
||||||
|
file << "# bootstrap sequences" << endl;
|
||||||
|
file << "# manifest file: " << manFileName << endl;
|
||||||
|
file << "# bin size: " << binSize << endl;
|
||||||
|
data[name[i]].dumpBootstrapSeq(file, nSample, seed);
|
||||||
|
}
|
||||||
s = data[name[i]].bootstrapMean(nSample, seed);
|
s = data[name[i]].bootstrapMean(nSample, seed);
|
||||||
Io::save<DMatSample>(s, outDirName + "/" + outFileName,
|
Io::save<DMatSample>(s, outDirName + "/" + outFileName,
|
||||||
File::Mode::write, outFileName);
|
File::Mode::write, outFileName);
|
||||||
|
@ -25,14 +25,21 @@ using namespace std;
|
|||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void loadAndCheck(vector<T> &sample, const vector<string> &fileName)
|
static void loadAndCheck(vector<T> &sample __dumb,
|
||||||
|
const vector<string> &fileName __dumb)
|
||||||
{
|
{
|
||||||
const unsigned int n = sample.size();
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void loadAndCheck(vector<DSample> &sample, const vector<string> &fileName)
|
||||||
|
{
|
||||||
|
const unsigned int n = static_cast<unsigned int>(sample.size());
|
||||||
Index nSample = 0;
|
Index nSample = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < n; ++i)
|
for (unsigned int i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
sample[i] = Io::load<T>(fileName[i]);
|
sample[i] = Io::load<DSample>(fileName[i]);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
nSample = sample[i].size();
|
nSample = sample[i].size();
|
||||||
@ -46,6 +53,62 @@ static void loadAndCheck(vector<T> &sample, const vector<string> &fileName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void loadAndCheck(vector<DMatSample> &sample, const vector<string> &fileName)
|
||||||
|
{
|
||||||
|
const unsigned int n = static_cast<unsigned int>(sample.size());
|
||||||
|
Index nSample = 0;
|
||||||
|
set<unsigned int> failed;
|
||||||
|
bool gotSize = false;
|
||||||
|
Index nRow = 0, nCol = 0;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sample[i] = Io::load<DMatSample>(fileName[i]);
|
||||||
|
if (!gotSize)
|
||||||
|
{
|
||||||
|
nSample = sample[i].size();
|
||||||
|
nRow = sample[i][central].rows();
|
||||||
|
nCol = sample[i][central].cols();
|
||||||
|
gotSize = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exceptions::Definition)
|
||||||
|
{
|
||||||
|
failed.insert(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned int i: failed)
|
||||||
|
{
|
||||||
|
DSample buf;
|
||||||
|
|
||||||
|
buf = Io::load<DSample>(fileName[i]);
|
||||||
|
sample[i].resize(nSample);
|
||||||
|
FOR_STAT_ARRAY(sample[i], s)
|
||||||
|
{
|
||||||
|
sample[i][s] = DMat::Constant(nRow, nCol, buf[s]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
if (sample[i].size() != nSample)
|
||||||
|
{
|
||||||
|
cerr << "error: number of sample mismatch (between '";
|
||||||
|
cerr << fileName[0] << "' and '" << fileName[i] << "')" << endl;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
if ((sample[i][central].rows() != nRow) and
|
||||||
|
(sample[i][central].cols() != nCol))
|
||||||
|
{
|
||||||
|
cerr << "error: matrix size mismatch (between '";
|
||||||
|
cerr << fileName[0] << "' and '" << fileName[i] << "')" << endl;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void combine(const string &outFileName __dumb,
|
static void combine(const string &outFileName __dumb,
|
||||||
const vector<T> &sample __dumb, const string &code __dumb)
|
const vector<T> &sample __dumb, const string &code __dumb)
|
||||||
@ -57,7 +120,7 @@ template <>
|
|||||||
void combine(const string &outFileName, const vector<DSample> &sample,
|
void combine(const string &outFileName, const vector<DSample> &sample,
|
||||||
const string &code)
|
const string &code)
|
||||||
{
|
{
|
||||||
const unsigned int n = sample.size();
|
const unsigned int n = static_cast<unsigned int>(sample.size());
|
||||||
DoubleFunction f = compile(code, n);
|
DoubleFunction f = compile(code, n);
|
||||||
DSample result(sample[0]);
|
DSample result(sample[0]);
|
||||||
DVec buf(n);
|
DVec buf(n);
|
||||||
@ -87,7 +150,7 @@ template <>
|
|||||||
void combine(const string &outFileName, const vector<DMatSample> &sample,
|
void combine(const string &outFileName, const vector<DMatSample> &sample,
|
||||||
const string &code)
|
const string &code)
|
||||||
{
|
{
|
||||||
const unsigned int n = sample.size();
|
const unsigned int n = static_cast<unsigned int>(sample.size());
|
||||||
DoubleFunction f = compile(code, n);
|
DoubleFunction f = compile(code, n);
|
||||||
DVec buf(n);
|
DVec buf(n);
|
||||||
DMatSample result(sample[0]);
|
DMatSample result(sample[0]);
|
||||||
|
@ -1,39 +1,103 @@
|
|||||||
#include <iostream>
|
/*
|
||||||
#include <string>
|
* sample-element.cpp, part of LatAnalyze 3
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 - 2016 Antonin Portelli, Matt Spraggs
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LatCore/OptParser.hpp>
|
||||||
#include <LatAnalyze/Io.hpp>
|
#include <LatAnalyze/Io.hpp>
|
||||||
#include <LatAnalyze/MatSample.hpp>
|
#include <LatAnalyze/MatSample.hpp>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
|
|
||||||
if (argc != 4 and argc != 5) {
|
int main(int argc, char* argv[])
|
||||||
cout << "Usage: " << argv[0] << " <input filename> <row> <column> ";
|
{
|
||||||
cout << "[output filename]" << endl;
|
// argument parsing ////////////////////////////////////////////////////////
|
||||||
return -1;
|
OptParser opt;
|
||||||
|
bool parsed;
|
||||||
|
string inFilename, outFilename;
|
||||||
|
Index r, c, nr, nc;
|
||||||
|
|
||||||
|
opt.addOption("r", "row", OptParser::OptType::value , false,
|
||||||
|
"row");
|
||||||
|
opt.addOption("c", "col", OptParser::OptType::value , false,
|
||||||
|
"column");
|
||||||
|
opt.addOption("" , "nrow", OptParser::OptType::value , true,
|
||||||
|
"number of rows (default: 1)", "1");
|
||||||
|
opt.addOption("" , "ncol", OptParser::OptType::value , true,
|
||||||
|
"number of columns (default: 1)", "1");
|
||||||
|
opt.addOption("o", "output", OptParser::OptType::value , true,
|
||||||
|
"output file name (default: result not saved)", "");
|
||||||
|
opt.addOption("" , "help" , OptParser::OptType::trigger, true,
|
||||||
|
"show this help message and exit");
|
||||||
|
parsed = opt.parse(argc, argv);
|
||||||
|
if (!parsed or (opt.getArgs().size() != 1) or opt.gotOption("help"))
|
||||||
|
{
|
||||||
|
cerr << "usage: " << argv[0];
|
||||||
|
cerr << " <options> <input file>" << endl;
|
||||||
|
cerr << endl << "Possible options:" << endl << opt << endl;
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
inFilename = opt.getArgs()[0];
|
||||||
|
outFilename = opt.optionValue("o");
|
||||||
|
r = opt.optionValue<Index>("r");
|
||||||
|
c = opt.optionValue<Index>("c");
|
||||||
|
nr = opt.optionValue<Index>("nrow");
|
||||||
|
nc = opt.optionValue<Index>("ncol");
|
||||||
|
|
||||||
string inFileName = argv[1];
|
// Data extraction /////////////////////////////////////////////////////////
|
||||||
auto row = strTo<Index>(argv[2]);
|
auto inputData = Io::load<DMatSample>(inFilename);
|
||||||
auto col = strTo<Index>(argv[3]);
|
|
||||||
string outFileName = (argc == 5) ? argv[4] : "";
|
|
||||||
|
|
||||||
auto inputData = Io::load<DMatSample>(inFileName);
|
if ((nr == 1) and (nc == 1))
|
||||||
cout << scientific;
|
|
||||||
cout << "central value:\n" << inputData[central](row, col) << endl;
|
|
||||||
cout << "standard deviation:\n";
|
|
||||||
cout << inputData.variance().cwiseSqrt()(row, col) << endl;
|
|
||||||
|
|
||||||
if (not outFileName.empty())
|
|
||||||
{
|
{
|
||||||
DSample outputData(inputData.size());
|
DSample outputData(inputData.size());
|
||||||
FOR_STAT_ARRAY(inputData, s) {
|
|
||||||
outputData[s] = inputData[s](row, col);
|
FOR_STAT_ARRAY(inputData, s)
|
||||||
|
{
|
||||||
|
outputData[s] = inputData[s](r, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Io::save(outputData, outFileName);
|
cout << scientific;
|
||||||
|
cout << "central value:\n" << outputData[central] << endl;
|
||||||
|
cout << "standard deviation:\n";
|
||||||
|
cout << sqrt(outputData.variance()) << endl;
|
||||||
|
if (not outFilename.empty())
|
||||||
|
{
|
||||||
|
Io::save(outputData, outFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DMatSample outputData(inputData.size(), nr, nc);
|
||||||
|
|
||||||
|
FOR_STAT_ARRAY(inputData, s)
|
||||||
|
{
|
||||||
|
outputData[s] = inputData[s].block(r, c, nr, nc);
|
||||||
|
}
|
||||||
|
cout << scientific;
|
||||||
|
cout << "central value:\n" << outputData[central] << endl;
|
||||||
|
cout << "standard deviation:\n";
|
||||||
|
cout << outputData.variance().cwiseSqrt() << endl;
|
||||||
|
if (not outFilename.empty())
|
||||||
|
{
|
||||||
|
Io::save(outputData, outFilename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
94
utils/sample-ft.cpp
Normal file
94
utils/sample-ft.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* sample-ft.cpp, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LatCore/OptParser.hpp>
|
||||||
|
#include <LatAnalyze/GslFFT.hpp>
|
||||||
|
#include <LatAnalyze/Io.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Latan;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
// argument parsing ////////////////////////////////////////////////////////
|
||||||
|
OptParser opt;
|
||||||
|
bool parsed;
|
||||||
|
string inFilename, outFilename;
|
||||||
|
unsigned int dir = FFT::Forward;
|
||||||
|
|
||||||
|
opt.addOption("o", "output", OptParser::OptType::value , true,
|
||||||
|
"output file name (default: result not saved)", "");
|
||||||
|
opt.addOption("b", "backward", OptParser::OptType::trigger, true,
|
||||||
|
"backward Fourier transform (forward by default)");
|
||||||
|
opt.addOption("" , "help" , OptParser::OptType::trigger, true,
|
||||||
|
"show this help message and exit");
|
||||||
|
parsed = opt.parse(argc, argv);
|
||||||
|
if (!parsed or (opt.getArgs().size() != 1) or opt.gotOption("help"))
|
||||||
|
{
|
||||||
|
cerr << "usage: " << argv[0];
|
||||||
|
cerr << " <options> <input file>" << endl;
|
||||||
|
cerr << endl << "Possible options:" << endl << opt << endl;
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
inFilename = opt.getArgs()[0];
|
||||||
|
outFilename = opt.optionValue("o");
|
||||||
|
if (opt.gotOption("b"))
|
||||||
|
{
|
||||||
|
dir = FFT::Backward;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fourier transform ///////////////////////////////////////////////////////
|
||||||
|
DMatSample in = Io::load<DMatSample>(inFilename);
|
||||||
|
Index nSample = in.size(), l = in[central].rows();
|
||||||
|
bool isInComplex = (in[central].cols() > 1);
|
||||||
|
CMatSample res(nSample, l, 1);
|
||||||
|
DMatSample out(nSample, l, 2);
|
||||||
|
GslFFT ft(l);
|
||||||
|
|
||||||
|
cout << "-- computing Fourier transform..." << endl;
|
||||||
|
FOR_STAT_ARRAY(in, s)
|
||||||
|
{
|
||||||
|
res[s].real() = in[s].col(0);
|
||||||
|
if (isInComplex)
|
||||||
|
{
|
||||||
|
res[s].imag() = in[s].col(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res[s].imag() = DVec::Constant(l, 0.);
|
||||||
|
}
|
||||||
|
ft(res[s], dir);
|
||||||
|
out[s].col(0) = res[s].real();
|
||||||
|
out[s].col(1) = res[s].imag();
|
||||||
|
}
|
||||||
|
|
||||||
|
// output /////////////////////////////////////////////////////////////////
|
||||||
|
cout << scientific;
|
||||||
|
cout << "central value:\n" << out[central];
|
||||||
|
cout << endl;
|
||||||
|
cout << "standard deviation:\n" << out.variance().cwiseSqrt();
|
||||||
|
cout << endl;
|
||||||
|
if (!outFilename.empty())
|
||||||
|
{
|
||||||
|
Io::save<DMatSample>(out, outFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
51
utils/sample-plot.cpp
Normal file
51
utils/sample-plot.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* sample-plot.cpp, 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LatAnalyze/Io.hpp>
|
||||||
|
#include <LatAnalyze/Math.hpp>
|
||||||
|
#include <LatAnalyze/Plot.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Latan;
|
||||||
|
using namespace Math;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
string xFileName, yFileName;
|
||||||
|
|
||||||
|
if (argc != 3)
|
||||||
|
{
|
||||||
|
cerr << "usage: " << argv[0] << " <x sample> <y sample>" << endl;
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
xFileName = argv[1];
|
||||||
|
yFileName = argv[2];
|
||||||
|
|
||||||
|
Plot p;
|
||||||
|
DMatSample x, y;
|
||||||
|
|
||||||
|
x = Io::load<DMatSample>(xFileName);
|
||||||
|
y = Io::load<DMatSample>(yFileName);
|
||||||
|
|
||||||
|
p << PlotData(x, y);
|
||||||
|
p.display();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Reference in New Issue
Block a user