1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-06-14 22:07:04 +01:00

4 Commits

165 changed files with 2782 additions and 12516 deletions

View File

@ -1,26 +0,0 @@
name: Build macOS
on: [push, workflow_dispatch]
jobs:
build:
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install basic dependencies
run: brew install automake autoconf libtool bison flex
- name: Build dependencies
shell: bash
run: |
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:${PATH}
cd ci-scripts
./install-deps.sh prefix 6
- name: Build LatAnalyze
shell: bash
run: |
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:${PATH}
cd ci-scripts
./install-latan.sh prefix 6

View File

@ -1,26 +0,0 @@
name: Build Ubuntu
on: [push]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install basic dependencies
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt install cmake bison flex
- name: Build dependencies
shell: bash
run: |
cd ci-scripts
CC=clang CXX=clang++ ./install-deps.sh prefix 6
- name: Build LatAnalyze
shell: bash
run: |
cd ci-scripts
CC=clang CXX=clang++ ./install-latan.sh prefix 6

33
.gitignore vendored
View File

@ -1,5 +1,7 @@
# builds # builds
build build/*
build_debug/*
sandbox/*
# Apple stuff # Apple stuff
*.xcodeproj *.xcodeproj
@ -8,13 +10,28 @@ build
# VIM # VIM
*.swp *.swp
# Eigen headers and archives # autotools
/lib/LatAnalyze/Eigen autom4te.cache/*
eigen-*.tar.bz2 *.in
*.in~
config.h*
configure
.buildutils/*
aclocal.m4
# bison/flex generated sources
lib/*Lexer.cpp
lib/*Parser.cpp
lib/*Parser.hpp
# Eigen headers
lib/Eigen/*
lib/eigen_files.mk
# CI builds # CI builds
/ci-scripts/local ci-scripts/local/*
# VS Code Studio stuff # CLion stuff
.vscode .idea/*
*.code-workspace CMakeLists.txt
cmake-build-debug/*

91
.travis.yml Normal file
View File

@ -0,0 +1,91 @@
language: cpp
notifications:
email: false
slack: ukqcd:mQLXCtz8D2cg89xT8j1a4wku
cache:
directories:
- ci-scripts/local
- ci-scripts/clang
matrix:
include:
- os: osx
osx_image: xcode7.2
compiler: clang
- os: osx
osx_image: xcode7.2
compiler: gcc
env: VERSION=-5
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- libgsl0-dev
- flex
- bison
env: VERSION=-4.9
- compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- libgsl0-dev
- flex
- bison
env: VERSION=-5
- 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.6.0/clang+llvm-3.6.0-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:
- export LATDIR=`pwd`
- cd ci-scripts
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CC" == "clang" ]] && [ ! -e clang/bin ]; then wget $CLANG_LINK; tar -xf `basename $CLANG_LINK`; mkdir clang; mv clang+*/* clang/; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CC" == "clang" ]]; then export PATH="${LATDIR}/ci-scripts/clang/bin:${PATH}"; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CC" == "clang" ]]; then export LD_LIBRARY_PATH="${LATDIR}/ci-scripts/clang/lib:${LD_LIBRARY_PATH}"; 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 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
install:
- export CC=$CC$VERSION
- export CXX=$CXX$VERSION
- echo $PATH
- which $CC
- $CC --version
- which $CXX
- $CXX --version
- ./install-deps.sh `pwd`/local
- cd ..
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=${LATDIR}/ci-scripts/local/lib:$LD_LIBRARY_PATH; fi
script:
- cd ci-scripts
- ./install-latan.sh `pwd`/local $TRAVIS_OS_NAME

View File

@ -1,94 +0,0 @@
# package config
cmake_minimum_required(VERSION 3.11.0)
project(
LatAnalyze
VERSION 3.6
LANGUAGES C CXX)
# includes
include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)
include(FetchContent)
include(FindPackageMessage)
include(GNUInstallDirs)
# C++ compile flags
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_FLAG "-march=native")
endif()
check_cxx_compiler_flag("-mtune=native" COMPILER_SUPPORTS_MTUNE_NATIVE)
if(COMPILER_SUPPORTS_MTUNE_NATIVE)
set(MTUNE_FLAG "-mtune=native")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O3 -g -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
add_library(compiler_flags INTERFACE)
target_compile_features(compiler_flags INTERFACE cxx_std_17)
target_compile_options(
compiler_flags
INTERFACE "$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>")
# position idependent code
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# installation rpath setup
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# fetch and create symbolic link to Eigen headers
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/deps)
FetchContent_Declare(
Eigen3
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0)
FetchContent_GetProperties(Eigen3)
if(NOT eigen3_POPULATED)
FetchContent_Populate(Eigen3)
message(STATUS "Eigen3 fetched")
endif()
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen
${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen SYMBOLIC)
# dependencies
find_package(Threads REQUIRED)
find_package(GSL REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C CXX)
find_package(Minuit2 QUIET)
if(Minuit2_FOUND)
set(Minuit2_MSG "yes")
find_package_message(
Minuit2
"Found Minuit2: ${Minuit2_DIR} (found version \"${Minuit2_VERSION}\")" " ")
else()
set(Minuit2_MSG "no")
message(STATUS "Minuit2 not found")
endif()
find_package(NLopt QUIET)
if(NLopt_FOUND)
set(NLopt_MSG "yes")
find_package_message(
NLopt "Found NLopt: ${NLopt_DIR} (found version \"${NLopt_VERSION}\")" " ")
else()
set(NLopt_MSG "no")
message(STATUS "NLopt not found")
endif()
# subdirectories
add_subdirectory(lib)
add_subdirectory(examples)
add_subdirectory(physics)
add_subdirectory(utils)
# summary
message(STATUS "---------------------------")
message(STATUS "LatAnalyze v${PROJECT_VERSION} configured")
message(STATUS "---------------------------")
message(STATUS " install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Minuit2 minimisers: ${Minuit2_MSG}")
message(STATUS " NLopt minimisers: ${NLopt_MSG}")
message(STATUS "---------------------------")

3
Makefile.am Normal file
View File

@ -0,0 +1,3 @@
SUBDIRS = lib utils physics examples
ACLOCAL_AMFLAGS = -I .buildutils/m4

149
Readme.md
View File

@ -1,21 +1,37 @@
# LatAnalyze # LatAnalyze
Contributors: Antonin Portelli, Matt Spraggs
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![DOI](https://zenodo.org/badge/10201777.svg)](https://zenodo.org/badge/latestdoi/10201777) [![Build Ubuntu](https://github.com/aportelli/LatAnalyze/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/aportelli/LatAnalyze/actions/workflows/build-ubuntu.yml) [![Build macOS](https://github.com/aportelli/LatAnalyze/actions/workflows/build-macos.yml/badge.svg)](https://github.com/aportelli/LatAnalyze/actions/workflows/build-macos.yml) 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 ## Description
LatAnalyze is a C++14 library for statistical data analysis based on bootstrap 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 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. 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 several key features can be found in the `examples` directory. 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: The main features are the following:
* Array and matrix types with fast arithmetic operations based on [Eigen](http://eigen.tuxfamily.org). * 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). * High-level types for bootstrap sample manipulation (including various statistical estimators and histogramming).
* Mathematical expression parser for runtime defined functions. * Mathematical expression parser for runtime defined functions.
* Data I/O in ASCII, XML, and HDF5. * Data I/O in ASCII and HDF5 (optional).
* High-level wrappers to minimisation routines from the [GSL](http://www.gnu.org/software/gsl/), [Minuit 2](https://github.com/root-project/root/tree/master/math/minuit2) (optional) and [NLopt](http://ab-initio.mit.edu/wiki/index.php/NLopt). * 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). * 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 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 functional types for function of model. General functions can be defined from C pointers, C++ objects, strings of mathematical expressions or tabulated data.
@ -24,128 +40,23 @@ The main features are the following:
## Installation ## Installation
The head of the `master` branch always points to the latest stable release. The `develop` branch is the main unstable branch of LatAnalyze. 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++14. It has been successfully built on various Unix platform using reasonably recent versions of Clang or GCC. 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 only strict dependencies are the [GSL](http://www.gnu.org/software/gsl/) and [HDF5](https://www.hdfgroup.org/HDF5/) (built with C++ support). The strict dependencies are the [GSL](http://www.gnu.org/software/gsl/) and [LatCore](https://github.com/aportelli/LatCore).
Additionally, cmake (from 3.11), 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. 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 [Minuit 2](https://github.com/root-project/root/tree/master/math/minuit2) and [NLopt](http://ab-initio.mit.edu/wiki/index.php/NLopt). 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).
LatAnalyze is built through CMake. Below are example instructions for compiling and installing LatAnalyze.
### Portable quick installation
For a quick installation with all possible extensions execute: For a quick installation with all possible extensions execute:
``` ```
./install-latan.sh <prefix> ./install-latan.sh <prefix> {osx|linux}
``` ```
in the `ci-scripts` directory where `<prefix>` is where you want LatAnalyze (and its dependencies) to be installed. This script will automatically download, build and install GSL, HDF5, Minuit, and NLopt. 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).
### Quick installation on macOS with dependencies through Homebrew 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`.
All the dependencies of LatAnalyze can be installed through the [Homebrew](https://brew.sh) package manager.
```
brew install automake autoconf libtool bison flex gsl minuit2 nlopt hdf5
```
Then build the library with `cmake`
```
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=<prefix> -DCMAKE_BUILD_TYPE=Release ..
make -j <n>
make install
```
where `<prefix>` should be replaced by the desired prefix for LatAnalyze installation, and `<n>` is the number of parallel build processes.
### Dependencies through Homebrew/Linuxbrew
If you use Homebrew/Linuxbrew to manage packages, the following command can install all the dependencies of LatAnalyze (including optional ones)
## Using LatAnalyze in CMake projects
When LatAnalyze is installed, the necessary CMake module configuration files to link against the library are available in the installation prefix.
To link against LatAnalyze in a downstream CMake project, simply use
```cmake
find_package(LatAnalyze)
target_link_libraries(<my_app> LatAnalyze::LatAnalyze)
```
where `<my_app>` is a CMake target. If LatAnalyze was installed in a non-standard prefix, you might have to set `CMAKE_PREFIX_PATH` accordingly for `find_package` to be successful.
You can additionally modify the `find_package` to ensure specific components are supported
```cmake
find_package(LatAnalyze REQUIRED COMPONENTS <...>)
```
where `<...>` is a space separated list of components. Currently available components are
- `MINUIT2`: Minuit 2 minimisers
- `NLOPT`: NLopt minimisers
## History ## History
#### v3.6
Build system:
* automake build discontinued, now using CMake
* CI through GitHub Actions
Additions:
* Discrete wavelet transform
* Thread pools
* Correlation dynamic range (CDR) calculation
* Data filtering and CDR optimisation
Changes:
* Significant optimisation of covariance matrix calculation
* Covariance matrix available for any `StatArray` (not only resampled arrays)
#### v3.5.1
Various fixes and cleaning of outdated code.
#### v3.5
Additions:
* 'Impulse' & line type plots
* Plot line width & dash modifiers
* Plot palettes (`category10` by default)
* Multivariate Gaussian RNG
* 2-pt fitter 'scan' mode over all possible fit ranges
* Command line utility for plotting data
Changes:
* Complete overhaul of the header structure
* Integration of LatCore in LatAnalyze
* p-value is now a 2-sided chi^2 test, 1-sided value kept as 'chi^2 CCDF'
Fixes:
* Matrix plot data now saving correctly
* Many compatibility fixes
#### 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 #### v3.2.1
Fixes: Fix:
* Wrong argument number check in `latan-resample` * Wrong argument number check in `latan-resample`
#### v3.2 (needs LatCore 1.1) #### v3.2 (needs LatCore 1.1)
@ -183,4 +94,4 @@ Fixes:
#### v3.0 #### v3.0
Commit `7b4f2884a5e99bbfab4d4bd7623f609a55403c39`. 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. 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.** **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.**

542
acinclude.m4 Normal file
View File

@ -0,0 +1,542 @@
AC_DEFUN([AX_GCC_OPTION], [
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([if gcc accepts $1 option])
AS_IF([ test "x$GCC" = "xyes" ],[
AS_IF([ test -z "$3" ],[
ax_gcc_option_test="int main()
{
return 0;
}"
],[
ax_gcc_option_test="$3"
])
# Dump the test program to file
cat <<EOF > conftest.c
$ax_gcc_option_test
EOF
# Dump back the file to the log, useful for debugging purposes
AC_TRY_COMMAND(cat conftest.c 1>&AS_MESSAGE_LOG_FD)
AS_IF([ AC_TRY_COMMAND($CC $2 $1 -c conftest.c 1>&AS_MESSAGE_LOG_FD) ],[
AC_MSG_RESULT([yes])
$4
],[
AC_MSG_RESULT([no])
$5
])
],[
AC_MSG_RESULT([no gcc available])
])
])
AC_DEFUN([AX_GCC_VERSION], [
GCC_VERSION=""
AX_GCC_OPTION([-dumpversion],[],[],[
ax_gcc_version_option=yes
],[
ax_gcc_version_option=no
])
AS_IF([test "x$GCC" = "xyes"],[
AS_IF([test "x$ax_gcc_version_option" != "xno"],[
AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
ax_cv_gcc_version="`$CC -dumpversion`"
AS_IF([test "x$ax_cv_gcc_version" = "x"],[
ax_cv_gcc_version=""
])
])
GCC_VERSION=$ax_cv_gcc_version
])
])
AC_SUBST([GCC_VERSION])
])
AC_DEFUN([AX_GXX_VERSION], [
GXX_VERSION=""
AX_GCC_OPTION([-dumpversion],[],[],[
ax_gcc_version_option=yes
],[
ax_gcc_version_option=no
])
AS_IF([test "x$GXX" = "xyes"],[
AS_IF([test "x$ax_gxx_version_option" != "no"],[
AC_CACHE_CHECK([gxx version],[ax_cv_gxx_version],[
ax_cv_gxx_version="`$CXX -dumpversion`"
AS_IF([test "x$ax_cv_gxx_version" = "x"],[
ax_cv_gxx_version=""
])
])
GXX_VERSION=$ax_cv_gxx_version
])
])
AC_SUBST([GXX_VERSION])
])
AC_DEFUN([AX_COMPILER_VENDOR],
[
AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
[ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
# note: don't check for gcc first since some other compilers define __GNUC__
for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale:__PATHCC__,__PATHSCALE__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
thisisanerror;
#endif
])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
done
])
])
# ============================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXXFLAGS to enable support.
#
# The first argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
# -std=c++11). If neither is specified, you get whatever works, with
# preference for an extended mode.
#
# The second argument, if specified 'mandatory' or if left unspecified,
# indicates that baseline C++11 support is required and that the macro
# should error out if no mode with that support is found. If specified
# 'optional', then configuration proceeds regardless, after defining
# HAVE_CXX11 if and only if a supporting mode is found.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
struct Base {
virtual void f() {}
};
struct Child : public Base {
virtual void f() override {}
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
auto l = [](){};
]])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
m4_if([$1], [], [],
[$1], [ext], [],
[$1], [noext], [],
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
AC_LANG_PUSH([C++])dnl
ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
ax_cv_cxx_compile_cxx11,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx11=yes],
[ax_cv_cxx_compile_cxx11=no])])
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
ac_success=yes
fi
m4_if([$1], [noext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=gnu++11 -std=gnu++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
m4_if([$1], [ext], [], [dnl
if test x$ac_success = xno; then
for switch in -std=c++11 -std=c++0x; do
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
$cachevar,
[ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $switch"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[eval $cachevar=yes],
[eval $cachevar=no])
CXXFLAGS="$ac_save_CXXFLAGS"])
if eval test x\$$cachevar = xyes; then
CXXFLAGS="$CXXFLAGS $switch"
ac_success=yes
break
fi
done
fi])
AC_LANG_POP([C++])
if test x$ax_cxx_compile_cxx11_required = xtrue; then
if test x$ac_success = xno; then
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
fi
else
if test x$ac_success = xno; then
HAVE_CXX11=0
AC_MSG_NOTICE([No compiler with C++11 support was found])
else
HAVE_CXX11=1
AC_DEFINE(HAVE_CXX11,1,
[define if the compiler supports basic C++11 syntax])
fi
AC_SUBST(HAVE_CXX11)
fi
])
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_lib_hdf5.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_HDF5([serial/parallel])
#
# DESCRIPTION
#
# This macro provides tests of the availability of HDF5 library.
#
# The optional macro argument should be either 'serial' or 'parallel'. The
# former only looks for serial HDF5 installations via h5cc. The latter
# only looks for parallel HDF5 installations via h5pcc. If the optional
# argument is omitted, serial installations will be preferred over
# parallel ones.
#
# The macro adds a --with-hdf5 option accepting one of three values:
#
# no - do not check for the HDF5 library.
# yes - do check for HDF5 library in standard locations.
# path - complete path to the HDF5 helper script h5cc or h5pcc.
#
# If HDF5 is successfully found, this macro calls
#
# AC_SUBST(HDF5_VERSION)
# AC_SUBST(HDF5_CC)
# AC_SUBST(HDF5_CFLAGS)
# AC_SUBST(HDF5_CPPFLAGS)
# AC_SUBST(HDF5_LDFLAGS)
# AC_SUBST(HDF5_LIBS)
# AC_SUBST(HDF5_FC)
# AC_SUBST(HDF5_FFLAGS)
# AC_SUBST(HDF5_FLIBS)
# AC_DEFINE(HAVE_HDF5)
#
# and sets with_hdf5="yes". Additionally, the macro sets
# with_hdf5_fortran="yes" if a matching Fortran wrapper script is found.
# Note that Autconf's Fortran support is not used to perform this check.
# H5CC and H5FC will contain the appropriate serial or parallel HDF5
# wrapper script locations.
#
# If HDF5 is disabled or not found, this macros sets with_hdf5="no" and
# with_hdf5_fortran="no".
#
# Your configuration script can test $with_hdf to take any further
# actions. HDF5_{C,CPP,LD}FLAGS may be used when building with C or C++.
# HDF5_F{FLAGS,LIBS} should be used when building Fortran applications.
#
# To use the macro, one would code one of the following in "configure.ac"
# before AC_OUTPUT:
#
# 1) dnl Check for HDF5 support
# AX_LIB_HDF5()
#
# 2) dnl Check for serial HDF5 support
# AX_LIB_HDF5([serial])
#
# 3) dnl Check for parallel HDF5 support
# AX_LIB_HDF5([parallel])
#
# One could test $with_hdf5 for the outcome or display it as follows
#
# echo "HDF5 support: $with_hdf5"
#
# You could also for example, override the default CC in "configure.ac" to
# enforce compilation with the compiler that HDF5 uses:
#
# AX_LIB_HDF5([parallel])
# if test "$with_hdf5" = "yes"; then
# CC="$HDF5_CC"
# else
# AC_MSG_ERROR([Unable to find HDF5, we need parallel HDF5.])
# fi
#
# LICENSE
#
# Copyright (c) 2009 Timothy Brown <tbrown@freeshell.org>
# Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
AC_DEFUN([AX_LIB_HDF5], [
AC_REQUIRE([AC_PROG_SED])
AC_REQUIRE([AC_PROG_AWK])
AC_REQUIRE([AC_PROG_GREP])
dnl Check first argument is one of the recognized values.
dnl Fail eagerly if is incorrect as this simplifies case statements below.
if test "m4_normalize(m4_default([$1],[]))" = "" ; then
: # Recognized value
elif test "m4_normalize(m4_default([$1],[]))" = "serial" ; then
: # Recognized value
elif test "m4_normalize(m4_default([$1],[]))" = "parallel"; then
: # Recognized value
else
AC_MSG_ERROR([
Unrecognized value for AX[]_LIB_HDF5 within configure.ac.
If supplied, argument 1 must be either 'serial' or 'parallel'.
])
fi
dnl Add a default --with-hdf5 configuration option.
AC_ARG_WITH([hdf5],
AS_HELP_STRING(
[--with-hdf5=[yes/no/PATH]],
m4_case(m4_normalize([$1]),
[serial], [location of h5cc for serial HDF5 configuration],
[parallel], [location of h5pcc for parallel HDF5 configuration],
[location of h5cc or h5pcc for HDF5 configuration])
),
[if test "$withval" = "no"; then
with_hdf5="no"
elif test "$withval" = "yes"; then
with_hdf5="yes"
else
with_hdf5="yes"
H5CC="$withval"
fi],
[with_hdf5="yes"]
)
dnl Set defaults to blank
HDF5_CC=""
HDF5_VERSION=""
HDF5_CFLAGS=""
HDF5_CPPFLAGS=""
HDF5_LDFLAGS=""
HDF5_LIBS=""
HDF5_FC=""
HDF5_FFLAGS=""
HDF5_FLIBS=""
dnl Try and find hdf5 compiler tools and options.
if test "$with_hdf5" = "yes"; then
if test -z "$H5CC"; then
dnl Check to see if H5CC is in the path.
AC_PATH_PROGS(
[H5CC],
m4_case(m4_normalize([$1]),
[serial], [h5cc],
[parallel], [h5pcc],
[h5cc h5pcc]),
[])
else
AC_MSG_CHECKING([Using provided HDF5 C wrapper])
AC_MSG_RESULT([$H5CC])
fi
AC_MSG_CHECKING([for HDF5 libraries])
if test ! -f "$H5CC" || test ! -x "$H5CC"; then
AC_MSG_RESULT([no])
AC_MSG_WARN(m4_case(m4_normalize([$1]),
[serial], [
Unable to locate serial HDF5 compilation helper script 'h5cc'.
Please specify --with-hdf5=<LOCATION> as the full path to h5cc.
HDF5 support is being disabled (equivalent to --with-hdf5=no).
], [parallel],[
Unable to locate parallel HDF5 compilation helper script 'h5pcc'.
Please specify --with-hdf5=<LOCATION> as the full path to h5pcc.
HDF5 support is being disabled (equivalent to --with-hdf5=no).
], [
Unable to locate HDF5 compilation helper scripts 'h5cc' or 'h5pcc'.
Please specify --with-hdf5=<LOCATION> as the full path to h5cc or h5pcc.
HDF5 support is being disabled (equivalent to --with-hdf5=no).
]))
with_hdf5="no"
with_hdf5_fortran="no"
else
dnl Get the h5cc output
HDF5_SHOW=$(eval $H5CC -show)
dnl Get the actual compiler used
HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]1}')
if test "$HDF5_CC" = "ccache"; then
HDF5_CC=$(eval $H5CC -show | $AWK '{print $[]2}')
fi
dnl h5cc provides both AM_ and non-AM_ options
dnl depending on how it was compiled either one of
dnl these are empty. Lets roll them both into one.
dnl Look for "HDF5 Version: X.Y.Z"
HDF5_VERSION=$(eval $H5CC -showconfig | $GREP 'HDF5 Version:' \
| $AWK '{print $[]3}')
dnl A ideal situation would be where everything we needed was
dnl in the AM_* variables. However most systems are not like this
dnl and seem to have the values in the non-AM variables.
dnl
dnl We try the following to find the flags:
dnl (1) Look for "NAME:" tags
dnl (2) Look for "H5_NAME:" tags
dnl (3) Look for "AM_NAME:" tags
dnl
HDF5_tmp_flags=$(eval $H5CC -showconfig \
| $GREP 'FLAGS\|Extra libraries:' \
| $AWK -F: '{printf("%s "), $[]2}' )
dnl Find the installation directory and append include/
HDF5_tmp_inst=$(eval $H5CC -showconfig \
| $GREP 'Installation point:' \
| $AWK '{print $[]NF}' )
dnl Add this to the CPPFLAGS
HDF5_CPPFLAGS="-I${HDF5_tmp_inst}/include"
dnl Now sort the flags out based upon their prefixes
for arg in $HDF5_SHOW $HDF5_tmp_flags ; do
case "$arg" in
-I*) echo $HDF5_CPPFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \
|| HDF5_CPPFLAGS="$arg $HDF5_CPPFLAGS"
;;
-L*) echo $HDF5_LDFLAGS | $GREP -e "$arg" 2>&1 >/dev/null \
|| HDF5_LDFLAGS="$arg $HDF5_LDFLAGS"
;;
-l*) echo $HDF5_LIBS | $GREP -e "$arg" 2>&1 >/dev/null \
|| HDF5_LIBS="$arg $HDF5_LIBS"
;;
esac
done
HDF5_LIBS="$HDF5_LIBS -lhdf5"
AC_MSG_RESULT([yes (version $[HDF5_VERSION])])
dnl See if we can compile
ax_lib_hdf5_save_CC=$CC
ax_lib_hdf5_save_CPPFLAGS=$CPPFLAGS
ax_lib_hdf5_save_LIBS=$LIBS
ax_lib_hdf5_save_LDFLAGS=$LDFLAGS
CC=$HDF5_CC
CPPFLAGS=$HDF5_CPPFLAGS
LIBS=$HDF5_LIBS
LDFLAGS=$HDF5_LDFLAGS
AC_CHECK_HEADER([hdf5.h], [ac_cv_hadf5_h=yes], [ac_cv_hadf5_h=no])
AC_CHECK_LIB([hdf5], [H5Fcreate], [ac_cv_libhdf5=yes],
[ac_cv_libhdf5=no])
if test "$ac_cv_hadf5_h" = "no" && test "$ac_cv_libhdf5" = "no" ; then
AC_MSG_WARN([Unable to compile HDF5 test program])
fi
dnl Look for HDF5's high level library
AC_HAVE_LIBRARY([hdf5_hl], [HDF5_LIBS="$HDF5_LIBS -lhdf5_hl"], [], [])
CC=$ax_lib_hdf5_save_CC
CPPFLAGS=$ax_lib_hdf5_save_CPPFLAGS
LIBS=$ax_lib_hdf5_save_LIBS
LDFLAGS=$ax_lib_hdf5_save_LDFLAGS
AC_MSG_CHECKING([for matching HDF5 Fortran wrapper])
dnl Presume HDF5 Fortran wrapper is just a name variant from H5CC
H5FC=$(eval echo -n $H5CC | $SED -n 's/cc$/fc/p')
if test -x "$H5FC"; then
AC_MSG_RESULT([$H5FC])
with_hdf5_fortran="yes"
AC_SUBST([H5FC])
dnl Again, pry any remaining -Idir/-Ldir from compiler wrapper
for arg in `$H5FC -show`
do
case "$arg" in #(
-I*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \
|| HDF5_FFLAGS="$arg $HDF5_FFLAGS"
;;#(
-L*) echo $HDF5_FFLAGS | $GREP -e "$arg" >/dev/null \
|| HDF5_FFLAGS="$arg $HDF5_FFLAGS"
dnl HDF5 installs .mod files in with libraries,
dnl but some compilers need to find them with -I
echo $HDF5_FFLAGS | $GREP -e "-I${arg#-L}" >/dev/null \
|| HDF5_FFLAGS="-I${arg#-L} $HDF5_FFLAGS"
;;
esac
done
dnl Make Fortran link line by inserting Fortran libraries
for arg in $HDF5_LIBS
do
case "$arg" in #(
-lhdf5_hl) HDF5_FLIBS="$HDF5_FLIBS -lhdf5hl_fortran $arg"
;; #(
-lhdf5) HDF5_FLIBS="$HDF5_FLIBS -lhdf5_fortran $arg"
;; #(
*) HDF5_FLIBS="$HDF5_FLIBS $arg"
;;
esac
done
else
AC_MSG_RESULT([no])
with_hdf5_fortran="no"
fi
AC_SUBST([HDF5_VERSION])
AC_SUBST([HDF5_CC])
AC_SUBST([HDF5_CFLAGS])
AC_SUBST([HDF5_CPPFLAGS])
AC_SUBST([HDF5_LDFLAGS])
AC_SUBST([HDF5_LIBS])
AC_SUBST([HDF5_FC])
AC_SUBST([HDF5_FFLAGS])
AC_SUBST([HDF5_FLIBS])
AC_DEFINE([HAVE_HDF5], [1], [Defined if you have HDF5 support])
fi
fi
])

5
bootstrap.sh Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
rm -rf .buildutils
mkdir -p .buildutils/m4
autoreconf -fvi

24
build.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -e
PREFIX=`cat Makefile | grep '^prefix =' | awk '{print $3}'`
case $1 in
'')
echo '-- building...'
make -j8
echo '-- installing...'
make uninstall 1>/dev/null
make install 1>/dev/null;;
# if [[ `basename \`pwd\`` == "lib" ]]
# then
# echo '-- creating debug symbols...'
# dsymutil .libs/libLatAnalyze.0.dylib -o ${PREFIX}/lib/libLatAnalyze.0.dylib.dSYM
# fi;;
'clean')
echo '-- cleaning...'
make -j8 clean;;
*)
echo 'error: unknown action' 1>&2
exit 1;;
esac

View File

@ -1,16 +1,16 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if (($# != 2)); then if (( $# != 1 )); then
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2 echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1 exit 1
fi fi
prefix=$1 PREFIX=$1
ntasks=$2
set -ex set -ex
mkdir -p local/build mkdir -p local/build
for d in gsl nlopt minuit hdf5; do for d in nlopt minuit hdf5; do
if [ ! -e local/.built.${d} ]; then if [ ! -e local/.built.${d} ]; then
./install-${d}.sh "${prefix}" "${ntasks}" ./install-${d}.sh ${PREFIX}
fi fi
done done
./install-latcore.sh ${PREFIX}

View File

@ -1,27 +0,0 @@
#!/usr/bin/env bash
name='gsl-2.6'
if (($# != 2)); then
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2
exit 1
fi
prefix=$1
ntasks=$2
set -ex
init_dir=$(pwd -P)
mkdir -p "${prefix}"
cd "${prefix}"
prefix=$(pwd -P)
cd "${init_dir}/local/build"
wget http://ftpmirror.gnu.org/gsl/${name}.tar.gz
tar -xzvf ${name}.tar.gz
mkdir -p ${name}/build
cd ${name}/build
../configure --prefix="${prefix}"
make -j"${ntasks}"
make install
cd "${init_dir}/local"
touch .built.gsl
cd "${init_dir}"

View File

@ -1,27 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
name='hdf5-1.14.3' NAME='hdf5-1.8.16'
if (($# != 2)); then if (( $# != 1 )); then
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2 echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1 exit 1
fi fi
prefix=$1 PREFIX=$1
ntasks=$2
set -ex set -ex
init_dir=$(pwd -P) INITDIR=`pwd`
mkdir -p "${prefix}" cd local/build
cd "${prefix}" wget http://www.hdfgroup.org/ftp/HDF5/releases/${NAME}/src/${NAME}.tar.gz
prefix=$(pwd -P) tar -xzvf ${NAME}.tar.gz
cd "${init_dir}/local/build" mkdir ${NAME}/build
wget "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/${name}/src/${name}.tar.gz" cd ${NAME}/build
tar -xzvf ${name}.tar.gz ../configure --prefix=${PREFIX} --enable-cxx
mkdir ${name}/build make -j4
cd ${name}/build
../configure --prefix="${prefix}" --enable-cxx
make -j "${ntasks}"
make install make install
cd "${init_dir}/local" cd ${INITDIR}/local
touch .built.hdf5 touch .built.hdf5
cd "${init_dir}" cd ${INITDIR}

View File

@ -1,22 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if (($# != 2)); then if (( $# != 2 )); then
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2 echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1 exit 1
fi fi
prefix=$1 PREFIX=$1
ntasks=$2 OS=$2
set -ex set -ex
init_dir=$(pwd -P) ./install-deps.sh ${PREFIX}
mkdir -p "${prefix}" cd ..
cd "${prefix}" ./bootstrap.sh
prefix=$(pwd -P) mkdir -p build
cd "${init_dir}" cd build
./install-deps.sh "${prefix}" "${ntasks}" if [[ "$OS" == "osx" ]]; then EXTRA_FLAGS='--with-gsl=/usr/local'; fi
mkdir -p "${init_dir}/local/build/latan" ../configure --prefix=$PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS CXXFLAGS='-O3 -march=native -mtune=native'
cd "${init_dir}/local/build/latan" make -j4
cmake -DCMAKE_INSTALL_PREFIX="${prefix}" -DCMAKE_PREFIX_PATH="${prefix}" \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" "${init_dir}/.."
make -j "${ntasks}"
make install make install

25
ci-scripts/install-latcore.sh Executable file
View File

@ -0,0 +1,25 @@
#!/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

@ -1,26 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if (($# != 2)); then NAME='Minuit2-5.34.14'
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2
if (( $# != 1 )); then
echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1 exit 1
fi fi
prefix=$1 PREFIX=$1
ntasks=$2
set -ex set -ex
init_dir=$(pwd -P) INITDIR=`pwd`
mkdir -p "${prefix}" cd local/build
cd "${prefix}" wget http://www.cern.ch/mathlibs/sw/5_34_14/Minuit2/${NAME}.tar.gz
prefix=$(pwd -P) tar -xzvf ${NAME}.tar.gz
cd "${init_dir}/local/build" mkdir -p ${NAME}/build
rm -rf root cd ${NAME}/build
git clone https://github.com/root-project/root.git ../configure --prefix=${PREFIX} --disable-openmp
cd root/math/minuit2/ make -j4
mkdir build
cd build
cmake .. -Dminuit2_standalone=ON -DCMAKE_INSTALL_PREFIX="${prefix}"
make -j "${ntasks}"
make install make install
cd "${init_dir}/local" cd ${INITDIR}/local
touch .built.minuit touch .built.minuit
cd "${init_dir}" cd ${INITDIR}

View File

@ -1,30 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
name='2.6.1' NAME='nlopt-2.4.2'
if (($# != 2)); then if (( $# != 1 )); then
echo "usage: $(basename "$0") <prefix> <ntasks>" 1>&2 echo "usage: `basename $0` <prefix> {osx|linux}" 1>&2
exit 1 exit 1
fi fi
prefix=$1 PREFIX=$1
ntasks=$2
set -ex set -ex
init_dir=$(pwd -P) INITDIR=`pwd`
mkdir -p "${prefix}" cd local/build
cd "${prefix}" wget http://ab-initio.mit.edu/nlopt/${NAME}.tar.gz
prefix=$(pwd -P) tar -xzvf ${NAME}.tar.gz
cd "${init_dir}/local/build" mkdir -p ${NAME}/build
wget "https://github.com/stevengj/nlopt/archive/v${name}.tar.gz" cd ${NAME}/build
tar -xzvf v${name}.tar.gz ../configure --prefix=${PREFIX} --with-cxx --without-guile --without-python --without-octave --without-matlab --with-pic
name=nlopt-${name} make -j4
mkdir -p ${name}/build
cd ${name}/build
cmake -DCMAKE_INSTALL_PREFIX="${prefix}" -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=TRUE \
-DCMAKE_INSTALL_NAME_DIR="${prefix}/lib" -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF \
-DNLOPT_MATLAB=OFF -DNLOPT_GUILE=OFF -DNLOPT_SWIG=OFF ..
make -j "${ntasks}"
make install make install
cd "${init_dir}/local" cd ${INITDIR}/local
touch .built.nlopt touch .built.nlopt
cd "${init_dir}" cd ${INITDIR}

151
configure.ac Normal file
View File

@ -0,0 +1,151 @@
# Process this file with autoconf to produce a configure script.
# Initialization
AC_PREREQ([2.63])
AC_INIT([LatAnalyze],[3.2.1-dev],[antonin.portelli@me.com],[LatAnalyze])
AC_CONFIG_AUX_DIR([.buildutils])
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_SILENT_RULES([yes])
AC_CONFIG_HEADERS([config.h])
AM_CONDITIONAL([HAVE_AM_MINOR_LE_11],
[test `automake --version | grep automake | awk -F '.' '{print $2}'` -le 11])
# Checks for programs
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LEX
AC_PROG_YACC
m4_ifdef([AM_PROG_AR],[AM_PROG_AR])
LT_INIT
# Options
AC_ARG_WITH([gsl],
[AS_HELP_STRING([--with-gsl=prefix],
[try this for a non-standard install prefix of the GSL library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_gsl/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_gsl/lib"])
AC_ARG_WITH([minuit],
[AS_HELP_STRING([--with-minuit=prefix],
[try this for a non-standard install prefix of the Minuit2 library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_minuit/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_minuit/lib"])
AC_ARG_WITH([nlopt],
[AS_HELP_STRING([--with-nlopt=prefix],
[try this for a non-standard install prefix of the NLopt library])],
[AM_CXXFLAGS="$AM_CXXFLAGS -I$with_nlopt/include"]
[AM_LDFLAGS="$AM_LDFLAGS -L$with_nlopt/lib"])
AC_ARG_WITH([hdf5],
[AS_HELP_STRING([--with-hdf5=prefix],
[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"])
CFLAGS="$AM_CFLAGS $CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
# Get compilers informations
AX_COMPILER_VENDOR
AC_DEFINE_UNQUOTED([C_COMP_VENDOR],["$ax_cv_c_compiler_vendor"],
[vendor of C compiler that will compile the code])
AM_CONDITIONAL([CC_GNU],[test $ax_cv_c_compiler_vendor = "gnu"])
AM_CONDITIONAL([CC_INTEL],[test $ax_cv_c_compiler_vendor = "intel"])
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11([noext],[mandatory])
AX_COMPILER_VENDOR
AC_DEFINE_UNQUOTED([CXX_COMP_VENDOR],["$ax_cv_cxx_compiler_vendor"],
[vendor of C++ compiler that will compile the code])
AM_CONDITIONAL([CXX_GNU],[test $ax_cv_cxx_compiler_vendor = "gnu"])
AM_CONDITIONAL([CXX_INTEL],[test $ax_cv_cxx_compiler_vendor = "intel"])
AX_GCC_VERSION
AC_DEFINE_UNQUOTED([GCC_VERSION],["$GCC_VERSION"],
[version of gcc that will compile the code])
AX_GXX_VERSION
AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"],
[version of g++ that will compile the code])
# Checks for libraries.
AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([libm library not found])])
AC_CHECK_LIB([gslcblas],[cblas_dgemm],[],
[AC_MSG_ERROR([GSL CBLAS library not found])])
AC_CHECK_LIB([gsl],[gsl_blas_dgemm],[],[AC_MSG_ERROR([GSL library not found])])
AC_CHECK_LIB([nlopt_cxx],[nlopt_create],
[AC_DEFINE([HAVE_NLOPT],
[1],
[Define to 1 if you have the `NLopt' library (-lnlopt_cxx).])]
[have_nlopt=true]
[LIBS="$LIBS -lnlopt_cxx"],[])
AM_CONDITIONAL([HAVE_NLOPT], [test x$have_nlopt = xtrue])
AC_CHECK_LIB([hdf5_cpp],[H5Fopen],
[AC_DEFINE([HAVE_HDF5],
[1],
[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
LDFLAGS="$LDFLAGS -lMinuit2"
AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]);
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <Minuit2/BasicMinimumError.h>],
[ROOT::Minuit2::BasicMinimumError dummy(0)])],
[LIBS="$LIBS -lMinuit2"]
[AC_DEFINE([HAVE_MINUIT2],
[1],
[Define to 1 if you have the `Minuit2' library (-lMinuit2).])]
[have_minuit=true]
[AC_MSG_RESULT([yes])],
[have_minuit=false]
[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
# Checks for header files.
AC_HEADER_STDC
AC_SUBST([LIBS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_CONFIG_FILES([Makefile lib/Makefile utils/Makefile physics/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

@ -1,21 +0,0 @@
set(EXAMPLES_STEM
exCompiledDoubleFunction
exDerivative
exDWT
exFit
exFitSample
exIntegrator
exInterp
exMat
exMathInterpreter
exMin
exPlot
exPValue
exRand
exRootFinder
exThreadPool)
foreach(_stem ${EXAMPLES_STEM})
add_executable(${_stem} ${_stem}.cpp)
target_link_libraries(${_stem} LatAnalyze compiler_flags)
endforeach()

1
examples/LatAnalyze Symbolic link
View File

@ -0,0 +1 @@
../lib

71
examples/Makefile.am Normal file
View File

@ -0,0 +1,71 @@
if CXX_GNU
COM_CXXFLAGS = -Wall -W -pedantic -Wno-deprecated-declarations
else
if CXX_INTEL
COM_CXXFLAGS = -wd1682 -Wall
endif
endif
noinst_PROGRAMS = \
exCompiledDoubleFunction\
exDerivative \
exFit \
exFitSample \
exIntegrator \
exInterp \
exMat \
exMathInterpreter \
exMin \
exPlot \
exRand \
exRootFinder
exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp
exCompiledDoubleFunction_CXXFLAGS = $(COM_CXXFLAGS)
exCompiledDoubleFunction_LDFLAGS = -L../lib/.libs -lLatAnalyze
exDerivative_SOURCES = exDerivative.cpp
exDerivative_CXXFLAGS = $(COM_CXXFLAGS)
exDerivative_LDFLAGS = -L../lib/.libs -lLatAnalyze
exFit_SOURCES = exFit.cpp
exFit_CXXFLAGS = $(COM_CXXFLAGS)
exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze
exFitSample_SOURCES = exFitSample.cpp
exFitSample_CXXFLAGS = $(COM_CXXFLAGS)
exFitSample_LDFLAGS = -L../lib/.libs -lLatAnalyze
exInterp_SOURCES = exInterp.cpp
exInterp_CXXFLAGS = $(COM_CXXFLAGS)
exInterp_LDFLAGS = -L../lib/.libs -lLatAnalyze
exIntegrator_SOURCES = exIntegrator.cpp
exIntegrator_CXXFLAGS = $(COM_CXXFLAGS)
exIntegrator_LDFLAGS = -L../lib/.libs -lLatAnalyze
exMat_SOURCES = exMat.cpp
exMat_CXXFLAGS = $(COM_CXXFLAGS)
exMat_LDFLAGS = -L../lib/.libs -lLatAnalyze
exMin_SOURCES = exMin.cpp
exMin_CXXFLAGS = $(COM_CXXFLAGS)
exMin_LDFLAGS = -L../lib/.libs -lLatAnalyze
exMathInterpreter_SOURCES = exMathInterpreter.cpp
exMathInterpreter_CXXFLAGS = $(COM_CXXFLAGS)
exMathInterpreter_LDFLAGS = -L../lib/.libs -lLatAnalyze
exPlot_SOURCES = exPlot.cpp
exPlot_CXXFLAGS = $(COM_CXXFLAGS)
exPlot_LDFLAGS = -L../lib/.libs -lLatAnalyze
exRand_SOURCES = exRand.cpp
exRand_CXXFLAGS = $(COM_CXXFLAGS)
exRand_LDFLAGS = -L../lib/.libs -lLatAnalyze
exRootFinder_SOURCES = exRootFinder.cpp
exRootFinder_CXXFLAGS = $(COM_CXXFLAGS)
exRootFinder_LDFLAGS = -L../lib/.libs -lLatAnalyze
ACLOCAL_AMFLAGS = -I .buildutils/m4

View File

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

View File

@ -1,28 +0,0 @@
#include <LatAnalyze/Numerical/DWT.hpp>
using namespace std;
using namespace Latan;
int main(void)
{
DVec data, dataRec;
vector<DWT::DWTLevel> dataDWT;
DWT dwt(DWTFilters::db3);
cout << "-- random data" << endl;
data.setRandom(16);
cout << data.transpose() << endl;
cout << "-- compute Daubechies 3 DWT" << endl;
dataDWT = dwt.forward(data, 4);
for (unsigned int l = 0; l < dataDWT.size(); ++l)
{
cout << "* level " << l << endl;
cout << "L= " << dataDWT[l].first.transpose() << endl;
cout << "H= " << dataDWT[l].second.transpose() << endl;
}
cout << "-- check inverse DWT" << endl;
dataRec = dwt.backward(dataDWT);
cout << "rel diff = " << 2.*(data - dataRec).norm()/(data + dataRec).norm() << endl;
return EXIT_SUCCESS;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +0,0 @@
#include <LatAnalyze/Core/Math.hpp>
using namespace std;
using namespace Latan;
int main(int argc, char* argv[])
{
double chi2, ndof;
if (argc != 3)
{
cerr << "usage: " << argv[0] << " <chi^2> <ndof>" << endl;
return EXIT_FAILURE;
}
chi2 = strTo<double>(argv[1]);
ndof = strTo<double>(argv[2]);
cout << "Two-sided p-value: " << Math::chi2PValue(chi2, ndof) << endl;
cout << "chi^2 CCDF : " << Math::chi2Ccdf(chi2, ndof) << endl;
return EXIT_SUCCESS;
}

View File

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

View File

@ -1,15 +1,11 @@
#include <LatAnalyze/Io/Io.hpp> #include <LatAnalyze/Io.hpp>
#include <LatAnalyze/Functional/CompiledFunction.hpp> #include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Core/Plot.hpp> #include <LatAnalyze/Plot.hpp>
#include <LatAnalyze/Statistics/Random.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
constexpr Index n = 8;
constexpr Index nDraw = 20000; constexpr Index nDraw = 20000;
constexpr Index nSample = 2000;
const string stateFileName = "exRand.seed"; const string stateFileName = "exRand.seed";
int main(void) int main(void)
@ -40,24 +36,5 @@ int main(void)
p << PlotFunction(compile("return exp(-x_0^2/2)/sqrt(2*pi);", 1), -5., 5.); p << PlotFunction(compile("return exp(-x_0^2/2)/sqrt(2*pi);", 1), -5., 5.);
p.display(); p.display();
DMat var(n, n);
DVec mean(n);
DMatSample sample(nSample, n, 1);
cout << "-- generating " << nSample << " Gaussian random vectors..." << endl;
var = DMat::Random(n, n);
var *= var.adjoint();
mean = DVec::Random(n);
RandomNormal mgauss(mean, var, rd());
sample[central] = mgauss();
FOR_STAT_ARRAY(sample, s)
{
sample[s] = mgauss();
}
cout << "* original variance matrix:\n" << var << endl;
cout << "* measured variance matrix:\n" << sample.varianceMatrix() << endl;
cout << "* original mean:\n" << mean << endl;
cout << "* measured mean:\n" << sample.mean() << endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -1,5 +1,5 @@
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Numerical/GslHybridRootFinder.hpp> #include <LatAnalyze/GslHybridRootFinder.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
@ -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([](const double *x){return a*(1.-x[0]);}, 2); DoubleFunction f1([a](const double *x){return a*(1.-x[0]);}, 2);
DoubleFunction f2([](const double *x){return b*(x[1]-x[0]*x[0]);}, 2); DoubleFunction f2([b](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;

View File

@ -1,29 +0,0 @@
#include <LatAnalyze/Core/ThreadPool.hpp>
using namespace std;
using namespace Latan;
int main(void)
{
ThreadPool pool;
cout << "Using " << pool.getThreadNum() << " threads" << endl;
for (unsigned int i = 1; i <= 20; ++i)
{
pool.addJob([i, &pool](void)
{
pool.critical([i](void)
{
cout << "job " << i << " wait for " << i*100 << " ms" << endl;
});
this_thread::sleep_for(chrono::milliseconds(i*100));
pool.critical([i](void)
{
cout << "job " << i << " done" << endl;
});
});
}
pool.terminate();
return EXIT_SUCCESS;
}

View File

@ -1,7 +1,7 @@
/* /*
* AsciiFile.cpp, part of LatAnalyze 3 * AsciiFile.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Io/AsciiFile.hpp> #include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* AsciiFile.hpp, part of LatAnalyze 3 * AsciiFile.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,10 +21,10 @@
#define Latan_AsciiFile_hpp_ #define Latan_AsciiFile_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/File.hpp> #include <LatAnalyze/File.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp> #include <LatAnalyze/MatSample.hpp>
#include <LatAnalyze/Core/ParserState.hpp> #include <LatAnalyze/ParserState.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* AsciiLexer.lpp, part of LatAnalyze 3 * AsciiLexer.lpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
%option yylineno %option yylineno
%{ %{
#include <LatAnalyze/Io/AsciiFile.hpp> #include <LatAnalyze/AsciiFile.hpp>
#include "AsciiParser.hpp" #include "AsciiParser.hpp"
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* AsciiParser.ypp, part of LatAnalyze 3 * AsciiParser.ypp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,9 +19,9 @@
%{ %{
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp> #include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp> #include <LatAnalyze/MatSample.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;

View File

@ -1,101 +0,0 @@
# config.h header for package version and name
execute_process(
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE LATAN_SHORT_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE LATAN_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE LATAN_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
# find bison & flex
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
# ASCII parser
bison_target(
AsciiParser LatAnalyze/Io/AsciiParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/AsciiParser.cpp COMPILE_FLAGS "-Wno-deprecated")
flex_target(AsciiLexer LatAnalyze/Io/AsciiLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/AsciiLexer.cpp)
add_flex_bison_dependency(AsciiLexer AsciiParser)
# math parser
bison_target(
MathParser LatAnalyze/Core/MathParser.ypp
${CMAKE_CURRENT_BINARY_DIR}/MathParser.cpp COMPILE_FLAGS "-Wno-deprecated")
flex_target(MathLexer LatAnalyze/Core/MathLexer.lpp
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
add_flex_bison_dependency(MathLexer MathParser)
# intermediate libraries
add_library(parsers STATIC)
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(
parsers PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS})
add_library(tinyxml2 STATIC)
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_sources(tinyxml2 PRIVATE LatAnalyze/Io/Xml/tinyxml2.hpp
LatAnalyze/Io/Xml/tinyxml2.cpp)
# library target
add_library(LatAnalyze SHARED)
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
target_include_directories(LatAnalyze PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
include(source-list.cmake)
target_sources(
LatAnalyze
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
PUBLIC FILE_SET
public_headers
TYPE
HEADERS
FILES
${EIGEN_HEADERS}
${LATAN_HEADERS})
target_link_libraries(LatAnalyze PRIVATE compiler_flags parsers tinyxml2)
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp
${CMAKE_THREAD_LIBS_INIT})
if(Minuit2_FOUND)
target_link_libraries(LatAnalyze PUBLIC Minuit2::Minuit2)
endif()
if(NLopt_FOUND)
target_link_libraries(LatAnalyze PUBLIC NLopt::nlopt)
endif()
set_target_properties(LatAnalyze PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(
LatAnalyze PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# installation
install(
TARGETS LatAnalyze
EXPORT LatAnalyzeTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FILE_SET public_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
EXPORT LatAnalyzeTargets
FILE LatAnalyzeTargets.cmake
NAMESPACE LatAnalyze::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LatAnalyzeConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LatAnalyze)

View File

@ -1,7 +1,7 @@
/* /*
* CompiledFunction.cpp, part of LatAnalyze 3 * CompiledFunction.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Functional/CompiledFunction.hpp> #include <LatAnalyze/CompiledFunction.hpp>
#include <LatAnalyze/Core/Math.hpp> #include <LatAnalyze/Math.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* CompiledFunction.hpp, part of LatAnalyze 3 * CompiledFunction.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#define Latan_CompiledFunction_hpp_ #define Latan_CompiledFunction_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp> #include <LatAnalyze/MathInterpreter.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* CompiledModel.cpp, part of LatAnalyze 3 * CompiledModel.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Functional/CompiledModel.hpp> #include <LatAnalyze/CompiledModel.hpp>
#include <LatAnalyze/Core/Math.hpp> #include <LatAnalyze/Math.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* CompiledModel.hpp, part of LatAnalyze 3 * CompiledModel.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#define Latan_CompiledModel_hpp_ #define Latan_CompiledModel_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Model.hpp> #include <LatAnalyze/Model.hpp>
#include <LatAnalyze/Core/MathInterpreter.hpp> #include <LatAnalyze/MathInterpreter.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,28 +0,0 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(GSL REQUIRED)
find_dependency(HDF5 REQUIRED COMPONENTS C CXX)
set(HAVE_Minuit2 @Minuit2_FOUND@)
set(HAVE_NLopt @NLopt_FOUND@)
if(HAVE_Minuit2)
find_dependency(Minuit2 REQUIRED)
list(APPEND _LatAnalyze_supported_components MINUIT2)
set(LatAnalyze_MINUIT2_FOUND True)
endif()
if(HAVE_NLopt)
find_dependency(NLopt REQUIRED)
list(APPEND _LatAnalyze_supported_components NLOPT)
set(LatAnalyze_NLOPT_FOUND True)
endif()
foreach(_comp ${LatAnalyze_FIND_COMPONENTS})
if (NOT ";${_LatAnalyze_supported_components};" MATCHES ";${_comp};")
set(LatAnalyze_FOUND False)
set(LatAnalyze_NOT_FOUND_MESSAGE "Unsupported LatAnalyze component: ${_comp}")
endif()
endforeach()
include("${CMAKE_CURRENT_LIST_DIR}/LatAnalyzeTargets.cmake")
check_required_components(LatAnalyze)

View File

@ -1,7 +1,7 @@
/* /*
* Dataset.hpp, part of LatAnalyze 3 * Dataset.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#define Latan_Dataset_hpp_ #define Latan_Dataset_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/File.hpp> #include <LatAnalyze/File.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp> #include <LatAnalyze/StatArray.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE
@ -47,8 +47,6 @@ 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);
@ -116,23 +114,6 @@ 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)
{ {

View File

@ -1,7 +1,7 @@
/* /*
* Derivative.cpp, part of LatAnalyze 3 * Derivative.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,9 +17,9 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Numerical/Derivative.hpp> #include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Core/Math.hpp> #include <LatAnalyze/Math.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;

View File

@ -1,7 +1,7 @@
/* /*
* Derivative.hpp, part of LatAnalyze 3 * Derivative.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_Derivative_hpp_ #define Latan_Derivative_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Exceptions.cpp, part of LatAnalyze 3 * Exceptions.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Core/Exceptions.hpp> #include <LatAnalyze/Exceptions.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#ifndef ERR_SUFF #ifndef ERR_SUFF

View File

@ -1,7 +1,7 @@
/* /*
* Exceptions.hpp, part of LatAnalyze 3 * Exceptions.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
/* /*
* File.cpp, part of LatAnalyze 3 * File.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Io/File.hpp> #include <LatAnalyze/File.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* File.hpp, part of LatAnalyze 3 * File.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
#define Latan_File_hpp_ #define Latan_File_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/IoObject.hpp> #include <LatAnalyze/IoObject.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp> #include <LatAnalyze/MatSample.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE
@ -105,12 +105,12 @@ const IoT& File::getData(const std::string &name) const
{ {
return dynamic_cast<const IoT &>(*(data_.at(name))); return dynamic_cast<const IoT &>(*(data_.at(name)));
} }
catch (std::out_of_range &) catch(std::out_of_range)
{ {
LATAN_ERROR(Definition, "no data with name '" + name + "' in file " LATAN_ERROR(Definition, "no data with name '" + name + "' in file "
+ name_); + name_);
} }
catch (std::bad_cast &) catch(std::bad_cast)
{ {
LATAN_ERROR(Definition, "data with name '" + name + "' in file " LATAN_ERROR(Definition, "data with name '" + name + "' in file "
+ name_ + " does not have type '" + typeid(IoT).name() + name_ + " does not have type '" + typeid(IoT).name()

View File

@ -1,7 +1,7 @@
/* /*
* FitInterface.cpp, part of LatAnalyze 3 * FitInterface.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Statistics/FitInterface.hpp> #include <LatAnalyze/FitInterface.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;
@ -200,7 +200,6 @@ 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)

View File

@ -1,7 +1,7 @@
/* /*
* FitInterface.hpp, part of LatAnalyze 3 * FitInterface.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_FitInterface_hpp_ #define Latan_FitInterface_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Function.cpp, part of LatAnalyze 3 * Function.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;
@ -111,20 +111,6 @@ double DoubleFunction::operator()(void) const
return (*this)(nullptr); return (*this)(nullptr);
} }
std::map<double, double> DoubleFunction::operator()(const std::map<double, double> &m) const
{
checkSize(1);
std::map<double, double> res;
for (auto &val: m)
{
res[val.first] = (*this)(val.second);
}
return res;
}
// bind //////////////////////////////////////////////////////////////////////// // bind ////////////////////////////////////////////////////////////////////////
DoubleFunction DoubleFunction::bind(const Index argIndex, DoubleFunction DoubleFunction::bind(const Index argIndex,
const double val) const const double val) const
@ -179,26 +165,6 @@ DoubleFunction DoubleFunction::bind(const Index argIndex,
return bindFunc; return bindFunc;
} }
// sample //////////////////////////////////////////////////////////////////////
DVec DoubleFunction::sample(const DMat &x) const
{
if (x.cols() != getNArg())
{
LATAN_ERROR(Size, "sampling point matrix and number of arguments "
"mismatch (matrix has " + strFrom(x.cols())
+ ", number of arguments is " + strFrom(getNArg()) + ")");
}
DVec res(x.rows());
for (Index i = 0; i < res.size(); ++i)
{
res(i) = (*this)(x.row(i));
}
return res;
}
// arithmetic operators //////////////////////////////////////////////////////// // arithmetic operators ////////////////////////////////////////////////////////
DoubleFunction DoubleFunction::operator-(void) const DoubleFunction DoubleFunction::operator-(void) const
{ {

View File

@ -1,7 +1,7 @@
/* /*
* Function.hpp, part of LatAnalyze 3 * Function.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#define Latan_Function_hpp_ #define Latan_Function_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp> #include <LatAnalyze/MatSample.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE
@ -52,12 +52,9 @@ public:
double operator()(void) const; double operator()(void) const;
template <typename... Ts> template <typename... Ts>
double operator()(const double arg0, const Ts... args) const; double operator()(const double arg0, const Ts... args) const;
std::map<double, double> operator()(const std::map<double, double> &m) const;
// bind // bind
DoubleFunction bind(const Index argIndex, const double val) const; DoubleFunction bind(const Index argIndex, const double val) const;
DoubleFunction bind(const Index argIndex, const DVec &x) const; DoubleFunction bind(const Index argIndex, const DVec &x) const;
// sample
DVec sample(const DMat &x) const;
// arithmetic operators // arithmetic operators
DoubleFunction operator-(void) const; DoubleFunction operator-(void) const;
DoubleFunction & operator+=(const DoubleFunction &f); DoubleFunction & operator+=(const DoubleFunction &f);

View File

@ -1,7 +1,7 @@
/* /*
* Global.cpp, part of LatAnalyze 3 * Global.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -25,13 +25,11 @@ using namespace Latan;
PlaceHolder Latan::_; PlaceHolder Latan::_;
const string Env::fullName = strFrom(PROJECT_NAME) + " " + strFrom(LATAN_SHORT_SHA) + " (v" + strFrom(PROJECT_VERSION) + ")"; const string Env::fullName = PACKAGE_STRING;
const string Env::name = PROJECT_NAME; const string Env::name = PACKAGE_NAME;
const string Env::version = PROJECT_VERSION; const string Env::version = PACKAGE_VERSION;
const string Env::gitShortSha = LATAN_SHORT_SHA; const string Env::msgPrefix = "[" + strFrom(PACKAGE_NAME) + " v"
const string Env::gitSha = LATAN_SHA; + strFrom(PACKAGE_VERSION) + "] ";
const string Env::gitBranch = LATAN_BRANCH;
const string Env::msgPrefix = "[" + Env::fullName + "] ";
void Env::function(void) void Env::function(void)
{} {}

View File

@ -1,7 +1,7 @@
/* /*
* Global.hpp, part of LatAnalyze 3 * Global.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,27 +20,13 @@
#ifndef Latan_Global_hpp_ #ifndef Latan_Global_hpp_
#define Latan_Global_hpp_ #define Latan_Global_hpp_
#include <LatAnalyze/Core/stdincludes.hpp> #include <LatCore/LatCore.hpp>
#define BEGIN_LATAN_NAMESPACE \ #define BEGIN_LATAN_NAMESPACE \
namespace Latan { namespace Latan {\
using namespace LatCore;
#define END_LATAN_NAMESPACE } #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 BEGIN_LATAN_NAMESPACE
// Placeholder type //////////////////////////////////////////////////////////// // Placeholder type ////////////////////////////////////////////////////////////
@ -54,9 +40,6 @@ namespace Env
extern const std::string fullName; extern const std::string fullName;
extern const std::string name; extern const std::string name;
extern const std::string version; extern const std::string version;
extern const std::string gitShortSha;
extern const std::string gitSha;
extern const std::string gitBranch;
extern const std::string msgPrefix; extern const std::string msgPrefix;
// empty function for library test // empty function for library test
void function(void); void function(void);
@ -64,8 +47,6 @@ namespace Env
END_LATAN_NAMESPACE END_LATAN_NAMESPACE
#include <LatAnalyze/Core/Eigen.hpp> #include <LatAnalyze/Exceptions.hpp>
#include <LatAnalyze/Core/Exceptions.hpp>
#include <LatAnalyze/Core/Utilities.hpp>
#endif // Latan_Global_hpp_ #endif // Latan_Global_hpp_

View File

@ -1,7 +1,7 @@
/* /*
* GslHybridRootFinder.cpp, part of LatAnalyze 3 * GslHybridRootFinder.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Numerical/GslHybridRootFinder.hpp> #include <LatAnalyze/GslHybridRootFinder.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <gsl/gsl_vector.h> #include <gsl/gsl_vector.h>
#include <gsl/gsl_multiroots.h> #include <gsl/gsl_multiroots.h>

View File

@ -1,7 +1,7 @@
/* /*
* GslHybridRootFinder.hpp, part of LatAnalyze 3 * GslHybridRootFinder.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_GslHybridRootFinder_hpp_ #define Latan_GslHybridRootFinder_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Numerical/RootFinder.hpp> #include <LatAnalyze/RootFinder.hpp>
#include <gsl/gsl_multiroots.h> #include <gsl/gsl_multiroots.h>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* GslMinimizer.cpp, part of LatAnalyze * GslMinimizer.cpp, part of LatAnalyze
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze is free software: you can redistribute it and/or modify * LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,9 +17,9 @@
* along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Numerical/GslMinimizer.hpp> #include <LatAnalyze/GslMinimizer.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Core/Math.hpp> #include <LatAnalyze/Math.hpp>
#include <gsl/gsl_multimin.h> #include <gsl/gsl_multimin.h>
#include <gsl/gsl_blas.h> #include <gsl/gsl_blas.h>

View File

@ -1,7 +1,7 @@
/* /*
* GslMinimizer.hpp, part of LatAnalyze * GslMinimizer.hpp, part of LatAnalyze
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze is free software: you can redistribute it and/or modify * LatAnalyze is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
#define Latan_GslMinimizer_hpp_ #define Latan_GslMinimizer_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Numerical/Derivative.hpp> #include <LatAnalyze/Derivative.hpp>
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp> #include <LatAnalyze/Minimizer.hpp>
#include <gsl/gsl_vector.h> #include <gsl/gsl_vector.h>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* GslQagsIntegrator.cpp, part of LatAnalyze 3 * GslQagsIntegrator.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,9 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Numerical/GslQagsIntegrator.hpp> #include <LatAnalyze/GslQagsIntegrator.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Core/Math.hpp>
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
@ -56,26 +55,9 @@ 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_,
gsl_integration_qags(&gslF, xMin, xMax, 0.0, precision_, limit_, &result, &error_);
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;
} }

View File

@ -1,7 +1,7 @@
/* /*
* GslQagsIntegrator.hpp, part of LatAnalyze 3 * GslQagsIntegrator.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +21,8 @@
#define Latan_GslQagsIntegrator_hpp_ #define Latan_GslQagsIntegrator_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
#include <LatAnalyze/Numerical/Integrator.hpp> #include <LatAnalyze/Integrator.hpp>
#include <gsl/gsl_integration.h> #include <gsl/gsl_integration.h>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Hdf5File.cpp, part of LatAnalyze 3 * Hdf5File.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli, Matt Spraggs * Copyright (C) 2013 - 2016 Antonin Portelli, Matt Spraggs
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,8 +17,8 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Io/Hdf5File.hpp> #include <LatAnalyze/Hdf5File.hpp>
#include <LatAnalyze/Io/IoObject.hpp> #include <LatAnalyze/IoObject.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
using namespace std; using namespace std;

View File

@ -1,7 +1,7 @@
/* /*
* Hdf5File.hpp, part of LatAnalyze 3 * Hdf5File.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli, Matt Spraggs * Copyright (C) 2013 - 2016 Antonin Portelli, Matt Spraggs
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,9 +21,9 @@
#define Latan_Hdf5File_hpp_ #define Latan_Hdf5File_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/File.hpp> #include <LatAnalyze/File.hpp>
#include <LatAnalyze/Core/Mat.hpp> #include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Statistics/MatSample.hpp> #include <LatAnalyze/MatSample.hpp>
#include <H5Cpp.h> #include <H5Cpp.h>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Histogram.cpp, part of LatAnalyze 3 * Histogram.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Statistics/Histogram.hpp> #include <LatAnalyze/Histogram.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <gsl/gsl_histogram.h> #include <gsl/gsl_histogram.h>
#include <gsl/gsl_sf.h> #include <gsl/gsl_sf.h>

View File

@ -1,7 +1,7 @@
/* /*
* Histogram.hpp, part of LatAnalyze 3 * Histogram.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_Histogram_hpp_ #define Latan_Histogram_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Statistics/StatArray.hpp> #include <LatAnalyze/StatArray.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Integrator.hpp, part of LatAnalyze 3 * Integrator.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_Integrator_hpp_ #define Latan_Integrator_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Function.hpp> #include <LatAnalyze/Function.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* Io.cpp, part of LatAnalyze 3 * Io.cpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,10 +17,12 @@
* along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>. * along with LatAnalyze 3. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <LatAnalyze/Io/Io.hpp> #include <LatAnalyze/Io.hpp>
#include <LatAnalyze/includes.hpp> #include <LatAnalyze/includes.hpp>
#include <LatAnalyze/Io/AsciiFile.hpp> #include <LatAnalyze/AsciiFile.hpp>
#include <LatAnalyze/Io/Hdf5File.hpp> #ifdef HAVE_HDF5
#include <LatAnalyze/Hdf5File.hpp>
#endif
using namespace std; using namespace std;
using namespace Latan; using namespace Latan;
@ -40,10 +42,12 @@ 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 + "'");

View File

@ -1,7 +1,7 @@
/* /*
* Io.hpp, part of LatAnalyze 3 * Io.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,7 @@
#define Latan_Io_hpp_ #define Latan_Io_hpp_
#include <LatAnalyze/Global.hpp> #include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Io/File.hpp> #include <LatAnalyze/File.hpp>
BEGIN_LATAN_NAMESPACE BEGIN_LATAN_NAMESPACE

View File

@ -1,7 +1,7 @@
/* /*
* IoObject.hpp, part of LatAnalyze 3 * IoObject.hpp, part of LatAnalyze 3
* *
* Copyright (C) 2013 - 2020 Antonin Portelli * Copyright (C) 2013 - 2016 Antonin Portelli
* *
* LatAnalyze 3 is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

1
lib/LatAnalyze Symbolic link
View File

@ -0,0 +1 @@
.

View File

@ -1,123 +0,0 @@
/*
* Eigen.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2020 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

View File

@ -1,60 +0,0 @@
/*
* 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) const
{
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) const
{
auto svd = jacobiSvd();
return svd.singularValues();
}

View File

@ -1,299 +0,0 @@
/*
* 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;
auto it = std::find_if(opt_.begin(), opt_.end(), [&par](const OptPar & p)
{
bool match = false;
match |= (par.shortName == p.shortName) and !par.shortName.empty();
match |= (par.longName == p.longName) and !par.longName.empty();
return match;
});
if (it != opt_.end())
{
string opt;
if (!it->shortName.empty())
{
opt += "-" + it->shortName;
}
if (!opt.empty())
{
opt += "/";
}
if (!it->longName.empty())
{
opt += "--" + it->longName;
}
throw(logic_error("duplicate option " + opt + " (in the code, not in the command line)"));
}
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;
}

View File

@ -1,103 +0,0 @@
/*
* 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

@ -1,117 +0,0 @@
/*
* ThreadPool.cpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2021 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/Core/ThreadPool.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
/******************************************************************************
* ThreadPool implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
ThreadPool::ThreadPool(void)
: ThreadPool(std::thread::hardware_concurrency())
{}
ThreadPool::ThreadPool(const unsigned int nThreads)
: nThreads_(nThreads)
{
for (unsigned int t = 0; t < nThreads_; ++t)
{
threads_.push_back(thread(&ThreadPool::workerLoop, this));
}
}
// destructor //////////////////////////////////////////////////////////////////
ThreadPool::~ThreadPool(void)
{
terminate();
}
// get the number of threads ///////////////////////////////////////////////////
unsigned int ThreadPool::getThreadNum(void) const
{
return nThreads_;
}
// get the pool mutex for synchronisation //////////////////////////////////////
std::mutex & ThreadPool::getMutex(void)
{
return mutex_;
}
// worker loop /////////////////////////////////////////////////////////////////
void ThreadPool::workerLoop(void)
{
while (true)
{
Job job;
{
unique_lock<mutex> lock(mutex_);
condition_.wait(lock, [this](){
return !queue_.empty() || terminatePool_;
});
if (terminatePool_ and queue_.empty())
{
return;
}
job = queue_.front();
queue_.pop();
}
job();
}
}
// add jobs ////////////////////////////////////////////////////////////////////
void ThreadPool::addJob(Job newJob)
{
{
unique_lock<mutex> lock(mutex_);
queue_.push(newJob);
}
condition_.notify_one();
}
// critical section ////////////////////////////////////////////////////////////
void ThreadPool::critical(Job fn)
{
unique_lock<mutex> lock(mutex_);
fn();
}
// wait for completion /////////////////////////////////////////////////////////
void ThreadPool::terminate(void)
{
{
unique_lock<mutex> lock(mutex_);
terminatePool_ = true;
}
condition_.notify_all();
for (auto &thread: threads_)
{
thread.join();
}
threads_.clear();
}

View File

@ -1,56 +0,0 @@
/*
* ThreadPool.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2021 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_ThreadPool_hpp_
#define Latan_ThreadPool_hpp_
#include <LatAnalyze/Global.hpp>
class ThreadPool
{
public:
typedef std::function<void(void)> Job;
public:
// constructors/destructor
ThreadPool(void);
ThreadPool(const unsigned int nThreads);
virtual ~ThreadPool(void);
// get the number of threads
unsigned int getThreadNum(void) const;
// get the pool mutex for synchronisation
std::mutex & getMutex(void);
// add jobs
void addJob(Job newJob);
// critical section
void critical(Job fn);
// wait for completion and terminate
void terminate(void);
private:
// worker loop
void workerLoop(void);
private:
unsigned int nThreads_;
std::condition_variable condition_;
std::vector<std::thread> threads_;
bool terminatePool_{false};
std::queue<Job> queue_;
std::mutex mutex_;
};
#endif

View File

@ -1,137 +0,0 @@
/*
* Utilities.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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());
}

View File

@ -1,250 +0,0 @@
/*
* Utilities.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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_

View File

@ -1,58 +0,0 @@
/*
* stdincludes.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2020 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 <condition_variable>
#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 <thread>
#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

@ -1,81 +0,0 @@
/*
* 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;
}

View File

@ -1,196 +0,0 @@
/*
* 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_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,84 +0,0 @@
/*
* XmlReader.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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;
}
}

View File

@ -1,235 +0,0 @@
/*
* XmlReader.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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

@ -1,151 +0,0 @@
COM_CXXFLAGS = -Wall
if CXX_GNU
COM_CXXFLAGS += -W -pedantic -Wno-deprecated-declarations
else
if CXX_INTEL
COM_CXXFLAGS += -wd1682
endif
endif
include eigen_files.mk
AM_LFLAGS = -olex.yy.c
AM_YFLAGS = -y -d -Wno-yacc -Wno-deprecated
lib_LTLIBRARIES = libLatAnalyze.la
noinst_LTLIBRARIES = libLexers.la
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 = \
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/ThreadPool.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/DWT.cpp \
Numerical/DWTFilters.cpp \
Numerical/GslFFT.cpp \
Numerical/GslHybridRootFinder.cpp\
Numerical/GslMinimizer.cpp \
Numerical/GslQagsIntegrator.cpp \
Numerical/Minimizer.cpp \
Numerical/RootFinder.cpp \
Numerical/Solver.cpp \
Physics/CorrelatorFitter.cpp \
Physics/DataFilter.cpp \
Physics/EffectiveMass.cpp \
Statistics/FitInterface.cpp \
Statistics/Histogram.cpp \
Statistics/Random.cpp \
Statistics/StatArray.cpp \
Statistics/XYSampleData.cpp \
Statistics/XYStatData.cpp \
../config.h
libLatAnalyze_ladir = $(pkgincludedir)
HPPFILES = \
Global.hpp \
Core/Eigen.hpp \
Core/EigenPlugin.hpp \
Core/Exceptions.hpp \
Core/Mat.hpp \
Core/Math.hpp \
Core/MathInterpreter.hpp \
Core/OptParser.hpp \
Core/ParserState.hpp \
Core/Plot.hpp \
Core/ThreadPool.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/DWT.hpp \
Numerical/DWTFilters.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 \
Physics/CorrelatorFitter.hpp \
Physics/DataFilter.hpp \
Physics/EffectiveMass.hpp \
Statistics/Dataset.hpp \
Statistics/FitInterface.hpp \
Statistics/Histogram.hpp \
Statistics/MatSample.hpp \
Statistics/Random.hpp \
Statistics/StatArray.hpp \
Statistics/XYSampleData.hpp \
Statistics/XYStatData.hpp
if HAVE_MINUIT
libLatAnalyze_la_SOURCES += Numerical/MinuitMinimizer.cpp
HPPFILES += Numerical/MinuitMinimizer.hpp
endif
if HAVE_NLOPT
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
Io/AsciiParser.hpp: Io/AsciiParser.ypp
$(AM_V_YACC) $(YACC) -o Io/AsciiParser.cpp --defines=Io/AsciiParser.hpp $<
Core/MathParser.hpp: Core/MathParser.ypp
$(AM_V_YACC) $(YACC) -o Core/MathParser.cpp --defines=Core/MathParser.hpp $<
endif
BUILT_SOURCES = Io/AsciiParser.hpp Core/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

@ -1,71 +0,0 @@
/*
* CompositeMinimizer.cpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2024 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/Numerical/CompositeMinimizer.hpp>
#include <LatAnalyze/includes.hpp>
#include "CompositeMinimizer.hpp"
using namespace std;
using namespace Latan;
/******************************************************************************
* CompositeMinimizer implementation *
******************************************************************************/
// constructor ////////////////////////////////////////////////////////////////
CompositeMinimizer::CompositeMinimizer(const std::vector<Minimizer *> &minimizer)
: minVec_(minimizer)
{
if (minVec_.size() == 0)
{
LATAN_ERROR(Size, "minimizer vector has size 0");
}
}
// access /////////////////////////////////////////////////////////////////////
bool CompositeMinimizer::supportLimits(void) const
{
return false;
}
// minimization ///////////////////////////////////////////////////////////////
const DVec &CompositeMinimizer::operator()(const DoubleFunction &f)
{
DVec &x = getState();
DVec tmp;
unsigned int i = 1, nMin = minVec_.size();
// resize minimizer state to match function number of arguments
if (f.getNArg() != x.size())
{
resize(f.getNArg());
}
for (auto &m: minVec_)
{
if (getVerbosity() >= Verbosity::Normal)
{
cout << "********** Composite minimizer step " << i << "/" << nMin << endl;
}
m->setInit(x);
x = (*m)(f);
i++;
}
return x;
}

View File

@ -1,68 +0,0 @@
/*
* CompositeMinimizer.hpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2024 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_CompositeMinimizer_hpp_
#define Latan_CompositeMinimizer_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Functional/Function.hpp>
#include <LatAnalyze/Numerical/Minimizer.hpp>
BEGIN_LATAN_NAMESPACE
/******************************************************************************
* Class for chaining minimizers *
******************************************************************************/
class CompositeMinimizer: public Minimizer
{
public:
// constructors
explicit CompositeMinimizer(const std::vector<Minimizer *> &minimizer);
template <typename... Ts>
CompositeMinimizer(Minimizer &min, Ts & ... minimisers);
// destructor
virtual ~CompositeMinimizer(void) = default;
// access
virtual bool supportLimits(void) const;
// minimization
virtual const DVec & operator()(const DoubleFunction &f);
private:
std::vector<Minimizer *> minVec_;
};
/******************************************************************************
* CompositeMinimizer template implementation *
******************************************************************************/
template <typename... Ts>
CompositeMinimizer::CompositeMinimizer(Minimizer &min, Ts & ... minimisers)
{
static_assert(static_or<std::is_assignable<Minimizer &, Ts>::value...>::value,
"model arguments are not compatible with Minimizer");
minVec_ = {&min, &minimisers...};
if (minVec_.size() == 0)
{
LATAN_ERROR(Size, "minimizer vector has size 0");
}
}
END_LATAN_NAMESPACE
#endif // Latan_CompositeMinimizer_hpp_

View File

@ -1,205 +0,0 @@
/*
* DWT.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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/Numerical/DWT.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
/******************************************************************************
* DWT implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
DWT::DWT(const DWTFilter &filter)
: filter_(filter)
{}
// convolution primitive ///////////////////////////////////////////////////////
template <typename MatType>
void filterConvolution(MatType &out, const MatType &data,
const std::vector<double> &filter, const Index offset)
{
Index n = data.rows(), nf = n*filter.size();
out.resizeLike(data);
out.fill(0.);
for (unsigned int i = 0; i < filter.size(); ++i)
{
FOR_MAT(out, j, k)
{
out(j, k) += filter[i]*data((j + i + nf - offset) % n, k);
}
}
}
void DWT::filterConvolution(DVec &out, const DVec &data,
const std::vector<double> &filter, const Index offset)
{
::filterConvolution(out, data, filter, offset);
}
void DWT::filterConvolution(DMat &out, const DMat &data,
const std::vector<double> &filter, const Index offset)
{
::filterConvolution(out, data, filter, offset);
}
// downsampling/upsampling primitives //////////////////////////////////////////
template <typename MatType>
void downsample(MatType &out, const MatType &in)
{
if (out.rows() < in.rows()/2)
{
LATAN_ERROR(Size, "output rows smaller than half the input vector rows");
}
if (out.cols() != in.cols())
{
LATAN_ERROR(Size, "output and input number of columns mismatch");
}
for (Index j = 0; j < in.cols(); j++)
for (Index i = 0; i < in.rows(); i += 2)
{
out(i/2, j) = in(i, j);
}
}
void DWT::downsample(DVec &out, const DVec &in)
{
::downsample(out, in);
}
void DWT::downsample(DMat &out, const DMat &in)
{
::downsample(out, in);
}
template <typename MatType>
void upsample(MatType &out, const MatType &in)
{
if (out.size() < 2*in.size())
{
LATAN_ERROR(Size, "output rows smaller than twice the input rows");
}
if (out.cols() != in.cols())
{
LATAN_ERROR(Size, "output and input number of columns mismatch");
}
out.block(0, 0, 2*in.size(), out.cols()).fill(0.);
for (Index j = 0; j < in.cols(); j++)
for (Index i = 0; i < in.size(); i ++)
{
out(2*i, j) = in(i, j);
}
}
void DWT::upsample(DVec &out, const DVec &in)
{
::upsample(out, in);
}
void DWT::upsample(DMat &out, const DMat &in)
{
::upsample(out, in);
}
// DWT /////////////////////////////////////////////////////////////////////////
std::vector<DWT::DWTLevel>
DWT::forward(const DVec &data, const unsigned int level) const
{
std::vector<DWTLevel> dwt(level);
DVec *finePt = const_cast<DVec *>(&data);
DVec tmp;
Index n = data.size(), o = filter_.fwdL.size()/2, minSize;
minSize = 1;
for (unsigned int l = 0; l < level; ++l) minSize *= 2;
if (n < minSize)
{
LATAN_ERROR(Size, "data vector too small for a " + strFrom(level)
+ "-level DWT (data size is " + strFrom(n) + ")");
}
for (unsigned int l = 0; l < level; ++l)
{
n /= 2;
dwt[l].first.resize(n);
dwt[l].second.resize(n);
filterConvolution(tmp, *finePt, filter_.fwdL, o);
downsample(dwt[l].first, tmp);
filterConvolution(tmp, *finePt, filter_.fwdH, o);
downsample(dwt[l].second, tmp);
finePt = &dwt[l].first;
}
return dwt;
}
DVec DWT::backward(const std::vector<DWTLevel>& dwt) const
{
unsigned int level = dwt.size();
Index n = dwt.back().second.size(), o = filter_.bwdL.size()/2 - 1;
DVec res, tmp, conv;
res = dwt.back().first;
for (int l = level - 2; l >= 0; --l)
{
n *= 2;
if (dwt[l].second.size() != n)
{
LATAN_ERROR(Size, "DWT result size mismatch");
}
}
n = dwt.back().second.size();
for (int l = level - 1; l >= 0; --l)
{
n *= 2;
tmp.resize(n);
upsample(tmp, res);
filterConvolution(conv, tmp, filter_.bwdL, o);
res = conv;
upsample(tmp, dwt[l].second);
filterConvolution(conv, tmp, filter_.bwdH, o);
res += conv;
}
return res;
}
// concatenate levels //////////////////////////////////////////////////////////
DVec DWT::concat(const std::vector<DWTLevel> &dwt, const int maxLevel, const bool dropLow)
{
unsigned int level = ((maxLevel >= 0) ? (maxLevel + 1) : dwt.size());
Index nlast = dwt[level - 1].first.size();
Index n = 2*dwt.front().first.size() - ((dropLow) ? nlast : 0);
Index pt = n, nl;
DVec res(n);
for (unsigned int l = 0; l < level; ++l)
{
nl = dwt[l].second.size();
pt -= nl;
res.segment(pt, nl) = dwt[l].second;
}
if (!dropLow)
{
res.segment(0, nl) = dwt[level-1].first;
}
return res;
}

View File

@ -1,62 +0,0 @@
/*
* DWT.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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_DWT_hpp_
#define Latan_DWT_hpp_
#include <LatAnalyze/Global.hpp>
#include <LatAnalyze/Numerical/DWTFilters.hpp>
#include <LatAnalyze/Core/Mat.hpp>
BEGIN_LATAN_NAMESPACE
/******************************************************************************
* Discrete wavelet transform class *
******************************************************************************/
class DWT
{
public:
typedef std::pair<DVec, DVec> DWTLevel;
public:
// constructor
DWT(const DWTFilter &filter);
// destructor
virtual ~DWT(void) = default;
// convolution primitive
static void filterConvolution(DVec &out, const DVec &data,
const std::vector<double> &filter, const Index offset);
static void filterConvolution(DMat &out, const DMat &data,
const std::vector<double> &filter, const Index offset);
// downsampling/upsampling primitives
static void downsample(DVec &out, const DVec &in);
static void downsample(DMat &out, const DMat &in);
static void upsample(DVec &out, const DVec &in);
static void upsample(DMat &out, const DMat &in);
// DWT
std::vector<DWTLevel> forward(const DVec &data, const unsigned int level) const;
DVec backward(const std::vector<DWTLevel>& dwt) const;
// concatenate levels
static DVec concat(const std::vector<DWTLevel>& dwt, const int maxLevel = -1, const bool dropLow = false);
private:
DWTFilter filter_;
};
END_LATAN_NAMESPACE
#endif // Latan_DWT_hpp_

View File

@ -1,528 +0,0 @@
/*
* DWTFilters.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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/Numerical/DWTFilters.hpp>
#include <LatAnalyze/includes.hpp>
// cf. http://wavelets.pybytes.com
// *here we implement the reverse filters more convenient for convolutions*
using namespace std;
using namespace Latan;
#define FILTDICT(x) {#x, &DWTFilters::x}
std::map<std::string, const DWTFilter *> DWTFilters::fromName = {
FILTDICT(haar),
FILTDICT(db2),
FILTDICT(db3),
FILTDICT(db4),
FILTDICT(db5),
FILTDICT(db6),
FILTDICT(bior13),
FILTDICT(bior15),
FILTDICT(bior22),
FILTDICT(bior24),
FILTDICT(bior31),
FILTDICT(bior33),
FILTDICT(bior35)
};
DWTFilter DWTFilters::haar = {
// fwdL
{0.7071067811865476,
0.7071067811865476},
// fwdH
{0.7071067811865476,
-0.7071067811865476},
// bwdL
{0.7071067811865476,
0.7071067811865476},
// bwdH
{-0.7071067811865476,
0.7071067811865476}
};
DWTFilter DWTFilters::db2 = {
// fwdL
{0.48296291314469025,
0.836516303737469,
0.22414386804185735,
-0.12940952255092145},
// fwdH
{-0.12940952255092145,
-0.22414386804185735,
0.836516303737469,
-0.48296291314469025},
// bwdL
{-0.12940952255092145,
0.22414386804185735,
0.836516303737469,
0.48296291314469025},
// bwdH
{-0.48296291314469025,
0.836516303737469,
-0.22414386804185735,
-0.12940952255092145}
};
DWTFilter DWTFilters::db3 = {
// fwdL
{0.3326705529509569,
0.8068915093133388,
0.4598775021193313,
-0.13501102001039084,
-0.08544127388224149,
0.035226291882100656},
// fwdH
{0.035226291882100656,
0.08544127388224149,
-0.13501102001039084,
-0.4598775021193313,
0.8068915093133388,
-0.3326705529509569},
// bwdL
{0.035226291882100656,
-0.08544127388224149,
-0.13501102001039084,
0.4598775021193313,
0.8068915093133388,
0.3326705529509569},
// bwdH
{-0.3326705529509569,
0.8068915093133388,
-0.4598775021193313,
-0.13501102001039084,
0.08544127388224149,
0.035226291882100656}
};
DWTFilter DWTFilters::db4 = {
// fwdL
{0.23037781330885523,
0.7148465705525415,
0.6308807679295904,
-0.02798376941698385,
-0.18703481171888114,
0.030841381835986965,
0.032883011666982945,
-0.010597401784997278},
// fwdH
{-0.010597401784997278,
-0.032883011666982945,
0.030841381835986965,
0.18703481171888114,
-0.02798376941698385,
-0.6308807679295904,
0.7148465705525415,
-0.23037781330885523},
// bwdL
{-0.010597401784997278,
0.032883011666982945,
0.030841381835986965,
-0.18703481171888114,
-0.02798376941698385,
0.6308807679295904,
0.7148465705525415,
0.23037781330885523},
// bwdH
{-0.23037781330885523,
0.7148465705525415,
-0.6308807679295904,
-0.02798376941698385,
0.18703481171888114,
0.030841381835986965,
-0.032883011666982945,
-0.010597401784997278}
};
DWTFilter DWTFilters::db5 = {
// fwdL
{0.160102397974125,
0.6038292697974729,
0.7243085284385744,
0.13842814590110342,
-0.24229488706619015,
-0.03224486958502952,
0.07757149384006515,
-0.006241490213011705,
-0.012580751999015526,
0.003335725285001549},
// fwdH
{0.003335725285001549,
0.012580751999015526,
-0.006241490213011705,
-0.07757149384006515,
-0.03224486958502952,
0.24229488706619015,
0.13842814590110342,
-0.7243085284385744,
0.6038292697974729,
-0.160102397974125},
// bwdL
{0.003335725285001549,
-0.012580751999015526,
-0.006241490213011705,
0.07757149384006515,
-0.03224486958502952,
-0.24229488706619015,
0.13842814590110342,
0.7243085284385744,
0.6038292697974729,
0.160102397974125},
// bwdH
{-0.160102397974125,
0.6038292697974729,
-0.7243085284385744,
0.13842814590110342,
0.24229488706619015,
-0.03224486958502952,
-0.07757149384006515,
-0.006241490213011705,
0.012580751999015526,
0.003335725285001549}
};
DWTFilter DWTFilters::db6 = {
// fwdL
{0.11154074335008017,
0.4946238903983854,
0.7511339080215775,
0.3152503517092432,
-0.22626469396516913,
-0.12976686756709563,
0.09750160558707936,
0.02752286553001629,
-0.031582039318031156,
0.0005538422009938016,
0.004777257511010651,
-0.00107730108499558},
// fwdH
{-0.00107730108499558,
-0.004777257511010651,
0.0005538422009938016,
0.031582039318031156,
0.02752286553001629,
-0.09750160558707936,
-0.12976686756709563,
0.22626469396516913,
0.3152503517092432,
-0.7511339080215775,
0.4946238903983854,
-0.11154074335008017},
// bwdL
{-0.00107730108499558,
0.004777257511010651,
0.0005538422009938016,
-0.031582039318031156,
0.02752286553001629,
0.09750160558707936,
-0.12976686756709563,
-0.22626469396516913,
0.3152503517092432,
0.7511339080215775,
0.4946238903983854,
0.11154074335008017},
// bwdH
{-0.11154074335008017,
0.4946238903983854,
-0.7511339080215775,
0.3152503517092432,
0.22626469396516913,
-0.12976686756709563,
-0.09750160558707936,
0.02752286553001629,
0.031582039318031156,
0.0005538422009938016,
-0.004777257511010651,
-0.00107730108499558}
};
DWTFilter DWTFilters::bior13 = {
// fwdL
{-0.08838834764831845,
0.08838834764831845,
0.7071067811865476,
0.7071067811865476,
0.08838834764831845,
-0.08838834764831845},
// fwdH
{0.0,
0.0,
0.7071067811865476,
-0.7071067811865476,
0.0,
0.0},
// bwdL
{0.0,
0.0,
0.7071067811865476,
0.7071067811865476,
0.0,
0.0},
// bwdH
{0.08838834764831845,
0.08838834764831845,
-0.7071067811865476,
0.7071067811865476,
-0.08838834764831845,
-0.08838834764831845}
};
DWTFilter DWTFilters::bior15 = {
// fwdL
{0.01657281518405971,
-0.01657281518405971,
-0.12153397801643787,
0.12153397801643787,
0.7071067811865476,
0.7071067811865476,
0.12153397801643787,
-0.12153397801643787,
-0.01657281518405971,
0.01657281518405971},
// fwdH
{0.0,
0.0,
0.0,
0.0,
0.7071067811865476,
-0.7071067811865476,
0.0,
0.0,
0.0,
0.0},
// bwdL
{0.0,
0.0,
0.0,
0.0,
0.7071067811865476,
0.7071067811865476,
0.0,
0.0,
0.0,
0.0},
// bwdH
{-0.01657281518405971,
-0.01657281518405971,
0.12153397801643787,
0.12153397801643787,
-0.7071067811865476,
0.7071067811865476,
-0.12153397801643787,
-0.12153397801643787,
0.01657281518405971,
0.01657281518405971}
};
DWTFilter DWTFilters::bior22 = {
// fwdL
{-0.1767766952966369,
0.3535533905932738,
1.0606601717798214,
0.3535533905932738,
-0.1767766952966369,
0.0},
// fwdH
{0.0,
0.0,
0.3535533905932738,
-0.7071067811865476,
0.3535533905932738,
0.0},
// bwdL
{0.0,
0.0,
0.3535533905932738,
0.7071067811865476,
0.3535533905932738,
0.0},
// bwdH
{0.1767766952966369,
0.3535533905932738,
-1.0606601717798214,
0.3535533905932738,
0.1767766952966369,
0.0}
};
DWTFilter DWTFilters::bior24 = {
// fwdL
{0.03314563036811942,
-0.06629126073623884,
-0.1767766952966369,
0.4198446513295126,
0.9943689110435825,
0.4198446513295126,
-0.1767766952966369,
-0.06629126073623884,
0.03314563036811942,
0.0},
// fwdH
{0.0,
0.0,
0.0,
0.0,
0.3535533905932738,
-0.7071067811865476,
0.3535533905932738,
0.0,
0.0,
0.0},
// bwdL
{0.0,
0.0,
0.0,
0.0,
0.3535533905932738,
0.7071067811865476,
0.3535533905932738,
0.0,
0.0,
0.0},
// bwdH
{-0.03314563036811942,
-0.06629126073623884,
0.1767766952966369,
0.4198446513295126,
-0.9943689110435825,
0.4198446513295126,
0.1767766952966369,
-0.06629126073623884,
-0.03314563036811942,
0.0}
};
DWTFilter DWTFilters::bior31 = {
// fwdL
{-0.3535533905932738,
1.0606601717798214,
1.0606601717798214,
-0.3535533905932738},
// fwdH
{0.1767766952966369,
-0.5303300858899107,
0.5303300858899107,
-0.1767766952966369},
// bwdL
{0.1767766952966369,
0.5303300858899107,
0.5303300858899107,
0.1767766952966369},
// bwdH
{0.3535533905932738,
1.0606601717798214,
-1.0606601717798214,
-0.3535533905932738}
};
DWTFilter DWTFilters::bior33 = {
// fwdL
{0.06629126073623884,
-0.19887378220871652,
-0.15467960838455727,
0.9943689110435825,
0.9943689110435825,
-0.15467960838455727,
-0.19887378220871652,
0.06629126073623884},
// fwdH
{0.0,
0.0,
0.1767766952966369,
-0.5303300858899107,
0.5303300858899107,
-0.1767766952966369,
0.0,
0.0},
// bwdL
{0.0,
0.0,
0.1767766952966369,
0.5303300858899107,
0.5303300858899107,
0.1767766952966369,
0.0,
0.0},
// bwdH
{-0.06629126073623884,
-0.19887378220871652,
0.15467960838455727,
0.9943689110435825,
-0.9943689110435825,
-0.15467960838455727,
0.19887378220871652,
0.06629126073623884}
};
DWTFilter DWTFilters::bior35 = {
// fwdL
{-0.013810679320049757,
0.04143203796014927,
0.052480581416189075,
-0.26792717880896527,
-0.07181553246425874,
0.966747552403483,
0.966747552403483,
-0.07181553246425874,
-0.26792717880896527,
0.052480581416189075,
0.04143203796014927,
-0.013810679320049757},
// fwdH
{0.0,
0.0,
0.0,
0.0,
0.1767766952966369,
-0.5303300858899107,
0.5303300858899107,
-0.1767766952966369,
0.0,
0.0,
0.0,
0.0},
// bwdL
{0.0,
0.0,
0.0,
0.0,
0.1767766952966369,
0.5303300858899107,
0.5303300858899107,
0.1767766952966369,
0.0,
0.0,
0.0,
0.0},
// bwdH
{0.013810679320049757,
0.04143203796014927,
-0.052480581416189075,
-0.26792717880896527,
0.07181553246425874,
0.966747552403483,
-0.966747552403483,
-0.07181553246425874,
0.26792717880896527,
0.052480581416189075,
-0.04143203796014927,
-0.013810679320049757}
};

View File

@ -1,53 +0,0 @@
/*
* DWTFilters.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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_DWTFilters_hpp_
#define Latan_DWTFilters_hpp_
#include <LatAnalyze/Global.hpp>
BEGIN_LATAN_NAMESPACE
struct DWTFilter
{
const std::vector<double> fwdL, fwdH, bwdL, bwdH;
};
namespace DWTFilters
{
extern DWTFilter haar;
extern DWTFilter db2;
extern DWTFilter db3;
extern DWTFilter db4;
extern DWTFilter db5;
extern DWTFilter db6;
extern DWTFilter bior13;
extern DWTFilter bior15;
extern DWTFilter bior22;
extern DWTFilter bior24;
extern DWTFilter bior31;
extern DWTFilter bior33;
extern DWTFilter bior35;
extern std::map<std::string, const DWTFilter *> fromName;
}
END_LATAN_NAMESPACE
#endif // Latan_DWTFilters_hpp_

View File

@ -1,53 +0,0 @@
/*
* FFT.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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_

View File

@ -1,90 +0,0 @@
/*
* GslFFT.cpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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/Numerical/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)
{
clear();
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_);
}
}

View File

@ -1,57 +0,0 @@
/*
* GslFFT.hpp, part of LatAnalyze
*
* Copyright (C) 2013 - 2020 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/Core/Mat.hpp>
#include <LatAnalyze/Numerical/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_

View File

@ -1,417 +0,0 @@
/*
* CorrelatorFitter.cpp, part of LatAnalyze 3
*
* Copyright (C) 2013 - 2020 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/Physics/CorrelatorFitter.hpp>
#include <LatAnalyze/includes.hpp>
using namespace std;
using namespace Latan;
/******************************************************************************
* Correlator models *
******************************************************************************/
DoubleModel CorrelatorModels::makeExpModel(const Index nState)
{
DoubleModel mod;
mod.setFunction([nState](const double *x, const double *p)
{
double res = 0.;
for (unsigned int i = 0; i < nState; ++i)
{
res += p[2*i + 1]*exp(-p[2*i]*x[0]);
}
return res;
}, 1, 2*nState);
for (unsigned int i = 0; i < nState; ++i)
{
mod.parName().setName(2*i, "E_" + strFrom(i));
mod.parName().setName(2*i + 1, "Z_" + strFrom(i));
}
return mod;
}
DoubleModel CorrelatorModels::makeCoshModel(const Index nState, const Index nt)
{
DoubleModel mod;
mod.setFunction([nState, nt](const double *x, const double *p)
{
double res = 0.;
for (unsigned int i = 0; i < nState; ++i)
{
res += p[2*i + 1]*(exp(-p[2*i]*x[0]) + exp(-p[2*i]*(nt - x[0])));
}
return res;
}, 1, 2*nState);
for (unsigned int i = 0; i < nState; ++i)
{
mod.parName().setName(2*i, "E_" + strFrom(i));
mod.parName().setName(2*i + 1, "Z_" + strFrom(i));
}
return mod;
}
DoubleModel CorrelatorModels::makeSinhModel(const Index nState, const Index nt)
{
DoubleModel mod;
mod.setFunction([nState, nt](const double *x, const double *p)
{
double res = 0.;
for (unsigned int i = 0; i < nState; ++i)
{
res += p[2*i + 1]*(exp(-p[2*i]*x[0]) - exp(-p[2*i]*(nt - x[0])));
}
return res;
}, 1, 2*nState);
for (unsigned int i = 0; i < nState; ++i)
{
mod.parName().setName(2*i, "E_" + strFrom(i));
mod.parName().setName(2*i + 1, "Z_" + strFrom(i));
}
return mod;
}
DoubleModel CorrelatorModels::makeConstModel(void)
{
DoubleModel mod;
mod.setFunction([](const double *x __dumb, const double *p __dumb)
{
return p[0];
}, 1, 1);
mod.parName().setName(0, "cst");
return mod;
}
DoubleModel CorrelatorModels::makeLinearModel(void)
{
DoubleModel mod;
mod.setFunction([](const double *x, const double *p)
{
return p[1] + p[0]*x[0];
}, 1, 2);
return mod;
}
CorrelatorModels::ModelPar CorrelatorModels::parseModel(const string s)
{
smatch sm;
ModelPar par;
if (regex_match(s, sm, regex("exp([0-9]+)")))
{
par.type = CorrelatorType::exp;
par.nState = strTo<Index>(sm[1].str());
}
else if (regex_match(s, sm, regex("cosh([0-9]+)")))
{
par.type = CorrelatorType::cosh;
par.nState = strTo<Index>(sm[1].str());
}
else if (regex_match(s, sm, regex("sinh([0-9]+)")))
{
par.type = CorrelatorType::sinh;
par.nState = strTo<Index>(sm[1].str());
}
else if (s == "linear")
{
par.type = CorrelatorType::linear;
par.nState = 1;
}
else if (s == "cst")
{
par.type = CorrelatorType::cst;
par.nState = 1;
}
else
{
par.type = CorrelatorType::undefined;
par.nState = 0;
}
return par;
}
DoubleModel CorrelatorModels::makeModel(const CorrelatorModels::ModelPar par,
const Index nt)
{
switch (par.type)
{
case CorrelatorType::undefined:
LATAN_ERROR(Argument, "correlator type is undefined");
break;
case CorrelatorType::exp:
return makeExpModel(par.nState);
break;
case CorrelatorType::cosh:
return makeCoshModel(par.nState, nt);
break;
case CorrelatorType::sinh:
return makeSinhModel(par.nState, nt);
break;
case CorrelatorType::linear:
return makeLinearModel();
break;
case CorrelatorType::cst:
return makeConstModel();
break;
}
}
DVec CorrelatorModels::parameterGuess(const DMatSample &corr,
const ModelPar par)
{
DVec init;
Index nt = corr[central].size();
switch (par.type)
{
case CorrelatorType::undefined:
LATAN_ERROR(Argument, "correlator type is undefined");
break;
case CorrelatorType::exp:
case CorrelatorType::cosh:
case CorrelatorType::sinh:
init.resize(2*par.nState);
init(0) = log(corr[central](nt/4)/corr[central](nt/4 + 1));
init(1) = corr[central](nt/4)/(exp(-init(0)*nt/4));
for (Index p = 2; p < init.size(); p += 2)
{
init(p) = 2*init(p - 2);
init(p + 1) = init(p - 1)/2.;
}
break;
case CorrelatorType::linear:
init.resize(2);
init(0) = corr[central](nt/4) - corr[central](nt/4 + 1, 0);
init(1) = corr[central](nt/4, 0) + nt/4*init(0);
break;
case CorrelatorType::cst:
init.resize(1);
init(0) = corr[central](nt/4);
break;
default:
break;
}
return init;
}
/******************************************************************************
* Correlator utilities *
******************************************************************************/
DMatSample CorrelatorUtils::shift(const DMatSample &c, const Index ts)
{
if (ts != 0)
{
const Index nt = c[central].rows();
DMatSample buf = c;
FOR_STAT_ARRAY(buf, s)
{
for (Index t = 0; t < nt; ++t)
{
buf[s]((t - ts + nt)%nt) = c[s](t);
}
}
return buf;
}
else
{
return c;
}
}
DMatSample CorrelatorUtils::fold(const DMatSample &c)
{
const Index nt = c[central].rows();
DMatSample buf = c;
FOR_STAT_ARRAY(buf, s)
{
for (Index t = 0; t < nt; ++t)
{
buf[s](t) = 0.5*(c[s](t) + c[s]((nt - t) % nt));
}
}
return buf;
}
DMatSample CorrelatorUtils::fourierTransform(const DMatSample &c, FFT &fft,
const unsigned int dir)
{
const Index nSample = c.size();
const Index nt = c[central].rows();
bool isComplex = (c[central].cols() > 1);
CMatSample buf(nSample, nt, 1);
DMatSample out(nSample, nt, 2);
fft.resize(nt);
FOR_STAT_ARRAY(buf, s)
{
buf[s].real() = c[s].col(0);
if (isComplex)
{
buf[s].imag() = c[s].col(1);
}
else
{
buf[s].imag() = DVec::Constant(nt, 0.);
}
fft(buf[s], dir);
out[s].col(0) = buf[s].real();
out[s].col(1) = buf[s].imag();
}
return out;
}
/******************************************************************************
* CorrelatorFitter implementation *
******************************************************************************/
// constructors ////////////////////////////////////////////////////////////////
CorrelatorFitter::CorrelatorFitter(const DMatSample &corr)
{
setCorrelator(corr);
}
CorrelatorFitter::CorrelatorFitter(const std::vector<DMatSample> &corr)
{
setCorrelators(corr);
}
// access //////////////////////////////////////////////////////////////////////
XYSampleData & CorrelatorFitter::data(void)
{
return *data_;
}
void CorrelatorFitter::setCorrelator(const DMatSample &corr)
{
std::vector<DMatSample> vec;
vec.push_back(corr);
setCorrelators(vec);
}
void CorrelatorFitter::setCorrelators(const std::vector<DMatSample> &corr)
{
Index nSample = corr[0].size();
DMatSample tVec(nSample);
std::vector<const DMatSample *> ptVec;
nt_ = corr[0][central].rows();
tVec.fill(DVec::LinSpaced(nt_, 0, nt_ - 1));
for (auto &c: corr)
{
ptVec.push_back(&c);
}
data_.reset(new XYSampleData(corr[0].size()));
data_->addXDim(nt_, "t/a", true);
for (unsigned int i = 0; i < corr.size(); ++i)
{
data_->addYDim("C_" + strFrom(i) + "(t)");
}
data_->setUnidimData(tVec, ptVec);
model_.resize(corr.size());
range_.resize(corr.size(), make_pair(0, nt_ - 1));
thinning_.resize(corr.size(), 1);
}
void CorrelatorFitter::setModel(const DoubleModel &model, const Index i)
{
model_[i] = model;
}
const DoubleModel & CorrelatorFitter::getModel(const Index i) const
{
return model_.at(i);
}
void CorrelatorFitter::setFitRange(const Index tMin, const Index tMax,
const Index i)
{
range_[i] = make_pair(tMin, tMax);
refreshRanges();
}
void CorrelatorFitter::setCorrelation(const bool isCorrelated, const Index i,
const Index j)
{
data_->assumeYYCorrelated(isCorrelated, i, j);
}
DMat CorrelatorFitter::getVarianceMatrix(void) const
{
return data_->getFitVarMat();
}
void CorrelatorFitter::setThinning(const Index thinning, const Index i)
{
thinning_[i] = thinning;
refreshRanges();
}
// fit functions ///////////////////////////////////////////////////////////////
SampleFitResult CorrelatorFitter::fit(Minimizer &minimizer, const DVec &init)
{
vector<Minimizer *> vecPt = {&minimizer};
return fit(vecPt, init);
}
SampleFitResult CorrelatorFitter::fit(vector<Minimizer *> &minimizer,
const DVec &init)
{
vector<const DoubleModel *> vecPt(model_.size());
for (unsigned int i = 0; i < model_.size(); ++i)
{
vecPt[i] = &(model_[i]);
}
return data_->fit(minimizer, init, vecPt);
}
// internal function to refresh fit ranges /////////////////////////////////////
void CorrelatorFitter::refreshRanges(void)
{
for (unsigned int i = 0; i < range_.size(); ++i)
for (Index t = 0; t < nt_; ++t)
{
data_->fitPoint((t >= range_[i].first) and (t <= range_[i].second)
and ((t - range_[i].first) % thinning_[i] == 0), t);
}
}

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