pax_global_header00006660000000000000000000000064131525765040014522gustar00rootroot0000000000000052 comment=4d78910d54cec43e944256087f15fdef10e61734 tools-1.4.1/000077500000000000000000000000001315257650400126655ustar00rootroot00000000000000tools-1.4.1/.gitignore000066400000000000000000000007421315257650400146600ustar00rootroot00000000000000*~ Makefile rules.ninja build.ninja .ninja_* build src/libtools/votca_config.h src/libtools/gitversion.h .project .cproject libvotca*.pc libvotca*.so libvotca*.so.* libvotca*.a scripts/VOTCARC.bash scripts/VOTCARC.csh share/doc/Doxyfile share/doc/html/* share/man/*.man src/tools/votca_property src/tools/*.man netbeans/*/build */nbproject/private CMakeFiles install_manifest.txt cmake_install.cmake cmake_uninstall.cmake CMakeCache.txt intel/* include/votca/tools/votca_config.h tools-1.4.1/.travis.yml000066400000000000000000000053171315257650400150040ustar00rootroot00000000000000#the original source of this file can be found in tools repository change it ther # changes in tools|csg tiggered a full rebuild # changes in csgapps|csg-manual|csg-tutorials only trigger tools+csg+ifself language: cpp sudo: false addons: apt: sources: - boost-latest - george-edison55-precise-backports - ubuntu-toolchain-r-test packages: - ccache - gcc-4.8 - g++-4.8 - libfftw3-dev - cmake - cmake-data - libgsl0-dev - txt2tags - libboost1.55-all-dev - libexpat1-dev - libsqlite3-dev - libhdf5-serial-dev - pkg-config - pgf - texlive-fonts-recommended - texlive-latex-extra - doxygen - graphviz - gnuplot-nox - octave env: global: - HDF5_VERSION=1.8.18 - GMX_MAX_THREADS=8 - CCACHE_CPP2=yes #for clang - GVER=4.8 matrix: #NINJA=1 is currently not support by Travis' cmake, enable when >=2.8.9 - XTP=yes BDIR=build WERROR=yes J=4 TYPE=Debug - XTP=yes BDIR=build WALL=yes J=4 TYPE=Debug - XTP=yes BDIR=build WERROR=yes J=4 TYPE=Release - XTP=yes BDIR=build WALL=yes J=4 TYPE=Release - MINIMAL=yes J=4 - CSG_MDRUN_STEPS=500 TEST=spce/cma/density J=4 - CSG_MDRUN_STEPS=500 TEST=spce/ibi J=4 - CSG_MDRUN_STEPS=10000 TEST=spce/imc J=4 - CSG_MDRUN_STEPS=5000 TEST=spce/re J=4 before_script: - rm -vrf * .git - wget https://raw.githubusercontent.com/votca/buildutil/master/build.sh && chmod 755 build.sh - mkdir -p "$HOME/votca/src" - if [[ ${MINIMAL} != yes ]]; then wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION%.*}/hdf5-${HDF5_VERSION}/src/hdf5-${HDF5_VERSION}.tar.gz | tar -xz && cd hdf5-${HDF5_VERSION} && ./configure --prefix=$HOME/hdf5 && make -j4 &> /dev/null && make install && cd ..; fi - if [[ ${MAN} ]]; then git clone --depth=1 https://github.com/votca/doxygen.git "$HOME/votca/src/devdoc"; fi - if [[ ${GVER} ]]; then export CC=gcc-${GVER}; export CXX=g++-${GVER}; fi - pip install --user numpy script: - PATH="$HOME/hdf5:$PATH" ./build.sh -Wu --prefix "$HOME/votca" ${TYPE:+-DCMAKE_BUILD_TYPE=${TYPE}} ${TEST:+--runtest=$TEST} ${WERROR:+--warn-to-errors} -DWITH_H5MD=ON ${MINIMAL:+--minimal} ${MAN:+--devdoc} ${J:+-j$J} ${BDIR:+--builddir=$BDIR} ${NINJA:+--ninja} ${WALL:+--Wall} ${GMX_VERSION:+--gmx-release ${GMX_VERSION}} --directory "$HOME/votca/src" --no-clean --depth 1 -DGMX_USE_RDTSCP=OFF ${GMX_DOUBLE:+-DGMX_DOUBLE=yes} tools $([[ ${MINIMAL} ]] || echo gromacs) csg csgapps ${MAN:+csg-manual} ${TEST:+csg-tutorials} ${CTP:+kmc moo ctp} ${XTP:+xtp} cache: - ccache compiler: - gcc notifications: email: - votca-commits@googlegroups.com tools-1.4.1/CMakeLists.txt000066400000000000000000000143561315257650400154360ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.8.3) project(votca-tools) set(PROJECT_VERSION "1.4.1") string(REGEX REPLACE "^[1-9]+\\.([1-9]+).*$" "\\1" SOVERSION "${PROJECT_VERSION}") if (NOT ${SOVERSION} MATCHES "[1-9]+") message(FATAL_ERROR "Could not determind SOVERSION from ${PROJECT_VERSION}") endif (NOT ${SOVERSION} MATCHES "[1-9]+") # Cmake modules/macros are in a subdirectory to keep this file cleaner set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) #release comes with -O3 by default set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) enable_language(CXX) ###################################################################### # compiler tests # these need ot be done early (before further tests). ##################################################################### include(CheckCXXCompilerFlag) ######################################################################## # User input options # ######################################################################## option(BUILD_SHARED_LIBS "Build shared libs" ON) if (NOT DEFINED LIB) set(LIB "lib") endif(NOT DEFINED LIB) if (NOT DEFINED MAN) set(MAN "share/man") endif(NOT DEFINED MAN) if (NOT DEFINED DATA) set(DATA "share/votca") endif(NOT DEFINED DATA) #this has to be the first include directive include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) #for votca_config.h include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) ######################################################################## #Find external packages ######################################################################## if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.git) find_package(Git) endif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.git) find_package(Threads REQUIRED) set(THREAD_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) find_package(Boost 1.39.0 REQUIRED COMPONENTS program_options filesystem system ) include_directories(${Boost_INCLUDE_DIRS}) set (BOOST_CFLAGS_PKG "-I${Boost_INCLUDE_DIRS}") set(BOOST_LIBS_PKG "-L${Boost_LIBRARY_DIRS}") foreach(_blib ${Boost_LIBRARIES}) string(REGEX REPLACE ".*/lib([^/]*)\\.[^.]*$" "-l\\1" _blib ${_blib}) set(BOOST_LIBS_PKG "${BOOST_LIBS_PKG} ${_blib}") endforeach(_blib) option(BUILD_MANPAGES "Build manpages (might lead to problem on system without rpath" ON) #define this target here, so that individual man pages can append to it. add_custom_target(manpages ALL) ######################################################################## # Checks what linear algebra packages are installed # ######################################################################## find_package(GSL) find_package(MKL) if (MKL_FOUND) message("-- MKL found, overloading uBLAS prod()") set(MKL TRUE) #used in votca_config.h elseif(GSL_FOUND) message("-- GSL found, overloading uBLAS prod()") include_directories(${GSL_INCLUDE_DIRS}) set(GSL_PKG "gsl") set(GSL TRUE) #used in votca_config.h endif() if(MKL_FOUND) set(MKL_URL "http://software.intel.com/sites/default/files/managed/76/8c/intel-mkl-and-boost-example.zip") set(MKL_MD5 b957ee63a2167ad21b650b47726cd55c ) set(MKL_FILE "intel-mkl-and-boost-example.zip") include(ExternalProject) ExternalProject_add(intel PREFIX intel URL "${MKL_URL}" URL_MD5 "${MKL_MD5}" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" ) set(MKL_BOOST_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/intel/src/intel/MKL_and_boost_example/headers") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/intel/src/intel") include_directories(${MKL_BOOST_INCLUDE_DIR}) set(MKL_HEADERS "${MKL_BOOST_INCLUDE_DIR}/mkl_boost_ublas_matrix_prod.hpp" "${MKL_BOOST_INCLUDE_DIR}/mkl_boost_ublas_gemm.hpp" ) install(FILES ${MKL_HEADERS} DESTINATION include/votca/tools) endif(MKL_FOUND) option(WITH_FFTW "Use FFTW3, disabling leads to reduced functionality!" ON) if (WITH_FFTW) find_package(FFTW3) if(NOT FFTW3_FOUND) message(FATAL_ERROR "FFTW3 not found, make sure you have also installed the fftw3 and it's dev package (it can be disable with -DWITH_FFTW=OFF)") endif(NOT FFTW3_FOUND) include_directories(${FFTW3_INCLUDE_DIRS}) set(FFTW3_PKG "fftw3") else(WITH_FFTW) #used in votca_config.h set(NOFFTW TRUE) set(FFTW3_PKG) endif(WITH_FFTW) ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # ######################################################################## include(CheckIncludeFile) foreach(HEADER assert.h math.h stdio.h stdlib.h string.h) check_include_file(${HEADER} FOUND_${HEADER}) if(NOT FOUND_${HEADER}) message(FATAL_ERROR "Could not find needed header - ${HEADER}") endif(NOT FOUND_${HEADER}) endforeach(HEADER) include(CheckIncludeFileCXX) foreach(HEADER cmath fstream functional iostream limits list map ostream sstream stack stdexcept string vector) check_include_file_cxx(${HEADER} FOUND_${HEADER}) if(NOT FOUND_${HEADER}) message(FATAL_ERROR "Could not find needed header - ${HEADER}") endif(NOT FOUND_${HEADER}) endforeach(HEADER) set(MATH_LIBRARIES "m" CACHE STRING "math library") mark_as_advanced( MATH_LIBRARIES ) include(CheckLibraryExists) foreach(FUNC sqrt) check_library_exists(${MATH_LIBRARIES} ${FUNC} "" FOUND_${FUNC}_${MATH_LIBRARIES}) if(NOT FOUND_${FUNC}_${MATH_LIBRARIES}) message(FATAL_ERROR "Could not find needed math function - ${FUNC}") endif(NOT FOUND_${FUNC}_${MATH_LIBRARIES}) endforeach(FUNC) ###################################### # Include the following subdirectory # ###################################### add_subdirectory(src) add_subdirectory(include/votca/tools) add_subdirectory(scripts) add_subdirectory(share/man) add_subdirectory(share/doc) configure_file(${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) include(FeatureSummary) feature_summary(INCLUDE_QUIET_PACKAGES WHAT ALL) tools-1.4.1/CMakeModules/000077500000000000000000000000001315257650400151765ustar00rootroot00000000000000tools-1.4.1/CMakeModules/FindEXPAT.cmake000066400000000000000000000032251315257650400176640ustar00rootroot00000000000000# - Find expat # Find the native EXPAT headers and libraries. # # EXPAT_INCLUDE_DIRS - where to find expat.h, etc. # EXPAT_LIBRARIES - List of libraries when using expat. # EXPAT_FOUND - True if expat found. #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2014 The VOTCA Development Team (http://www.votca.org) # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. # # This software is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) find_package(PkgConfig) pkg_check_modules(PC_EXPAT expat) # Look for the header file. FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS} ) # Look for the library. FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat HINTS ${PC_EXPAT_LIBRARY_DIRS} ) # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR) # Copy the results to the output variables. IF(EXPAT_FOUND) SET(EXPAT_LIBRARIES ${EXPAT_LIBRARY}) SET(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR}) ELSE(EXPAT_FOUND) SET(EXPAT_LIBRARIES) SET(EXPAT_INCLUDE_DIRS) ENDIF(EXPAT_FOUND) MARK_AS_ADVANCED(EXPAT_INCLUDE_DIR EXPAT_LIBRARY) tools-1.4.1/CMakeModules/FindEigen.cmake000066400000000000000000000056621315257650400200410ustar00rootroot00000000000000# - Try to find Eigen3 lib # # This module supports requiring a minimum version, e.g. you can do # find_package(Eigen3 3.1.2) # to require version 3.1.2 or newer of Eigen3. # # Once done this will define # # EIGEN_FOUND - system has eigen lib with correct version # EIGEN_INCLUDE_DIR - the eigen include directory # EIGEN_VERSION - eigen version # Copyright (c) 2006, 2007 Montel Laurent, # Copyright (c) 2008, 2009 Gael Guennebaud, # Copyright (c) 2009 Benoit Jacob # Redistribution and use is allowed according to the terms of the 2-clause BSD license. if(NOT Eigen_FIND_VERSION) if(NOT Eigen_FIND_VERSION_MAJOR) set(Eigen_FIND_VERSION_MAJOR 2) endif(NOT Eigen_FIND_VERSION_MAJOR) if(NOT Eigen_FIND_VERSION_MINOR) set(Eigen_FIND_VERSION_MINOR 91) endif(NOT Eigen_FIND_VERSION_MINOR) if(NOT Eigen_FIND_VERSION_PATCH) set(Eigen_FIND_VERSION_PATCH 0) endif(NOT Eigen_FIND_VERSION_PATCH) set(Eigen_FIND_VERSION "${Eigen_FIND_VERSION_MAJOR}.${Eigen_FIND_VERSION_MINOR}.${Eigen_FIND_VERSION_PATCH}") endif(NOT Eigen_FIND_VERSION) macro(_eigen3_check_version) file(READ "${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}") string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}") string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}") set(EIGEN_VERSION ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}) if(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION}) set(EIGEN_VERSION_OK FALSE) else(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION}) set(EIGEN_VERSION_OK TRUE) endif(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION}) if(NOT EIGEN_VERSION_OK) message(STATUS "Eigen version ${EIGEN_VERSION} found in ${EIGEN_INCLUDE_DIR}, " "but at least version ${Eigen_FIND_VERSION} is required") endif(NOT EIGEN_VERSION_OK) endmacro(_eigen3_check_version) if (EIGEN_INCLUDE_DIRS) # in cache already _eigen3_check_version() set(EIGEN_FOUND ${EIGEN_VERSION_OK}) else () find_path(EIGEN_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library PATHS ${CMAKE_INSTALL_PREFIX}/include ${KDE4_INCLUDE_DIR} PATH_SUFFIXES eigen3 eigen ) if(EIGEN_INCLUDE_DIR) _eigen3_check_version() endif(EIGEN_INCLUDE_DIR) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR EIGEN_VERSION_OK) mark_as_advanced(EIGEN_INCLUDE_DIR) SET(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR} CACHE PATH "The Eigen include path.") endif() tools-1.4.1/CMakeModules/FindFFTW3.cmake000066400000000000000000000041171315257650400176350ustar00rootroot00000000000000# - Find fftw3 # Find the native FFTW3 headers and libraries. # # FFTW3_INCLUDE_DIRS - where to find fftw3.h, etc. # FFTW3_LIBRARIES - List of libraries when using fftw3. # FFTW3_FOUND - True if fftw3 found. # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) pkg_check_modules(PC_FFTW3 fftw3) find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS}) find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS} ) set(FFTW3_LIBRARIES ${FFTW3_LIBRARY} ) set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR} ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR ) if (FFTW3_FOUND) include(CheckLibraryExists) #adding MATH_LIBRARIES here to allow static libs, this does not harm us as we are anyway using it check_library_exists("${FFTW3_LIBRARIES};${MATH_LIBRARIES}" fftw_plan_r2r_1d "" FOUND_FFTW_PLAN) if(NOT FOUND_FFTW_PLAN) message(FATAL_ERROR "Could not find fftw_plan_r2r_1d in ${FFTW3_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of fftw3 in FFTW3_LIBRARY by hand (i.e. -DFFTW3_LIBRARY='/path/to/libfftw3.so;/path/to/libm.so') !") endif(NOT FOUND_FFTW_PLAN) endif (FFTW3_FOUND) mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY ) tools-1.4.1/CMakeModules/FindGSL.cmake000066400000000000000000000063561315257650400174400ustar00rootroot00000000000000# - Find gsl # Find the native GSL headers and libraries. # # GSL_INCLUDE_DIRS - where to find gsl/gsl_linalg.h, etc. # GSL_LIBRARIES - List of libraries when using gsl. # GSL_FOUND - True if gsl found. # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) pkg_check_modules(PC_GSL gsl) find_path(GSL_INCLUDE_DIR gsl/gsl_linalg.h HINTS ${PC_GSL_INCLUDE_DIRS}) find_library(GSL_LIBRARY NAMES gsl HINTS ${PC_GSL_LIBRARY_DIRS} ) include(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE # if all listed variables are TRUE find_package_handle_standard_args(GSL DEFAULT_MSG GSL_LIBRARY GSL_INCLUDE_DIR) set(GSL_LIBRARIES "${GSL_LIBRARY}") set(GSL_INCLUDE_DIRS ${GSL_INCLUDE_DIR} ) if (GSL_FOUND) include(CheckLibraryExists) #adding MATH_LIBRARIES here to allow static libs, this does not harm us as we are anyway using it check_library_exists("${GSL_LIBRARIES};${MATH_LIBRARIES}" gsl_linalg_QR_decomp "" FOUND_QR_DECOMP) if(NOT FOUND_QR_DECOMP) #Some distributions like OpenSUSE need cblas in the linker flags, too find_library(GSLCBLAS_LIBRARY NAMES gslcblas cblas HINTS ${PC_GSL_LIBRARY_DIRS} ) find_package_handle_standard_args(GSLCBLAS DEFAULT_MSG GSLCBLAS_LIBRARY) if (GSLCBLAS_FOUND) check_library_exists("${GSLCBLAS_LIBRARY};${MATH_LIBRARIES}" cblas_dsyrk "" FOUND_DSYRK) if(NOT FOUND_DSYRK) message(FATAL_ERROR "Could not find cblas_dsyrk in ${GSLCBLAS_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of libcblas in GSLCBLAS_LIBRARY by hand (i.e. -DGSLCBLAS_LIBRARY='/path/to/libcblas.so;/path/to/libm.so')! If your gsl was build against an different version of cblas, specify it in GSLCBLAS_LIBRARY") endif(NOT FOUND_DSYRK) set(GSL_LIBRARIES "${GSL_LIBRARY};${GSLCBLAS_LIBRARY}") check_library_exists("${GSL_LIBRARIES};${MATH_LIBRARIES}" gsl_linalg_QR_lssolve "" FOUND_QR_DECOMP_AGAIN) endif(GSLCBLAS_FOUND) endif(NOT FOUND_QR_DECOMP) if(NOT FOUND_QR_DECOMP AND NOT FOUND_QR_DECOMP_AGAIN) message(FATAL_ERROR "Could not find gsl_linalg_QR_decompx in ${GSL_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of libgsl in GSL_LIBRARY by hand (i.e. -DGSL_LIBRARY='/path/to/libgsl.so;/path/to/libm.so') !") endif(NOT FOUND_QR_DECOMP AND NOT FOUND_QR_DECOMP_AGAIN) endif (GSL_FOUND) mark_as_advanced(GSL_INCLUDE_DIR GSL_LIBRARY) tools-1.4.1/CMakeModules/FindMKL.cmake000066400000000000000000000251431315257650400174310ustar00rootroot00000000000000# CMake script to detect Intel(R) Math Kernel Library (MKL) # # This will try to find Intel MKL libraries, and include path by automatic # search through typical install locations and if failed it will # examine MKLROOT environment variable. # Note, MKLROOT is not set by IPP installer, it should be set manually. # # Usage example: # set(MKL_USE_STATIC_LIBS ON) # find_package(MKL) # if (MKL_FOUND) # include_directories(${MKL_INCLUDE_DIRS}) # add_executable(foo foo.cc) # target_link_libraries(foo ${MKL_LIBRARIES}) # endif() # # Variables used by this module, they can change the default behaviour and # need to be set before calling find_package: # # MKL_ADDITIONAL_VERSIONS A list of version numbers to use for searching # the MKL include directory. # # MKL_USE_STATIC_LIBS Can be set to ON to force the use of the static # boost libraries. Defaults to OFF. # # MKL_FIND_DEBUG Set this to TRUE to enable debugging output # of FindMKL.cmake if you are having problems. # # On return this will define: # MKL_FOUND Indicates whether MKL was found (True/False) # MKL_INCLUDE_DIRS MKL include folder # MKL_LIBRARY_DIRS MKL libraries folder # MKL_LIBRARIES MKL libraries names # # NOTE: this script has only been tested with Intel(R) Parallel Studio XE 2011 # and may need changes for compatibility with older versions. # # Adapted from OpenCV IPP detection script # https://code.ros.org/trac/opencv/browser/trunk/opencv/OpenCVFindIPP.cmake # Many portions taken from FindBoost.cmake # TODO: # - caller needs to link with libiomp5md.lib or /Qopenmp... # - runtime DLLs: # -> C:\Program Files\Intel\ComposerXE-2011 # redist\ia32\mkl # redist\intel64\mkl set(_MKL_IA32 FALSE) set(_MKL_INTEL64 FALSE) if (CMAKE_SIZEOF_VOID_P EQUAL 4) set(_MKL_IA32 TRUE) elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) set(_MKL_INTEL64 TRUE) else() message(FATAL_ERROR "Unsupported 'void *' size (${SIZEOF_VOID_P})") endif() # Versions should be listed is decreasing order of preference set(_MKL_TEST_VERSIONS ${MKL_ADDITIONAL_VERSIONS} "2011" # alternative form: "2011.xxx.y" # (y is the release-update number and xxx is the package number) ) if (MKL_FIND_VERSION AND NOT MKL_FIND_QUIETLY) message(WARNING "Requesting a specific version of Intel(R) MKL is not supported") endif() # Use environment variables from Intel build scripts, if available if (NOT MKL_ROOT AND NOT $ENV{MKLROOT} STREQUAL "") set(MKL_ROOT $ENV{MKLROOT}) endif() if (MKL_ROOT) file(TO_CMAKE_PATH ${MKL_ROOT} MKL_ROOT) endif() if (NOT INTEL_ROOT AND NOT $ENV{INTELROOT} STREQUAL "") set(INTEL_ROOT $ENV{INTELROOT}) endif() if (INTEL_ROOT) file(TO_CMAKE_PATH ${INTEL_ROOT} INTEL_ROOT) endif() if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_MKL_TEST_VERSIONS = ${_MKL_TEST_VERSIONS}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "MKL_ADDITIONAL_VERSIONS = ${MKL_ADDITIONAL_VERSIONS}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "MKL_USE_STATIC_LIBS = ${MKL_USE_STATIC_LIBS}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "MKL_ROOT = ${MKL_ROOT}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "INTEL_ROOT = ${INTEL_ROOT}") endif() # Find MKL include directory set(_MKL_ROOT_SEARCH_DIRS ${MKL_ROOT} ) foreach (_MKL_VER ${_MKL_TEST_VERSIONS}) if (WIN32) list(APPEND _MKL_ROOT_SEARCH_DIRS "$ENV{ProgramFiles}/Intel/Composer XE/mkl") else() list(APPEND _MKL_ROOT_SEARCH_DIRS "/opt/intel/composerxe-${_MKL_VER}/mkl") endif() endforeach() if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_MKL_ROOT_SEARCH_DIRS = ${_MKL_ROOT_SEARCH_DIRS}") endif() find_path(MKL_INCLUDE_DIR NAMES mkl.h PATHS ${_MKL_ROOT_SEARCH_DIRS} PATH_SUFFIXES include DOC "The path to Intel(R) MKL header files" ) if (MKL_INCLUDE_DIR) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "location of mkl.h: ${MKL_INCLUDE_DIR}/mkl.h") endif() else() if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "unable to find Intel(R) MKL header files. Please set MKLROOT" " to the root directory containing MKL.") endif() endif() # Find MKL library directory set(_INTEL_LIBRARY_DIR_SUFFIXES "lib") if (_MKL_IA32) list(APPEND _INTEL_LIBRARY_DIR_SUFFIXES "lib/ia32") elseif (_MKL_INTEL64) list(APPEND _INTEL_LIBRARY_DIR_SUFFIXES "lib/intel64") else() message(FATAL_ERROR "unreachable") endif() set(_MKL_LIBRARY_SEARCH_DIRS ${_MKL_ROOT_SEARCH_DIRS}) if (MKL_INCLUDE_DIR) list(APPEND _MKL_LIBRARY_SEARCH_DIRS "${MKL_INCLUDE_DIR}/..") endif() if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_INTEL_LIBRARY_DIR_SUFFIXES = ${_INTEL_LIBRARY_DIR_SUFFIXES}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_MKL_LIBRARY_SEARCH_DIRS = ${_MKL_LIBRARY_SEARCH_DIRS}") endif() set(MKL_LIB_PREFIX "mkl_") if (MKL_USE_STATIC_LIBS) if (_MKL_IA32) if (WIN32) set(_MKL_LIBRARIES intel_c) else() set(_MKL_LIBRARIES intel) endif() elseif (_MKL_INTEL64) set(_MKL_LIBRARIES intel_lp64) else() message(FATAL_ERROR "unreachable") endif() list(APPEND _MKL_LIBRARIES intel_thread) list(APPEND _MKL_LIBRARIES core) else() set(_MKL_LIBRARIES rt) endif() set(_MKL_MISSING_LIBRARIES "") set(MKL_LIBRARIES "") set(MKL_LIBRARY_DIRS "") # Find MKL libraries foreach (_MKL_LIB_RAW ${_MKL_LIBRARIES}) set(_MKL_LIB ${MKL_LIB_PREFIX}${_MKL_LIB_RAW}) string(TOUPPER ${_MKL_LIB} _MKL_LIB_UPPER) find_library(${_MKL_LIB_UPPER}_LIBRARY NAMES ${_MKL_LIB} PATHS ${_MKL_LIBRARY_SEARCH_DIRS} PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES} DOC "The path to Intel(R) MKL ${_MKL_LIB_RAW} library" ) mark_as_advanced(${_MKL_LIB_UPPER}_LIBRARY) if (NOT ${_MKL_LIB_UPPER}_LIBRARY) list(APPEND _MKL_MISSING_LIBRARIES ${_MKL_LIB}) else() list(APPEND MKL_LIBRARIES ${${_MKL_LIB_UPPER}_LIBRARY}) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Found ${_MKL_LIB}: ${${_MKL_LIB_UPPER}_LIBRARY}") endif() get_filename_component(_MKL_LIB_PATH "${${_MKL_LIB_UPPER}_LIBRARY}" PATH) list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH}) endif() endforeach() ## Find OpenMP, pthread and math libraries set(_INTEL_LIBRARY_SEARCH_DIRS ${INTEL_ROOT} ${INTEL_ROOT}/compiler ) foreach(_MKL_DIR ${_MKL_ROOT_SEARCH_DIRS}) list(APPEND _INTEL_LIBRARY_SEARCH_DIRS "${_MKL_DIR}/..") list(APPEND _INTEL_LIBRARY_SEARCH_DIRS "${_MKL_DIR}/../compiler") endforeach() if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "_INTEL_LIBRARY_SEARCH_DIRS = ${_INTEL_LIBRARY_SEARCH_DIRS}") endif() if (NOT WIN32) find_library(PTHREAD_LIBRARY pthread DOC "Path to POSIX threads library") endif() set(_IOMP5_LIB iomp5) if (WIN32) if (MKL_USE_STATIC_LIBS) list(APPEND _IOMP5_LIB libiomp5mt.lib) else() list(APPEND _IOMP5_LIB libiomp5md.lib) endif() endif() find_library(IOMP5_LIBRARY NAMES ${_IOMP5_LIB} PATHS ${_INTEL_LIBRARY_SEARCH_DIRS} PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES} DOC "Path to OpenMP runtime library" ) if (NOT IOMP5_LIBRARY) # we could instead fallback to default library (via FindOpenMP.cmake) list(APPEND _MKL_MISSING_LIBRARIES IOMP5) else() list(APPEND MKL_LIBRARIES ${IOMP5_LIBRARY}) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Found IOMP5_LIBRARY: ${IOMP5_LIBRARY}") endif() get_filename_component(_MKL_LIB_PATH "${IOMP5_LIBRARY}" PATH) list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH}) endif() # Optimized math library (optional) set(_MATH_LIB imf) # linked by default with Intel compiler if (WIN32) if (MKL_USE_STATIC_LIBS) list(APPEND _MATH_LIB libmmds.lib) # assumes (/MD) otherwise libmmt.lib (for /MT) else() list(APPEND _MATH_LIB libmmd.lib) endif() endif() find_library(MATH_LIBRARY NAMES ${_MATH_LIB} PATHS ${_INTEL_LIBRARY_SEARCH_DIRS} PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES} DOC "Path to optimized math library" ) if (NOT MATH_LIBRARY) # we could instead fallback to default library (via FindOpenMP.cmake) list(APPEND _MKL_MISSING_LIBRARIES MATH) else() list(APPEND MKL_LIBRARIES ${MATH_LIBRARY}) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Found MATH_LIBRARY: ${MATH_LIBRARY}") endif() get_filename_component(_MKL_LIB_PATH "${MATH_LIBRARY}" PATH) list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH}) endif() # Check all required libraries are available list(REMOVE_DUPLICATES MKL_LIBRARY_DIRS) set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} ) set(MKL_FOUND TRUE) if (NOT MKL_INCLUDE_DIR) set(MKL_FOUND FALSE) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "MKL not found - MKL_INCLUDE_DIR was empty") endif() elseif (_MKL_MISSING_LIBRARIES) set(MKL_FOUND FALSE) if (MKL_FIND_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "MKL not found - the following libraries are missing: " "${_MKL_MISSING_LIBRARIES}") endif() endif() if (MKL_FOUND) if (NOT MKL_FIND_QUIETLY OR MKL_FIND_DEBUG) message(STATUS "Intel(R) MKL was found:\n" " MKL_INCLUDE_DIRS: ${MKL_INCLUDE_DIRS}\n" " MKL_LIBRARY_DIRS: ${MKL_LIBRARY_DIRS}\n" " MKL_LIBRARIES: ${MKL_LIBRARIES}" ) endif() else() if (MKL_FIND_REQUIRED) message(SEND_ERROR "Intel(R) MKL could not be found.") else() message(STATUS "Intel(R) MKL could not be found.") endif() endif() mark_as_advanced( MKL_INCLUDE_DIR MKL_INCLUDE_DIRS MKL_LIBRARY_DIRS ) tools-1.4.1/CMakeModules/FindSQLITE3.cmake000066400000000000000000000025271315257650400200730ustar00rootroot00000000000000# - Find libsqlite3 # Find the native libsqlite3 headers and libraries. # # SQLITE3_INCLUDE_DIRS - where to find sqlite3.h, etc # SQLITE3_LIBRARIES - List of libraries when using sqlite3. # SQLITE3_FOUND - True if sqlite3 found. # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # find_package(PkgConfig) pkg_check_modules(PC_SQLITE3 sqlite3) find_path(SQLITE3_INCLUDE_DIR sqlite3.h HINTS ${PC_SQLITE3_INCLUDE_DIRS}) find_library(SQLITE3_LIBRARY NAMES sqlite3 HINTS ${PC_SQLITE3_LIBRARY_DIRS} ) set(SQLITE3_LIBRARIES "${SQLITE3_LIBRARY}" ) set(SQLITE3_INCLUDE_DIRS "${SQLITE3_INCLUDE_DIR}" ) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR ) mark_as_advanced(SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY ) tools-1.4.1/CMakeModules/cmake_uninstall.cmake.in000066400000000000000000000016551315257650400217650ustar00rootroot00000000000000IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) STRING(REGEX REPLACE "\n" ";" files "${files}") FOREACH(file ${files}) MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") IF(EXISTS "$ENV{DESTDIR}${file}") EXEC_PROGRAM( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) IF(NOT "${rm_retval}" STREQUAL 0) MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") ENDIF(NOT "${rm_retval}" STREQUAL 0) ELSE(EXISTS "$ENV{DESTDIR}${file}") MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") ENDIF(EXISTS "$ENV{DESTDIR}${file}") ENDFOREACH(file) tools-1.4.1/CMakeModules/gitversion.cmake000066400000000000000000000020151315257650400203670ustar00rootroot00000000000000set(CMAKE_MODULE_PATH ${TOP_SOURCE_DIR}/CMakeModules) if (GIT_EXECUTABLE) #later use git describe here execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${TOP_SOURCE_DIR} OUTPUT_VARIABLE TOOLS_GIT_ID OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD WORKING_DIRECTORY ${TOP_SOURCE_DIR} OUTPUT_VARIABLE _HAS_CHANGES OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) if (NOT "${_HAS_CHANGES}" STREQUAL "") set(TOOLS_GIT_ID "${TOOLS_GIT_ID} (dirty)") endif() message("Current git revision is ${TOOLS_GIT_ID}") set(TOOLS_GIT_ID "gitid: ${TOOLS_GIT_ID}") else() set (TOOLS_GIT_ID) endif() set (GIT_HEADER "gitversion.h") set (NEW_GIT_HEADER "new_gitversion.h") file(WRITE ${NEW_GIT_HEADER} "static const std::string gitversion = \"${TOOLS_GIT_ID}\";\n") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NEW_GIT_HEADER} ${GIT_HEADER}) execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${NEW_GIT_HEADER}) tools-1.4.1/LICENSE000066400000000000000000000261361315257650400137020ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. tools-1.4.1/NOTICE000066400000000000000000000006531315257650400135750ustar00rootroot00000000000000Versatile Object-oriented Toolkit for Coarse-graining Applications Copyright 2009-2011 The VOTCA Development Team This product includes software developed at The VOTCA Development Team (http://www.votca.org). This software contains code, in particular the vec, matrix, objectfactory and property class, which was derived from a project by V. Ruehle. The code in src/libboost is taken from the Boost package (www.boost.org). tools-1.4.1/README.md000066400000000000000000000002611315257650400141430ustar00rootroot00000000000000This is the tools module of the VOTCA package. Further information on VOTCA can be found at http://www.votca.org You can contact the VOTCA Development Team at devs@votca.org. tools-1.4.1/include/000077500000000000000000000000001315257650400143105ustar00rootroot00000000000000tools-1.4.1/include/votca/000077500000000000000000000000001315257650400154245ustar00rootroot00000000000000tools-1.4.1/include/votca/tools/000077500000000000000000000000001315257650400165645ustar00rootroot00000000000000tools-1.4.1/include/votca/tools/CMakeLists.txt000066400000000000000000000011301315257650400213170ustar00rootroot00000000000000configure_file(votca_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/votca_config.h) file(GLOB_RECURSE VOTCA_HEADERS *.h ${CMAKE_CURRENT_BINARY_DIR}/votca_config.h ) if (NOT WITH_SQLITE3) file(GLOB_RECURSE NOT_VOTCA_HEADERS database.h statement.h) list(REMOVE_ITEM VOTCA_HEADERS ${NOT_VOTCA_HEADERS}) endif(NOT WITH_SQLITE3) if (NOT GSL_FOUND OR MKL_FOUND) file(GLOB_RECURSE NOT_VOTCA_HEADERS votca_gsl_boost_ublas_matrix_prod.h) list(REMOVE_ITEM VOTCA_HEADERS ${NOT_VOTCA_HEADERS}) endif (NOT GSL_FOUND OR MKL_FOUND) install(FILES ${VOTCA_HEADERS} DESTINATION include/votca/tools) tools-1.4.1/include/votca/tools/akimaspline.h000066400000000000000000000073501315257650400212370ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _AKIMASPLINE_H #define _AKIMASPLINE_H #include "spline.h" #include #include #include #include namespace votca { namespace tools { namespace ub = boost::numeric::ublas; /** * * \brief An Akima Spline Class * * does Akima interpolation based on the paper * "A new method of interpolation and smooth curve fitting based on local procedures" * * Fitting is not supported. In order to fit data, do linear fitting and interpolate * the linear fitted values by Akima interpolation. */ class AkimaSpline : public Spline { public: // default constructor AkimaSpline() {}; //AkimaSpline() : // _boundaries(splineNormal) {} // destructor ~AkimaSpline() {}; /** * \brief Calculate the slope according to the original Akima paper ("A New Method of Interpolation and Smooth Curve Fitting Based on Local Procedures") * \param slopes m1 to m4 of line segments connecting the five data points * \return slope * handles all special cases to determine the slope t based on slopes m1,m2,m3,m4 */ double getSlope(double m1, double m2, double m3, double m4); // construct an interpolation spline // x, y are the the points to construct interpolation, both vectors must be of same size void Interpolate(ub::vector &x, ub::vector &y); // fit spline through noisy data // x,y are arrays with noisy data, both vectors must be of same size void Fit(ub::vector &x, ub::vector &y); // Calculate the function value double Calculate(const double &x); // Calculate the function derivative double CalculateDerivative(const double &x); // Calculate the function value for a whole array, story it in y template void Calculate(vector_type1 &x, vector_type2 &y); // Calculate the derivative value for a whole array, story it in y template void CalculateDerivative(vector_type1 &x, vector_type2 &y); protected: // p1,p2,p3,p4 and t1,t2 (same identifiers as in Akima paper, page 591) ub::vector p0; ub::vector p1; ub::vector p2; ub::vector p3; ub::vector t; }; inline double AkimaSpline::Calculate(const double &r) { int interval = getInterval(r); double z = r-_r[interval]; return p0(interval) + p1(interval)*z + p2(interval)*z*z + p3(interval)*z*z*z; } inline double AkimaSpline::CalculateDerivative(const double &r) { int interval = getInterval(r); double z = r-_r[interval]; return + p1(interval) + 2.0*p2(interval)*z + 3.0*p3(interval)*z*z; } inline double AkimaSpline::getSlope(double m1, double m2, double m3, double m4) { if ((m1==m2) && (m3==m4)) { return (m2+m3)/2.0; } else { return (fabs(m4-m3)*m2 + fabs(m2-m1)*m3) / (fabs(m4-m3) + fabs(m2-m1)); } } }} #endif /* _AKIMASPLINE_H */ tools-1.4.1/include/votca/tools/application.h000066400000000000000000000125561315257650400212510ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_APPLICATION_H #define __VOTCA_APPLICATION_H #include #include "property.h" namespace votca { namespace tools { class Application { public: Application(); virtual ~Application(); /** * \brief executes the program * \param argc argc from main * \param argv argv from main * \return return code */ int Exec(int argc, char **argv); int ExecThreaded(int argc, char **argv); /** * \brief program name * \return string with program name * * overload this function to set the program name */ virtual string ProgramName() = 0; /** * \brief version string of application * \return version string */ virtual string VersionString(); /** * \brief help text of application without version information * \param out ostream for output */ virtual void HelpText(std::ostream &out) = 0; /** * \brief Initialize application data * * Initialize is called by run before parsing the command line. * All necesassary command line arguments can be added here */ virtual void Initialize() {} /** * \brief Process command line options * \return true to contine, false to stop * * EvaluateOptions is called by Run after parsing the command line. * return true if everything is ok, false to stop and show help text. */ virtual bool EvaluateOptions() { return false; } /** * \brief Check weather required option is set * \param option_name name of the option * \param error_msg error message if option is missing * * CheckRequired is called from EvaluateOptions if a required options is set. * If not, the list of possible options is shown and an exception with * the error messig given in error_msg is thrown */ void CheckRequired(const string &option_name, const string &error_msg=""); /** * \brief Main body of application * * Run is called after command line was parsed + evaluated. All * the work should be done in here. */ virtual void Run() { } virtual void RunThreaded() { } /** * \brief add option for command line * \param group group string * \return easy_init of boost, see documentation * * Adds an option to the available command line options. If no group is * specified, it is added to the standard group (Allowed Options). If group * is given, a sub group for this set of options will be created. */ boost::program_options::options_description_easy_init AddProgramOptions(const string &group = ""); /** * \brief get available program options & descriptions * \return variables_map (see boost documentation) */ boost::program_options::variables_map &OptionsMap() { return _op_vm; } boost::program_options::options_description &OptionsDesc() { return _op_desc; } /** * \brief filters out the Hidden group from the options descriptions * \return Option descriptions without the "Hidden" group */ boost::program_options::options_description &VisibleOptions(){ return _visible_options; } /** * \brief call StopExecution after EvaluateOptions * * This is useful if the program executes an operation in EvaluateOptions * and then wants to stop execution successfully. Call StopExecution and * return true in EvaluateOptions. */ void StopExecution() { _continue_execution = false; } /// length of the output help enum HelpType{ HelpShort, HelpLong }; /** * \brief Print long/short descriptions of calculators * * @param calculator_name name of a calculator * @param help_path path in VOTCASHARE were xml file with help is stored * @param helptype long or short (with options) help */ void PrintDescription(std::ostream &out, const string &calculator_name, const string help_path, HelpType helptype ); protected: /// Variable map containing all program options boost::program_options::variables_map _op_vm; /// program options required by all applications boost::program_options::options_description _op_desc; std::map _op_groups; virtual void ShowHelpText(std::ostream &out); void ShowManPage(std::ostream &out); void ShowTEXPage(std::ostream &out); bool _continue_execution; private: /// get input parameters from file, location may be specified in command line void ParseCommandLine(int argc, char **argv); /// program options without the Hidden group boost::program_options::options_description _visible_options; }; }} #endif /* __VOTCA_APPLICATION_H */ tools-1.4.1/include/votca/tools/average.h000066400000000000000000000047141315257650400203550ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _AVERAGE_H #define _AVERAGE_H namespace votca { namespace tools { // do not use this calss yet! template class Average { public: Average(); ~Average() {} void Process(const T &v); void Clear(); template void ProcessRange(const iterator_type &begin, const iterator_type &end); T CalcDev(); T CalcSig2(); const T &getAvg(); const T getM2(); size_t getN(); private: size_t _n; T _av; // average T _m2; // second moment }; template Average::Average() : _n(0) {} template <> inline Average::Average() : _n(0), _av(0), _m2(0) {} template inline void Average::Process(const T &value) { _av = _av*(double)_n/(double)(_n+1) + value / (double)(_n+1); _n++; _m2 += value*value; } template inline void Average::Clear() { _av = 0; _n = 0; _m2 = 0 ; } /* template<> inline void Average::Process(const double &value) { _av = _av*(double)_n/(double)(_n+1) + value / (double)(_n+1); _n++; _m2 += value*value; } */ template template void Average::ProcessRange(const iterator_type &begin, const iterator_type &end){ for(iterator_type iter=begin; iter!=end; ++iter){ Process(*iter); } } template T Average::CalcDev(){ double dev = 0.0; dev = sqrt((_m2-_n*_av*_av)/(_n-1)); return dev; } template T Average::CalcSig2(){ double dev = 0.0; dev = _m2/_n-_av*_av ; return dev; } template const T &Average::getAvg(){ return _av; } template const T Average::getM2(){ double m2 = 0.0; m2 = _m2/_n; return m2; } template size_t Average::getN(){ return _n; } }} #endif /* _AVERAGE_H */ tools-1.4.1/include/votca/tools/calculator.h000066400000000000000000000127161315257650400210750ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team * (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License") * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef VOTCA_TOOLS_CALCULATOR_H #define VOTCA_TOOLS_CALCULATOR_H #include #include #include namespace votca { namespace tools { /** * \brief Base class for all calculators * * Calculators are grouped in CalculatorFactories and are run by Threads * or Applications. Every calculator has a description (an XML file) installed * in VOTCASHARE which is used to compile HELP and run TESTSUITE. * This XML file also contains default values. * */ class Calculator { public: Calculator() {} virtual ~Calculator() {} /** * \brief Calculator name * * This name is used to register a calculator in a Factory * It the name of the XML file with the default calculator options * stored in VOTCASHARE * * @return calculator name */ virtual std::string Identify() = 0; /** * \brief reads default options from an XML file in VOTCASHARE * * Help files for calculators are installed in the VOTCASHARE folder * These files also contain default values (default attribute) * */ void LoadDefaults(); /** * \brief Initializes a calculator from an XML file with options * * Options are passed to a calculator by the Application * These option overwrite defaults * * @param options Property object passed by the application to a calculator */ virtual void Initialize(votca::tools::Property *options) = 0; /** * \brief Sets number of threads to use * * If only one thread is used, this calculator behaves as a master * * @param nThreads number of threads running this calculator * */ void setnThreads(unsigned int nThreads) { _nThreads = nThreads; _maverick = (_nThreads == 1) ? true : false; } /** * \brief Outputs all options of a calculator * * @param output stream */ void DisplayOptions( std::ostream &out ); /** * \brief Updates options with default options stored in VOTCASHARE * * If a value is not given or tag is not present and at the same time * a default value exists in the corresponding XML file in VOTCASHARE * a tag is created and/or a default value is assigned to it */ void UpdateWithDefaults(votca::tools::Property *options,std::string package="tools"); protected: unsigned int _nThreads; bool _maverick; void AddDefaults( votca::tools::Property &p, votca::tools::Property &defaults ); }; inline void Calculator::LoadDefaults() { } inline void Calculator::UpdateWithDefaults(votca::tools::Property *options, std::string package) { // copy options from the object supplied by the Application std::string id = Identify(); votca::tools::Property _options = options->get( "options." + id ); // add default values if specified in VOTCASHARE char *votca_share = getenv("VOTCASHARE"); if(votca_share == NULL) throw std::runtime_error("VOTCASHARE not set, cannot open help files."); // load the xml description of the calculator (with defaults and test values) std::string xmlFile = std::string(getenv("VOTCASHARE"))+std::string("/") +package +std::string("/xml/") + id + std::string(".xml"); votca::tools::Property defaults, _defaults; votca::tools::load_property_from_xml(_defaults, xmlFile); defaults = _defaults.get( "options." + id ); //std::cout << _options; //std::cout << defaults; // if a value not given or a tag not present, provide default values AddDefaults( _options, defaults ); // output calculator options std::string indent(" "); int level = 1; votca::tools::PropertyIOManipulator IndentedText(votca::tools::PropertyIOManipulator::TXT,level,indent); if ( tools::globals::verbose ) { std::cout << "\n... ... options\n" << IndentedText << _options << "... ... options\n" << std::flush; } } inline void Calculator::AddDefaults( votca::tools::Property &p, votca::tools::Property &defaults ) { for(std::list::iterator iter = defaults.begin(); iter!=defaults.end(); ++iter) { std::string name = (*iter).path() + "." + (*iter).name(); votca::tools::Property rootp = *p.begin(); if ( (*iter).hasAttribute("default") ) { if ( rootp.exists( name ) ) { //std::cout << "E " << rootp.value() << std::endl; if ( rootp.HasChilds()) rootp.value() = (*iter).value(); } else { //std::cout << "N " << (*iter).name() << std::endl; rootp.add((*iter).name(), (*iter).value()); } } AddDefaults( p, (*iter) ); } } }} #endif /* VOTCA_TOOLS_CALCULATOR_H */ tools-1.4.1/include/votca/tools/colors.h000066400000000000000000000123171315257650400202420ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_COLORS_H #define __VOTCA_TOOLS_COLORS_H namespace votca { namespace tools { /** \brief stores color codes for colorful help output * * "\x1b[%dm" * * 0: reset colors/style * 1: bold * 4: underline * 30 - 37: black, red, green, yellow, blue, magenta, cyan, and white text * 40 - 47: black, red, green, yellow, blue, magenta, cyan, and white background * A, B, C, D - moves cursor one line above, under, right, left * * example: "\x1b[1;35;42m" */ namespace Colors { static const char Empty[] = {0}; static const char Reset[] = { 0x1b, '[', '0', ';', '3', '9', 'm', 0 }; static const char Black[] = { 0x1b, '[', '0', ';', '3', '0', 'm', 0 }; static const char Red[] = { 0x1b, '[', '0', ';', '3', '1', 'm', 0 }; static const char Green[] = { 0x1b, '[', '0', ';', '3', '2', 'm', 0 }; static const char Yellow[] = { 0x1b, '[', '0', ';', '3', '3', 'm', 0 }; static const char Blue[] = { 0x1b, '[', '0', ';', '3', '4', 'm', 0 }; static const char Magenta[] = { 0x1b, '[', '0', ';', '3', '5', 'm', 0 }; static const char Cyan[] = { 0x1b, '[', '0', ';', '3', '6', 'm', 0 }; static const char White[] = { 0x1b, '[', '0', ';', '3', '7', 'm', 0 }; static const char BoldBlack[] = { 0x1b, '[', '1', ';', '3', '0', 'm', 0 }; static const char BoldRed[] = { 0x1b, '[', '1', ';', '3', '1', 'm', 0 }; static const char BoldGreen[] = { 0x1b, '[', '1', ';', '3', '2', 'm', 0 }; static const char BoldYellow[] = { 0x1b, '[', '1', ';', '3', '3', 'm', 0 }; static const char BoldBlue[] = { 0x1b, '[', '1', ';', '3', '4', 'm', 0 }; static const char BoldMagenta[] = { 0x1b, '[', '1', ';', '3', '5', 'm', 0 }; static const char BoldCyan[] = { 0x1b, '[', '1', ';', '3', '6', 'm', 0 }; static const char BoldWhite[] = { 0x1b, '[', '1', ';', '3', '7', 'm', 0 }; }; class ColorScheme { public: virtual const char *_reset() const = 0; virtual const char *_black() const = 0; virtual const char *_red() const = 0; virtual const char *_green() const = 0; virtual const char *_yellow() const = 0; virtual const char *_blue() const = 0; virtual const char *_magenta() const = 0; virtual const char *_cyan() const = 0; virtual const char *_white() const = 0; }; class ColorSchemeBase { public: virtual const char *Reset() const = 0; virtual const char *Black() const = 0; virtual const char *Red() const = 0; virtual const char *Green() const = 0; virtual const char *Yellow() const = 0; virtual const char *Blue() const = 0; virtual const char *Magenta() const = 0; virtual const char *Cyan() const = 0; virtual const char *White() const = 0; virtual ~ColorSchemeBase(){}; }; template class Color : public ColorSchemeBase { TColorScheme _cs; public: const char *Reset() const { return _cs._reset(); } const char *Black() const { return _cs._black(); } const char *Red() const { return _cs._red(); } const char *Green() const { return _cs._green(); } const char *Yellow() const { return _cs._yellow(); } const char *Blue() const { return _cs._blue(); } const char *Magenta() const { return _cs._magenta(); } const char *Cyan() const { return _cs._cyan(); } const char *White() const { return _cs._white(); } }; class csDefault : public ColorScheme { public: const char *_reset() const {return Colors::Empty;} const char *_black() const {return Colors::Empty;} const char *_red() const {return Colors::Empty;} const char *_green() const {return Colors::Empty;} const char *_yellow() const {return Colors::Empty;} const char *_blue() const {return Colors::Empty;} const char *_magenta() const {return Colors::Empty;} const char *_cyan() const {return Colors::Empty;} const char *_white() const {return Colors::Empty;} }; class csRGB : public ColorScheme { public: const char *_reset() const {return Colors::Reset;} const char *_black() const {return Colors::Black;} const char *_red() const {return Colors::Red;} const char *_green() const {return Colors::Green;} const char *_yellow() const {return Colors::Yellow;} const char *_blue() const {return Colors::Blue;} const char *_magenta() const {return Colors::Magenta;} const char *_cyan() const {return Colors::Cyan;} const char *_white() const {return Colors::White;} }; extern Color DEFAULT_COLORS; }} #endif /* __VOTCA_TOOLS_COLORS_H */ tools-1.4.1/include/votca/tools/constants.h000066400000000000000000000044351315257650400207570ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_CONSTANTS_H #define __VOTCA_TOOLS_CONSTANTS_H #include #include namespace votca { namespace tools { namespace conv{ // mathematical constants const double Pi = boost::math::constants::pi(); const double rSqrtPi = 1.0/sqrt(Pi); // natural constants const double kB = 8.617332478E-5; // double eV/K const double hbar = 6.5821192815E-16; // double eV*s //length conversions //votca xtp-uses for any conversions the following scheme unitA2unitB const double bohr2nm =0.052917721092; // double 0.052917721092 const double nm2bohr =18.897259886; //double 18.897259886 const double ang2bohr = 1.8897259886; // double 1.8897259886 const double bohr2ang =1.0/1.8897259886; //double const double nm2ang=10.0; //double 10.0 const double ang2nm=0.1; //double 0.1 const double ryd2hrt=0.5; //double 0.5 const double hrt2ryd=2; //double 2 const double ryd2ev= 13.60569253; //double 13.60569253 const double ev2ryd=1.0/13.60569253; //double const double hrt2ev= 27.21138602; //double 27.21138602 const double ev2hrt=1.0/27.21138602; //double //ewald internal to eV conversion const double int2eV = 1/(4*Pi*8.854187817e-12) * 1.602176487e-19 / 1.000e-9; const double int2V_m = 1/(4*Pi*8.854187817e-12) * 1.602176487e-19 / 1.000e-18; const double int2V = 1/(4*Pi*8.854187817e-12) * 1.602176487e-19 / 1.000e-9; // floats for gwbse const float ryd2ev_f= 13.60569253; //float 13.60569253 } }} #endif /* CONVERSIONFACTORS */ tools-1.4.1/include/votca/tools/correlate.h000066400000000000000000000030731315257650400207200ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _correlate_H #define _correlate_H #include #include #include "datacollection.h" namespace votca { namespace tools { using namespace std; /** \brief class to calculate correlations of values */ class Correlate { public: /// constructor Correlate() {}; /// destructor ~Correlate() {}; /** calculate the correlation of the first row in selection with all the other */ void CalcCorrelations(DataCollection::selection *data); vector< pair > &getData() { return _corr; } private: vector< pair > _corr; }; inline ostream& operator<<(ostream& out, Correlate &c) { vector< pair > &data = c.getData(); for(size_t i=0; i #include #include "datacollection.h" namespace votca { namespace tools { using namespace std; /** \brief class to calculate cross correlkations and autocorrelations This class is relatively outdated and only used in csg_boltzmann! \todo implementation */ class CrossCorrelate { public: /// constructor CrossCorrelate() {}; /// destructor ~CrossCorrelate() {}; /** calculate the cross correlation */ //void CrossCorrelate(DataCollection::selection *data1, // DataCollection::selection *data2, bool average = false); /** calculate the auto correlation */ void AutoCorrelate(DataCollection::selection *data, bool average = false); // Calculates only the Fourier trafo void FFTOnly(vector & ivec); // Calculates only the Discrete Cosine trafo void DCTOnly(vector & ivec); // Calculates Fourier trafo and then auto correlation void AutoFourier(vector & ivec); // Calculates Discrete Cosine trafo and then auto correlation void AutoCosine(vector & ivec); // Calculates auto correlation via two Fourier trafos void AutoCorr(vector & ivec); vector &getData() { return _corrfunc; } private: vector _corrfunc; }; inline ostream& operator<<(ostream& out, CrossCorrelate &c) { vector &data = c.getData(); for(size_t i=0; i #include #include #include using namespace std; namespace votca { namespace tools { namespace ub = boost::numeric::ublas; /** \brief A cubic spline class This class does cubic piecewise spline interpolation and spline fitting. As representation of a single spline, the general form \f[ S_i(x) = A(x,h_i) f_i + B(x,h_i) f_{i+1} + C(x,h_i) f''_i + d(x,h_i) f''_{i+1} \f] with \f[ x_i \le x < x_{i+1}\,,\\ h_i = x_{i+1} - x_{i} \f] The \f$f_i\,,\,,f''_i\f$ are the function values and second derivates at point \f$x_i\f$. The parameters \f$f''_i\f$ are no free parameters, they are determined by the smoothing condition that the first derivatives are continuous. So the only free paramers are the grid points x_i as well as the functon values f_i at these points. A spline can be generated in several ways: - Interpolation spline - Fitting spline (fit to noisy data) - calculate the parameters elsewere and fill the spline class */ class CubicSpline : public Spline { public: // default constructor CubicSpline() {}; //CubicSpline() : // _boundaries(splineNormal) {} // destructor ~CubicSpline() {}; // construct an interpolation spline // x, y are the the points to construct interpolation, both vectors must be of same size void Interpolate(ub::vector &x, ub::vector &y); // fit spline through noisy data // x,y are arrays with noisy data, both vectors must be of same size void Fit(ub::vector &x, ub::vector &y); // Calculate the function value double Calculate(const double &x); // Calculate the function derivative double CalculateDerivative(const double &x); // Calculate the function value for a whole array, story it in y template void Calculate(vector_type1 &x, vector_type2 &y); // Calculate the derivative value for a whole array, story it in y template void CalculateDerivative(vector_type1 &x, vector_type2 &y); // set spline parameters to values that were externally computed template void setSplineData(vector_type &f, vector_type &f2) { _f = f; _f2 = f2;} /** * \brief Add a point (one entry) to fitting matrix * \param pointer to matrix * \param value x * \param offsets relative to getInterval(x) * \param scale parameters for terms "A,B,C,D" * When creating a matrix to fit data with a spline, this function creates * one entry in that fitting matrix. */ template void AddToFitMatrix(matrix_type &A, double x, int offset1, int offset2=0, double scale=1); /** * \brief Add a vector of points to fitting matrix * \param pointer to matrix * \param vector of x values * \param offsets relative to getInterval(x) * Same as previous function, but vector-valued and with scale=1.0 */ template void AddToFitMatrix(matrix_type &M, vector_type &x, int offset1, int offset2=0); /** * \brief Add boundary condition of sum_i f_i =0 to fitting matrix * \param pointer to matrix * \param offsets */ template void AddBCSumZeroToFitMatrix(matrix_type &A, int offset1, int offset2=0); /** * \brief Add boundary conditions to fitting matrix * \param pointer to matrix * \param offsets */ template void AddBCToFitMatrix(matrix_type &A, int offset1, int offset2=0); protected: // A spline can be written in the form // S_i(x) = A(x,x_i,x_i+1)*f_i + B(x,x_i,x_i+1)*f''_i // + C(x,x_i,x_i+1)*f_{i+1} + D(x,x_i,x_i+1)*f''_{i+1} double A(const double &r); double B(const double &r); double C(const double &r); double D(const double &r); double Aprime(const double &r); double Bprime(const double &r); double Cprime(const double &r); double Dprime(const double &r); // tabulated derivatives at grid points. Second argument: 0 - left, 1 - right double A_prime_l(int i); double A_prime_r(int i); double B_prime_l(int i); double B_prime_r(int i); double C_prime_l(int i); double C_prime_r(int i); double D_prime_l(int i); double D_prime_r(int i); }; inline double CubicSpline::Calculate(const double &r) { int interval = getInterval(r); return A(r)*_f[interval] + B(r)*_f[interval + 1] + C(r)*_f2[interval] + D(r)*_f2[interval + 1]; } inline double CubicSpline::CalculateDerivative(const double &r) { int interval = getInterval(r); return Aprime(r)*_f[interval] + Bprime(r)*_f[interval + 1] + Cprime(r)*_f2[interval] + Dprime(r)*_f2[interval + 1]; } template inline void CubicSpline::AddToFitMatrix(matrix_type &M, double x, int offset1, int offset2, double scale) { int spi = getInterval(x); M(offset1, offset2 + spi) += A(x)*scale; M(offset1, offset2 + spi+1) += B(x)*scale; M(offset1, offset2 + spi + _r.size()) += C(x)*scale; M(offset1, offset2 + spi + _r.size() + 1) += D(x)*scale; } template inline void CubicSpline::AddToFitMatrix(matrix_type &M, vector_type &x, int offset1, int offset2) { for(size_t i=0; i inline void CubicSpline::AddBCSumZeroToFitMatrix(matrix_type &M, int offset1, int offset2) { for(size_t i=0; i<_r.size(); ++i) { M(offset1, offset2 + i) = 1; M(offset1, offset2 + _r.size() + i) = 0; } } template inline void CubicSpline::AddBCToFitMatrix(matrix_type &M, int offset1, int offset2) { for(size_t i=0; i<_r.size() - 2; ++i) { M(offset1+i+1, offset2 + i) = A_prime_l(i); M(offset1+i+1, offset2 + i+1) = B_prime_l(i) - A_prime_r(i); M(offset1+i+1, offset2 + i+2) = -B_prime_r(i); M(offset1+i+1, offset2 + _r.size() + i) = C_prime_l(i); M(offset1+i+1, offset2 + _r.size() + i+1) = D_prime_l(i) - C_prime_r(i); M(offset1+i+1, offset2 + _r.size() + i+2) = -D_prime_r(i); } // currently only natural boundary conditions: switch(_boundaries) { case splineNormal: M(offset1, offset2 + _r.size()) = 1; M(offset1 + _r.size() - 1, offset2 + 2*_r.size()-1) = 1; break; case splineDerivativeZero: // y M(offset1+0, offset2 + 0) = -1*A_prime_l(0); M(offset1+0, offset2 + 1) = -1*B_prime_l(0); M(offset1+ _r.size()-1, offset2 + _r.size()-2) = A_prime_l(_r.size()-2); M(offset1+ _r.size()-1, offset2 + _r.size()-1) = B_prime_l(_r.size()-2); // y'' M(offset1+0, offset2 + _r.size() + 0) = D_prime_l(0); M(offset1+0, offset2 + _r.size() + 1) = C_prime_l(0); M(offset1+ _r.size()-1, offset2 + 2*_r.size()-2) = C_prime_l(_r.size()-2); M(offset1+ _r.size()-1, offset2 + 2*_r.size()-1) = D_prime_l(_r.size()-2); break; case splinePeriodic: M(offset1, offset2) = 1; M(offset1, offset2 + _r.size()-1) = -1; M(offset1 + _r.size() - 1, offset2 + _r.size()) = 1; M(offset1 + _r.size() - 1, offset2 + 2*_r.size()-1) = -1; break; } } inline double CubicSpline::A(const double &r) { return ( 1.0 - (r -_r[getInterval(r)])/(_r[getInterval(r)+1]-_r[getInterval(r)]) ); } inline double CubicSpline::Aprime(const double &r) { return -1.0/(_r[getInterval(r)+1]-_r[getInterval(r)]); } inline double CubicSpline::B(const double &r) { return (r -_r[getInterval(r)])/(_r[getInterval(r)+1]-_r[getInterval(r)]) ; } inline double CubicSpline::Bprime(const double &r) { return 1.0/(_r[getInterval(r)+1]-_r[getInterval(r)]); } inline double CubicSpline::C(const double &r) { double xxi, h; xxi = r -_r[getInterval(r)]; h = _r[getInterval(r)+1]-_r[getInterval(r)]; return ( 0.5*xxi*xxi - (1.0/6.0)*xxi*xxi*xxi/h - (1.0/3.0)*xxi*h) ; } inline double CubicSpline::Cprime(const double &r) { double xxi, h; xxi = r -_r[getInterval(r)]; h = _r[getInterval(r)+1]-_r[getInterval(r)]; return (xxi - 0.5*xxi*xxi/h - h/3); } inline double CubicSpline::D(const double &r) { double xxi, h; xxi = r -_r[getInterval(r)]; h = _r[getInterval(r)+1]-_r[getInterval(r)]; return ( (1.0/6.0)*xxi*xxi*xxi/h - (1.0/6.0)*xxi*h ) ; } inline double CubicSpline::Dprime(const double &r) { double xxi, h; xxi = r -_r[getInterval(r)]; h = _r[getInterval(r)+1]-_r[getInterval(r)]; return ( 0.5*xxi*xxi/h - (1.0/6.0)*h ) ; } /** inline int CubicSpline::getInterval(double &r) { if (r < _r[0] || r > _r[_r.size() - 1]) return -1; return int( (r - _r[0]) / (_r[_r.size()-1] - _r[0]) * (_r.size() - 1) ); } **/ inline double CubicSpline::A_prime_l(int i) { return -1.0/(_r[i+1]-_r[i]); } inline double CubicSpline::B_prime_l(int i) { return 1.0/(_r[i+1]-_r[i]); } inline double CubicSpline::C_prime_l(int i) { return (1.0/6.0)*(_r[i+1]-_r[i]); } inline double CubicSpline::D_prime_l(int i) { return (1.0/3.0)*(_r[i+1]-_r[i]); } inline double CubicSpline::A_prime_r(int i) { return -1.0/(_r[i+2]-_r[i+1]); } inline double CubicSpline::B_prime_r(int i) { return 1.0/(_r[i+2]-_r[i+1]); } inline double CubicSpline::C_prime_r(int i) { return -(1.0/3.0)*(_r[i+2]-_r[i+1]); } inline double CubicSpline::D_prime_r(int i) { return -(1.0/6.0)*(_r[i+2]-_r[i+1]); } }} #endif /* _CUBICSPLINE_H */ tools-1.4.1/include/votca/tools/database.h000066400000000000000000000052561315257650400205110ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_DATABASE_H #define __VOTCA_TOOLS_DATABASE_H #include #include #include "statement.h" namespace votca { namespace tools { using namespace std; /** * \brief SQLite Database wrapper * * */ class Database { public: Database(); ~Database(); sqlite3 *getSQLiteDatabase() { return _db; } /** * \brief Helper function for opening / creating / upgrading a sqlite3 database * @param file * * This function helps to manage a sqlite database. It is inspired by the * SQLiteOpenHelper from the Android API. * * If this function is used to open a database, and the database * doesn't exist already, onCreate is called. If it exists but in an * older Version, onUpgrade is called to bring it to the most current version. */ void OpenHelper(string file); void Open(string file, int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); void Close(void); /** * \brief called by OpenHelper if database doesnt exists * * All necessary SQL statements to create the database if it does * not exist should be executed here. This is only called if the * database is opened via OpenHelper. */ virtual void onCreate(); /** * \brief called if database has an older version * * If the version specified does not match the database version, * onUpgrade is called to make necessary changes. This is only called if the * database is opened via OpenHelper. */ virtual void onUpgrade(int oldVersion, int newVersion); void Exec(string sql); Statement *Prepare(string sql); int LastInsertRowId(); void BeginTransaction() { Exec("BEGIN TRANSACTION;"); } void EndTransaction() { Exec("END TRANSACTION;"); } void CommitTransaction() { Exec("COMMIT TRANSACTION;"); } void RollbackTransaction() { Exec("ROLLBACK TRANSACTION;"); } protected: sqlite3 *_db; }; }} #endif tools-1.4.1/include/votca/tools/datacollection.h000066400000000000000000000137421315257650400217310ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _datacollection_H #define _datacollection_H #include #include #include #include #include "tokenizer.h" namespace votca { namespace tools { using namespace std; template /** \brief This class handles a set of arrays which can be identified by name tags This class is a Container of arrays. The arrays can be accessed by specifying a name, or whole groups of arrays can be selected using select an regular expressions. Regular expressions are not fully implemented at the moment. Instead, selections are performed using wildcard compare. Be aware that you might specify as typename if you define a container, array or iterator! There is currently no suppurt for user created groups, but will follow later. This class is relatively outdated and only used in csg_boltzmann! */ class DataCollection { public: /** \brief The array class, extends vector by a name tag */ class array : public vector< T > { public: array(string name) {_name = name; } const string &getName() { return _name; } private: string _name; }; //typedef vector< T > array; typedef vector< array * > container; typedef typename vector< array * >::iterator iterator; /** \brief class for array selection */ class selection { public: selection() {} ~selection() {} typedef typename vector::iterator iterator; size_t size() { return _arrays.size(); } bool empty() { return _arrays.empty(); } array &operator[](size_t i) { assert(i<_arrays.size()); return *(_arrays[i]); } void push_back(array *a) { _arrays.push_back(a); } void push_back(selection *s) { _arrays.insert(_arrays.end(), s->begin(), s->end()); } iterator begin() { return _arrays.begin(); } iterator end() { return _arrays.end(); } private: vector _arrays; }; /// constructor DataCollection() {} /// destructor ~DataCollection() { clear(); } /** \brief clears the data collection */ void clear(); /** * \ brief returns the number of arrays */ size_t size() { return _data.size(); } bool empty() { return _data.empty(); } array &operator[](int i) { assert(i<_data.size()); return *(_data[i]); } iterator begin() { return _data.begin(); } iterator end() { return _data.end(); } /** \brief create a new array */ array *CreateArray(string name); /* \brief create a new group */ //selection *CreateGroup(string group); /** \brief access the data container */ container &Data() { return _data; } /** \brief access an array by name */ array *ArrayByName(string name); /* \brief group an array by name */ //selection *GroupByName(string name); /** \brief select a set of arrays */ selection *select(string strselection, selection *sel_append=NULL); //map &Groups() { return _group_by_name; } private: container _data; map _array_by_name; //map _group_by_name; }; template void DataCollection::clear() { { typename container::iterator iter; for(iter=_data.begin(); iter!=_data.end(); ++iter) delete *iter; _data.clear(); } /* _array_by_name.clear(); { typename map::iterator iter; for(iter=_group_by_name.begin();iter!=_group_by_name.end();++iter) delete (*iter).second; _group_by_name.clear(); }*/ } template typename DataCollection::array *DataCollection::CreateArray(string name) { assert(ArrayByName(name)==NULL); array *a = new array(name); _data.push_back(a); _array_by_name[name.c_str()] = a; return a; } /*template typename DataCollection::selection *DataCollection::CreateGroup(string group) { selection *s = new selection; _group_by_name[group] = s; return s; }*/ template typename DataCollection::array *DataCollection::ArrayByName(string name) { typename map::iterator i; i = _array_by_name.find(name); if(i == _array_by_name.end()) return NULL; return (*i).second; } /*template typename DataCollection::selection *DataCollection::GroupByName(string name) { typename map::iterator i; i = _group_by_name.find(name); if(i == _group_by_name.end()) return NULL; return (*i).second; }*/ template typename DataCollection::selection *DataCollection::select(string strselection, selection *sel_append) { typename DataCollection::selection *sel = sel_append; if(!sel_append) sel = new typename DataCollection::selection; for(typename map::iterator i=_array_by_name.begin(); i!=_array_by_name.end();++i) { if(wildcmp(strselection.c_str(), (*i).second->getName().c_str())) sel->push_back((*i).second); } return sel; } ostream& operator<<(ostream& out, DataCollection::selection &sel); }} #endif /* _datacontainer_H */ tools-1.4.1/include/votca/tools/getline.h000066400000000000000000000021401315257650400203610ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _VOTCA_TOOLS_GETLINE_H #define _VOTCA_TOOLS_GETLINE_H #include #include #include namespace votca { namespace tools { /** \brief Wrapper for a getline function Removes Windows end-of-line character */ inline std::istream& getline (std::istream& is, std::string& str) { std::istream& ist = getline( is, str, '\n' ); str.erase(remove(str.begin(), str.end(), '\r'), str.end()); return ist; } }} #endif tools-1.4.1/include/votca/tools/globals.h000066400000000000000000000045761315257650400203740ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_GLOBALS_H #define __VOTCA_TOOLS_GLOBALS_H #include namespace votca { namespace tools { /** \brief class to store global variables This class is used to access global variables */ struct globals { /// be loud and noisy static bool verbose; /// web of the package static std::string url; /// email address of the developers static std::string email; /// man pages format strings struct man { static std::string option; static std::string header; static std::string name; static std::string authors; static std::string copyright; static std::string synopsis; static std::string description; static std::string options; }; /// TEX pages format strings struct tex { static std::string section; static std::string label; static std::string description; static std::string options; static std::string option; }; // constants struct constants { static const double pi; static const double kB; // eV/K static const double hbar; // eV*s }; // conversion factors struct conversion { static const double Bohr2nm; static const double nm2Bohr; static const double Ang2Bohr; static const double Ryd2eV; static const double Hrt2eV; static const double int2eV; //ewald internal to eV conversion }; }; }} #endif /* __VOTCA_TOOLS_GLOBALS_H */ tools-1.4.1/include/votca/tools/histogram.h000066400000000000000000000053251315257650400207370ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _histogram_H #define _histogram_H #include #include #include "datacollection.h" #include #include namespace votca { namespace tools { using namespace std; /** \brief class to generate histograms This class produces a histogram out of a vector of values. This class is obsolate and only used in csg_boltzman. Use HistogramNew instead! */ class Histogram { public: struct options_t; /// constructor Histogram(options_t op); Histogram(); /// destructor ~Histogram(); /** process data and generate histogram */ void ProcessData(DataCollection::selection *data); /// returns the minimum value double getMin() const {return _min; } /// return the maximum value double getMax() const {return _max; } /// return the number of grid points double getN() const {return _options._n; } vector &getPdf() {return _pdf; } double getInterval() const { return _interval; } void Normalize(void); struct options_t { int _n; bool _auto_interval; bool _extend_interval; double _min, _max; bool _periodic; bool _normalize; string _scale; options_t() { _n=101; _auto_interval = true; _extend_interval = false; _min = 0.; _max = 1.; _periodic = false; _normalize = true; _scale = "no"; } }; private: vector _pdf; double _min, _max; double _interval; options_t _options; }; inline ostream& operator<<(ostream& out, Histogram &h) { for(int i=0; i #include #include #include #include "table.h" namespace votca { namespace tools { using namespace std; /** \brief class to generate histograms This class produces a histogram out of a vector of values */ class HistogramNew { public: /// constructor HistogramNew(); /// constructor HistogramNew(const HistogramNew &hist); /// destructor ~HistogramNew() {}; /** * \brief Initialize the HistogramNew * @param min lower bound of interval * @param max upper bound of interval * @param nbins number of bins */void Initialize(double min, double max, int nbins); /** * \brief process a data point * \param v value of this point * \scale scale weighting of this point, bin of v is increased by scale instead of 1 */ void Process(const double &v, double scale = 1.0); /** \brief process a range of data using iterator interface */ template void ProcessRange(const iterator_type &begin, const iterator_type &end); /** * \brief get the lower bound of the histogram intervaö * \return lower limit of interval */ double getMin() const {return _min; } /** * \brief get the upper bound of the histogram intervaö * \return upper limit of interval */ double getMax() const {return _max; } /** * \brief Get number of grid points * \return number of grid poitns */ double getNBins() const {return _nbins; } /** * \brief get the grid of histogram * \return step per bin */ double getStep() const { return _step; } /** * \brief normalize the histogram that the integral is 1 */ void Normalize(); /** * \brief clear all data */ void Clear(); /** * \brief get access to content of histogram * \return table object with bins in x and values in y */ Table &data() { return _data; } /** * \brief set whether interval is periodic * \param periodic is periodic */ void setPeriodic(bool periodic) { _periodic = periodic; } private: double _min, _max; double _step; double _weight; bool _periodic; int _nbins; Table _data; }; inline ostream& operator<<(ostream& out, HistogramNew &h) { out << h.data(); //for(int i=0; i inline void HistogramNew::ProcessRange(const iterator_type &begin, const iterator_type &end) { for(iterator_type iter = begin; iter!=end; ++iter) Process(*iter); } }} #endif /* _HistogramNew_H */ tools-1.4.1/include/votca/tools/lexical_cast.h000066400000000000000000000024471315257650400213770ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_LEXICAL_CAST_H #define __VOTCA_TOOLS_LEXICAL_CAST_H #include #include #include namespace votca { namespace tools { /** * Wrapper for boost::lexical_cast with improved error messages * @param arg variable to convert * @param error additional error text * @return converted value */ template inline Target lexical_cast(const Source &arg, const std::string &error) { try { return boost::lexical_cast(arg); } catch(std::exception &err) { throw std::runtime_error("invaid type: " + error); } } }} #endif /* LEXICAL_CAST_H */ tools-1.4.1/include/votca/tools/linalg.h000066400000000000000000000203051315257650400202030ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_LINALG_H #define __VOTCA_TOOLS_LINALG_H #include #if defined(GSL) #include "votca_gsl_boost_ublas_matrix_prod.h" #elif defined(MKL) #include "mkl_boost_ublas_matrix_prod.hpp" #endif #include #include #include namespace votca { namespace tools { namespace ub = boost::numeric::ublas; /** * \brief inverts A * @param A symmetric positive definite matrix * @param V inverse matrix * * This function wraps the inversion of a matrix */ void linalg_invert( ub::matrix &A, ub::matrix &V ); void linalg_invert( ub::matrix &A, ub::matrix &V ); /** * \brief determines Cholesky decomposition of matrix A * @param A symmetric positive definite matrix * * This function wraps the Cholesky decomposition */ void linalg_cholesky_decompose( ub::matrix &A ); void linalg_cholesky_decompose( ub::matrix &A ); /** * \brief solves A*x=b * @param x storage for x * @param A symmetric positive definite matrix for linear system * @param b inhomogeniety * @param if A is not symmetric positive definite throws error code * * This function wraps the cholesky linear system solver */ void linalg_cholesky_solve(ub::vector &x, ub::matrix &A, ub::vector &b); /** * \brief solves A*x=b * @param x storage for x * @param A matrix for linear equation system * @param b inhomogenity * @param residual if non-zero, residual will be stored here * * This function wrapps the qrsolver */ void linalg_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::vector *residual=NULL); /** * \brief solves A*x=b under the constraint B*x = 0 * @param x storage for x * @param A matrix for linear equation system * @param b inhomogenity * @param constr constrained condition B (or is it the transposed one? check that) * * This function wraps the qrsolver under constraints */ void linalg_constrained_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::matrix &constr); /** * \brief eigenvalues of a symmetric matrix A*x=E*x * @param A symmetric matrix * @param E vector of eigenvalues * @param V matrix of eigenvalues * * This function wraps gsl_eigen_symmv / DSYEV * note that the eigenvalues/eigenvectors are UNSORTED * */ bool linalg_eigenvalues_symmetric( ub::symmetric_matrix &A, ub::vector &E, ub::matrix &V ); /** * \brief eigenvalues of a symmetric matrix A*x=E*x * @param A matrix * @param E vector of eigenvalues * @param V matrix of eigenvalues * * This function wraps gsl_eigen_symmv / DSYEV * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V ); /** * \brief eigenvalues of a symmetric matrix A*x=E*x * @param E vector of eigenvalues * @param V input: matrix to diagonalize * @param V output: eigenvectors * * This function wrapps gsl_eigen_symmv / DSYEV * */ bool linalg_eigenvalues( ub::vector &E, ub::matrix &V ); /** * \brief eigenvalues of a symmetric matrix A*x=E*x * @param E vector of eigenvalues * @param V input: matrix to diagonalize * @param V output: eigenvectors * * This function wrapps gsl_eigen_symmv / DSYEV * */ bool linalg_eigenvalues( ub::vector &E, ub::matrix &V ); /** * \brief eigenvalues of a symmetric matrix A*x=E*x * @param E vector of eigenvalues * @param V input: matrix to diagonalize * @param V output: eigenvectors * * This function wrapps gsl_eigen_symmv / DSYEV * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax ); /** * \brief eigenvalues of a symmetric matrix A*x=E*x single precision * @param E vector of eigenvalues * @param V input: matrix to diagonalize * @param V output: eigenvectors * * This function wrapps gsl_eigen_symmv / DSYEV * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax ); /** * \brief eigenvalues of a symmetric matrix A*x=E*B*x double precision * @param E vector of eigenvalues * @param A input: matrix to diagonalize * @param B input: overlap matrix * @param V output: eigenvectors * * This function wrapps gsl_eigen_gensymmv / dsygv * */ bool linalg_eigenvalues_general(const ub::matrix &A,const ub::matrix &B, ub::vector &E, ub::matrix &V); /** * \brief computes Singular value decomposition A = U S V^T double precision * @param S vector of singular values * @param A input: matrix for SVD, is oerwritten with U * @param B input: overlap matrix * @param V output: eigenvectors * * This function wrapps eigen_gensymmv / dsygv * */ bool linalg_singular_value_decomposition(ub::matrix &A, ub::matrix &VT, ub::vector &S ); /** * \brief inverts A via svd * @param A symmetric positive definite matrix * @param V inverse matrix * @param lower limit of condition number of the matrix, singular values below that will be set to zero * This function wraps the inversion of a matrix via svd */ int linalg_invert_svd(ub::matrix &A, ub::matrix &V,double limitCN); /** * \brief calculates loewdin transformation of matrices * @param J matrix to transform, returns transformed matrix * @param S, overlap matrix, returns S-1/2 * @param returns smallest eigenvalue of S * This function calculates the loewdin transformation of a matrix */ double linalg_loewdin(ub::matrix &J, ub::matrix &S); /** * \brief calculates matrix sqrt of a matrix * @param matrix to calculate sqrt of S, return S1/2 * This function calculates the sqrt of a matrix */ int linalg_matrixsqrt(ub::matrix &S); /** * \brief returns the the element with the largest absolute value of a matrix * @param matrix to find largest value of * returns the the element with the largest absolute value of a matrix */ double linalg_getMax( const ub::matrix& _matrix ); /** * * \brief returns the rms value of a matrix * @param matrix to find rms value of * returns the rms value of a matrix */ double linalg_getRMS(const ub::matrix& _matrix ); /** * \brief returns Tr(A*B) * @param A, first matrix * * @param B, second matrix * @param returns smallest eigenvalue of S * @param Trace of the product of two matrices * returns the the Trace of the product of two matrices */ double linalg_traceofProd(const ub::matrix& A,const ub::matrix& B ); /** * \brief solves A*x=b * @param A, first matrix * * @param b, inhomogenity, destroyed and contains the x afterwards * returns the the solves A*x=b for a matrix of b. */ bool linalg_solve(const ub::matrix &A, ub::vector &b); }} #endif /* __VOTCA_TOOLS_LINALG_H */ tools-1.4.1/include/votca/tools/linspline.h000066400000000000000000000050011315257650400207260ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _LINSPLINE_H #define _LINSPLINE_H #include "spline.h" #include #include #include #include namespace votca { namespace tools { namespace ub = boost::numeric::ublas; /** * \brief A Linear Spline Class * * class supports linear interpolation and linear fit of data */ class LinSpline : public Spline { public: // default constructor LinSpline() {}; //LinSpline() : // _boundaries(splineNormal) {} // destructor ~LinSpline() {}; // construct an interpolation spline // x, y are the the points to construct interpolation, both vectors must be of same size void Interpolate(ub::vector &x, ub::vector &y); // fit spline through noisy data // x,y are arrays with noisy data, both vectors must be of same size void Fit(ub::vector &x, ub::vector &y); // Calculate the function value double Calculate(const double &x); // Calculate the function derivative double CalculateDerivative(const double &x); // Calculate the function value for a whole array, story it in y template void Calculate(vector_type1 &x, vector_type2 &y); // Calculate the derivative value for a whole array, story it in y template void CalculateDerivative(vector_type1 &x, vector_type2 &y); protected: // a,b for piecewise splines: ax+b ub::vector a; ub::vector b; }; inline double LinSpline::Calculate(const double &r) { int interval = getInterval(r); return a(interval)*r + b(interval); } inline double LinSpline::CalculateDerivative(const double &r) { int interval = getInterval(r); return a(interval); } }} #endif /* _LINSPLINE_H */ tools-1.4.1/include/votca/tools/matrix.h000066400000000000000000000205201315257650400202400ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _mat_H #define _mat_H #include "types.h" #include "ostream" #include "vec.h" namespace votca { namespace tools { class matrix { public: matrix() {}; matrix(const double &v) { *this=v; } matrix(const matrix &m) { *this=m; } matrix(double arr[9]) {*this=arr; } matrix(const vec& a, const vec& b, const vec& c){ _m[0]=a.getX(); _m[1]=b.getX(); _m[2]=c.getX(); _m[3]=a.getY(); _m[4]=b.getY(); _m[5]=c.getY(); _m[6]=a.getZ(); _m[7]=b.getZ(); _m[8]=c.getZ(); } // takes three vectors and creates a matrix with them as columns void Invert(); matrix &operator=(const double &v); matrix &operator=(const matrix &v); matrix &operator=(double [9]); //vec &operator+=(const vec &v); //vec &operator-=(const vec &v); matrix &operator*=(const double &d){ for(size_t i=0; i<9; ++i) _m[i] *=d; return *this; } //matrix &operator*(const double &d){ //} matrix &operator/=(const double &d){ for(size_t i=0; i<9; ++i) _m[i] /=d; return *this; } matrix &operator-=(const matrix &v){ for(size_t i=0; i<9; ++i) _m[i] -= v._m[i]; return *this; } matrix &operator+=(const matrix &v){ for(size_t i=0; i<9; ++i) _m[i] += v._m[i]; return *this; } /** * \brief initialize the matrix with zeros */ void ZeroMatrix(); /** * \brief initialize the matrix as identity */ void UnitMatrix(); /** * \brief set an element of the matrix * @param i row * @param j column * @param v value */ void set(const byte_t &i, const byte_t &j, const double &v) { _m[i*3+j] = v; } /** * \brief get an element of the matrix */ const double &get(const byte_t &i, const byte_t &j) const { return _m[i*3+j]; } /** * \brief get a row vector * @param i row * @return row vector i */ vec getRow(const byte_t &i) const { return vec(&_m[i*3]); } /** * \brief get a column vector * @param i column * @return column vector i */ vec getCol(const byte_t &i) const { return vec(_m[i], _m[i+3], _m[i+6]); } /** * \brief direct read/write access * @param i row * @return pointer to beginning of row i * use it as matrix[a][b] */ double *operator[](size_t i) { return &_m[i*3]; } struct eigensystem_t { double eigenvalues[3]; vec eigenvecs[3]; eigensystem_t operator+=(const eigensystem_t &e) { eigenvalues[0]+=e.eigenvalues[0]; eigenvalues[1]+=e.eigenvalues[1]; eigenvalues[2]+=e.eigenvalues[2]; eigenvecs[0]+=e.eigenvecs[0]; eigenvecs[1]+=e.eigenvecs[1]; eigenvecs[2]+=e.eigenvecs[2]; return *this; } eigensystem_t operator*=(const double &f) { eigenvalues[0]*=f; eigenvalues[1]*=f; eigenvalues[2]*=f; eigenvecs[0]*=f; eigenvecs[1]*=f; eigenvecs[2]*=f; return *this; } void zero() { eigenvalues[0]=eigenvalues[1]=eigenvalues[2]=0; eigenvecs[0]=eigenvecs[1]=eigenvecs[2]=vec(0.,0.,0.); } }; /** * \brief create a uniform random rotation matrix * * Euler angles are not good for creating random rotations. This function * uses a method proposed by Arvo in Graphics Gems to produce uniform * random rotations. */ void RandomRotation(); /** * \brief calculate eigenvalues and eigenvectors * @param out struct containing eigenvals + eigenvecs */ void SolveEigensystem(eigensystem_t &out); /** * \brief transpose the matrix * @return the matrix after transpose * * After this operation, matrix stores the transposed value. */matrix &Transpose(){ std::swap( _m[1], _m[3]); std::swap( _m[2], _m[6]); std::swap( _m[5], _m[7]); return *this; } /** * \brief matrix-matrix product * @param a the matrix to multiply with * @return multiplied matrix */ matrix operator * (const matrix & a){ matrix r; r._m[0] = _m[0] * a._m[0] + _m[1] * a._m[3] + _m[2] * a._m[6]; r._m[1] = _m[0] * a._m[1] + _m[1] * a._m[4] + _m[2] * a._m[7]; r._m[2] = _m[0] * a._m[2] + _m[1] * a._m[5] + _m[2] * a._m[8]; r._m[3] = _m[3] * a._m[0] + _m[4] * a._m[3] + _m[5] * a._m[6]; r._m[4] = _m[3] * a._m[1] + _m[4] * a._m[4] + _m[5] * a._m[7]; r._m[5] = _m[3] * a._m[2] + _m[4] * a._m[5] + _m[5] * a._m[8]; r._m[6] = _m[6] * a._m[0] + _m[7] * a._m[3] + _m[8] * a._m[6]; r._m[7] = _m[6] * a._m[1] + _m[7] * a._m[4] + _m[8] * a._m[7]; r._m[8] = _m[6] * a._m[2] + _m[7] * a._m[5] + _m[8] * a._m[8]; return r; } /** * \brief matrix-vector product A*x * @param a vector * @return A*x */ vec operator * ( const vec & a){ return vec( _m[0] * a.getX() + _m[1] * a.getY() + _m[2] * a.getZ(), _m[3] * a.getX() + _m[4] * a.getY() + _m[5] * a.getZ(), _m[6] * a.getX() + _m[7] * a.getY() + _m[8] * a.getZ() ); } friend matrix operator*(const double &, const matrix &); friend vec operator*(const vec &, const matrix &); template void serialize(Archive &arch, const unsigned int version) { arch & _m; } private: double _m[9]; }; inline matrix &matrix::operator=(const double &v) { for(size_t i=0; i<9; ++i) _m[i] = v; return *this; } inline matrix &matrix::operator=(const matrix &m) { for(size_t i=0; i<9; ++i) _m[i] = m._m[i]; return *this; } inline matrix &matrix::operator=(double arr[9]) { for(size_t i=0; i<9; ++i) _m[i] = arr[i]; return *this; } inline void matrix::UnitMatrix() { ZeroMatrix(); _m[0] = _m[4] = _m[8] = 1.0; } inline void matrix::ZeroMatrix() { for(size_t i=0; i<9; ++i) _m[i] = 0.;//(*this) = 0.; } inline std::ostream &operator<<(std::ostream &out, matrix& m) { out << '|' << m[0][0] << ',' << m[0][1] << ',' << m[0][2] << '|' << std::endl; out << '|' << m[1][0] << ',' << m[1][1] << ',' << m[1][2] << '|' << std::endl; out << '|' << m[2][0] << ',' << m[2][1] << ',' << m[2][2] << '|' << std::endl; return out; } inline matrix operator|( const vec & a, const vec & b){ matrix res; res.set(0,0, a.getX() * b.getX()); res.set(0,1, a.getX() * b.getY()); res.set(0,2, a.getX() * b.getZ()); res.set(1,0, a.getY() * b.getX()); res.set(1,1, a.getY() * b.getY()); res.set(1,2, a.getY() * b.getZ()); res.set(2,0, a.getZ() * b.getX()); res.set(2,1, a.getZ() * b.getY()); res.set(2,2, a.getZ() * b.getZ()); return res; } inline matrix operator*(const matrix & r, const double &d){ return ( matrix(r) *= d); } inline matrix operator*(const double &d, const matrix &m) { matrix mm; for(size_t i=0; i<9; ++i) mm._m[i] = d*m._m[i]; return mm; } inline vec operator*(const matrix & r, const vec &a){ return matrix(r) * a; } inline matrix operator/(const matrix & r,const double &d){ return ( matrix(r) /= d); } inline matrix operator+(const matrix & r, const matrix & v){ return ( matrix(r) += v); } inline matrix operator-(const matrix & r, const matrix & v){ return ( matrix(r) -= v); } /* provided the matrix a diagonalizes it and returns the eigenvalues lambda0 = a[0][0], lambda1 = a[1][1], lambda2= a[2][2], ... as well as the corresponding eigenvectors v[][0], v[][1], v[][2] */ int cjcbi(matrix &a, matrix &v, double eps=1e-10, int jt=100); }} #endif /* _matrix_H */ tools-1.4.1/include/votca/tools/mutex.h000066400000000000000000000021731315257650400201020ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef MUTEX_H #define MUTEX_H #include namespace votca { namespace tools { /** \brief Convenient class for Mutexes * Class allows to create, lock and unlock mutexes. Destroying is handled * by the destructor. */ class Mutex { public: Mutex(); ~Mutex(); void Lock(); void Unlock(); private: pthread_mutex_t _mutexVar; }; } } #endif /* MUTEX_H */ tools-1.4.1/include/votca/tools/objectfactory.h000066400000000000000000000105011315257650400215700ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _objectfactory_H #define _objectfactory_H #include #include #include #include #include namespace votca { namespace tools { using namespace std; /** The REGISTER_OBJECT macro allows to easily register an object in an object factory. */ #define REGISTER_OBJECT(factory, object, key) \ namespace { \ ObjectFactoryRegister \ _register_##object(factory, key); \ } /** \brief template class for object factory This class is a template for an object factory. The factory creates an instance of an derived class, be giving a key (e.g. a string) for the object which identifies it uniquely. This allows the implementation of new features (e.g. new file formats, new mapping algorithms) without touching or recompiling existing bits of code. If you don't understand this, read the book by Alexandresku (Modern C++ design) everything explained there in detail! */ template class ObjectFactory { private: typedef T* (*creator_t)(); public: typedef T abstract_type; typedef map assoc_map; ObjectFactory() {} ~ObjectFactory() {}; /** * \brief register an object * \param key identifier * \param creator create policy * * This function is called to register an object in the factory. After an object is registered, * an instance of it can be created by calling Create specifying the corresponding key. */ void Register(const key_t &key, creator_t creator ); template< typename obj_t > void Register(const key_t &key); /** Create an instance of the object identified by key. */ T *Create(const key_t &key); bool IsRegistered(const key_t & _id) const; static ObjectFactory& Instance() { static ObjectFactory _this; return _this; } const assoc_map &getObjects() { return _objects; } private: assoc_map _objects; }; template parent* create_policy_new() { return new T(); } template inline void ObjectFactory::Register(const key_t &key, creator_t creator) { (void)_objects.insert(typename assoc_map::value_type(key, creator)).second; } template template< typename obj_t > inline void ObjectFactory::Register(const key_t &key) { Register(key, create_policy_new); } template inline T* ObjectFactory::Create(const key_t &key) { typename assoc_map::const_iterator it(_objects.find(key)); if (it != _objects.end()) return (it->second)(); else throw std::runtime_error("factory key " + boost::lexical_cast(key) + " not found."); } /*template inline static ObjectFactory& ObjectFactory::Instance() { static ObjectFactory _this; return _this; }*/ template inline bool ObjectFactory::IsRegistered(const key_t & _id) const { return ( _objects.find(_id)!= _objects.end() ); } /*std::string list_keys() const { std::stringstream _str; for (typename assoc_map::const_iterator it(map.begin()); it != map.end(); it++) { _str << (*it).first << "\n"; } return _str.str(); } */ template class ObjectFactoryRegister { public: template ObjectFactoryRegister(factory_type &factory, key_type &key) { factory.Register(key, &create_policy_new); } }; }} #endif /* _objectfactory_H */ tools-1.4.1/include/votca/tools/parsexml.h000066400000000000000000000074371315257650400206030ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _PARSEXML_H #define _PARSEXML_H #include #include #include #include namespace votca { namespace tools { using namespace std; /** \brief XML SAX parser (wrapper for expat) This class is a wrapper for the expat SAX interface. Parsing the xml file is done via callback functions (Element handlers). The class implements contains a stupid implementation for functors to handle callbacks to memeber functions but there is lots of room for improvement. So far only callbacks for start element handlers is implemented. The extension to EndElement handler (to signal if an element is close) is similar and straight forward. So far it was not needed and was therefore not done. */ class ParseXML { public: /// constructor ParseXML() {} /// destructor ~ParseXML() {} /** * \brief open an XML file and start parsing it * @param _filename file to read * * This functions opens a file and parses the nodes of an XML file. * Make sure to set the corresponding element handler before to redirect * element handling. */ void Open(const string &_filename); /** * \brief Set handler for next element (only member functions possible) * @param object instance of class which for callback * @param fkt member function for callback * * This function always has to be called after processing an element to * say what is coming next. Optionally call IgnoreElement */ template void NextHandler(T *object, void (T::*fkt)(const string &, map &)); /** * \brief Ignore the content of this elements and all of its childs */ void IgnoreChilds(); private: // virtual void ParseRoot(const string &el, map &attr); void ParseIgnore(const string &el, map &attr); /// end element callback for xml parser void StartElemHndl(const string &el, map &attr); /// end element callback for xml parser void EndElemHndl(const string &el); class Functor { public: Functor() {} virtual void operator()(const string &, map &) = 0; virtual ~Functor() {}; }; template class FunctorMember : public Functor { public: typedef void (T::*fkt_t)(const string &, map &); FunctorMember(T* cls, fkt_t fkt) : _cls(cls), _fkt(fkt) {} void operator()(const string &el, map & attr) { (_cls->*_fkt)(el, attr); } private: T* _cls; fkt_t _fkt; }; stack _stack_handler; Functor *_handler; friend void start_hndl(void *data, const char *el, const char **attr); friend void end_hndl(void *data, const char *el); }; inline void ParseXML::IgnoreChilds() { NextHandler(this, &ParseXML::ParseIgnore); } template inline void ParseXML::NextHandler(T *object, void (T::*fkt)(const string &, map &)) { _handler = dynamic_cast(new FunctorMember(object, fkt)); _stack_handler.push(_handler); } }} #endif tools-1.4.1/include/votca/tools/property.h000066400000000000000000000222611315257650400206240ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _VOTCA_TOOLS_PROPERTY_H #define _VOTCA_TOOLS_PROPERTY_H #include #include #include #include #include #include "lexical_cast.h" #include #include #include "vec.h" #include "tokenizer.h" namespace votca { namespace tools { /** * \brief class to manage program options with xml serialization functionality * * This class stores tags and content in a hierarchical (tree) structure similar * to the one used in the XML format. The structure can be either filled manually * or read in from an XML file using load_property_from_xml. * The supported XML constructs are TAGS, ATTRIBUTES, and CONTENT: * * content * * The property object can be output to an ostream using format modifiers: * cout << XML << property; * Supported formats are XML, TXT, TEX, HLP */ class Property { /// \brief outputs the property to the ostream friend std::ostream &operator<<(std::ostream &out, Property& p); public: Property() : _path("") {} Property(const string &name, const string &value, const string &path) : _name(name), _value(value), _path(path) {} /** * \brief add a new property to structure * @param key identifier * @param value value * @return reference to the created Property object */ Property &add(const string &key, const string &value); /** * \brief set value of existing property * @param key identifier * @param value value * @return reference to the created Property object */ Property &set(const string &key, const string &value); /** * \brief get existing property * @param key identifier * @return Reference to property object * * This function tries to find a property specified by key separated * by "." to step down hierarchy. If the property is not * found a runtime_exception is thrown. */ Property &get(const string &key); /** * \brief check whether property exists * @param key identifier * @return true or false */ bool exists(const string &key); /** * \brief select property based on a filter * @param filter * @return list of pointers to property objects * * returns a list of properties that match the key criteria including * wildcards "*" and "?". Example: "base.item*.value" */ std::list Select(const string &filter); /** * \brief reference to value of property * @return string content */ string &value() { return _value; } /** * \brief name of property * @return name */ string name() { return _name; } /** * \brief full path of property (including parents) * @return path * * e.g. cg.inverse.value */ string path() { return _path; } /** * \brief return value as type * * returns the value after type conversion, e.g. * p.as() returns an integer */ template T as() const; /** * \brief does the property has childs? * \return true or false */ bool HasChilds() { return !_map.empty(); } /// iterator to iterate over properties typedef list::iterator iterator; /// \brief iterator to first child property iterator begin() { return _properties.begin(); } /// \brief end iterator for child properties iterator end() { return _properties.end(); } /// \brief number of child properties list::size_type size() { return _properties.size(); } // throw error and comment (with filename+code line) void throwRuntimeError(string message); /** * \brief return attribute as type * * returns an attribute after type conversion, e.g. * p.getAttribute() returns an integer */ template T getAttribute(const string &attribute); /** * \brief set an attribute */ template void setAttribute(const string &attribute, const T &value); /** * \brief return true if a node has attributes */ bool hasAttributes() { return _attributes.size() > 0; } /** * \brief return true if an attribute exists */ bool hasAttribute(const string &attribute); /** for iterator-based access of Attributes */ typedef std::map::iterator AttributeIterator; /** * \brief returns an iterator to an attribute */ AttributeIterator findAttribute(const string &attribute){ return _attributes.find(attribute); } /** * \brief returns an iterator to the first attribute */ AttributeIterator firstAttribute(){ return _attributes.begin(); } /** * \brief returns an iterator to the last attribute */ AttributeIterator lastAttribute(){ return _attributes.end(); } /** * \brief return attribute as type * * returns an attribute after type conversion, e.g. * p.getAttribute() returns an integer */ template T getAttribute( AttributeIterator it); static int getIOindex(){return IOindex;}; private: map _map; map _attributes; list _properties; string _name; string _value; string _path; static const int IOindex; }; inline Property &Property::set(const string &key, const string &value) { Property &p = get(key); p.value() = value; return p; } inline Property &Property::add(const string &key, const string &value) { string path = _path; if(path != "") path = path + "."; _properties.push_back(Property(key, value, path + _name )); _map[key] = &(_properties.back()); return _properties.back(); } inline bool Property::exists(const string &key) { try { get(key); } catch(std::exception &err) { return false;} return true; } bool load_property_from_xml(Property &p, string file); // TO DO: write a better function for this!!!! template<> inline bool Property::as() const { if(_value == "true" || _value == "TRUE" || _value == "1") return true; else return false; } template inline T Property::as() const { return lexical_cast(_value, "wrong type in " + _path + "." + _name + "\n"); } template<> inline std::string Property::as() const { string tmp(_value); boost::trim(tmp); return tmp; } template<> inline vec Property::as() const { vector tmp; Tokenizer tok(as (), " ,"); tok.ConvertToVector(tmp); if (tmp.size() != 3) throw runtime_error("Vector has " + boost::lexical_cast (tmp.size()) + " instead of three entries"); return vec(tmp[0], tmp[1], tmp[2]); } template<> inline vector Property::as >() const { vector tmp; Tokenizer tok(as (), " ,"); tok.ConvertToVector(tmp); return tmp; } template<> inline vector Property::as >() const { vector tmp; Tokenizer tok(as (), " ,\n\t"); tok.ConvertToVector(tmp); return tmp; } template<> inline vector Property::as >() const { vector tmp; Tokenizer tok(as (), " ,\n\t"); tok.ConvertToVector(tmp); return tmp; } inline bool Property::hasAttribute(const string &attribute) { std::map::iterator it; it = _attributes.find(attribute); if ( it == _attributes.end() ) return false; return true; } template inline T Property::getAttribute(std::map::iterator it) { if (it != _attributes.end()) { return lexical_cast((*it).second); } else { throw std::runtime_error("attribute " + (*it).first + " not found\n"); } } template inline T Property::getAttribute(const string &attribute) { std::map::iterator it; it = _attributes.find(attribute); if (it != _attributes.end()) { return lexical_cast(_attributes[attribute], "wrong type in attribute " + attribute + " of element " + _path + "." + _name + "\n"); } else { throw std::runtime_error("attribute " + attribute + " not found\n"); } } template inline void Property::setAttribute(const string &attribute, const T &value) { _attributes[attribute] = lexical_cast(value, "wrong type to set attribute"); } inline void throwRuntimeError(string message) { } }} #endif /* _VOTCA_TOOLS_PROPERTY_H */ tools-1.4.1/include/votca/tools/propertyiomanipulator.h000066400000000000000000000051161315257650400234300ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _VOTCA_TOOLS_PROPERTY_IO_MANIPULATOR_H #define _VOTCA_TOOLS_PROPERTY_IO_MANIPULATOR_H #include #include "property.h" #include "colors.h" namespace votca { namespace tools { /** * \brief Manipulates the format state of the output stream * * Changes the state of the output stream. Property class reads this state * and formats its output according to this state (XML, TXT, T2T, etc) */ class PropertyIOManipulator { public: enum Type{ XML, HLP, TEX, TXT }; explicit PropertyIOManipulator( Type type = XML, int level = 0, std::string indentation = "", ColorSchemeBase *color_scheme = NULL ) : _type(type), _level(level), _indentation(indentation), _color_scheme(color_scheme) { ; } ~PropertyIOManipulator() { delete _color_scheme; } friend std::ostream& operator << (std::ostream& os, PropertyIOManipulator& piom ) { os.pword( Property::getIOindex() ) = &piom; return os; } const Type &getType(){return _type;} void setType( Type type ){ _type = type; } const int &getLevel (){return _level; } void setLevel (int level){ _level = level; } const std::string &getIndentation(){return _indentation;} void setIndentation(std::string indentation){_indentation = indentation;} const ColorSchemeBase *getColorScheme() { if ( !_color_scheme ) return &DEFAULT_COLORS; return _color_scheme; } template const ColorSchemeBase *setColorScheme() { if (_color_scheme) delete _color_scheme; _color_scheme = new Color(); return _color_scheme; } private: Type _type; int _level; std::string _indentation; ColorSchemeBase* _color_scheme; }; extern PropertyIOManipulator XML; extern PropertyIOManipulator TXT; extern PropertyIOManipulator TEX; extern PropertyIOManipulator HLP; }} #endif /* _VOTCA_TOOLS_PROPERTY_FORMAT_H */ tools-1.4.1/include/votca/tools/random.h000066400000000000000000000035111315257650400202150ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /************************************************* MARSAGLIA pseudo random number generator See: G. Marsaglia and A. Zaman. Toward a universal random number generator, Statistics & Probability Letters, 9(1):35–39, 1990. This function returns a double precision floating point number uniformly distributed in the range [0,1) *************************************************/ #ifndef _RANMARS_H_ #define _RANMARS_H_ #include #include #include #define MARS_FIELD_SIZE 98 #define _pi 3.1415926535897932384626433832795 namespace votca { namespace tools { /** \brief MARSAGLIA pseudo random number generator This class generates double precision floating point numbers uniformly distributed in the range [0,1) */ class Random { public: static void init( int nA1, int nA2, int nA3, int nB1 ); static double rand_uniform( void ); static int rand_uniform_int( int max_int ); static double rand_gaussian( double sigma ); static void save( char *fileName ); static void restore( char *fileName ); private: static double *MARSarray, MARSc, MARScd, MARScm ; static int MARSi, MARSj ; }; }} #endif /* _RANMARS_H_ */ tools-1.4.1/include/votca/tools/random2.h000066400000000000000000000035121315257650400203000ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /************************************************* MARSAGLIA pseudo random number generator See: G. Marsaglia and A. Zaman. Toward a universal random number generator, Statistics & Probability Letters, 9(1):35–39, 1990. This function returns a double precision floating point number uniformly distributed in the range [0,1) *************************************************/ #ifndef _RANMARS2_H_ #define _RANMARS2_H_ #include #include #include #define MARS_FIELD_SIZE 98 #define _pi 3.1415926535897932384626433832795 namespace votca { namespace tools { /** \brief MARSAGLIA pseudo random number generator This class generates double precision floating point numbers uniformly distributed in the range [0,1) */ class Random2 { public: Random2() {}; ~Random2() {}; void init( int nA1, int nA2, int nA3, int nB1 ); void save( char *fileName ); void restore( char *fileName ); double rand_uniform( void ); int rand_uniform_int( int max_int ); double rand_gaussian( double sigma ); private: double *MARSarray, MARSc, MARScd, MARScm ; int MARSi, MARSj ; }; }} #endif /* _RANMARS2_H_ */ tools-1.4.1/include/votca/tools/rangeparser.h000066400000000000000000000072011315257650400212460ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _RANGEPARSER_H #define _RANGEPARSER_H #include #include #include namespace votca { namespace tools { using namespace std; /** * \brief RangeParser * * parse strings like min:step:max, not flexible enough yet to be really useful */ class RangeParser { public: RangeParser(); void Parse(string range); void Add(int begin, int end, int stride=1); private: struct block_t { block_t() {} block_t(const int &begin, const int &end, const int &stride) : _begin(begin), _end(end), _stride(stride) {} int _begin, _end, _stride; }; public: struct iterator { iterator() {} int operator*() const { return _current; } RangeParser::iterator &operator++(); bool operator==(const RangeParser::iterator &); bool operator!=(const RangeParser::iterator &); private: RangeParser *_parent; iterator(RangeParser *, list::iterator); list::iterator _block; int _current; friend class RangeParser; }; RangeParser::iterator begin(); RangeParser::iterator end(); private: void ParseBlock(string block); int ToNumber(string str); list< block_t > _blocks; //bool _has_begin, _has_end; //int _begin, _end; friend std::ostream &operator<<(std::ostream &out, const RangeParser &rp); }; inline void RangeParser::Add(int begin, int end, int stride) { _blocks.push_back(block_t(begin, end, stride)); } inline RangeParser::iterator RangeParser::begin() { return RangeParser::iterator(this, _blocks.begin()); } inline RangeParser::iterator RangeParser::end() { return RangeParser::iterator(this, _blocks.end()); } inline RangeParser::iterator::iterator(RangeParser *parent, list::iterator block) : _parent(parent), _block(block) { if(block != parent->_blocks.end()) _current = (*block)._begin; else _current = -1; } inline bool RangeParser::iterator::operator==(const RangeParser::iterator &i) { return (_block == i._block) && (_current == i._current); } inline bool RangeParser::iterator::operator!=(const RangeParser::iterator &i) { return !((_block == i._block) && (_current == i._current)); } inline std::ostream &operator<<(std::ostream &out, const RangeParser &rp) { std::list< RangeParser::block_t >::const_iterator iter(rp._blocks.begin()); for(; iter!=rp._blocks.end(); ++iter) { if(iter!=rp._blocks.begin()) out << ","; if(iter->_begin == iter->_end) out << iter->_begin; else if(iter->_stride == 1) out << iter->_begin << ":" << iter->_end; else out << iter->_begin << ":" << iter->_stride << ":" << iter->_end; } return out; } }} #endif /* _RANGEPARSER_H */ tools-1.4.1/include/votca/tools/spline.h000066400000000000000000000147271315257650400202420ustar00rootroot00000000000000/* * Copyright 2010-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_SPLINE_H #define __VOTCA_SPLINE_H #include #include #include namespace votca{namespace tools{ namespace ub = boost::numeric::ublas; /** * \brief Spline Class * * class supports spline interpolation and fit of data * the cubic spline class, akima spline class and linear spline class are inherited from this one */ class Spline { public: Spline() : _boundaries(splineNormal) {} virtual ~Spline() {} /** * \brief Calculate interpolating spline for given (x,y) values. Points on resulting spline can be obtained via Calculate(). * \param x values of data to be interpolated * \param y values of data to be interpolated * both vectors must be of same size */ virtual void Interpolate(ub::vector &x, ub::vector &y) = 0; /** * \brief Fit spline through noisy (x,y) values. Points on resulting fitted spline can be obtained via Calculate(). * \param x values of data to be fitted * \param y values of data to be fitted * both vectors must be of same size */ virtual void Fit(ub::vector &x, ub::vector &y) = 0; /** * \brief Calculate spline function value for a given x value on the spline created by Interpolate() or Fit() * \param x data value * \return y value */ virtual double Calculate(const double &x) = 0; /** * \brief Calculate y value for a given x value on the derivative of the spline created by function Interpolate or Fit * \param x data value * \return y value of derivative */ virtual double CalculateDerivative(const double &x) = 0; /// enum for type of boundary condition enum eBoundary { splineNormal = 0, ///< normal boundary conditions: \f$f_0=f_N=0\f$ splinePeriodic = 1, ///< periodic boundary conditions: \f$f_0=f_N\f$ splineDerivativeZero = 2 ///< derivatives and end-points are zero. }; /** * \brief Set the boundary type of the spline * \param boundary of type eBoundary */ void setBC(eBoundary bc) {_boundaries = bc;} /** * \brief Set the boundary type of the spline * \param boundary of type int */ void setBCInt(int bc) { switch(bc){ case 0: _boundaries = splineNormal; break; case 1: _boundaries = splinePeriodic; break; case 2: _boundaries = splineDerivativeZero; break; } } /** * \brief Get the grid point of certain index * \param index of grid point * \return grid value */ inline double getGridPoint(const size_t &i); /** * \brief Calculate spline function values for given x values on the spline created by Interpolate() or Fit() * \param vector of x data values * \return vector of y value */ template inline void Calculate(vector_type1 &x, vector_type2 &y); /** * \brief Calculate y values for given x values on the derivative of the spline created by function Interpolate or Fit * \param vector of x data values * \return vector of y value */ template inline void CalculateDerivative(vector_type1 &x, vector_type2 &y); /** * \brief Print spline values (using Calculate()) on output "out" on the entire grid in steps of "interval" * \param reference "out" to output * \param steps of size "interval" */ inline void Print(std::ostream &out, double interval); /** * \brief Determine the index of the interval containing value r * \param value r * \return interval index */ inline int getInterval(const double &r); /** * \brief Generate the grid for fitting from "min" to "max" in steps of "h" * \param left interval border "min" * \param right interval border "max" * \param step "h" * \return number of grid values in the interval */ int GenerateGrid(double min, double max, double h); /** * \brief Get the grid array x * \return pointer to the corresponding array */ ub::vector &getX() {return _r; } /** * \brief Get the spline data _f * \return pointer to the corresponding array */ ub::vector &getSplineF() { return _f; } /** * \brief Get second derivatives (cubic splines) * \return pointer to the corresponding array */ ub::vector &getSplineF2() { return _f2; } protected: eBoundary _boundaries; // the grid points ub::vector _r; // y values of grid points ub::vector _f; // second derivatives of grid points ub::vector _f2; }; template inline void Spline::Calculate(vector_type1 &x, vector_type2 &y) { for(size_t i=0; i inline void Spline::CalculateDerivative(vector_type1 &x, vector_type2 &y) { for(size_t i=0; i _r[_r.size() - 2]) return _r.size()-2; size_t i; for(i=0; i<_r.size(); ++i) if(_r[i]>r) break; return i-1; } inline double Spline::getGridPoint(const size_t &i) { if(i>=_r.size()) { return 0; } return _r[i]; } }} #endif /* __VOTCA_SPLINE_H */ tools-1.4.1/include/votca/tools/statement.h000066400000000000000000000050541315257650400207450ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_STATEMENT_H #define __VOTCA_TOOLS_STATEMENT_H #include #include #include #include "lexical_cast.h" namespace votca { namespace tools { class Database; /** * \brief Wrapper for sqlite prepared statements * * The Statement class wraps the interface to sqlite_stmt. It checks * for some of the basic errors and throws an exception in case * one occurs. */ class Statement { public: ~Statement(); /** * \brief bind a value to prepared statement * @param col column number, sqlite starts counting with 1 * @param value value */ template void Bind(int col, const T &value); /** * \brief read a column after a select statement was executed * @param col column number, sqlite starts counting with 0 here */ template T Column(int col); /** * \brief perform a step * @return sqlite return code, see sqlite manual for details */ int Step(); /** * \brief perform an insert step * * This is basically just a call to Step and does an additional * error check if SQLITE_DONE was returned (= insert successful). * If not an exception is thrown. */ int InsertStep(); /** * \brief reset the statment to perform another insert or query */ void Reset(); sqlite3_stmt *getSQLiteStatement() { return _stmt; } protected: Statement(sqlite3_stmt *stmt) : _stmt(stmt) {} sqlite3_stmt *_stmt; friend class Database; }; inline int Statement::InsertStep() { int ret = Step(); if(ret != SQLITE_DONE) throw std::runtime_error("Statment::Step did not return SQLITE_DONE. Return code was " + boost::lexical_cast(ret) + "\n" "This might be caused be a failed insert statement to the database."); return ret; } }} #endif tools-1.4.1/include/votca/tools/table.h000066400000000000000000000105021315257650400200220ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _TABLE_H #define _TABLE_H #include #include #include namespace votca { namespace tools { using namespace std; namespace ub = boost::numeric::ublas; // the entry is invalid, e.g. could not be calculated (ln(0), ...) #define TBL_INVALID 1 /** \brief class to store tables like rdfs, tabulated potentials, etc \think about weather to make this a template, can be used in histogram as well, of for counting with integeers... */ class Table { public: Table() ; Table(Table &tbl); ~Table() {}; void clear(void); void GenerateGridSpacing(double min, double max, double spacing); // void resize(int N, bool preserve=true) { _x.resize(N, preserve); _y.resize(N, preserve); _flags.resize(N, preserve); } void resize(int N, bool preserve=true); unsigned int size() const {return _x.size(); } double &x(int i) { return _x[i]; } double &y(int i) { return _y[i]; } char &flags(int i) { return _flags[i]; } double &yerr(int i) { return _yerr[i]; } void set(const int &i, const double &x, const double &y) { _x[i] = x; _y[i]=y; } void set(const int &i, const double &x, const double &y, const char &flags) { _x[i] = x; _y[i]=y; _flags[i] = flags; } void set(const int &i, const double &x, const double &y, const char &flags, const double &yerr) { _x[i] = x; _y[i]=y; _flags[i] = flags; _yerr[i] = yerr; } void set_comment(const string comment) {_has_comment=true; _comment_line = comment;} void Load(string filename); void Save(string filename) const; void Smooth(int Nsmooth); bool GetHasYErr() { return _has_yerr; } void SetHasYErr(bool has_yerr) { _has_yerr = has_yerr; } ub::vector &x() { return _x; } ub::vector &y() { return _y; } ub::vector &flags() { return _flags; } ub::vector &yerr() { return _yerr; } void push_back(double x, double y, char flags); const string &getErrorDetails() { return _error_details; } void setErrorDetails(string str) { _error_details = str; } private: ub::vector _x; ub::vector _y; ub::vector _flags; ub::vector _yerr; string _error_details; bool _has_yerr; bool _has_comment; friend ostream &operator<<(ostream &out, const Table& v); friend istream &operator>>(istream &out, Table& v); string _comment_line; }; inline Table::Table() { _has_yerr = false; _error_details = ""; } inline Table::Table(Table &tbl) { resize(tbl.size()); _x = tbl._x; _y = tbl._y; _flags = tbl._flags; _has_yerr = tbl._has_yerr; if (_has_yerr) _yerr = tbl._yerr; _has_comment = false; _error_details = ""; } inline ostream &operator<<(ostream &out, const Table& t) { //TODO: use a smarter precision guess, XXX.YYYYY=8, so 10 should be enough out.precision(10); if ( t._has_yerr ) { for(size_t i=0; i>(istream &in, Table& t); }} #endif /* _TABLE_H */ tools-1.4.1/include/votca/tools/thread.h000066400000000000000000000031501315257650400202030ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef THREAD_H #define THREAD_H #include namespace votca { namespace tools { /** \brief Framework for threaded execution * The Thread class handles the threaded execution of VOTCA code. * In its current state, it is based on POSIX threads. * It mainly contains a wrapper, a start and a wait function. * This class should not be touched by the user. */ class Thread { public: Thread(); virtual ~Thread(); void Start(); /** * \brief Run() executes the actual code. Overload it. */ virtual void Run(void) = 0; /** * \brief WaitDone() will not exit until thread ends computation. */ void WaitDone(); bool IsFinished() const; private: pthread_t _thread; bool _finished; }; } } #endif /* THREAD_H */ tools-1.4.1/include/votca/tools/tokenizer.h000066400000000000000000000062661315257650400207610ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _tools_H #define _tools_H #include #include #include #include namespace votca { namespace tools { /** * \brief break string into words * * This class wraps boost::tokenizer to break a string into words. A list of * delimeters can be freely choosen. */ class Tokenizer { public: typedef boost::tokenizer >::iterator iterator; /** * \brief startup tokenization * @param str string to break up * @param separators list of separators * * After initialization,the words can be accessed using the iterator * interface or directly transferred to a vector ToVector of ConvertToVector. */ Tokenizer(const std::string &str, const char *separators) { _str = str; boost::char_separator sep(separators); tok = new boost::tokenizer >(_str, sep); //boost::escaped_list_separator sep(" ", separators, "\""); //tok = new boost::tokenizer >(str, sep); } ~Tokenizer() { delete tok; } /** * \brief iterator to first element * @return begin iterator */ iterator begin() { return tok->begin(); } /** * \brief end iterator * @return end iterator */ iterator end() { return tok->end(); } /** * \brief store all words in a vector of strings. * @param v storage vector * * This class appends all words to a vector of strings. */ void ToVector(std::vector &v) { for(iterator iter=begin(); iter!=end(); ++iter) v.push_back(*iter); } /** * \brief store all words in a vector with type conversion. * @param v storage vector * * This class appends all words to a vector of arbitrary type (e.g. double) * and also does type conversion. */ template < typename T > void ConvertToVector(std::vector &v){ std::vector tmp; ToVector(tmp); v.resize(tmp.size()); typename std::vector::iterator viter = v.begin(); typename std::vector::iterator iter; for(iter = tmp.begin(); iter!=tmp.end(); ++iter, ++viter) *viter = boost::lexical_cast(*iter); } private: boost::tokenizer< boost::char_separator > *tok; std::string _str; }; int wildcmp(const char *wild, const char *string); }} #endif /* _tools_H */ tools-1.4.1/include/votca/tools/types.h000066400000000000000000000015031315257650400201000ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _types_H #define _types_H namespace votca { namespace tools { typedef unsigned char byte_t; typedef unsigned short word_t; typedef unsigned long dword_t; }} #endif /* _types_H */ tools-1.4.1/include/votca/tools/vec.h000066400000000000000000000201051315257650400175100ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _vec_H #define _vec_H #include #include #include #include #include #include "tokenizer.h" namespace votca { namespace tools { using namespace std; /** \brief Vector class for a 3 component vector This class represents a 3 component vector to store e.g. postitions, velocities, forces, ... Operators for basic vector-vector and vector-scalar operations are defined. you can access the elements with the functions x(), y(), z(), both reading and writing is possible; x + v.x(); v.x() = 5.; */ class vec { public: vec(); vec(const vec &v); vec(const double r[3]); vec(const double &x, const double &y, const double &z); vec(const boost::numeric::ublas::vector &v); vec(const string &str); vec &operator=(const vec &v); vec &operator+=(const vec &v); vec &operator-=(const vec &v); vec &operator*=(const double &d); vec &operator/=(const double &d); /** * \brief get full access to x element * @return reference to x */ double &x() { return _x; } /** * \brief get full access to y element * @return reference to y */ double &y() { return _y; } /** * \brief get full access to z element * @return reference to z */ double &z() { return _z; } void setX(const double &x) { _x = x; } void setY(const double &y) { _y = y; } void setZ(const double &z) { _z = z; } /** * \brief read only access to x element * @return x const reference to x * * This function can be usefule when const is used to allow for better * optimization. Always use getX() instead of x() if possible. */ const double &getX() const { return _x; } /** * \brief read only access to y element * @return x const reference to y * * This function can be usefule when const is used to allow for better * optimization. Always use getY() instead of y() if possible. */ const double &getY() const { return _y; } /** * \brief read only access to z element * @return x const reference to z * * This function can be usefule when const is used to allow for better * optimization. Always use getZ() instead of Z() if possible. */ const double &getZ() const { return _z; } /** * \brief normalize the vector * @return normalized vector * This function normalizes the vector and returns itself after normalization. * After this call, the vector stores the normalized value. */ vec &normalize(); boost::numeric::ublas::vector converttoub(); template void serialize(Archive &arch, const unsigned int version) { arch & _x; arch & _y; arch & _z; } private: double _x, _y, _z; }; inline vec::vec() {} inline vec::vec(const vec &v) : _x(v._x), _y(v._y), _z(v._z) {} inline vec::vec(const double r[3]) : _x(r[0]), _y(r[1]), _z(r[2]) {} inline vec::vec(const boost::numeric::ublas::vector &v) {try {_x=v(0); _y=v(1); _z=v(2); } catch(std::exception &err){throw std::length_error("Conversion from ub::vector to votca-vec failed");} } inline vec::vec(const string &str) { // usage: vec(" 1 2.5 17 "); separator = spaces Tokenizer tok(str, " "); vector< string > values; tok.ToVector(values); if (values.size()!=3) { throw std::runtime_error("\n\n\t error, string to vec, size!=3\n\n"); } try { _x = boost::lexical_cast(values[0]); _y = boost::lexical_cast(values[1]); _z = boost::lexical_cast(values[2]); } catch(const boost::bad_lexical_cast& e) { throw std::runtime_error("\n\n\t error, string to vec, can't convert string to double\n\n"); } } inline vec::vec(const double &x, const double &y, const double &z) : _x(x), _y(y), _z(z) {} inline bool operator==(const vec &v1, const vec &v2) { return ((v1.getX()==v2.getX()) && (v1.getY()==v2.getY()) && (v1.getZ()==v2.getZ())); } inline bool operator!=(const vec &v1, const vec &v2) { return ((v1.getX()!=v2.getX()) || (v1.getY()!=v2.getY()) || (v1.getZ()==v2.getZ())); } inline vec &vec::operator=(const vec &v) { _x=v._x; _y=v._y; _z=v._z; return *this; } inline vec &vec::operator+=(const vec &v) { _x+=v._x; _y+=v._y; _z+=v._z; return *this; } inline vec &vec::operator-=(const vec &v) { _x-=v._x; _y-=v._y; _z-=v._z; return *this; } inline vec &vec::operator*=(const double &d) { _x*=d; _y*=d; _z*=d; return *this; } inline vec &vec::operator/=(const double &d) { _x/=d; _y/=d; _z/=d; return *this; } inline vec operator+(const vec &v1, const vec &v2) { return (vec(v1)+=v2); } inline vec operator-(const vec &v1, const vec &v2) { return (vec(v1)-=v2); } inline vec operator-(const vec &v1){ return vec (-v1.getX(), -v1.getY(), -v1.getZ()); } inline vec operator*(const vec &v1, const double &d) { return (vec(v1)*=d); } inline vec operator*(const double &d, const vec &v1) { return (vec(v1)*=d); } inline vec operator/(const vec &v1, const double &d) { return (vec(v1)/=d); } inline std::ostream &operator<<(std::ostream &out, const vec& v) { out << '[' << v.getX() << ", " << v.getY() << ", " << v.getZ() << ']'; return out; } inline std::istream &operator>>(std::istream &in, vec& v) { char c; in.get(c); if(c != '[') { throw std::runtime_error("error, invalid character in vector string"); } string str; while (in.good()) { in.get(c); if(c==']') { // found end of vector Tokenizer tok(str, ","); vector d; tok.ConvertToVector(d); if(d.size() != 3) throw std::runtime_error("error, invalid number of entries in vector"); v.setX(d[0]); v.setY(d[1]); v.setZ(d[2]); return in; } str += c; } throw std::runtime_error("did not find closing bracket in string to vec conversion"); return in; } /// dot product inline double operator*(const vec &v1, const vec &v2) { return v1.getX()*v2.getX() + v1.getY()*v2.getY() + v1.getZ()*v2.getZ(); } /// cross product inline vec operator^(const vec &v1, const vec &v2) { return vec( v1.getY()*v2.getZ() - v1.getZ()*v2.getY(), v1.getZ()*v2.getX() - v1.getX()*v2.getZ(), v1.getX()*v2.getY() - v1.getY()*v2.getX() ); } /// elementwise product inline vec elementwiseproduct(const vec &v1, const vec &v2) { return vec( v1.getX()*v2.getX() , v1.getY()*v2.getY() , v1.getZ()*v2.getZ() ); } inline double abs(const vec &v) { return sqrt(v*v); } inline double maxnorm(const vec &v) { return ( std::abs(v.getX()) > std::abs(v.getY()) ) ? ( ( std::abs(v.getX()) > std::abs(v.getZ()) ) ? std::abs(v.getX()) : std::abs(v.getZ()) ) : ( ( std::abs(v.getY()) > std::abs(v.getZ()) ) ? std::abs(v.getY()) : std::abs(v.getZ()) ); } inline vec &vec::normalize() { return ((*this)*=1./abs(*this)); } inline boost::numeric::ublas::vector vec::converttoub() { boost::numeric::ublas::vector temp=boost::numeric::ublas::zero_vector(3); temp(0)=_x; temp(1)=_y; temp(2)=_z; return temp; } }} #endif /* _vec_H */ tools-1.4.1/include/votca/tools/version.h000066400000000000000000000014731315257650400204270ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _tools_version_H #define _tools_version_H #include namespace votca { namespace tools { const std::string & ToolsVersionStr(); }} #endif /* _tools_version_H */ tools-1.4.1/include/votca/tools/votca_config.h.in000066400000000000000000000020211315257650400217760ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __VOTCA_TOOLS_VOTCA_CONFIG_H #define __VOTCA_TOOLS_VOTCA_CONFIG_H /* Compile without fftw and disable CrossCorrelate class */ #cmakedefine NOFFTW /* OpenMP */ #if defined(_OPENMP) #include #endif /* Linear algebra packages */ #cmakedefine MKL #cmakedefine GSL /* Version number of package */ #define TOOLS_VERSION "@PROJECT_VERSION@" #endif // __VOTCA_TOOLS_VOTCA_CONFIG_H tools-1.4.1/include/votca/tools/votca_gsl_boost_ublas_matrix_prod.h000066400000000000000000000207011315257650400257220ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _GSL_BOOST_UBLAS_MATRIX_PROD_ #define _GSL_BOOST_UBLAS_MATRIX_PROD_ #include #include #include #include namespace boost { namespace numeric { namespace ublas { /* * GSL has separate implementations for floats and doubles * hence we first have specializations for these two types * TSeparate templates for diagonal and symmetric matreces * and their combinations. To check whether a specific * routine is called, define GSLDEBUG */ // partial specialization for double precision (dgemm)) template inline matrix // prod( m1, m2 ) prod(const matrix &m1, const matrix &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;34mGSL [CMD,CM]\x1b[0;39m\n" << std::flush; #endif gsl_matrix_const_view mA = gsl_matrix_const_view_array (&m1(0,0), m1.size1(), m1.size2()); gsl_matrix_const_view mB = gsl_matrix_const_view_array (&m2(0,0), m2.size1(), m2.size2()); boost::numeric::ublas::matrix AxB( m1.size1(), m2.size2() ); gsl_matrix_view mC = gsl_matrix_view_array (&AxB(0,0), AxB.size1(), AxB.size2()); gsl_blas_dgemm (CblasNoTrans, CblasNoTrans, 1.0, &mA.matrix, &mB.matrix, 0.0, &mC.matrix); return AxB; } // partial specialization for single precision (sgemm)) template inline matrix // prod( m1, m2 ) prod(const matrix &m1, const matrix &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;34mGSL [CMS,CM]\x1b[0;39m\n" << std::flush; #endif gsl_matrix_float_const_view mA = gsl_matrix_float_const_view_array (&m1(0,0), m1.size1(), m1.size2()); gsl_matrix_float_const_view mB = gsl_matrix_float_const_view_array (&m2(0,0), m2.size1(), m2.size2()); boost::numeric::ublas::matrix AxB( m1.size1(), m2.size2() ); gsl_matrix_float_view mC = gsl_matrix_float_view_array (&AxB(0,0), AxB.size1(), AxB.size2()); gsl_blas_sgemm (CblasNoTrans, CblasNoTrans, 1.0, &mA.matrix, &mB.matrix, 0.0, &mC.matrix); return AxB; } // full specialization template inline matrix // prod( m1, m2 ) prod(const matrix &m1, const matrix &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;34mGSL [CM,CM]\x1b[0;39m -> " << std::flush; #endif return prod(m1,m2); } /// transpose products template inline matrix // prod( trans(m1), m2 ) prod(const matrix_unary2,scalar_identity > &m1, const matrix &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;32mGSL [CTM,CM]\x1b[0;39m -> " << std::flush; #endif boost::numeric::ublas::matrix _m1 = m1; return prod(_m1,m2); } template inline matrix // prod( m1, trans(m2) ) prod(const matrix &m1, const matrix_unary2,scalar_identity > &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;32mGSL [CM,CTM]\x1b[0;39m -> " << std::flush; #endif const boost::numeric::ublas::matrix _m2 = m2; return prod(m1,_m2); } template inline matrix // prod( trans(m1), trans(m2) ) prod(const matrix_unary2,scalar_identity > &m1, const matrix_unary2,scalar_identity > &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;32mGSL [CTM,CTM]\x1b[0;39m -> " << std::flush; #endif boost::numeric::ublas::matrix _m1 = m1; boost::numeric::ublas::matrix _m2 = m2; return prod(_m1,_m2); } /// diagonal matrix template inline matrix // prod( diagonal m1, m2 ) prod(const diagonal_matrix &m1, const matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CDM, CM]\x1b[0;39m -> " << std::flush; #endif const matrix _m1 = m1; return prod(_m1,m2); } template inline matrix // prod( m1, diagonal m2 ) prod(const matrix &m1, const diagonal_matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CM, CDM]\x1b[0;39m -> " << std::flush; #endif const matrix _m2 = m2; return prod(m1,_m2); } template inline matrix // prod( diagonal m1, diagonal m2 ) prod(const diagonal_matrix &m1, const diagonal_matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CDM, CM]\x1b[0;39m -> " << std::flush; #endif const matrix _m1 = m1; const matrix _m2 = m2; return prod(_m1,_m2); } template inline matrix // prod( diagonal m1, transpose m2 ) prod(const diagonal_matrix &m1, const matrix_unary2,scalar_identity > &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CDM, CTM]\x1b[0;39m -> " << std::flush; #endif const matrix _m1 = m1; const matrix _m2 = m2; return prod(_m1,_m2); } template inline matrix // prod( transpose m1, diagonal m2 ) prod(const matrix_unary2,scalar_identity > &m1, const diagonal_matrix &m2) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CTM, CDM]\x1b[0;39m -> " << std::flush; #endif const matrix _m1 = m1; const matrix _m2 = m2; return prod(_m1,_m2); } // symmetric matrix template inline matrix // prod( symmetric m1, m2 ) prod(symmetric_matrix &m1, matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CSM, CM]\x1b[0;39m -> " << std::flush; #endif assert( m1.size1() == m2.size1() ); const matrix _m1 = m1; return prod(_m1, m2 ); } template inline matrix // prod( m1, symmetric m2 ) prod( matrix &m1, symmetric_matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CSM, CM]\x1b[0;39m -> " << std::flush; #endif assert( m1.size1() == m2.size1() ); const matrix _m2 = m2; return prod(m1, _m2 ); } template inline matrix // prod( symmetric m1, symmetric m2 ) prod(symmetric_matrix &m1, symmetric_matrix &m2 ) { #ifdef GSLDEBUG std::cout << "\x1b[0;33mGSL [CSM, CM]\x1b[0;39m -> " << std::flush; #endif assert( m1.size1() == m2.size1() ); const matrix _m1 = m1; const matrix _m2 = m2; return prod(_m1, _m2 ); } }}} #endif // _GSL_BOOST_UBLAS_MATRIX_PROD_ tools-1.4.1/netbeans/000077500000000000000000000000001315257650400144645ustar00rootroot00000000000000tools-1.4.1/netbeans/libtools/000077500000000000000000000000001315257650400163135ustar00rootroot00000000000000tools-1.4.1/netbeans/libtools/Makefile_nb000066400000000000000000000043351315257650400204370ustar00rootroot00000000000000# # There exist several targets which are by default empty and which can be # used for execution of your targets. These targets are usually executed # before and after some main targets. They are: # # .build-pre: called before 'build' target # .build-post: called after 'build' target # .clean-pre: called before 'clean' target # .clean-post: called after 'clean' target # .clobber-pre: called before 'clobber' target # .clobber-post: called after 'clobber' target # .all-pre: called before 'all' target # .all-post: called after 'all' target # .help-pre: called before 'help' target # .help-post: called after 'help' target # # Targets beginning with '.' are not intended to be called on their own. # # Main targets can be executed directly, and they are: # # build build a specific configuration # clean remove built files from a configuration # clobber remove all built files # all build all configurations # help print help mesage # # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and # .help-impl are implemented in nbproject/makefile-impl.mk. # # NOCDDL # Environment MKDIR=mkdir CP=cp CCADMIN=CCadmin RANLIB=ranlib # build build: .build-pre .build-impl .build-post .build-pre: # Add your pre 'build' code here... .build-post: # Add your post 'build' code here... # clean clean: .clean-pre .clean-impl .clean-post .clean-pre: # Add your pre 'clean' code here... .clean-post: # Add your post 'clean' code here... # clobber clobber: .clobber-pre .clobber-impl .clobber-post .clobber-pre: # Add your pre 'clobber' code here... .clobber-post: # Add your post 'clobber' code here... # all all: .all-pre .all-impl .all-post .all-pre: # Add your pre 'all' code here... .all-post: # Add your post 'all' code here... # help help: .help-pre .help-impl .help-post .help-pre: # Add your pre 'help' code here... .help-post: # Add your post 'help' code here... # include project implementation makefile include nbproject/Makefile-impl.mk tools-1.4.1/netbeans/libtools/nbproject/000077500000000000000000000000001315257650400203015ustar00rootroot00000000000000tools-1.4.1/netbeans/libtools/nbproject/Makefile-impl.mk000066400000000000000000000101741315257650400233110ustar00rootroot00000000000000# # Generated Makefile - do not edit! # # Edit the Makefile in the project folder instead (../Makefile). Each target # has a pre- and a post- target defined where you can add customization code. # # This makefile implements macros and targets common to all configurations. # # NOCDDL # Building and Cleaning subprojects are done by default, but can be controlled with the SUB # macro. If SUB=no, subprojects will not be built or cleaned. The following macro # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf # and .clean-reqprojects-conf unless SUB has the value 'no' SUB_no=NO SUBPROJECTS=${SUB_${SUB}} BUILD_SUBPROJECTS_=.build-subprojects BUILD_SUBPROJECTS_NO= BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} CLEAN_SUBPROJECTS_=.clean-subprojects CLEAN_SUBPROJECTS_NO= CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} # Project Name PROJECTNAME=libtools # Active Configuration DEFAULTCONF=Debug CONF=${DEFAULTCONF} # All Configurations ALLCONFS=Debug Release profile_release # build .build-impl: .build-pre .validate-impl .depcheck-impl @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf # clean .clean-impl: .clean-pre .validate-impl .depcheck-impl @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf # clobber .clobber-impl: .clobber-pre .depcheck-impl @#echo "=> Running $@..." for CONF in ${ALLCONFS}; \ do \ "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ done # all .all-impl: .all-pre .depcheck-impl @#echo "=> Running $@..." for CONF in ${ALLCONFS}; \ do \ "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ done # build tests .build-tests-impl: .build-impl .build-tests-pre @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf # run tests .test-impl: .build-tests-impl .test-pre @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf # dependency checking support .depcheck-impl: @echo "# This code depends on make tool being used" >.dep.inc @if [ -n "${MAKE_VERSION}" ]; then \ echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ echo "include \$${DEPFILES}" >>.dep.inc; \ echo "endif" >>.dep.inc; \ else \ echo ".KEEP_STATE:" >>.dep.inc; \ echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ fi # configuration validation .validate-impl: @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ then \ echo ""; \ echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ echo "See 'make help' for details."; \ echo "Current directory: " `pwd`; \ echo ""; \ fi @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ then \ exit 1; \ fi # help .help-impl: .help-pre @echo "This makefile supports the following configurations:" @echo " ${ALLCONFS}" @echo "" @echo "and the following targets:" @echo " build (default target)" @echo " clean" @echo " clobber" @echo " all" @echo " help" @echo "" @echo "Makefile Usage:" @echo " make [CONF=] [SUB=no] build" @echo " make [CONF=] [SUB=no] clean" @echo " make [SUB=no] clobber" @echo " make [SUB=no] all" @echo " make help" @echo "" @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," @echo " also build subprojects." @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," @echo " also clean subprojects." @echo "Target 'clobber' will remove all built files from all configurations and," @echo " unless 'SUB=no', also from subprojects." @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," @echo " also build subprojects." @echo "Target 'help' prints this message." @echo "" tools-1.4.1/netbeans/libtools/nbproject/configurations.xml000066400000000000000000001065541315257650400240700ustar00rootroot00000000000000 ../../include/votca/tools/akimaspline.h ../../include/votca/tools/application.h ../../include/votca/tools/average.h ../../include/votca/tools/calculator.h ../../include/votca/tools/colors.h ../../include/votca/tools/constants.h ../../include/votca/tools/correlate.h ../../include/votca/tools/crosscorrelate.h ../../include/votca/tools/cubicspline.h ../../include/votca/tools/database.h ../../include/votca/tools/datacollection.h ../../include/votca/tools/getline.h ../../include/votca/tools/globals.h ../../include/votca/tools/histogram.h ../../include/votca/tools/histogramnew.h ../../include/votca/tools/lexical_cast.h ../../include/votca/tools/linalg.h ../../include/votca/tools/linspline.h ../../include/votca/tools/matrix.h ../../include/votca/tools/mutex.h ../../include/votca/tools/objectfactory.h ../../include/votca/tools/parsexml.h ../../include/votca/tools/property.h ../../include/votca/tools/random.h ../../include/votca/tools/rangeparser.h ../../include/votca/tools/spline.h ../../include/votca/tools/statement.h ../../include/votca/tools/table.h ../../include/votca/tools/thread.h ../../include/votca/tools/tokenizer.h ../../include/votca/tools/types.h ../../include/votca/tools/vec.h ../../include/votca/tools/version.h ../../include/votca/tools/votca_config.h.in ../../include/votca/tools/votca_gsl_boost_ublas_matrix_prod.h ../../src/libtools/linalg/dummy/cholesky.cc ../../src/libtools/linalg/dummy/eigensystems.cc ../../src/libtools/linalg/dummy/invert.cc ../../src/libtools/linalg/dummy/qrsolve.cc ../../src/libtools/linalg/dummy/svd.cc ../../src/libtools/linalg/gsl/cholesky.cc ../../src/libtools/linalg/gsl/eigensystems.cc ../../src/libtools/linalg/gsl/invert.cc ../../src/libtools/linalg/gsl/qrsolve.cc ../../src/libtools/linalg/gsl/svd.cc ../../src/libtools/linalg/mkl/cholesky.cc ../../src/libtools/linalg/mkl/eigensystems.cc ../../src/libtools/linalg/mkl/invert.cc ../../src/libtools/linalg/mkl/qrsolve.cc ../../src/libtools/linalg/mkl/svd.cc ../../src/libtools/linalg.cc ../../src/libtools/akimaspline.cc ../../src/libtools/application.cc ../../src/libtools/correlate.cc ../../src/libtools/crosscorrelate.cc ../../src/libtools/cubicspline.cc ../../src/libtools/database.cc ../../src/libtools/datacollection.cc ../../src/libtools/globals.cc ../../src/libtools/histogram.cc ../../src/libtools/histogramnew.cc ../../src/libtools/linspline.cc ../../src/libtools/matrix.cc ../../src/libtools/mutex.cc ../../src/libtools/parcer.cc ../../src/libtools/parsexml.cc ../../src/libtools/property.cc ../../src/libtools/random.cc ../../src/libtools/rangeparser.cc ../../src/libtools/spline.cc ../../src/libtools/statement.cc ../../src/libtools/table.cc ../../src/libtools/thread.cc ../../src/libtools/version.cc Makefile_nb Makefile_nb ../../src/libtools ../../include ../../src/libtools ../../include Makefile_nb GNU|GNU true false ../../include ../../../include/votca ../../include -I../../include ../../src/libtools/libtools.a GNU|GNU true false 6 ../../include 6 ../../include -I../../include 5 ../../src/libtools/libtools.a GNU|GNU true false 6 ../../include 6 ../../include -I../../include -pg 5 ../../src/libtools/libtools.a tools-1.4.1/netbeans/libtools/nbproject/project.properties000066400000000000000000000000001315257650400240530ustar00rootroot00000000000000tools-1.4.1/netbeans/libtools/nbproject/project.xml000066400000000000000000000027021315257650400224720ustar00rootroot00000000000000 org.netbeans.modules.cnd.makeproject libtools 0 cc h UTF-8 ../../src/libtools ../../include ../../src/libtools ../../include Debug 3 Release 3 profile_release 3 false tools-1.4.1/netbeans/votca_property/000077500000000000000000000000001315257650400175445ustar00rootroot00000000000000tools-1.4.1/netbeans/votca_property/Makefile_nb000066400000000000000000000043351315257650400216700ustar00rootroot00000000000000# # There exist several targets which are by default empty and which can be # used for execution of your targets. These targets are usually executed # before and after some main targets. They are: # # .build-pre: called before 'build' target # .build-post: called after 'build' target # .clean-pre: called before 'clean' target # .clean-post: called after 'clean' target # .clobber-pre: called before 'clobber' target # .clobber-post: called after 'clobber' target # .all-pre: called before 'all' target # .all-post: called after 'all' target # .help-pre: called before 'help' target # .help-post: called after 'help' target # # Targets beginning with '.' are not intended to be called on their own. # # Main targets can be executed directly, and they are: # # build build a specific configuration # clean remove built files from a configuration # clobber remove all built files # all build all configurations # help print help mesage # # Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and # .help-impl are implemented in nbproject/makefile-impl.mk. # # NOCDDL # Environment MKDIR=mkdir CP=cp CCADMIN=CCadmin RANLIB=ranlib # build build: .build-pre .build-impl .build-post .build-pre: # Add your pre 'build' code here... .build-post: # Add your post 'build' code here... # clean clean: .clean-pre .clean-impl .clean-post .clean-pre: # Add your pre 'clean' code here... .clean-post: # Add your post 'clean' code here... # clobber clobber: .clobber-pre .clobber-impl .clobber-post .clobber-pre: # Add your pre 'clobber' code here... .clobber-post: # Add your post 'clobber' code here... # all all: .all-pre .all-impl .all-post .all-pre: # Add your pre 'all' code here... .all-post: # Add your post 'all' code here... # help help: .help-pre .help-impl .help-post .help-pre: # Add your pre 'help' code here... .help-post: # Add your post 'help' code here... # include project implementation makefile include nbproject/Makefile-impl.mk tools-1.4.1/netbeans/votca_property/nbproject/000077500000000000000000000000001315257650400215325ustar00rootroot00000000000000tools-1.4.1/netbeans/votca_property/nbproject/Makefile-Debug.mk000066400000000000000000000041061315257650400246250ustar00rootroot00000000000000# # Generated Makefile - do not edit! # # Edit the Makefile in the project folder instead (../Makefile). Each target # has a -pre and a -post target defined where you can add customized code. # # This makefile implements configuration specific macros and targets. # Environment MKDIR=mkdir CP=cp GREP=grep NM=nm CCADMIN=CCadmin RANLIB=ranlib CC=gcc CCC=g++ CXX=g++ FC=gfortran AS=as # Macros CND_PLATFORM=GNU-Linux CND_DLIB_EXT=so CND_CONF=Debug CND_DISTDIR=dist CND_BUILDDIR=build # Include project Makefile include Makefile_nb # Object Directory OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ ${OBJECTDIR}/_ext/2aac7050/votca_property.o # C Compiler Flags CFLAGS= # CC Compiler Flags CCFLAGS= CXXFLAGS= # Fortran Compiler Flags FFLAGS= # Assembler Flags ASFLAGS= # Link Libraries and Options LDLIBSOPTIONS=../libtools/../../src/libtools/libtools.a -lxml2 # Build Targets .build-conf: ${BUILD_SUBPROJECTS} "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property: ../libtools/../../src/libtools/libtools.a ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property: ${OBJECTFILES} ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property ${OBJECTFILES} ${LDLIBSOPTIONS} ${OBJECTDIR}/_ext/2aac7050/votca_property.o: ../../src/tools/votca_property.cc ${MKDIR} -p ${OBJECTDIR}/_ext/2aac7050 ${RM} "$@.d" $(COMPILE.cc) -g -I../include -I../../include -I../../src/libboost -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/2aac7050/votca_property.o ../../src/tools/votca_property.cc # Subprojects .build-subprojects: cd ../libtools && ${MAKE} -f Makefile_nb CONF=Debug # Clean Targets .clean-conf: ${CLEAN_SUBPROJECTS} ${RM} -r ${CND_BUILDDIR}/${CND_CONF} ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property # Subprojects .clean-subprojects: cd ../libtools && ${MAKE} -f Makefile_nb CONF=Debug clean # Enable dependency checking .dep.inc: .depcheck-impl include .dep.inc tools-1.4.1/netbeans/votca_property/nbproject/Makefile-Release.mk000066400000000000000000000034171315257650400251630ustar00rootroot00000000000000# # Generated Makefile - do not edit! # # Edit the Makefile in the project folder instead (../Makefile). Each target # has a -pre and a -post target defined where you can add customized code. # # This makefile implements configuration specific macros and targets. # Environment MKDIR=mkdir CP=cp GREP=grep NM=nm CCADMIN=CCadmin RANLIB=ranlib CC=gcc CCC=g++ CXX=g++ FC=gfortran AS=as # Macros CND_PLATFORM=GNU-Linux CND_DLIB_EXT=so CND_CONF=Release CND_DISTDIR=dist CND_BUILDDIR=build # Include project Makefile include Makefile_nb # Object Directory OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} # Object Files OBJECTFILES= \ ${OBJECTDIR}/_ext/2aac7050/votca_property.o # C Compiler Flags CFLAGS= # CC Compiler Flags CCFLAGS= CXXFLAGS= # Fortran Compiler Flags FFLAGS= # Assembler Flags ASFLAGS= # Link Libraries and Options LDLIBSOPTIONS= # Build Targets .build-conf: ${BUILD_SUBPROJECTS} "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property: ${OBJECTFILES} ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property ${OBJECTFILES} ${LDLIBSOPTIONS} ${OBJECTDIR}/_ext/2aac7050/votca_property.o: ../../src/tools/votca_property.cc ${MKDIR} -p ${OBJECTDIR}/_ext/2aac7050 ${RM} "$@.d" $(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/2aac7050/votca_property.o ../../src/tools/votca_property.cc # Subprojects .build-subprojects: # Clean Targets .clean-conf: ${CLEAN_SUBPROJECTS} ${RM} -r ${CND_BUILDDIR}/${CND_CONF} ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/votca_property # Subprojects .clean-subprojects: # Enable dependency checking .dep.inc: .depcheck-impl include .dep.inc tools-1.4.1/netbeans/votca_property/nbproject/Makefile-impl.mk000066400000000000000000000102071315257650400245370ustar00rootroot00000000000000# # Generated Makefile - do not edit! # # Edit the Makefile in the project folder instead (../Makefile). Each target # has a pre- and a post- target defined where you can add customization code. # # This makefile implements macros and targets common to all configurations. # # NOCDDL # Building and Cleaning subprojects are done by default, but can be controlled with the SUB # macro. If SUB=no, subprojects will not be built or cleaned. The following macro # statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf # and .clean-reqprojects-conf unless SUB has the value 'no' SUB_no=NO SUBPROJECTS=${SUB_${SUB}} BUILD_SUBPROJECTS_=.build-subprojects BUILD_SUBPROJECTS_NO= BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} CLEAN_SUBPROJECTS_=.clean-subprojects CLEAN_SUBPROJECTS_NO= CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} # Project Name PROJECTNAME=votca_property # Active Configuration DEFAULTCONF=Debug CONF=${DEFAULTCONF} # All Configurations ALLCONFS=Debug Release # build .build-impl: .build-pre .validate-impl .depcheck-impl @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf # clean .clean-impl: .clean-pre .validate-impl .depcheck-impl @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf # clobber .clobber-impl: .clobber-pre .depcheck-impl @#echo "=> Running $@..." for CONF in ${ALLCONFS}; \ do \ "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ done # all .all-impl: .all-pre .depcheck-impl @#echo "=> Running $@..." for CONF in ${ALLCONFS}; \ do \ "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ done # build tests .build-tests-impl: .build-impl .build-tests-pre @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf # run tests .test-impl: .build-tests-impl .test-pre @#echo "=> Running $@... Configuration=$(CONF)" "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf # dependency checking support .depcheck-impl: @echo "# This code depends on make tool being used" >.dep.inc @if [ -n "${MAKE_VERSION}" ]; then \ echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \ echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ echo "include \$${DEPFILES}" >>.dep.inc; \ echo "endif" >>.dep.inc; \ else \ echo ".KEEP_STATE:" >>.dep.inc; \ echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ fi # configuration validation .validate-impl: @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ then \ echo ""; \ echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ echo "See 'make help' for details."; \ echo "Current directory: " `pwd`; \ echo ""; \ fi @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ then \ exit 1; \ fi # help .help-impl: .help-pre @echo "This makefile supports the following configurations:" @echo " ${ALLCONFS}" @echo "" @echo "and the following targets:" @echo " build (default target)" @echo " clean" @echo " clobber" @echo " all" @echo " help" @echo "" @echo "Makefile Usage:" @echo " make [CONF=] [SUB=no] build" @echo " make [CONF=] [SUB=no] clean" @echo " make [SUB=no] clobber" @echo " make [SUB=no] all" @echo " make help" @echo "" @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," @echo " also build subprojects." @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," @echo " also clean subprojects." @echo "Target 'clobber' will remove all built files from all configurations and," @echo " unless 'SUB=no', also from subprojects." @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," @echo " also build subprojects." @echo "Target 'help' prints this message." @echo "" tools-1.4.1/netbeans/votca_property/nbproject/configurations.xml000066400000000000000000000052131315257650400253070ustar00rootroot00000000000000 ../../src/tools/votca_property.cc Makefile_nb ../../src/tools Makefile_nb localhost GNU|GNU 2 ../include ../../include ../../src/libboost xml2 localhost GNU|GNU 2 5 5 5 tools-1.4.1/netbeans/votca_property/nbproject/private/000077500000000000000000000000001315257650400232045ustar00rootroot00000000000000tools-1.4.1/netbeans/votca_property/nbproject/private/configurations.xml000066400000000000000000000022371315257650400267640ustar00rootroot00000000000000 Makefile_nb 0 GizmoSimple ../../tests true 0 0 0 GizmoSimple true 0 0 0 tools-1.4.1/netbeans/votca_property/nbproject/private/private.properties000066400000000000000000000000001315257650400267620ustar00rootroot00000000000000tools-1.4.1/netbeans/votca_property/nbproject/project.properties000066400000000000000000000000001315257650400253040ustar00rootroot00000000000000tools-1.4.1/netbeans/votca_property/nbproject/project.xml000066400000000000000000000016331315257650400237250ustar00rootroot00000000000000 org.netbeans.modules.cnd.makeproject votca_property 0 cc UTF-8 ../libtools ../../src/tools Debug Release tools-1.4.1/scripts/000077500000000000000000000000001315257650400143545ustar00rootroot00000000000000tools-1.4.1/scripts/CMakeLists.txt000066400000000000000000000014371315257650400171210ustar00rootroot00000000000000option(WITH_RC_FILES "Install votca rc files, no need when installing under /usr" ON) if (WITH_RC_FILES) if(APPLE) set(LD_LIBRARY_PATH "DYLD_LIBRARY_PATH") else(APPLE) include(CheckCSourceCompiles) check_c_source_compiles( "int main(void) { #ifndef _AIX #error #endif return 0; }" HAVE_AIX) if(HAVE_AIX) set(LD_LIBRARY_PATH "LIBPATH") else(HAVE_AIX) set(LD_LIBRARY_PATH "LD_LIBRARY_PATH") endif(HAVE_AIX) endif(APPLE) configure_file(VOTCARC.csh.in ${CMAKE_CURRENT_BINARY_DIR}/VOTCARC.csh @ONLY) configure_file(VOTCARC.bash.in ${CMAKE_CURRENT_BINARY_DIR}/VOTCARC.bash @ONLY) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/VOTCARC.csh ${CMAKE_CURRENT_BINARY_DIR}/VOTCARC.bash DESTINATION bin) endif (WITH_RC_FILES) tools-1.4.1/scripts/VOTCARC.bash.in000066400000000000000000000025511315257650400167240ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #path is never empty PATH="@CMAKE_INSTALL_PREFIX@/bin:${PATH}" #debian wants to have : at the end MANPATH="@CMAKE_INSTALL_PREFIX@/@MAN@:${MANPATH}" @LD_LIBRARY_PATH@="@CMAKE_INSTALL_PREFIX@/@LIB@${@LD_LIBRARY_PATH@:+:}${@LD_LIBRARY_PATH@}" PKG_CONFIG_PATH="@CMAKE_INSTALL_PREFIX@/@LIB@/pkgconfig${PKG_CONFIG_PATH:+:}${PKG_CONFIG_PATH}" VOTCASHARE="@CMAKE_INSTALL_PREFIX@/@DATA@" export PATH MANPATH @LD_LIBRARY_PATH@ PKG_CONFIG_PATH VOTCASHARE #votca rc files for rc in "@CMAKE_INSTALL_PREFIX@/@DATA@"/rc/*rc.bash; do [ -r "$rc" ] && . "$rc" done unset rc #bash completion if [ -n "$BASH_VERSION" ]; then for comp in "@CMAKE_INSTALL_PREFIX@/@DATA@"/rc/*completion.bash; do [ -r "$comp" ] && source "$comp" done unset comp fi tools-1.4.1/scripts/VOTCARC.csh.in000066400000000000000000000030161315257650400165610ustar00rootroot00000000000000#!/usr/bin/env csh # # Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # #path is never empty setenv PATH "@CMAKE_INSTALL_PREFIX@/bin:${PATH}" #debian wants to have : at the end if (! $?MANPATH) setenv MANPATH "" setenv MANPATH "@CMAKE_INSTALL_PREFIX@/@MAN@:${MANPATH}" if (! $?@LD_LIBRARY_PATH@) setenv @LD_LIBRARY_PATH@ "" if ( "$@LD_LIBRARY_PATH@" != "" ) setenv @LD_LIBRARY_PATH@ ":${@LD_LIBRARY_PATH@}" setenv @LD_LIBRARY_PATH@ "@CMAKE_INSTALL_PREFIX@/@LIB@${@LD_LIBRARY_PATH@}" if (! $?PKG_CONFIG_PATH) setenv PKG_CONFIG_PATH "" if ( "$PKG_CONFIG_PATH" != "") setenv PKG_CONFIG_PATH ":${PKG_CONFIG_PATH}" setenv PKG_CONFIG_PATH "@CMAKE_INSTALL_PREFIX@/@LIB@/pkgconfig${PKG_CONFIG_PATH}" if (! $?VOTCASHARE) setenv VOTCASHARE "" if ( "$VOTCASHARE" != "") setenv VOTCASHARE ":${VOTCASHARE}" setenv VOTCASHARE "@CMAKE_INSTALL_PREFIX@/@DATA@${VOTCASHARE}" #votca rc files foreach rc ( "@CMAKE_INSTALL_PREFIX@/@DATA@"/rc/*rc.csh ) [ -r "$rc" ] && source "$rc" end unset rc tools-1.4.1/share/000077500000000000000000000000001315257650400137675ustar00rootroot00000000000000tools-1.4.1/share/doc/000077500000000000000000000000001315257650400145345ustar00rootroot00000000000000tools-1.4.1/share/doc/CMakeLists.txt000066400000000000000000000003641315257650400172770ustar00rootroot00000000000000find_package(Doxygen) if (DOXYGEN_FOUND) configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(html COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Build doxygen documentation") endif (DOXYGEN_FOUND) tools-1.4.1/share/doc/Doxyfile.in000066400000000000000000001747351315257650400166700ustar00rootroot00000000000000# Doxyfile 1.5.9 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = @CMAKE_PROJECT_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @PROJECT_VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it parses. # With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this tag. # The format is ext=language, where ext is a file extension, and language is one of # the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, # Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat # .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), # use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen to replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penality. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will rougly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by # doxygen. The layout file controls the global structure of the generated output files # in an output format independent way. The create the layout file that represents # doxygen's defaults, run doxygen with the -l option. You can optionally specify a # file name after the option, if omitted DoxygenLayout.xml will be used as the name # of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_SOURCE_DIR@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */.git/* EXCLUDE_PATTERNS += */CMakeFiles/* EXCLUDE_PATTERNS += */CMakeModules/* EXCLUDE_PATTERNS += *.py # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER # are set, an additional index file will be generated that can be used as input for # Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated # HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. # For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's # filter section matches. # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which # disables this behavior completely. For backwards compatibility with previous # releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE # respectively. GENERATE_TREEVIEW = NONE # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # By default doxygen will write a font called FreeSans.ttf to the output # directory and reference it in all dot files that doxygen generates. This # font does not include all possible unicode characters however, so when you need # these (or just want a differently looking font) you can specify the font name # using DOT_FONTNAME. You need need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO tools-1.4.1/share/man/000077500000000000000000000000001315257650400145425ustar00rootroot00000000000000tools-1.4.1/share/man/CMakeLists.txt000066400000000000000000000003551315257650400173050ustar00rootroot00000000000000if (BUILD_MANPAGES) add_custom_target(votca_tools_manpages DEPENDS votca-tools.man) add_dependencies(manpages votca_tools_manpages) install(FILES votca-tools.man DESTINATION ${MAN}/man7 RENAME votca-tools.7) endif (BUILD_MANPAGES) tools-1.4.1/share/man/votca-tools.man000066400000000000000000000030051315257650400175070ustar00rootroot00000000000000.TH "votca-tools" 7 "03/11/2013" "VOTCA Development Team " .SH NAME .P votca\-tools \- The basic tools library of the VOTCA package .SH DESCRIPTION .P votca\-tools provides the basic functions used by all parts of the VOTCA package. .P Please visit the program site at __http://www.votca.org__. .SH SYNOPSIS .P If VOTCA was installed in a non\-default location one can use the VOTCARC file to set the important environment variables (PATH, MANPATH, CSGSHARE). .P In bash shell: \fBsource VOTCARC.bash\fR .P In tcsh shell: \fBsource VOTCARC.csh\fR .P In sh shell: \fB. VOTCARC.bash\fR .SH AUTHORS .P Written and maintained by the VOTCA Development Team .P This Manual Page converted from t2t format to the this format by txt2tags (http://txt2tags.org) ! .SH COPYRIGHT .P Copyright 2009\-2013 The VOTCA Development Team (http://www.votca.org) .P Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at .P http://www.apache.org/licenses/LICENSE\-2.0 .P Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. .\" man code generated by txt2tags 2.6 (http://txt2tags.org) .\" cmdline: txt2tags -q -t man -i votca-tools.t2t -o votca-tools.man tools-1.4.1/share/man/votca-tools.t2t000066400000000000000000000030011315257650400174410ustar00rootroot00000000000000votca-tools VOTCA Development Team %%mtime(%d/%m/%Y) %to build votca-tools.man run: %txt2tags -q -t man -i votca-tools.t2t -o votca-tools.man %make the manpage type 7, txt2tags does 1 by default %!postproc(man): "^(\.TH.*) 1 " "\1 7 " = NAME = votca-tools - The basic tools library of the VOTCA package = DESCRIPTION = votca-tools provides the basic functions used by all parts of the VOTCA package. Please visit the program site at __http://www.votca.org__. = SYNOPSIS = If VOTCA was installed in a non-default location one can use the VOTCARC file to set the important environment variables (PATH, MANPATH, CSGSHARE). In bash shell: **source VOTCARC.bash** In tcsh shell: **source VOTCARC.csh** In sh shell: **. VOTCARC.bash** = AUTHORS = Written and maintained by the VOTCA Development Team This Manual Page converted from t2t format to the this format by [txt2tags http://txt2tags.org] ! = COPYRIGHT = Copyright 2009-2013 The VOTCA Development Team (http://www.votca.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. tools-1.4.1/src/000077500000000000000000000000001315257650400134545ustar00rootroot00000000000000tools-1.4.1/src/CMakeLists.txt000066400000000000000000000000631315257650400162130ustar00rootroot00000000000000add_subdirectory(libtools) add_subdirectory(tools) tools-1.4.1/src/libtools/000077500000000000000000000000001315257650400153035ustar00rootroot00000000000000tools-1.4.1/src/libtools/CMakeLists.txt000066400000000000000000000052051315257650400200450ustar00rootroot00000000000000find_package(EXPAT) if(NOT EXPAT_FOUND) message(FATAL_ERROR "EXPAT not found, make sure you have also installed the expat and it's dev package") endif(NOT EXPAT_FOUND) include_directories(${EXPAT_INCLUDE_DIR}) set (EXPAT_CFLAGS_PKG "-I${EXPAT_INCLUDE_DIRS}") string(REGEX REPLACE "^(.*)/lib([^/]*)\\.[^.]*$" "-L\\1 -l\\2" EXPAT_LIBS_PKG ${EXPAT_LIBRARY}) if(NOT MKL_FOUND AND NOT GSL_FOUND) #explicitly disabled file(GLOB VOTCA_LINALG_SOURCES linalg/dummy/*.cc) elseif (MKL_FOUND) include_directories(${MKL_INCLUDE_DIRS}) file(GLOB VOTCA_LINALG_SOURCES linalg/mkl/*.cc) set(LINALG_LIBRARIES ${MKL_LIBRARIES}) elseif(GSL_FOUND) include_directories(${GSL_INCLUDE_DIRS}) file(GLOB VOTCA_LINALG_SOURCES linalg/gsl/*.cc) set(LINALG_LIBRARIES ${GSL_LIBRARIES}) endif() file(GLOB VOTCA_SOURCES *.cc) file(GLOB NOT_VOTCA_SOURCES version_nb.cc) file(GLOB_RECURSE VOTCA_SQL_SOURCES database.cc statement.cc) list(REMOVE_ITEM VOTCA_SOURCES ${NOT_VOTCA_SOURCES} ${VOTCA_SQL_SOURCES}) option(WITH_SQLITE3 "Use SQLite3, at this point only needed for charge transport parts!" ON) if (WITH_SQLITE3) find_package(SQLITE3) if(NOT SQLITE3_FOUND) message(FATAL_ERROR "SQLITE3 not found, make sure you have also installed the sqlite3 and it's dev package, at this point sqlite3 is only needed for charge transport parts of VOTCA, so you can just switch it off using -DWITH_SQLITE3=OFF in case you do not need it.") endif(NOT SQLITE3_FOUND) include_directories(${SQLITE3_INCLUDE_DIRS}) set(SQLITE3_PKG "sqlite3") else(WITH_SQLITE3) set(SQLITE3_PKG) set(VOTCA_SQL_SOURCES) endif(WITH_SQLITE3) #for gitversion.h include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_custom_target(gitversion COMMAND ${CMAKE_COMMAND} -DTOP_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DGIT_EXECUTABLE="${GIT_EXECUTABLE}" -DMERCURIAL_EXECUTABLE="${MERCURIAL_EXECUTABLE}" -P ${CMAKE_MODULE_PATH}/gitversion.cmake) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES gitversion.h) add_library(votca_tools ${VOTCA_SOURCES} ${VOTCA_SQL_SOURCES} ${VOTCA_LINALG_SOURCES}) add_dependencies(votca_tools gitversion) if(MKL_FOUND) add_dependencies(votca_tools intel) endif(MKL_FOUND) set_target_properties(votca_tools PROPERTIES SOVERSION ${SOVERSION}) target_link_libraries(votca_tools ${Boost_LIBRARIES} ${LINALG_LIBRARIES} ${SQLITE3_LIBRARIES} ${FFTW3_LIBRARIES} ${EXPAT_LIBRARIES} ${THREAD_LIBRARIES} ${MATH_LIBRARIES}) install(TARGETS votca_tools LIBRARY DESTINATION ${LIB} ARCHIVE DESTINATION ${LIB}) configure_file(libvotca_tools.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libvotca_tools.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libvotca_tools.pc DESTINATION ${LIB}/pkgconfig) tools-1.4.1/src/libtools/akimaspline.cc000066400000000000000000000131101315257650400201030ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include namespace votca { namespace tools { using namespace std; void AkimaSpline::Interpolate(ub::vector &x, ub::vector &y) { if(x.size() != y.size()) throw std::invalid_argument("error in AkimaSpline::Interpolate : sizes of vectors x and y do not match"); // Akima splines require at least 4 points if(x.size()<4) throw std::invalid_argument("error in AkimaSpline::Interpolate : vectors x and y have to contain at least 4 points"); const int N = x.size(); // adjust the grid _r.resize(N); // copy the grid points into f _r = x; // initialize vectors p1,p2,p3,p4 and t p0 = ub::zero_vector(N); p1 = ub::zero_vector(N); p2 = ub::zero_vector(N); p3 = ub::zero_vector(N); t = ub::zero_vector(N); double m1,m2,m3,m4; double temp, g0, g1, g2, x1, x2, y1, y2, x4, x5, y4, y5, m5; // boundary conditions // >> determine t(0), t(1) and t(N-2), t(N-1) switch(_boundaries) { case splineNormal: // Akima method: estimation of two more points on each side using a // degree two polyomial // resulting slopes t(0), t(1), t(N-2), t(N-1) are directly calculated // left side: t(0), t(1) temp = (x(1)-x(0))/(x(2)-x(0)); temp = temp*temp; g0 = y(0); g1 = ( (y(1)-y(0)) - temp*(y(2)-y(0)) ) / ( (x(1)-x(0)) - temp*(x(2)-x(0)) ); g2 = ( (y(2)-y(0)) - g1*(x(2)-x(0)) ) / ( (x(2)-x(0))*(x(2)-x(0)) ); x1 = x(0) - (x(2)-x(0)); x2 = x(1) - (x(2)-x(0)); y1 = g0 + g1*(x1-x(0)) + g2*(x1-x(0))*(x1-x(0)); y2 = g0 + g1*(x2-x(0)) + g2*(x2-x(0))*(x2-x(0)); m1 = (y2-y1)/(x2-x1); m2 = (y(0)-y2)/(x(0)-x2); m3 = (y(1)-y(0))/(x(1)-x(0)); m4 = (y(2)-y(1))/(x(2)-x(1)); t(0) = getSlope(m1,m2,m3,m4); m5 = (y(3)-y(2))/(x(3)-x(2)); t(1) = getSlope(m2,m3,m4,m5); // right side: t(N-2), t(N-1) temp = (x(N-2)-x(N-1))/(x(N-3)-x(N-1)); temp = temp*temp; g0 = y(N-1); g1 = ( (y(N-2)-y(N-1)) - temp*(y(N-3)-y(N-1)) ) / ( (x(N-2)-x(N-1)) - temp*(x(N-3)-x(N-1)) ); g2 = ( (y(N-3)-y(N-1)) - g1*(x(N-3)-x(N-1)) ) / ( (x(N-3)-x(N-1))*(x(N-3)-x(N-1)) ); x4 = x(N-2) + (x(N-1)-x(N-3)); x5 = x(N-1) + (x(N-1)-x(N-3)); y4 = g0 + g1*(x4-x(N-1)) + g2*(x4-x(N-1))*(x4-x(N-1)); y5 = g0 + g1*(x5-x(N-1)) + g2*(x5-x(N-1))*(x5-x(N-1)); m1 = (y(N-3)-y(N-4))/(x(N-3)-x(N-4)); m2 = (y(N-2)-y(N-3))/(x(N-2)-x(N-3)); m3 = (y(N-1)-y(N-2))/(x(N-1)-x(N-2)); m4 = (y4-y(N-1))/(x4-x(N-1)); m5 = (y5-y4)/(x5-x4); t(N-2) = getSlope(m1,m2,m3,m4); t(N-1) = getSlope(m2,m3,m4,m5); break; case splinePeriodic: // left: last two points determine the slopes t(0), t(1) m1 = (y(N-1)-y(N-2))/(x(N-1)-x(N-2)); m2 = (y(0)-y(N-1))/(x(0)-x(N-1)); m3 = (y(1)-y(0))/(x(1)-x(0)); m4 = (y(2)-y(1))/(x(2)-x(1)); m5 = (y(3)-y(2))/(x(3)-x(2)); t(0) = getSlope(m1,m2,m3,m4); t(1) = getSlope(m2,m3,m4,m5); // right: first two points determine the slopes t(N-2), t(N-1) m1 = (y(N-3)-y(N-4))/(x(N-3)-x(N-4)); m2 = (y(N-2)-y(N-3))/(x(N-2)-x(N-3)); m3 = (y(N-1)-y(N-2))/(x(N-1)-x(N-2)); m4 = (y(0)-y(N-1))/(x(0)-x(N-1)); m5 = (y(1)-y(0))/(x(1)-x(0)); t(N-2) = getSlope(m1,m2,m3,m4); t(N-1) = getSlope(m2,m3,m4,m5); break; case splineDerivativeZero: throw std::runtime_error("erro in AkimaSpline::Interpolate: case splineDerivativeZero not implemented yet"); break; } // calculate t's for all inner points [2,N-3] for (int i=2; i &x, ub::vector &y) { throw std::runtime_error("Akima fit not implemented."); } }} tools-1.4.1/src/libtools/application.cc000066400000000000000000000213261315257650400201210ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include namespace votca { namespace tools { Application::Application() : _op_desc("Allowed options"), _continue_execution(true) { } Application::~Application() { } string Application::VersionString() { return ""; } void Application::ShowHelpText(std::ostream &out) { out << "==================================================\n"; out << "======== VOTCA (http://www.votca.org) ========\n"; out << "==================================================\n\n"; out << "please submit bugs to bugs@votca.org\n\n"; out << ProgramName(); if(VersionString() != "") out << ", version " << VersionString(); out << endl << "votca_tools, version " << ToolsVersionStr() << "\n\n"; HelpText(out); // remove Hidden group from the option list and print out << "\n\n" << VisibleOptions() << endl; //out << "\n\n" << OptionsDesc() << endl; } void Application::ShowManPage(std::ostream &out) { out << boost::format(globals::man::header) % ProgramName() % VersionString(); out << boost::format(globals::man::name) % ProgramName() % globals::url; out << boost::format(globals::man::synopsis) % ProgramName(); std::stringstream ss; HelpText(ss); out << boost::format(globals::man::description) % ss.str(); out << boost::format(globals::man::options); typedef std::vector >::const_iterator OptionsIterator; OptionsIterator it = _op_desc.options().begin(), it_end = _op_desc.options().end(); while(it < it_end) { string format_name = (*it)->format_name() + " " + (*it)->format_parameter(); boost::replace_all(format_name, "-", "\\-"); out << boost::format(globals::man::option) % format_name % (*it)->description(); ++it; } out << boost::format(globals::man::authors) % globals::email; out << boost::format(globals::man::copyright) % globals::url; } void Application::ShowTEXPage(std::ostream &out) { string program_name = ProgramName(); boost::replace_all(program_name, "_", "\\_"); out << boost::format(globals::tex::section) % program_name; out << boost::format(globals::tex::label) % ProgramName(); std::stringstream ss, os; HelpText(ss); out << boost::format(globals::tex::description) % ss.str(); typedef std::vector >::const_iterator OptionsIterator; OptionsIterator it = _op_desc.options().begin(), it_end = _op_desc.options().end(); while(it < it_end) { string format_name = (*it)->format_name() + " " + (*it)->format_parameter(); boost::replace_all(format_name, "-", "{-}"); os << boost::format(globals::tex::option) % format_name % (*it)->description(); ++it; } out << boost::format(globals::tex::options) % os.str(); } int Application::Exec(int argc, char **argv) { try { //_continue_execution = true; AddProgramOptions()("help,h", " display this help and exit"); AddProgramOptions()("verbose,v", " be loud and noisy"); AddProgramOptions("Hidden")("man", " output man-formatted manual pages"); AddProgramOptions("Hidden")("tex", " output tex-formatted manual pages"); Initialize(); // initialize program-specific parameters ParseCommandLine(argc, argv); // initialize general parameters & read input file if (_op_vm.count("verbose")) { globals::verbose = true; } if (_op_vm.count("man")) { ShowManPage(cout); return 0; } if (_op_vm.count("tex")) { ShowTEXPage(cout); return 0; } if (_op_vm.count("help")) { ShowHelpText(cout); return 0; } if(!EvaluateOptions()) { ShowHelpText(cout); return -1; } if(_continue_execution) Run(); else cout << "nothing to be done - stopping here\n"; } catch(std::exception &error) { cerr << "an error occurred:\n" << error.what() << endl; return -1; } return 0; } boost::program_options::options_description_easy_init Application::AddProgramOptions(const string &group) { // if no group is given, add it to standard options if(group == "") return _op_desc.add_options(); // does group already exist, if yes, add it there std::map::iterator iter; iter = _op_groups.find(group); if(iter!=_op_groups.end()) return iter->second.add_options(); // no group with given name was found -> create group _op_groups.insert(make_pair(group, boost::program_options::options_description(group))); return _op_groups[group].add_options(); } void Application::ParseCommandLine(int argc, char **argv) { namespace po = boost::program_options; std::map::iterator iter; // default options should be added to visible (the rest is handled via a map)) _visible_options.add(_op_desc); // add all categories to list of available options for(iter=_op_groups.begin(); iter!=_op_groups.end(); ++iter) { _op_desc.add(iter->second); if ( iter->first != "Hidden" ) _visible_options.add(iter->second); } // parse the command line try { po::store(po::parse_command_line(argc, argv, _op_desc), _op_vm); po::notify(_op_vm); } catch(boost::program_options::error err) { throw runtime_error(string("error parsing command line: ") + err.what()); } } void Application::CheckRequired(const string &option_name, const string &error_msg) { if(!_op_vm.count(option_name)) { ShowHelpText(cout); throw std::runtime_error("missing argument " + option_name + "\n" + error_msg); } } void Application::PrintDescription(std::ostream &out, const string &calculator_name, const string help_path, HelpType help_type ) { boost::format _format("%|3t|%1% %|20t|%2% \n"); string help_string; boost::filesystem::path arg_path; Property options; string xmlFile = (arg_path / string(getenv("VOTCASHARE")) / help_path / (boost::format("%1%.%2%") % calculator_name % "xml").str()).string().c_str(); // loading the documentation xml file from VOTCASHARE char *votca_share = getenv("VOTCASHARE"); if(votca_share == NULL) throw std::runtime_error("VOTCASHARE not set, cannot open help files."); try { load_property_from_xml(options, xmlFile); Property &calculator_options = options.get("options." + calculator_name); Property::AttributeIterator atr_it = calculator_options.findAttribute("help"); if (atr_it != calculator_options.lastAttribute()) { help_string = (*atr_it).second; } else { if (tools::globals::verbose) out << _format % calculator_name % "Undocumented"; return; } switch (help_type) { default: break; case HelpShort: // short description of the calculator out << _format % calculator_name % help_string; break; case HelpLong: votca::tools::PropertyIOManipulator iom(votca::tools::PropertyIOManipulator::HLP, 2, ""); out << iom << options; break; } } catch (std::exception &error) { if (tools::globals::verbose) out << _format % calculator_name % "Undocumented"; } } }} tools-1.4.1/src/libtools/colors.cc000066400000000000000000000013571315257650400171210ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { Color DEFAULT_COLORS; }} tools-1.4.1/src/libtools/correlate.cc000066400000000000000000000027521315257650400176000ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { /** \todo clean implementation!!! */ void Correlate::CalcCorrelations(DataCollection::selection *data) { size_t N; double xm(0), xsq(0); N = (*data)[0].size(); for(size_t i=0; isize(); v++) { pair p("do_names", 0); double ym(0), ysq(0); for(size_t i=0; i #include #ifndef NOFFTW #include #endif namespace votca { namespace tools { /** \todo clean implementation!!! */ void CrossCorrelate::AutoCorrelate(DataCollection::selection *data, bool average) { #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::AutoCorrelate is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = (*data)[0].size(); _corrfunc.resize(N); fftw_complex *tmp; fftw_plan fft, ifft; tmp = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * (N/2+1)); fft = fftw_plan_dft_r2c_1d(N, &(*data)[0][0], tmp, FFTW_ESTIMATE); ifft = fftw_plan_dft_c2r_1d(N, tmp, &_corrfunc[0], FFTW_ESTIMATE); fftw_execute(fft); tmp[0][0] = tmp[0][1] = 0; for(size_t i=1; i& ivec){ #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::AutoFourier is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = ivec.size(); _corrfunc.resize(N); fftw_complex *tmp; fftw_plan fft; tmp = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * (N/2+1)); fft = fftw_plan_dft_r2c_1d(N, &ivec[0], tmp, FFTW_ESTIMATE); fftw_execute(fft); tmp[0][0] = tmp[0][1] = 0; for(size_t i=1; i& ivec){ #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::FFTOnly is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = ivec.size(); _corrfunc.resize(N); fftw_complex *tmp; fftw_plan fft; tmp = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * (N/2+1)); fft = fftw_plan_dft_r2c_1d(N, &ivec[0], tmp, FFTW_ESTIMATE); fftw_execute(fft); // copy the real component of temp to the _corrfunc vector for(size_t i=0; i& ivec){ #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::DCTOnly is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = ivec.size(); _corrfunc.resize(N); vector tmp; tmp.resize(N); fftw_plan fft; // do real to real discrete cosine trafo fft = fftw_plan_r2r_1d(N, &ivec[0], &tmp[0], FFTW_REDFT10, FFTW_ESTIMATE); fftw_execute(fft); // store results for(size_t i=0; i& ivec){ #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::AutoCosine is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = ivec.size(); _corrfunc.resize(N); vector tmp; tmp.resize(N); fftw_plan fft; // do real to real discrete cosine trafo fft = fftw_plan_r2r_1d(N, &ivec[0], &tmp[0], FFTW_REDFT10, FFTW_ESTIMATE); fftw_execute(fft); // compute autocorrelation tmp[0] = 0; for(size_t i=1; i& ivec){ #ifdef NOFFTW throw std::runtime_error("CrossCorrelate::AutoCorr is not compiled-in due to disabling of FFTW -recompile Votca Tools with FFTW3 support "); #else size_t N = ivec.size(); _corrfunc.resize(N); fftw_complex *tmp; fftw_plan fft, ifft; tmp = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * (N/2+1)); fft = fftw_plan_dft_r2c_1d(N, &ivec[0], tmp, FFTW_ESTIMATE); ifft = fftw_plan_dft_c2r_1d(N, tmp, &_corrfunc[0], FFTW_ESTIMATE); fftw_execute(fft); tmp[0][0] = tmp[0][1] = 0; for(size_t i=1; i #include #include #include #include #include #include namespace votca { namespace tools { using namespace std; void CubicSpline::Interpolate(ub::vector &x, ub::vector &y) { if(x.size() != y.size()) throw std::invalid_argument("error in CubicSpline::Interpolate : sizes of vectors x and y do not match"); if(x.size()<3) throw std::invalid_argument("error in CubicSpline::Interpolate : vectors x and y have to contain at least 3 points"); const int N = x.size(); // adjust the grid _r.resize(N); _f.resize(N); _f2.resize(N); // create vector proxies to individually access f and f'' // copy the grid points into f _r = x; _f = y; _f2 = ub::zero_vector(N); // not calculate the f'' ub::matrix A(N, N); A = ub::zero_matrix(N,N); for(int i=0; i &x, ub::vector &y) { if(x.size() != y.size()) throw std::invalid_argument("error in CubicSpline::Fit : sizes of vectors x and y do not match"); const int N = x.size(); const int ngrid = _r.size(); // construct the equation // A*u = b // where u = { {f[i]}, {f''[i]} } // and b[i] = y[i] for 0<=i=N (for smoothing condition) // A[i,j] contains the data fitting + the spline smoothing conditions ub::matrix A(N, 2*ngrid); ub::vector b(N); ub::matrix B_constr(ngrid, 2*ngrid); // Matrix with smoothing conditions A = ub::zero_matrix(N, 2*ngrid); b = ub::zero_vector(N); B_constr = ub::zero_matrix(ngrid, 2*ngrid); // Construct smoothing matrix AddBCToFitMatrix(B_constr, 0); // construct the matrix to fit the points and the vector b AddToFitMatrix(A, x, 0); b = -y; // why is it -y? // now do a constrained qr solve ub::vector sol(2*ngrid); votca::tools::linalg_constrained_qrsolve(sol, A, b, B_constr); // check vector "sol" for nan's for(int i=0; i<2*ngrid; i++) { if( (isinf(sol(i))) || (isnan(sol(i))) ) { throw std::runtime_error("error in CubicSpline::Fit : value nan occurred due to wrong fitgrid boundaries"); } } _f = ub::vector_range >(sol, ub::range (0, ngrid)); _f2 = ub::vector_range >(sol, ub::range (ngrid, 2*ngrid)); } }} tools-1.4.1/src/libtools/database.cc000066400000000000000000000043341315257650400173620ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { Database::Database() : _db(NULL) {} Database::~Database() { Close(); } void Database::Open(string file, int flags) { int ret = sqlite3_open_v2(file.c_str(),&_db,flags,NULL); if(ret != SQLITE_OK) throw std::runtime_error("cannot open database " + file); } void Database::OpenHelper(string file) { int ret = sqlite3_open_v2(file.c_str(),&_db,SQLITE_OPEN_READWRITE,NULL); if(ret != SQLITE_OK) { Open(file, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); onCreate(); } // TODO: onUpgrade } void Database::onCreate() { throw std::runtime_error("database is opened via OpenHelper but onCreate is not imlemented"); } void Database::onUpgrade(int oldVersion, int newVersion) { throw std::runtime_error("database is opened via OpenHelper but onUpgrade is not implemented"); } void Database::Close() { if(_db) sqlite3_close(_db); } void Database::Exec(string sql) { char *error; int ret = sqlite3_exec(_db, sql.c_str(), NULL, NULL, &error); if(ret != SQLITE_OK) throw std::runtime_error(string("sql execute failed\n") + error + "\nSQL: " + sql); } Statement *Database::Prepare(string sql) { //char *error; sqlite3_stmt *stmt; int ret = sqlite3_prepare_v2(_db, sql.c_str(), -1, &stmt, NULL); if(ret != SQLITE_OK) throw std::runtime_error(string("prepare statement failed") + "\nSQL: " + sql); return new Statement(stmt); } int Database::LastInsertRowId() { return sqlite3_last_insert_rowid(_db); } }} tools-1.4.1/src/libtools/datacollection.cc000066400000000000000000000027131315257650400206020ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { ostream& operator<<(ostream& out, DataCollection::selection &sel) { DataCollection::selection::iterator iter; if(sel.empty()) { out << "-- empty selection --" << endl; return out; } stringstream s; int written; for(size_t i=0; ; ++i) { s.clear(); s.str(""); s.setf(ios::scientific); written = 0; for(size_t j=0; j= sel[j].size()) { s << " -"; continue; } written++; s << " " << (double)sel[j][i]; } if(written == 0) return out; out << i << s.str() << endl; } return out; } }} tools-1.4.1/src/libtools/globals.cc000066400000000000000000000075351315257650400172470ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { bool globals::verbose = false; std::string globals::url = "http://www.votca.org"; std::string globals::email = "devs@votca.org"; std::string globals::man::option(".TP\n\\fB%1%\\fR\n%2%\n"); std::string globals::man::header(".TH \"%1%\" 1 \"\" \"Version: %2%\"\n\n"); std::string globals::man::name ( ".SH NAME\n" "\n.P\n" "%1% \\- Part of the VOTCA package\n" "\n.P\n" "For more info please visit %2%\n\n" ); std::string globals::man::authors ( "\n.SH AUTHORS\n" "\n.P\n" "Written and maintained by the VOTCA Development Team <%1%>\n" ); std::string globals::man::copyright ( "\n.SH COPYRIGHT\n" "\n.P\n\n" "Copyright 2009\\-2013 The VOTCA Development Team (%1%).\n" "\n.P\n" "Licensed under the Apache License, Version 2.0 (the \"License\") " "you may not use this file except in compliance with the License. " "You may obtain a copy of the License at" "\n.P\n" "http://www.apache.org/licenses/LICENSE\\-2.0\n" "\n.P\n" "Unless required by applicable law or agreed to in writing, software " "distributed under the License is distributed on an \"AS IS\" BASIS, " "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. " "See the License for the specific language governing permissions and " "limitations under the License." ); std::string globals::man::synopsis ( "\n.SH SYNOPSIS\n" "\n.P\n\\fB%1%\\fR [\\fIOPTION\\fR] [\\fIARGUMENT\\fR]\n" ); std::string globals::man::description ( "\n.SH DESCRIPTION\n" "\n.P\n%1%\n" ); std::string globals::man::options("\n.SH OPTIONS\n"); std::string globals::tex::section("\n\\subsection{%1%}"); std::string globals::tex::label("\n\\label{prog:%1%}"); std::string globals::tex::description("\n%1%"); std::string globals::tex::option("\n\\item[ ] \\texttt{%1%} %2%"); std::string globals::tex::options("\n\\begin{compactitem}%1%\n\\end{compactitem}\n"); // constants const double globals::constants::pi = 3.1415926535897; const double globals::constants::kB = 8.617332478E-5; // eV/K const double globals::constants::hbar = 6.5821192815E-16; // eV*s // conversion factors const double globals::conversion::Bohr2nm = 0.052917721092; const double globals::conversion::nm2Bohr = 18.897259886; const double globals::conversion::Ang2Bohr = 1.8897259886; const double globals::conversion::Ryd2eV = 13.6058; const double globals::conversion::Hrt2eV = 27.21138386; const double globals::conversion::int2eV = 1/(4*constants::pi*8.854187817e-12) * 1.602176487e-19 / 1.000e-9; }} tools-1.4.1/src/libtools/histogram.cc000066400000000000000000000076521315257650400176210ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace tools { Histogram::Histogram() : _min(0), _max(0) {} Histogram::Histogram(options_t op) : _min(0), _max(0), _options(op) { } Histogram::~Histogram() { } void Histogram::ProcessData(DataCollection::selection *data) { DataCollection::selection::iterator array; DataCollection::array::iterator iter; int ii; int ndata = 0; _pdf.assign(_options._n, 0); if(_options._auto_interval) { _min = numeric_limits::max(); _max = numeric_limits::min(); _options._extend_interval = true; } else { _min = _options._min; _max = _options._max; } for(array = data->begin(); array!=data->end(); ++array) { ndata+=(*array)->size(); if(_options._extend_interval || _options._auto_interval) { for(iter=(*array)->begin(); iter!=(*array)->end(); ++iter) { _min = min(*iter, _min); _max = max(*iter, _max); } } } // make that the highes value fits into interval //if(_options._auto_interval || _max!=_options._max) // _max = _max + 0.5*(_max - _min)/(double)(_options._n); _interval = (_max - _min)/(double)(_options._n-1); double v = 1.; for(array = data->begin(); array!=data->end(); ++array) { for(iter=(*array)->begin(); iter!=(*array)->end(); ++iter) { ii = (int)floor( (*iter - _min) / _interval + 0.5); // the interval should be centered around the sampling point if(ii< 0 || ii >= _options._n) { if(_options._periodic) { while(ii<0) ii+=_options._n; ii = ii % _options._n; } else { continue; } //cout << "[histogram.cc]: out of bounds" << endl; continue;} } _pdf[ii]+= v; } } //cout << _pdf.size() << " " << _options._periodic << endl; if(_options._scale == "bond") { for(size_t i=0; i<_pdf.size(); ++i) { double r = _min + _interval*(double)i; if(abs(r) < 1e-10) { r = _min + _interval*(double)(i+1); _pdf[i] = _pdf[i+1]; } _pdf[i] /= (r*r); } } else if(_options._scale == "angle") { for(size_t i=0; i<_pdf.size(); ++i) { double alpha = _min + _interval*(double)i; double sa = sin(alpha); if(abs(sa) < 1e-5) { if(i<_pdf.size()-1) { alpha = _min + _interval*(double)(i+1); _pdf[i]=_pdf[i+1]/sin(alpha); } else { _pdf[i]=_pdf[i-1]; } } else _pdf[i] /= sa; } } if(_options._periodic) { _pdf[0] = (_pdf[0] + _pdf[_options._n-1]); _pdf[_options._n-1] = _pdf[0]; } if(_options._normalize) Normalize(); } void Histogram::Normalize(void) { double norm = 1./ (_interval * accumulate(_pdf.begin(), _pdf.end(), 0.0)); transform(_pdf.begin(), _pdf.end(), _pdf.begin(), bind2nd(multiplies(), norm)); } }} tools-1.4.1/src/libtools/histogramnew.cc000066400000000000000000000040031315257650400203160ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { HistogramNew::HistogramNew() { _min=_max=_step=0; _weight = 1.; _periodic=false; } HistogramNew::HistogramNew(const HistogramNew &hist) : _min(hist._min), _max(hist._max), _step(hist._step), _weight(hist._weight), _periodic(hist._periodic) {} void HistogramNew::Initialize(double min, double max, int nbins) { _min = min; _max = max; _step = (_max - _min)/nbins; _weight = 1.; _data.resize(nbins); _nbins = nbins; for(double v=_min, i=0; i(_nbins); _data.yerr()=ub::zero_vector(_nbins); _data.flags()=ub::scalar_vector(_nbins, 'i'); } void HistogramNew::Process(const double &v, double scale) { int i = (int)floor((v - _min) / _step + 0.5); if (i < 0 || i >= _nbins) { if(!_periodic) return; if(i<0) i = _nbins - ((-i) % _nbins); else i = i % _nbins; } _data.y(i) += _weight * scale; } void HistogramNew::Normalize() { double area = 0; area=ub::norm_1(_data.y()) * _step; double scale = 1./area; _data.y() *= scale; } void HistogramNew::Clear() { _weight = 1.; _data.y() = ub::zero_vector(_nbins); _data.yerr() = ub::zero_vector(_nbins); } }} tools-1.4.1/src/libtools/libvotca_tools.pc.in000066400000000000000000000006521315257650400212620ustar00rootroot00000000000000prefix=@CMAKE_INSTALL_PREFIX@ libdir=${prefix}/@LIB@ includedir=${prefix}/include Name: libvotca_tools Description: basic tools of the votca package URL: http://www.votca.org Version: @PROJECT_VERSION@ Requires: @SQLITE3_PKG@ @GSL_PKG@ @EIGEN_PKG@ @FFTW3_PKG@ Libs: -L${libdir} -lvotca_tools @EXPAT_LIBS_PKG@ @BOOST_LIBS_PKG@ @THREAD_LIBRARIES@ Libs.private: -lm Cflags: -I${includedir} @EXPAT_CFLAGS_PKG@ @BOOST_CFLAGS_PKG@ tools-1.4.1/src/libtools/linalg.cc000066400000000000000000000117711315257650400170670ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace tools { using namespace std; namespace ub = boost::numeric::ublas; int linalg_invert_svd(ub::matrix &A, ub::matrix &V,double limitCN){ int dimensions=0; if(A.size1()!=A.size2()){ throw runtime_error("You cannot invert a non quadratic matrix!. linalg_invert_svd"); } if(A.size1()==0){ throw runtime_error("Matrix has size 0. linalg_invert_svd"); } //make local copy because svd destroys A ub::matrix work=A; ub::matrixVT=ub::zero_matrix(A.size1(),A.size2()); ub::vectorS=ub::zero_vector(A.size1()); bool check=linalg_singular_value_decomposition(work, VT,S ); if (check){ throw runtime_error("Svd Calculation failed. linalg_invert_svd"); } /* cout << "Hallo"< S_eigenvalues; linalg_eigenvalues( S_eigenvalues, S); if ( S_eigenvalues[0] < 0.0 ) { cerr << " \n Negative eigenvalues in Loewdin transformation " << endl; return -1; } ub::matrix _diagS = ub::zero_matrix(J.size1(),J.size2() ); for ( unsigned _i =0; _i < J.size1() ; _i++){ _diagS(_i,_i) = 1.0/sqrt(S_eigenvalues[_i]); } ub::matrix _temp = ub::prod( _diagS, ub::trans(S)); S = ub::prod( S,_temp ); _temp = ub::prod(J, S); J = ub::prod( S, _temp); return S_eigenvalues[0]; } int linalg_matrixsqrt(ub::matrix &S){ if (S.size1()!=S.size2()) { cerr << " \nMatrix sqrt only works for quadratic matrices " << endl; return -1; } ub::vector S_eigenvalues; linalg_eigenvalues( S_eigenvalues, S); if ( S_eigenvalues[0] < 0.0 ) { cerr << " \n Negative eigenvalues in matrix_sqrt transformation " << endl; return -1; } ub::matrix _diagS = ub::zero_matrix(S.size1(),S.size2() ); for ( unsigned _i =0; _i < S.size1() ; _i++){ _diagS(_i,_i) = sqrt(S_eigenvalues[_i]); } ub::matrix _temp = ub::prod( _diagS, ub::trans(S)); S = ub::prod( S,_temp ); return 1; } double linalg_getMax( const ub::matrix& _matrix ){ double _maximum = 0.0; for ( unsigned _i = 0; _i < _matrix.size1(); _i++ ){ for ( unsigned _j = 0; _j < _matrix.size2(); _j++ ){ if ( std::abs(_matrix(_i,_j)) > _maximum ) { _maximum = std::abs(_matrix(_i,_j)); } } } return _maximum; } double linalg_getRMS(const ub::matrix& _matrix ){ double _rms = 0.0; int _n = 0; for ( unsigned _i = 0; _i < _matrix.size1(); _i++ ){ for ( unsigned _j = 0; _j < _matrix.size2(); _j++ ){ _rms += _matrix(_i,_j) * _matrix(_i,_j); _n++; } } _rms = sqrt(_rms/_n); return _rms; } double linalg_traceofProd(const ub::matrix& A,const ub::matrix& B ){ double trace=0.0; const ub::vector& Aarray=A.data(); const ub::vector& Barray=B.data(); if (Aarray.size()!=Barray.size() || A.size1()!=B.size2() || A.size2()!=B.size1()) { cerr << " \ntraceofProd Matrcies have different number of indexes " << endl; return -1; } for (unsigned i=0;i #include namespace votca { namespace tools { using namespace std; void linalg_cholesky_decompose( ub::matrix &A){ throw std::runtime_error("linalg_cholesky_decompose is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); } void linalg_cholesky_solve(ub::vector &x, ub::matrix &A, ub::vector &b){ throw std::runtime_error("linalg_cholesky_solve is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); } }} tools-1.4.1/src/libtools/linalg/dummy/eigensystems.cc000066400000000000000000000066231315257650400227410ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace tools { using namespace std; /** * * ublas binding for gsl_eigen_symmv * note that the eigenvalues/eigenvectors are UNSORTED * */ bool linalg_eigenvalues_symmetric( ub::symmetric_matrix &A, ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues_symmetric is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL and MKL support"); }; /** * * ublas binding for gsl_eigen_symmv * input matrix type general matrix! * wrapping gsl_eigen_symmv * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); }; /** * * ublas binding for gsl_eigen_symmv * input matrix type general matrix single precision! * wrapping gsl_eigen_symmv * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); }; bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); }; /** * * ublas binding for gsl_eigen_symm * input matrix type general matrix! * wrapping gsl_eigen_symm leaves input matrix * */ bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); }; /* * use expert routine to calculate only a subrange of eigenvalues */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); } /* * use expert routine to calculate only a subrange of eigenvalues single precision */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); } bool linalg_eigenvalues_general( ub::matrix &A,ub::matrix &B, ub::vector &E, ub::matrix &V) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); }; }} tools-1.4.1/src/libtools/linalg/dummy/invert.cc000066400000000000000000000023101315257650400215160ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { using namespace std; void linalg_invert( ub::matrix &A, ub::matrix &V){ throw std::runtime_error("linalg_invert is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); } bool linalg_solve(const ub::matrix &A, ub::matrix &B){ throw std::runtime_error("linalg_solve is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); } }} tools-1.4.1/src/libtools/linalg/dummy/qrsolve.cc000066400000000000000000000024671315257650400217170ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { using namespace std; void linalg_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::vector *residual) { throw std::runtime_error("linalg_qrsolve is not compiled-in due to disabling of GSL and MKL - recompile Votca Tools with GSL or MKL support"); } void linalg_constrained_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::matrix &constr) { throw std::runtime_error("linalg_constrained_qrsolve is not compiled-in due to disabling of GSL - recompile Votca Tools with GSLsupport"); } }} tools-1.4.1/src/libtools/linalg/dummy/svd.cc000066400000000000000000000024701315257650400210120ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include namespace votca { namespace tools { using namespace std; /** * ublas binding to GSL Singular Value Decomposition * * A = U S V^T * * @param A MxN matrix do decompose. Becomes an MxN orthogonal matrix U * @param V NxN orthogonal square matrix * @param E NxN diagonal matrix of singular values * @return succeeded or not */ bool linalg_singular_value_decomposition( ub::matrix &A, ub::matrix &VT, ub::vector &S ) { throw std::runtime_error("linalg_singular_value_decomposition is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); }; }} tools-1.4.1/src/libtools/linalg/gsl/000077500000000000000000000000001315257650400173365ustar00rootroot00000000000000tools-1.4.1/src/libtools/linalg/gsl/cholesky.cc000066400000000000000000000043771315257650400215010ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include namespace votca { namespace tools { using namespace std; void linalg_cholesky_decompose( ub::matrix &A){ // Cholesky decomposition using GSL const size_t N = A.size1(); gsl_matrix_view A_view = gsl_matrix_view_array(&A(0,0), N, N); // get the Cholesky matrices (void)gsl_linalg_cholesky_decomp ( &A_view.matrix ); } void linalg_cholesky_decompose( ub::matrix &A){ // Cholesky decomposition using GSL throw std::runtime_error("linalg_cholesky_decompose (float) is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); } void linalg_cholesky_solve(ub::vector &x, ub::matrix &A, ub::vector &b){ /* calling program should catch the error error code GSL_EDOM * thrown by gsl_linalg_cholesky_decomp and take * necessary steps */ gsl_matrix_view m = gsl_matrix_view_array (&A(0,0), A.size1(), A.size2()); gsl_vector_view gb = gsl_vector_view_array (&b(0), b.size()); gsl_vector *gsl_x = gsl_vector_alloc (x.size()); gsl_set_error_handler_off(); int status = gsl_linalg_cholesky_decomp(&m.matrix); if( status == GSL_EDOM) throw std::runtime_error("Matrix not symmetric positive definite"); gsl_linalg_cholesky_solve(&m.matrix, &gb.vector, gsl_x); for (size_t i =0 ; i < x.size(); i++) x(i) = gsl_vector_get(gsl_x, i); gsl_vector_free (gsl_x); } }} tools-1.4.1/src/libtools/linalg/gsl/eigensystems.cc000066400000000000000000000166641315257650400224010ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include /* sqrt */ #include #include #include namespace votca { namespace tools { using namespace std; /** * * ublas binding for gsl_eigen_symmv * note that the eigenvalues/eigenvectors are UNSORTED * */ bool linalg_eigenvalues_symmetric( ub::symmetric_matrix &A, ub::vector &E, ub::matrix &V) { gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // gsl does not handle conversion of a symmetric_matrix ub::matrix _A( N,N ); _A = A; E.resize(N, false); V.resize(N, N, false); gsl_matrix_view A_view = gsl_matrix_view_array(&_A(0,0), N, N); gsl_vector_view E_view = gsl_vector_view_array(&E(0), N); gsl_matrix_view V_view = gsl_matrix_view_array(&V(0,0), N, N); gsl_eigen_symmv_workspace *w = gsl_eigen_symmv_alloc(N); int status = gsl_eigen_symmv(&A_view.matrix, &E_view.vector, &V_view.matrix, w); //gsl_eigen_symmv_sort(&E_view.vector, &V_view.matrix, GSL_EIGEN_SORT_ABS_ASC); gsl_eigen_symmv_free(w); gsl_set_error_handler(handler); return (status != 0); }; /** * * ublas binding for gsl_eigen_symmv * input matrix type general matrix! * wrapping gsl_eigen_symmv * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V) { gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // gsl does not handle conversion of a symmetric_matrix ub::matrix _A( N,N ); _A = A; E.resize(N, false); V.resize(N, N, false); gsl_matrix_view A_view = gsl_matrix_view_array(&_A(0,0), N, N); gsl_vector_view E_view = gsl_vector_view_array(&E(0), N); gsl_matrix_view V_view = gsl_matrix_view_array(&V(0,0), N, N); gsl_eigen_symmv_workspace *w = gsl_eigen_symmv_alloc(N); int status = gsl_eigen_symmv(&A_view.matrix, &E_view.vector, &V_view.matrix, w); gsl_eigen_symmv_sort(&E_view.vector, &V_view.matrix, GSL_EIGEN_SORT_VAL_ASC); gsl_eigen_symmv_free(w); gsl_set_error_handler(handler); return (status != 0); }; /** * * ublas binding for gsl_eigen_symmv * input matrix type general matrix single precision! * wrapping gsl_eigen_symmv * */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V) { gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // gsl does not handle symmetric_matrix and floats, so this is super stupid ub::matrix _A( N,N ); _A = A; ub::vector _E(N); ub::matrix _V(N,N); gsl_matrix_view A_view = gsl_matrix_view_array(&_A(0,0), N, N); gsl_vector_view E_view = gsl_vector_view_array(&_E(0), N); gsl_matrix_view V_view = gsl_matrix_view_array(&_V(0,0), N, N); gsl_eigen_symmv_workspace *w = gsl_eigen_symmv_alloc(N); int status = gsl_eigen_symmv(&A_view.matrix, &E_view.vector, &V_view.matrix, w); gsl_eigen_symmv_sort(&E_view.vector, &V_view.matrix, GSL_EIGEN_SORT_VAL_ASC); gsl_eigen_symmv_free(w); gsl_set_error_handler(handler); //E.resize(N, false); //V.resize(N, N, false); E = _E; V = _V; return (status != 0); }; bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { /* on input V is the matrix that shall be diagonalized * GSL does not provide an in-place routine, so we wrap * gsl_eigen_symmv for compatibility */ // make a copy of E ub::matrix A = V; // now call wrapper for gsl_eigen_symmv bool status = linalg_eigenvalues( A , E, V ); return (status != 0); }; /** * * ublas binding for gsl_eigen_symm * input matrix type general matrix! * wrapping gsl_eigen_symm leaves input matrix * */ bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { /* on input V is the matrix that shall be diagonalized * GSL does not provide an in-place routine, so we wrap * gsl_eigen_symmv for compatibility */ // make a copy of E ub::matrix A = V; // now call wrapper for gsl_eigen_symmv bool status = linalg_eigenvalues( A , E, V ); return status; }; /* * use expert routine to calculate only a subrange of eigenvalues */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { throw std::runtime_error("linalg_eigenvalues is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); } /* * use expert routine to calculate only a subrange of eigenvalues single precision */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { // now call wrapper for gsl_eigen_symmv bool status = linalg_eigenvalues( A , E, V ); return status; } bool linalg_eigenvalues_general(const ub::matrix &A, const ub::matrix &B, ub::vector &E, ub::matrix &V) { gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // gsl destroys A so use copy ub::matrix _A( N,N ); _A = A; ub::matrix _B( N,N ); _B=B; E.resize(N, false); V.resize(N, N, false); gsl_matrix_view A_view = gsl_matrix_view_array(&_A(0,0), N, N); gsl_matrix_view B_view = gsl_matrix_view_array(&_B(0,0), N, N); gsl_vector_view E_view = gsl_vector_view_array(&E(0), N); gsl_matrix_view V_view = gsl_matrix_view_array(&V(0,0), N, N); gsl_eigen_gensymmv_workspace *w = gsl_eigen_gensymmv_alloc(N); int status = gsl_eigen_gensymmv(&A_view.matrix,&B_view.matrix, &E_view.vector, &V_view.matrix, w); gsl_eigen_gensymmv_sort(&E_view.vector, &V_view.matrix, GSL_EIGEN_SORT_VAL_ASC); gsl_eigen_gensymmv_free(w); gsl_set_error_handler(handler); ub::matrix _temp= ub::prod(B,V); ub::matrix n=ub::prod(ub::trans(V),_temp); /* for (int i=0;i #include #include #include #include namespace votca { namespace tools { using namespace std; void linalg_invert( ub::matrix &A, ub::matrix &V){ // matrix inversion using gsl gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // signum s (for LU decomposition) int s; //make copy of A as A is destroyed by GSL ub::matrix work=A; V.resize(N, N, false); // Define all the used matrices gsl_matrix_view A_view = gsl_matrix_view_array(&work(0,0), N, N); gsl_matrix_view V_view = gsl_matrix_view_array(&V(0,0), N, N); gsl_permutation * perm = gsl_permutation_alloc (N); // Make LU decomposition of matrix A_view gsl_linalg_LU_decomp (&A_view.matrix, perm, &s); // Invert the matrix A_view (void)gsl_linalg_LU_invert (&A_view.matrix, perm, &V_view.matrix); gsl_set_error_handler(handler); // return (status != 0); } void linalg_invert( ub::matrix &A, ub::matrix &V){ // matrix inversion using gsl throw std::runtime_error("linalg_invert (float) is not compiled-in due to disabling of MKL - recompile Votca Tools with MKL support"); } // not really tested bool linalg_solve(const ub::matrix &A, ub::vector &b){ gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t N = A.size1(); // signum s (for LU decomposition) int s; //make copy of A as A is destroyed by GSL ub::matrix work=A; ub::vectorx=ub::zero_vector(N); // Define all the used matrices gsl_matrix_view A_view = gsl_matrix_view_array(&work(0,0), N, N); gsl_vector_view B_view = gsl_vector_view_array(&b(0), N); gsl_vector_view X_view = gsl_vector_view_array(&x(0), N); gsl_permutation * perm = gsl_permutation_alloc (N); // Make LU decomposition of matrix A_view gsl_linalg_LU_decomp (&A_view.matrix, perm, &s); // Invert the matrix A_view int info=gsl_linalg_LU_solve (&A_view.matrix, perm, &B_view.vector,&X_view.vector); gsl_set_error_handler(handler); b=x; bool success=(info==0); return success; } }} tools-1.4.1/src/libtools/linalg/gsl/qrsolve.cc000066400000000000000000000224441315257650400213460ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include namespace votca { namespace tools { using namespace std; void linalg_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::vector *residual) { // check matrix for zero column int nonzero_found = 0; for(size_t j=0; j0) { nonzero_found = 1; } } if(nonzero_found==0) { throw "qrsolve_zero_column_in_matrix"; } } gsl_matrix_view m = gsl_matrix_view_array (&A(0,0), A.size1(), A.size2()); gsl_vector_view gb = gsl_vector_view_array (&b(0), b.size()); gsl_vector *gsl_x = gsl_vector_alloc (x.size()); gsl_vector *tau = gsl_vector_alloc (x.size()); gsl_vector *gsl_residual = gsl_vector_alloc (b.size()); gsl_linalg_QR_decomp (&m.matrix, tau); gsl_linalg_QR_lssolve (&m.matrix, tau, &gb.vector, gsl_x, gsl_residual); for (size_t i =0 ; i < x.size(); i++) x(i) = gsl_vector_get(gsl_x, i); if(residual) for (size_t i =0 ; i < residual->size(); i++) (*residual)(i) = gsl_vector_get(gsl_residual, i); gsl_vector_free (gsl_x); gsl_vector_free (tau); gsl_vector_free (gsl_residual); } void linalg_constrained_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::matrix &constr) { // check matrix for zero column int nonzero_found = 0; for(size_t j=0; j0) { nonzero_found = 1; } } if(nonzero_found==0) { throw std::runtime_error("constrained_qrsolve_zero_column_in_matrix"); } } const int N = b.size(); const int ngrid = x.size()/2; const int ysize = constr.size1(); //number of constraints is number of rows of constr //std::cout << "ysize: " << ysize << std::endl; //std::cout << "constr^T.size1: " << constr.size1() << " , constr^T.size2: " << constr.size2() << std::endl; // Transpose constr: constr = trans(constr); // temporary variables ub::matrix Q(2*ngrid, 2*ngrid); // Q matrix: QR decomposition of trans(B) (trans(B) has 2*ngrid rows and ysize columns ) // Q matrix is orthogonal 2*ngrid x 2*ngrid matrix ub::matrix Q_k(2*ngrid, 2*ngrid); ub::identity_matrix I (2*ngrid); ub::vector v(2*ngrid); Q = ub::zero_matrix(2*ngrid, 2*ngrid); Q_k = ub::zero_matrix(2*ngrid, 2*ngrid); v = ub::zero_vector(2*ngrid); double *tmp = & constr(0,0); gsl_matrix_view gsl_constr = gsl_matrix_view_array (tmp, constr.size1(), constr.size2()); tmp = &b(0); gsl_vector_view gsl_b = gsl_vector_view_array (tmp, b.size()); //vector to store Householder coefficients of QR-decomposition of trans(B) gsl_vector *tau_qr = gsl_vector_alloc (ysize); gsl_linalg_QR_decomp (&gsl_constr.matrix, tau_qr); //construct the matrix Q of trans(B)=Q * R Q = I; //k=1,..,ysize (number of rows of B, meaning number of constraints) for (int k = ysize; k > 0 ; k--) { for (int icout = 0; icout < k - 1; icout++) { v(icout) = 0; } v(k - 1) = 1.0; for (int icout = k; icout < 2*ngrid; icout++) { v(icout) = gsl_matrix_get(&gsl_constr.matrix, icout, k - 1 ); } Q_k = I - gsl_vector_get(tau_qr, k - 1 ) * outer_prod ( v, v ); Q = prec_prod(Q, Q_k); } //now Q is the one of trans(B)=Q * R Q = trans(Q); gsl_vector_free (tau_qr); // Calculate A * Q and store the result in A A = prec_prod(A, Q); // A = [A1 A2], so A2 is just a block of A // [A1 A2] has N rows. A1 has ysize columns (range(0,ysize) ). //A2 has 2*ngrid-ysize columns ( range(ysize,2*ngrid) ). ub::matrix A2 = ub::matrix_range >(A, ub::range (0, N), ub::range (ysize, 2*ngrid) ); tmp = &A2(0,0); gsl_matrix_view gsl_A2 = gsl_matrix_view_array (tmp, A2.size1(), A2.size2()); //now perform QR-decomposition of A2 to solve the least-squares problem A2 * z = b //A2 has N rows and (2*ngrid-ysize) columns -> gsl_vector *z = gsl_vector_alloc (2*ngrid-ysize); gsl_vector *tau_solve = gsl_vector_alloc (2*ngrid-ysize); gsl_vector *residual = gsl_vector_alloc (N); gsl_linalg_QR_decomp (&gsl_A2.matrix, tau_solve); gsl_linalg_QR_lssolve (&gsl_A2.matrix, tau_solve, &gsl_b.vector, z, residual); // Next two cycles assemble vector from y (which is zero-vector) and z // (which we just got by gsl_linalg_QR_lssolve) //vector y has ysize components for (int i = 0; i < ysize; i++ ) { x[i] = 0.0; } //vector z has (2*ngrid-ysize) components for (int i = ysize; i < 2 * ngrid; i++ ) { x[i] = gsl_vector_get(z, i - ysize); } /*for (int i = 0; i < 2 * ngrid; i++ ) { std::cout << "x[" << i << "]: " << x[i] << std::endl; }*/ // To get the final answer this vector should be multiplied by matrix Q // TODO: here i changed the sign, check again! (victor) x = -prec_prod( Q, x ); /*for (int i = 0; i < 2 * ngrid; i++ ) { std::cout << "x[" << i << "]: " << x[i] << std::endl; }*/ gsl_vector_free (z); gsl_vector_free (tau_solve); gsl_vector_free (residual); } /*void linalg_constrained_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::matrix &constr) { // check matrix for zero column int nonzero_found = 0; for(size_t j=0; j0) { nonzero_found = 1; } } if(nonzero_found==0) { throw std::runtime_error("constrained_qrsolve_zero_column_in_matrix"); } } // Transpose constr: constr = trans(constr); const int N = b.size(); const int ngrid = x.size()/2; // temporary variables ub::matrix Q(2*ngrid, 2*ngrid); // Q matrix: QR decomposition of trans(B) ub::matrix Q_k(2*ngrid, 2*ngrid); ub::identity_matrix I (2*ngrid); ub::vector v(2*ngrid); Q = ub::zero_matrix(2*ngrid, 2*ngrid); Q_k = ub::zero_matrix(2*ngrid, 2*ngrid); v = ub::zero_vector(2*ngrid); double *tmp = & constr(0,0); gsl_matrix_view gsl_constr = gsl_matrix_view_array (tmp, constr.size1(), constr.size2()); tmp = &b(0); gsl_vector_view gsl_b = gsl_vector_view_array (tmp, b.size()); gsl_vector *tau_qr = gsl_vector_alloc (ngrid); gsl_linalg_QR_decomp (&gsl_constr.matrix, tau_qr); Q = I; for (int k = ngrid; k > 0 ; k--) { for (int icout = 0; icout < k - 1; icout++) { v(icout) = 0; } v(k - 1) = 1.0; for (int icout = k; icout < 2*ngrid; icout++) { v(icout) = gsl_matrix_get(&gsl_constr.matrix, icout, k - 1 ); } Q_k = I - gsl_vector_get(tau_qr, k - 1 ) * outer_prod ( v, v ); Q = prec_prod(Q, Q_k); } Q = trans(Q); gsl_vector_free (tau_qr); // Calculate A * Q and store the result in A A = prec_prod(A, Q); // A = [A1 A2], so A2 is just a block of A ub::matrix A2 = ub::matrix_range >(A, ub::range (0, N), ub::range (ngrid, 2*ngrid) ); tmp = &A2(0,0); gsl_matrix_view gsl_A2 = gsl_matrix_view_array (tmp, A2.size1(), A2.size2()); gsl_vector *z = gsl_vector_alloc (ngrid); gsl_vector *tau_solve = gsl_vector_alloc (ngrid); // already done! gsl_vector *residual = gsl_vector_alloc (N); gsl_linalg_QR_decomp (&gsl_A2.matrix, tau_solve); gsl_linalg_QR_lssolve (&gsl_A2.matrix, tau_solve, &gsl_b.vector, z, residual); // Next two cycles assemble vector from y (which is zero-vector) and z // (which we just got by gsl_linalg_QR_lssolve) for (int i = 0; i < ngrid; i++ ) { x[i] = 0.0; } for (int i = ngrid; i < 2 * ngrid; i++ ) { x[i] = gsl_vector_get(z, i - ngrid); } // To get the final answer this vector should be multiplied by matrix Q // TODO: here i changed the sign, check again! (victor) x = -prec_prod( Q, x ); gsl_vector_free (z); gsl_vector_free (tau_solve); gsl_vector_free (residual); }*/ }} tools-1.4.1/src/libtools/linalg/gsl/svd.cc000066400000000000000000000043071315257650400204450ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include namespace votca { namespace tools { using namespace std; /** * ublas binding to GSL Singular Value Decomposition * * A = U S V^T * * @param A MxN matrix do decompose. Becomes an MxN orthogonal matrix U * @param V NxN orthogonal square matrix * @param S N vector of non-negative numbers forming a non-increasing sequence * @return succeeded or not */ bool linalg_singular_value_decomposition(ub::matrix &A, ub::matrix &VT, ub::vector &S ) { gsl_error_handler_t *handler = gsl_set_error_handler_off(); const size_t M = A.size1(); const size_t N = A.size2(); // gsl does not handle conversion of a symmetric_matrix if (M>N){ throw runtime_error("Matrix for svd has the wrong shape first dimension must be equal or larger than second."); } S.resize(N, false); VT.resize(N, N, false); gsl_matrix_view A_view = gsl_matrix_view_array(&A(0,0), M, N); gsl_vector_view S_view = gsl_vector_view_array(&S(0), N); gsl_matrix_view V_view = gsl_matrix_view_array(&VT(0,0), N, N); gsl_vector * work = gsl_vector_alloc(N); int status = gsl_linalg_SV_decomp (&A_view.matrix, &V_view.matrix, &S_view.vector, work); //gsl_eigen_symmv_sort(&E_view.vector, &V_view.matrix, GSL_EIGEN_SORT_ABS_ASC); gsl_set_error_handler(handler); gsl_vector_free (work); VT=ub::trans(VT); return (status != 0); }; }} tools-1.4.1/src/libtools/linalg/mkl/000077500000000000000000000000001315257650400173345ustar00rootroot00000000000000tools-1.4.1/src/libtools/linalg/mkl/cholesky.cc000066400000000000000000000052311315257650400214650ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "mkl.h" #include "mkl_lapacke.h" namespace votca { namespace tools { using namespace std; void linalg_cholesky_decompose( ub::matrix &A){ // Cholesky decomposition using MKL // input matrix A will be changed // LAPACK variables MKL_INT info; MKL_INT n = A.size1(); char uplo = 'L'; // pointer for LAPACK double * pA = const_cast(&A.data().begin()[0]); info = LAPACKE_dpotrf( LAPACK_ROW_MAJOR , uplo , n, pA, n ); if ( info != 0 ) throw std::runtime_error("Matrix not symmetric positive definite"); } void linalg_cholesky_decompose( ub::matrix &A){ // Cholesky decomposition using MKL // input matrix A will be changed // LAPACK variables MKL_INT info; MKL_INT n = A.size1(); char uplo = 'L'; // pointer for LAPACK float * pA = const_cast(&A.data().begin()[0]); info = LAPACKE_spotrf( LAPACK_ROW_MAJOR , uplo , n, pA, n ); if ( info != 0 ) throw std::runtime_error("Matrix not symmetric positive definite"); } void linalg_cholesky_solve( ub::vector &x, ub::matrix &A, ub::vector &b ){ /* calling program should catch the error error code * thrown by LAPACKE_dpotrf and take * necessary steps */ // LAPACK variables MKL_INT info; MKL_INT n = A.size1(); char uplo = 'L'; // pointer for LAPACK LU factorization of input matrix double * pA = const_cast(&A.data().begin()[0]); // input array // get LU factorization info = LAPACKE_dpotrf( LAPACK_ROW_MAJOR , uplo , n, pA, n ); if ( info != 0 ) throw std::runtime_error("Matrix not symmetric positive definite"); MKL_INT nrhs = 1; // pointer of LAPACK LU solver double * pb = const_cast(&b.data()[0]); info = LAPACKE_dpotrs(LAPACK_ROW_MAJOR, uplo, n, nrhs, pA, n, pb, n ); // on output, b contains solution x = b; } }} tools-1.4.1/src/libtools/linalg/mkl/eigensystems.cc000066400000000000000000000207351315257650400223710ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "mkl.h" #include "mkl_lapacke.h" namespace votca { namespace tools { using namespace std; /* Wrapper for DSYEV * - make copy of input matrix */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V) { // cout << " \n I'm really using MKL! " << endl; int n = A.size1(); int lda = n ; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(n); V.resize(n, n); // Query and allocate the optimal workspace double wkopt; double* work; int info; int lwork; lwork = -1; // MKL is different to GSL because it overwrites the input matrix V = A; // make a copy (might actually be unnecessary in most cases!) // make a pointer to the ublas matrix so that LAPACK understands it double * pV = const_cast(&V.data().begin()[0]); double * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, pV , lda, pE ); if( info > 0 ) { return false; } else { return true; } }; bool linalg_eigenvalues_symmetric( ub::symmetric_matrix &A, ub::vector &E, ub::matrix &V) { // cout << " \n I'm really using MKL! " << endl; int n = A.size1(); int lda = n ; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(n); V.resize(n, n); // Query and allocate the optimal workspace double wkopt; double* work; int info; int lwork; lwork = -1; // MKL does not handle conversion of a symmetric_matrix V = A; // make a pointer to the ublas matrix so that LAPACK understands it double * pV = const_cast(&V.data().begin()[0]); double * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, pV , lda, pE ); if( info > 0 ) { return false; } else { return true; } }; bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { // cout << " \n I'm really using MKL! " << endl; int n = V.size1(); int lda = n ; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(n); // V.resize(n, n); // Query and allocate the optimal workspace double wkopt; double* work; int info; int lwork; lwork = -1; // MKL is different to GSL because it overwrites the input matrix // V = A; // make a copy (might actually be unnecessary in most cases!) // make a pointer to the ublas matrix so that LAPACK understands it double * pV = const_cast(&V.data().begin()[0]); double * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_dsyev( LAPACK_ROW_MAJOR, 'V', 'U', n, pV , lda, pE ); if( info > 0 ) { return false; } else { return true; } }; bool linalg_eigenvalues( ub::vector &E, ub::matrix &V) { // cout << " \n I'm really using MKL! " << endl; int n = V.size1(); int lda = n ; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(n); // V.resize(n, n); // Query and allocate the optimal workspace float wkopt; float* work; int info; int lwork; lwork = -1; // MKL is different to GSL because it overwrites the input matrix // V = A; // make a copy (might actually be unnecessary in most cases!) // make a pointer to the ublas matrix so that LAPACK understands it float * pV = const_cast(&V.data().begin()[0]); float * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_ssyev( LAPACK_ROW_MAJOR, 'V', 'U', n, pV , lda, pE ); if( info > 0 ) { return false; } else { return true; } }; /* * use expert routine to calculate only a subrange of eigenvalues */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { /* * INPUT: matrix A (N,N) * OUTPUT: matrix V (N,NMAX) * vector E (NMAX) */ double wkopt; double* work; double abstol, vl, vu; MKL_INT lda; MKL_INT info; MKL_INT lwork; MKL_INT il, iu, m, ldz ; int n = A.size1(); MKL_INT ifail[n]; lda = n; ldz = nmax; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(nmax); V.resize(n,nmax); lwork = -1; il = 1; iu = nmax; abstol = 0.0; // use default vl = 0.0; vu = 0.0; // make a pointer to the ublas matrix so that LAPACK understands it double * pA = const_cast(&A.data().begin()[0]); double * pV = const_cast(&V.data().begin()[0]); double * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_dsyevx( LAPACK_ROW_MAJOR, 'V', 'I', 'U', n, pA , lda, vl, vu, il, iu, abstol, &m, pE, pV, nmax, ifail ); if( info > 0 ) { return false; } else { return true; } }; /* * use expert routine to calculate only a subrange of eigenvalues */ bool linalg_eigenvalues( ub::matrix &A, ub::vector &E, ub::matrix &V , int nmax) { /* * INPUT: matrix A (N,N) * OUTPUT: matrix V (N,NMAX) * vector E (NMAX) */ float wkopt; float* work; float abstol, vl, vu; MKL_INT lda; MKL_INT info; MKL_INT lwork; MKL_INT il, iu, m, ldz ; int n = A.size1(); MKL_INT ifail[n]; lda = n; ldz = nmax; // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(nmax); V.resize(n,nmax); lwork = -1; il = 1; iu = nmax; abstol = 0.0; // use default vl = 0.0; vu = 0.0; // make a pointer to the ublas matrix so that LAPACK understands it float * pA = const_cast(&A.data().begin()[0]); float * pV = const_cast(&V.data().begin()[0]); float * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_ssyevx( LAPACK_ROW_MAJOR, 'V', 'I', 'U', n, pA , lda, vl, vu, il, iu, abstol, &m, pE, pV, nmax, ifail ); if( info > 0 ) { return false; } else { return true; } }; /* calculate the eigenvalues and vectors of the generalized eigenvalue problem */ bool linalg_eigenvalues_general(const ub::matrix &A,const ub::matrix &B, ub::vector &E, ub::matrix &V) { // cout << " \n I'm really using MKL! " << endl; //check to see if matrices have same size int lda = A.size1(); MKL_INT n = lda ; int ldb =B.size1(); ub::matrix _B(ldb,ldb); _B=B; if (lda!=ldb){ cout << "Matrices A and B have not the same size"<< endl; exit(1); } // make sure that containers for eigenvalues and eigenvectors are of correct size E.resize(lda); V.resize(lda, lda); // Query and allocate the optimal workspace MKL_INT info=0; MKL_INT LDA=lda; MKL_INT LDB=ldb; // MKL is different to GSL because it overwrites the input matrix V = A; // make a copy (might actually be unnecessary in most cases!) // make a pointer to the ublas matrix so that LAPACK understands it double * pB = const_cast(&_B.data().begin()[0]); double * pV = const_cast(&V.data().begin()[0]); double * pE = const_cast(&E.data()[0]); // call LAPACK via C interface info = LAPACKE_dsygv( LAPACK_ROW_MAJOR,1,'V', 'U', n, pV , lda,pB,ldb, pE ); if( info != 0 ) { return false; } else { return true; } }; }} tools-1.4.1/src/libtools/linalg/mkl/invert.cc000066400000000000000000000055041315257650400211560ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "mkl.h" #include "mkl_lapacke.h" namespace votca { namespace tools { using namespace std; void linalg_invert( ub::matrix &A, ub::matrix &V){ // matrix inversion using MKL // input matrix is destroyed, make local copy ub::matrix work = A; // define LAPACK variables MKL_INT n = A.size1(); MKL_INT info; MKL_INT ipiv[n]; // initialize V V = ub::identity_matrix(n,n); // pointers for LAPACK double * pV = const_cast(&V.data().begin()[0]); double * pwork = const_cast(&work.data().begin()[0]); // solve info = LAPACKE_dgesv( LAPACK_ROW_MAJOR, n, n, pwork , n, ipiv, pV, n ); if(info!=0){ throw std::runtime_error("Matrix not symmetric positive definite"); } } void linalg_invert( ub::matrix &A, ub::matrix &V){ // matrix inversion using MKL // input matrix is destroyed, make local copy ub::matrix work = A; // define LAPACK variables MKL_INT n = A.size1(); MKL_INT info; MKL_INT ipiv[n]; // initialize V V = ub::identity_matrix(n,n); // pointers for LAPACK float * pV = const_cast(&V.data().begin()[0]); float * pwork = const_cast(&work.data().begin()[0]); // solve info = LAPACKE_sgesv( LAPACK_ROW_MAJOR, n, n, pwork , n, ipiv, pV, n ); if(info!=0){ throw std::runtime_error("Matrix not symmetric positive definite"); } } bool linalg_solve(const ub::matrix &A, ub::vector &b){ // matrix inversion using MKL // input matrix is destroyed, make local copy ub::matrix work = A; // define LAPACK variables MKL_INT n = A.size1(); MKL_INT info; MKL_INT ipiv[n]; MKL_INT bsize = 1; // initialize V // pointers for LAPACK double * pV = const_cast(&b.data().begin()[0]); double * pwork = const_cast(&work.data().begin()[0]); // solve info = LAPACKE_dgesv( LAPACK_ROW_MAJOR, n, bsize, pwork , n, ipiv, pV, bsize ); bool success=(info==0); return success; } }} tools-1.4.1/src/libtools/linalg/mkl/qrsolve.cc000066400000000000000000000045721315257650400213460ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "mkl.h" #include "mkl_lapacke.h" namespace votca { namespace tools { using namespace std; void linalg_qrsolve(ub::vector &x, ub::matrix &A, ub::vector &b, ub::vector *residual){ // check matrix for zero column int nonzero_found = 0; for(size_t j=0; j0) { nonzero_found = 1; } } if(nonzero_found==0) { throw "qrsolve_zero_column_in_matrix"; } } MKL_INT info; MKL_INT sizeM = A.size1(); MKL_INT sizeN = A.size2(); MKL_INT nrhs = 1; char trans = 'N'; // pointer for LAPACK double * pA = const_cast(&A.data().begin()[0]); double * pb = const_cast(&b.data()[0]); info = LAPACKE_dgels( LAPACK_ROW_MAJOR , trans , sizeM, sizeN, nrhs , pA , sizeM , pb , sizeM ); if ( info != 0 ) throw std::runtime_error("QR least-squares solver failed"); for (size_t i =0 ; i < x.size(); i++){ x(i) = b(i); } /* std::cout <<" x "< &x, ub::matrix &A, ub::vector &b, ub::matrix &constr){ // matrix inversion using MKL throw std::runtime_error("linalg_constrained_qrsolve is not compiled-in due to disabling of GSL - recompile Votca Tools with GSLsupport"); } }} tools-1.4.1/src/libtools/linalg/mkl/svd.cc000066400000000000000000000041371315257650400204440ustar00rootroot00000000000000/* * Copyright 2009-2015 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include "mkl.h" #include "mkl_lapacke.h" namespace votca { namespace tools { using namespace std; /** * ublas binding to MKL Singular Value Decomposition * * A = U S V^T * * @param A MxN matrix do decompose. Becomes an MxN orthogonal matrix U * @param V NxN orthogonal square matrix * @param S N vector of non-negative numbers forming a non-increasing sequence * @return succeeded or not */ bool linalg_singular_value_decomposition(ub::matrix &A, ub::matrix &VT, ub::vector &S ){ // matrix inversion using MKL // define LAPACK variables MKL_INT m = A.size1(); MKL_INT n = A.size2(); if (m>n){ throw runtime_error("Matrix for svd has the wrong shape first dimension must be equal or larger than second."); } //MKL_INT info; //MKL_INT ipiv[n]; ub::matrixwork=ub::zero_matrix(m,n); // initialize V S.resize(n, false); VT.resize(n, n, false); // pointers for LAPACK double * a = const_cast(&A.data().begin()[0]); double * s = const_cast(&S.data().begin()[0]); double * vt = const_cast(&VT.data().begin()[0]); double * superb = const_cast(&work.data().begin()[0]); // solve int status= LAPACKE_dgesvd( LAPACK_ROW_MAJOR, 'O', 'A', m, n, a, n, s, NULL,m, vt, n, superb ); return (status != 0); } }} tools-1.4.1/src/libtools/linspline.cc000066400000000000000000000064611315257650400176160ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include namespace votca { namespace tools { using namespace std; void LinSpline::Interpolate(ub::vector &x, ub::vector &y) { if(x.size() != y.size()) throw std::invalid_argument("error in LinSpline::Interpolate : sizes of vectors x and y do not match"); if(x.size()<2) throw std::invalid_argument("error in LinSpline::Interpolate : vectors x and y have to contain at least 2 points"); const int N = x.size(); // adjust the grid _r.resize(N); // copy the grid points into f _r = x; // LINEAR SPLINE: a(i) * x + b(i) // where i=number of interval // initialize vectors a,b a = ub::zero_vector(N); b = ub::zero_vector(N); // boundary conditions not applicable // calculate a,b for all intervals 0..(N-2), where interval // [x(i),x(i+1)] shall have number i (this means that the last interval // has number N-2) for (int i=0; i &x, ub::vector &y) { if(x.size() != y.size()) throw std::invalid_argument("error in LinSpline::Fit : sizes of vectors x and y do not match"); const int N = x.size(); const int ngrid = _r.size(); // construct the equation // A*u = b // The matrix A contains all conditions // s_i(x) = (y(i+1)-y(i)) * (x-r(i))/(r(i+1)-r(i)) + y(i) // where y(i) are the unknown values at grid points r(i), and // the condition y=s_i(x) is to be satisfied at all input points: // therefore b=y and u=vector of all unknown y(i) ub::matrix A(N, ngrid); A = ub::zero_matrix(N, ngrid); int interval; // construct matrix A for (int i=0; i sol(ngrid); votca::tools::linalg_qrsolve(sol, A, y); // vector "sol" contains all y-values of fitted linear splines at each // interval border // get a(i) and b(i) for piecewise splines out of solution vector "sol" a = ub::zero_vector(ngrid-1); b = ub::zero_vector(ngrid-1); for (int i=0; i #include #include #define PITIMES2 2*3.141592654 namespace votca { namespace tools { void matrix::RandomRotation() { matrix &M=(*this); double theta = drand48() * PITIMES2; /* Rotation about the pole (Z). */ double phi = drand48() * PITIMES2; /* For direction of pole deflection. */ double z = drand48() * 2.0; /* For magnitude of pole deflection. */ /* Compute a vector V used for distributing points over the sphere */ /* via the reflection I - V Transpose(V). This formulation of V */ /* will guarantee that if x[1] and x[2] are uniformly distributed, */ /* the reflected points will be uniform on the sphere. Note that V */ /* has length sqrt(2) to eliminate the 2 in the Householder matrix. */ double r = sqrt( z ); double Vx = sin( phi ) * r; double Vy = cos( phi ) * r; double Vz = sqrt( 2.0 - z ); /* Compute the row vector S = Transpose(V) * R, where R is a simple */ /* rotation by theta about the z-axis. No need to compute Sz since */ /* it's just Vz. */ double st = sin( theta ); double ct = cos( theta ); double Sx = Vx * ct - Vy * st; double Sy = Vx * st + Vy * ct; /* Construct the rotation matrix ( V Transpose(V) - I ) R, which */ /* is equivalent to V S - R. */ M[0][0] = Vx * Sx - ct; M[0][1] = Vx * Sy - st; M[0][2] = Vx * Vz; M[1][0] = Vy * Sx + st; M[1][1] = Vy * Sy - ct; M[1][2] = Vy * Vz; M[2][0] = Vz * Sx; M[2][1] = Vz * Sy; M[2][2] = 1.0 - z; /* This equals Vz * Vz - 1.0 */ } int cjcbi(matrix &a, matrix &v, double eps, int jt) { int n=3; int i,j,p=-1,q=-1,l; double fm,cn,sn,omega,x,y,d; l=1; v.UnitMatrix(); while (true) { fm=0.0; for (i=1; i<=n-1; i++) for (j=0; j<=i-1; j++) { d=fabs(a[i][j]); if ((i!=j)&&(d>fm)) { fm=d; p=i; q=j;} } if (fmjt) return(-1); l=l+1; x=-a[p][q]; y=(a[q][q]-a[p][p])/2.0; omega=x/sqrt(x*x+y*y); if (y<0.0) omega=-omega; sn=1.0+sqrt(1.0-omega*omega); sn=omega/sqrt(2.0*sn); cn=sqrt(1.0-sn*sn); fm=a[p][p]; a[p][p]=fm*cn*cn+a[q][q]*sn*sn+a[p][q]*omega; a[q][q]=fm*sn*sn+a[q][q]*cn*cn-a[p][q]*omega; a[p][q]=0.0; a[q][p]=0.0; for (j=0; j<=n-1; j++) if ((j!=p)&&(j!=q)) { //u=p*n+j; w=q*n+j; fm=a[p][j]; a[p][j]=fm*cn+a[q][j]*sn; a[q][j]=-fm*sn+a[q][j]*cn; } for (i=0; i<=n-1; i++) if ((i!=p)&&(i!=q)) { //u=i*n+p; w=i*n+q; fm=a[i][p]; a[i][p]=fm*cn+a[i][q]*sn; a[i][q]=-fm*sn+a[i][q]*cn; } for (i=0; i<=n-1; i++) { //u=i*n+p; w=i*n+q; fm=v[i][p]; v[i][p]=fm*cn+v[i][q]*sn; v[i][q]=-fm*sn+v[i][q]*cn; } } return(1); } using namespace std; void matrix::SolveEigensystem(eigensystem_t &out) { matrix m(*this); matrix v; cjcbi(m, v); for(int i=0; i<3; ++i) { out.eigenvalues[i] = m[i][i]; out.eigenvecs[i] = vec(v[0][i], v[1][i], v[2][i]); out.eigenvecs[i].normalize(); } //cout << v << endl; // sort by eigenvalues if(out.eigenvalues[0] > out.eigenvalues[1]) { std::swap(out.eigenvalues[0], out.eigenvalues[1]); std::swap(out.eigenvecs[0], out.eigenvecs[1]); } if(out.eigenvalues[1] > out.eigenvalues[2]) { std::swap(out.eigenvalues[1], out.eigenvalues[2]); std::swap(out.eigenvecs[1], out.eigenvecs[2]); } if(out.eigenvalues[0] > out.eigenvalues[1]) { std::swap(out.eigenvalues[0], out.eigenvalues[1]); std::swap(out.eigenvecs[0], out.eigenvecs[1]); } } void matrix::Invert() { matrix mi; matrix &m=*this; mi[0][0] = m[1][1]*m[2][2] - m[1][2]*m[2][1]; mi[1][0] = m[1][2]*m[2][0] - m[1][0]*m[2][2]; mi[2][0] = m[1][0]*m[2][1] - m[1][1]*m[2][0]; mi[0][1] = m[0][2]*m[2][1] - m[0][1]*m[2][2]; mi[1][1] = m[0][0]*m[2][2] - m[0][2]*m[2][0]; mi[2][1] = m[0][1]*m[2][0] - m[0][0]*m[2][1]; mi[0][2] = m[0][1]*m[1][2] - m[0][2]*m[1][1]; mi[1][2] = m[0][2]*m[1][0] - m[0][0]*m[1][2]; mi[2][2] = m[0][0]*m[1][1] - m[0][1]*m[1][0]; ///calc the determinant, with the diagonal double D; D = m[0][0]*mi[0][0] + m[0][1]*mi[1][0] + m[0][2]*mi[2][0]; mi /= D; *this = mi; } }} tools-1.4.1/src/libtools/mutex.cc000066400000000000000000000020531315257650400167540ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { Mutex::Mutex() { pthread_mutex_init(&_mutexVar, NULL); } Mutex::~Mutex() { pthread_mutex_destroy(&_mutexVar); } void Mutex::Lock() { pthread_mutex_lock(&_mutexVar); } void Mutex::Unlock() { pthread_mutex_unlock(&_mutexVar); } } } tools-1.4.1/src/libtools/parcer.cc000066400000000000000000000025471315257650400170760ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace tools { using namespace std; //wrapper written with Denis to do MOO only on a file which give the unitary transformation + displacement one per line void parce_string (string line, string delims, vector* result ) { string::size_type begIdx, endIdx; begIdx = line.find_first_not_of(delims); while (begIdx != string::npos) { endIdx = line.find_first_of (delims, begIdx); if (endIdx == string::npos) { endIdx = line.length(); } result->push_back( line.substr(begIdx, endIdx-begIdx) ); if (endIdx == line.length()) { break; cout << "I am still here";} begIdx = line.find_first_not_of (delims, endIdx); } } }}tools-1.4.1/src/libtools/parsexml.cc000066400000000000000000000051561315257650400174540ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include namespace votca { namespace tools { void start_hndl(void *data, const char *el, const char **attr) { ParseXML *reader = (ParseXML*) XML_GetUserData((XML_Parser*) data); map mattr; for (int i = 0; attr[i]; i += 2) mattr[attr[i]] = attr[i + 1]; string sel = el; reader->StartElemHndl(sel, mattr); } void end_hndl(void *data, const char *el) { ParseXML *reader = (ParseXML*) XML_GetUserData((XML_Parser*) data); reader->EndElemHndl(el); } void ParseXML::Open(const string &filename) { XML_Parser parser = XML_ParserCreate(NULL); if (!parser) throw std::runtime_error("Couldn't allocate memory for xml parser"); XML_UseParserAsHandlerArg(parser); XML_SetElementHandler(parser, start_hndl, end_hndl); // XML_SetCharacterDataHandler(parser, char_hndl); ifstream fl; fl.open(filename.c_str()); if (!fl.is_open()) throw std::ios_base::failure("Error on open xml file: " + filename); XML_SetUserData(parser, (void*) this); while (!fl.eof()) { string line; getline(fl, line); line = line + "\n"; if (!XML_Parse(parser, line.c_str(), line.length(), fl.eof())) throw std::ios_base::failure(filename + ": Parse error in " + filename + " at line " + boost::lexical_cast (XML_GetCurrentLineNumber(parser)) + "\n" + XML_ErrorString(XML_GetErrorCode(parser))); } fl.close(); } void ParseXML::ParseIgnore(const string &el, map &attr) { NextHandler(this, &ParseXML::ParseIgnore); } void ParseXML::StartElemHndl(const string &el, map &attr) { (*_handler)(el, attr); } void ParseXML::EndElemHndl(const string &el) { delete _handler; _stack_handler.pop(); _handler = _stack_handler.top(); } }} tools-1.4.1/src/libtools/property.cc000066400000000000000000000353511315257650400175050ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace votca { namespace tools { // ostream modifier defines the output format, level, indentation const int Property::IOindex = std::ios_base::xalloc(); Property &Property::get(const string &key) { Tokenizer tok(key, "."); Tokenizer::iterator n; n = tok.begin(); if(n==tok.end()) return *this; Property *p; map::iterator iter; if(*n=="") { p = this; } else { iter = _map.find(*n); if(iter == _map.end()) throw runtime_error("property not found: " + key); p = (((*iter).second)); } ++n; try { for(; n!=tok.end(); ++n) { p = &p->get(*n); } } catch(string err) { // catch here to get full key in exception throw runtime_error("property not found: " + key); } return *p; } std::list Property::Select(const string &filter) { Tokenizer tok(filter, "."); std::list selection; if(tok.begin()==tok.end()) return selection; selection.push_back(this); for (Tokenizer::iterator n = tok.begin(); n != tok.end(); ++n) { std::list childs; for (std::list::iterator p = selection.begin(); p != selection.end(); ++p) { for (list::iterator iter = (*p)->_properties.begin(); iter != (*p)->_properties.end(); ++iter) { if (wildcmp((*n).c_str(), (*iter).name().c_str())) { childs.push_back(&(*iter)); } } } selection = childs; } return selection; } static void start_hndl(void *data, const char *el, const char **attr) { stack *property_stack = (stack *)XML_GetUserData((XML_Parser*)data); Property *cur = property_stack->top(); Property &np = cur->add(el, ""); for (int i = 0; attr[i]; i += 2) np.setAttribute(attr[i], attr[i + 1]); property_stack->push(&np); } static void end_hndl(void *data, const char *el) { stack *property_stack = (stack *)XML_GetUserData((XML_Parser*)data); property_stack->pop(); } void char_hndl(void *data, const char *txt, int txtlen) { stack *property_stack = (stack *)XML_GetUserData((XML_Parser*)data); Property *cur = property_stack->top(); cur->value().append(txt, txtlen); } bool load_property_from_xml(Property &p, string filename) { XML_Parser parser = XML_ParserCreate(NULL); if (! parser) throw std::runtime_error("Couldn't allocate memory for xml parser"); XML_UseParserAsHandlerArg(parser); XML_SetElementHandler(parser, start_hndl, end_hndl); XML_SetCharacterDataHandler(parser, char_hndl); ifstream fl; fl.open(filename.c_str()); if(!fl.is_open()) throw std::ios_base::failure("Error on open xml file: " + filename); stack pstack; pstack.push(&p); XML_SetUserData(parser, (void*)&pstack); while(!fl.eof()) { string line; getline(fl, line); line=line + "\n"; if (! XML_Parse(parser, line.c_str(), line.length(), fl.eof())) throw std::ios_base::failure(filename + ": Parse error at line " + boost::lexical_cast(XML_GetCurrentLineNumber(parser)) + "\n" + XML_ErrorString(XML_GetErrorCode(parser))); } fl.close(); return true; } void PrintNodeTXT(std::ostream &out, Property &p, const int start_level, int level=0, string prefix="", string offset="") { list::iterator iter; if((p.value() != "") || p.HasChilds() ) { if ( level >= start_level ) { if((p.value()).find_first_not_of("\t\n ") != std::string::npos) out << offset << prefix << " = " << p.value() << endl; } else { prefix=""; } } for(iter = p.begin(); iter!=p.end(); ++iter) { if(prefix=="") { level++; PrintNodeTXT(out, (*iter), start_level, level, prefix + (*iter).name(), offset ); level--; } else { level++; PrintNodeTXT(out, (*iter), start_level, level, prefix + "." + (*iter).name(), offset ); level--; } } } void PrintNodeXML(std::ostream &out, Property &p, PropertyIOManipulator *piom, int level=0, string offset="") { list::iterator iter; Property::AttributeIterator ia; bool _endl = true; bool has_value; const ColorSchemeBase *color = &DEFAULT_COLORS; string indent(""); int start_level(0); if ( piom ) { start_level = piom->getLevel(); indent = piom->getIndentation(); color = piom->getColorScheme(); } string cKey = color->Magenta(); string cAttribute = color->Blue(); string cAttributeValue = color->Green(); string cReset = color->Reset(); // print starting only from the start_level (the first node (level 0) can be <> ) if ( level >= start_level ) { // print the node name out << indent << offset << "<" << cKey << p.name() << cReset; // print the node attributes for(ia = p.firstAttribute(); ia!=p.lastAttribute(); ++ia) out << " " << cAttribute << ia->first << cReset << "=\"" << cAttributeValue << ia->second << cReset << "\"" ; out << ">"; // print node value if it is not empty has_value = ( (p.value()).find_first_not_of("\t\n ") != std::string::npos ); if( has_value ) { out << cAttributeValue << p.value() << cReset; _endl = false; } // check if we need the end of the line or not if( !has_value && p.HasChilds() ) out << endl; if( !has_value && !p.HasChilds() ) _endl = false; } // continue iteratively through the rest of the nodes for(iter = p.begin(); iter!=p.end(); ++iter) { level++; if ( level > start_level ) offset += "\t"; PrintNodeXML(out, (*iter), piom, level, offset); if ( level > start_level ) offset.resize(offset.size()-1); level--; } if ( level >= start_level ) { if ( _endl ) { out << indent << offset << "" << endl; } else { if (has_value) { // avoid indent after the value out << "" << endl; } else { out << indent << offset << "" << endl; } } } } void PrintNodeTEX(std::ostream &out, Property &p, PropertyIOManipulator *piom, int level=0, string prefix="") { list::iterator iter; string head_name; string _label(""); // reference of the xml file in the manual string _section(""); // reference of the description section in the manual string _help(""); string _default(""); // default value if supplied string _unit(""); //unit, if supplied int start_level(0); if ( piom ) { start_level = piom->getLevel(); } string header_format("\\subsection{%1%}\n" "\\label{%2%}\n%3%\n" "\\rowcolors{1}{invisiblegray}{white}\n" "{\\small\n " "\\begin{longtable}{m{3cm}|m{2cm}|m{1cm}|m{8cm}}\n" " option & default & unit & description\\\\\n\\hline\n"); string footer_format("\\end{longtable}\n}\n" "\\noindent Return to the description of \\slink{%1%}{\\texttt{%2%}}.\n"); string body_format(" \\hspace{%1%pt}\\hypertarget{%2%}{%3%} & %4% & %5% & %6% \\\\\n"); // if this is the head node, print the header if ( level == start_level ) { head_name = p.name(); _label = "calc:" + head_name; if ( p.hasAttribute("section") ) _section = p.getAttribute("section"); if ( p.hasAttribute("help") ) _help = p.getAttribute("help"); out << boost::format(header_format) % head_name % _label % _help; prefix = p.name(); } if ( level > start_level ) { // if this node has children or a value or is not the first, start recursive printing if( ( p.value() != "" || p.HasChilds() ) && level > -1) { string _tex_name = boost::replace_all_copy( p.name(), "_", "\\_" ); if ( p.hasAttribute("default") ) _default = p.getAttribute("default"); if ( p.hasAttribute("unit") ) _unit = p.getAttribute("unit"); if ( p.hasAttribute("help") ) _help = p.getAttribute("help"); out << boost::format(body_format) % int((level-start_level-1)*10) % prefix % _tex_name % _default % _unit % _help; } } // continue iteratively through the rest of the nodes for(iter = p.begin(); iter != p.end(); ++iter) { if(prefix=="") { level++; PrintNodeTEX(out, (*iter), piom, level, prefix); level--; } else { level++; PrintNodeTEX(out, (*iter), piom, level, prefix); level--; } } // if this is the head node, print the footer if ( level == start_level ) out << boost::format(footer_format) % _section % head_name; } void PrintNodeHLP(std::ostream &out, Property &p, const int start_level=0, int level=0, string prefix="", string offset="") { list::iterator iter; string head_name; string _help(""); string _unit(""); string _default(""); string _name(""); typedef Color ColorRGB; // use the RGB palette ColorRGB RGB; // Instance of an RGB palette string fmt = "t|%1%%|15t|" + string(RGB.Blue()) + "%2%" + string(RGB.Green()) + "%|40t|%3%%|55t|" + string(RGB.Reset()) + "%4%\n"; int _offset = level; // if this is the head node, print the header if ( level == start_level ) { head_name = string(RGB.Magenta()) + p.name(); if ( p.hasAttribute("help") ) { if ( p.hasAttribute("help") ) _help = string(RGB.Red()) + p.getAttribute("help"); out << boost::format(" %1%: %|18t| %2%" + string(RGB.Reset()) + "\n") % head_name % _help; } _offset=0; out << boost::format("%|3" + fmt) % "OPTION" % "DEFAULT" % "UNIT" % "DESCRIPTION"; } if ( level > start_level ) { string ofmt; ofmt = "%|" + boost::lexical_cast(_offset) + fmt; //cout << ofmt << " " << fmt << endl; if ( p.hasAttribute("unit") ) _unit = p.getAttribute("unit"); if ( p.hasAttribute("default") ) _default = p.getAttribute("default"); if ( p.hasAttribute("help") ) _help = p.getAttribute("help") ; if ( !_unit.empty() ) _unit = "[" + _unit + "]"; if ( !_default.empty() ) _default = "(" + _default + ")"; _name = p.name(); out << boost::format(ofmt) % _name % _default % _unit % _help; } for(iter = p.begin(); iter != p.end(); ++iter) { if(prefix=="") { _offset = level + 2; level++; PrintNodeHLP(out, (*iter), start_level, level, (*iter).name(), offset); _offset = level - 2; level--; } else { _offset = level + 2; level++; PrintNodeHLP(out, (*iter), start_level, level, prefix + "." + (*iter).name(), offset); _offset = level - 2; level--; } } } std::ostream &operator<<(std::ostream &out, Property& p) { if (!out.good()) return out; std::ostream::sentry sentry(out); if(sentry) { // get the property format object attached to the stream PropertyIOManipulator *pm = (PropertyIOManipulator*)out.pword(Property::getIOindex()); string _indentation(""); int _level = 0; PropertyIOManipulator::Type _type = PropertyIOManipulator::XML; if (pm) { _indentation = pm->getIndentation(); _level = pm->getLevel(); _type = pm->getType(); // check if we > or >> to a file and remove color codes // if ( out.tellp() != -1 ) - not suitable for pipes if( !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO) ) { pm->setColorScheme(); } } switch( _type ) { default: PrintNodeTXT(out, p, _level); case PropertyIOManipulator::XML: PrintNodeXML(out, p, pm); break; case PropertyIOManipulator::TXT: PrintNodeTXT(out, p, _level, 0, "", _indentation); break; case PropertyIOManipulator::TEX: PrintNodeTEX(out, p, pm); break; case PropertyIOManipulator::HLP: PrintNodeHLP(out, p, _level, 0, "", _indentation); break; } //out << endl; } return out; }; }} tools-1.4.1/src/libtools/propertyiomanipulator.cc000066400000000000000000000016701315257650400223060ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { PropertyIOManipulator XML(PropertyIOManipulator::XML); PropertyIOManipulator TXT(PropertyIOManipulator::TXT); PropertyIOManipulator TEX(PropertyIOManipulator::TEX); PropertyIOManipulator HLP(PropertyIOManipulator::HLP); }} tools-1.4.1/src/libtools/random.cc000066400000000000000000000112231315257650400170710ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace tools { using namespace std; double *Random::MARSarray, Random::MARSc, Random::MARScd, Random::MARScm ; int Random::MARSi, Random::MARSj ; void Random::init( int nA1, int nA2, int nA3, int nB1 ) { nA1 = nA1 % 178 + 1; nA2 = nA2 % 178 + 1; nA3 = nA3 % 178 + 1; nB1 = nB1 % 169; if ((nA1 == 1) && (nA2 == 1) && (nA3 == 1)) { // Should not all be unity cout << "WARNING: MARSAGLIA RNG INITIALISED INCORRECTLY. " << "ADAPTING SEEDS APPROPRIATELY." << endl; nA1 += nB1; } cout << "INITIALIZED MARSFIELD WITH " << nA1 << " " << nA2 << " " << nA3 << " " << nB1 << endl; /* initializes the global data of the MARSAGLIA pseudo random number generator */ int mA1, mA2, mA3, mANEW, mB1, mHELP ; int i1, i2 ; double varS, varT ; MARSarray = (double*)malloc(MARS_FIELD_SIZE*sizeof(double)); mA1 = nA1 ; mA2 = nA2 ; mA3 = nA3 ; mB1 = nB1 ; MARSi = 97 ; MARSj = 33 ; for( i1 = 1 ; i1 < 98 ; i1++ ) { varS = 0.0 ; varT = 0.5 ; for( i2 = 1 ; i2 < 25 ; i2++ ) { mANEW = ((( mA1 * mA2 ) % 179 )*mA3 ) % 179 ; mA1 = mA2 ; mA2 = mA3 ; mA3 = mANEW ; mB1 = ( 53*mB1 + 1 ) % 169 ; mHELP = ( mB1 * mANEW ) % 64 ; if( mHELP > 31 ) varS += varT ; varT *= 0.5 ; } MARSarray[ i1 ] = varS ; } MARSc = 362436.0 / 16777216.0 ; MARScd = 7654321.0 / 16777216.0 ; MARScm = 16777213.0 / 16777216.0 ; return; } void Random::save( char *fileName ) { FILE *ranFP; int c[2]; double w[3]; size_t t; ranFP = fopen(fileName, "wb"); if (ranFP==NULL) { throw runtime_error(string("error, cannot open file ") + fileName); } c[0] = MARSi; c[1] = MARSj; t=fwrite(c, sizeof(int), 2, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write read ranFP file "); } w[0] = MARSc; w[1] = MARScd; w[2] = MARScm; t=fwrite(w, sizeof(double), 3, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write ranFP file "); } t=fwrite(MARSarray, sizeof(double), MARS_FIELD_SIZE, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write ranFP file "); } fclose(ranFP); } void Random::restore( char *fileName ) { FILE *ranFP; double w[3]; int c[2]; size_t t; ranFP = fopen(fileName, "rb"); if (ranFP==NULL) { throw runtime_error(string("error, cannot open file ") + fileName); } t=fread(c, sizeof(int), 2, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } MARSi = c[0]; MARSj = c[1]; t=fread(w, sizeof(double), 3, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } MARSc = w[0]; MARScd = w[1]; MARScm = w[2]; t=fread(MARSarray, sizeof(double), MARS_FIELD_SIZE, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } fclose(ranFP); } double Random::rand_uniform( void ) { /* generates a pseudo random number 0 .. +1 following the proposal of MARSAGLIA */ double ranMARS ; ranMARS = MARSarray[ MARSi ] - MARSarray[ MARSj ] ; if( ranMARS < 0.0 ) ranMARS += 1.0 ; MARSarray[ MARSi ] = ranMARS ; MARSi-- ; if( MARSi < 1 ) MARSi = 97 ; MARSj-- ; if( MARSj < 1 ) MARSj = 97 ; MARSc -= MARScd ; if( MARSc < 0.0 ) MARSc += MARScm ; ranMARS -= MARSc ; if( ranMARS < 0.0 ) ranMARS += 1.0 ; return ranMARS ; } /** generates a random integer number in the interval [0,max_int-1] */ int Random::rand_uniform_int( int max_int ) { return floor (max_int * rand_uniform() ); } /** generates a gaussian distributed value */ double Random::rand_gaussian( double sigma ) { double r = sigma * sqrt( -2.0*log ( 1 - Random::rand_uniform()) ); double theta = 2.0 * _pi * Random::rand_uniform() ; return r * cos(theta); // second independent number is r*sin(theta) } }} tools-1.4.1/src/libtools/random2.cc000066400000000000000000000114031315257650400171530ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include namespace votca { namespace tools { using namespace std; void Random2::init( int nA1, int nA2, int nA3, int nB1 ) { nA1 = nA1 % 178 + 1; nA2 = nA2 % 178 + 1; nA3 = nA3 % 178 + 1; nB1 = nB1 % 169; if ((nA1 == 1) && (nA2 == 1) && (nA3 == 1)) { // Should not all be unity cout << flush << "WARNING: MARSAGLIA RNG INITIALISED INCORRECTLY. " << "ADAPTING SEEDS APPROPRIATELY." << endl; nA1 += nB1; } cout << flush << "INITIALIZED MARSFIELD WITH " << nA1 << " " << nA2 << " " << nA3 << " " << nB1 << endl; /* initializes the global data of the MARSAGLIA pseudo random number generator */ int mA1, mA2, mA3, mANEW, mB1, mHELP ; int i1, i2 ; double varS, varT ; MARSarray = (double*)malloc(MARS_FIELD_SIZE*sizeof(double)); mA1 = nA1 ; mA2 = nA2 ; mA3 = nA3 ; mB1 = nB1 ; MARSi = 97 ; MARSj = 33 ; for( i1 = 1 ; i1 < 98 ; i1++ ) { varS = 0.0 ; varT = 0.5 ; for( i2 = 1 ; i2 < 25 ; i2++ ) { mANEW = ((( mA1 * mA2 ) % 179 )*mA3 ) % 179 ; mA1 = mA2 ; mA2 = mA3 ; mA3 = mANEW ; mB1 = ( 53*mB1 + 1 ) % 169 ; mHELP = ( mB1 * mANEW ) % 64 ; if( mHELP > 31 ) varS += varT ; varT *= 0.5 ; } MARSarray[ i1 ] = varS ; } MARSc = 362436.0 / 16777216.0 ; MARScd = 7654321.0 / 16777216.0 ; MARScm = 16777213.0 / 16777216.0 ; return; } void Random2::save( char *fileName ) { FILE *ranFP; int c[2]; double w[3]; size_t t; ranFP = fopen(fileName, "wb"); if (ranFP==NULL) { throw runtime_error(string("error, cannot open file ") + fileName); } c[0] = MARSi; c[1] = MARSj; t=fwrite(c, sizeof(int), 2, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write ranFP file "); } w[0] = MARSc; w[1] = MARScd; w[2] = MARScm; t=fwrite(w, sizeof(double), 3, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write ranFP file "); } t=fwrite(MARSarray, sizeof(double), MARS_FIELD_SIZE, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot write ranFP file "); } fclose(ranFP); } void Random2::restore( char *fileName ) { FILE *ranFP; double w[3]; int c[2]; size_t t; ranFP = fopen(fileName, "rb"); if (ranFP==NULL) { throw runtime_error(string("error, cannot open file ") + fileName); } t=fread(c, sizeof(int), 2, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } MARSi = c[0]; MARSj = c[1]; t=fread(w, sizeof(double), 3, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } MARSc = w[0]; MARScd = w[1]; MARScm = w[2]; t=fread(MARSarray, sizeof(double), MARS_FIELD_SIZE, ranFP); if (t==0){ fclose(ranFP); throw runtime_error("cannot read ranFP file "); } fclose(ranFP); } double Random2::rand_uniform( void ) { /* generates a pseudo random number 0 .. +1 following the proposal of MARSAGLIA */ double ranMARS ; ranMARS = MARSarray[ MARSi ] - MARSarray[ MARSj ] ; if( ranMARS < 0.0 ) ranMARS += 1.0 ; MARSarray[ MARSi ] = ranMARS ; MARSi-- ; if( MARSi < 1 ) MARSi = 97 ; MARSj-- ; if( MARSj < 1 ) MARSj = 97 ; MARSc -= MARScd ; if( MARSc < 0.0 ) MARSc += MARScm ; ranMARS -= MARSc ; if( ranMARS < 0.0 ) ranMARS += 1.0 ; return ranMARS ; } /** generates a random integer number in the interval [0,max_int-1] */ int Random2::rand_uniform_int( int max_int ) { return floor (max_int * rand_uniform() ); } /** generates a gaussian distributed value */ double Random2::rand_gaussian( double sigma ) { double r = sigma * sqrt( -2.0*log ( 1 - Random2::rand_uniform()) ); double theta = 2.0 * _pi * Random2::rand_uniform() ; return r * cos(theta); // second independent number is r*sin(theta) } }} tools-1.4.1/src/libtools/rangeparser.cc000066400000000000000000000051031315257650400201220ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include namespace votca { namespace tools { RangeParser::RangeParser() //: _has_begin(false) , _has_end(false) { } void RangeParser::Parse(string str) { // remove all spaces in string string::iterator it = remove_if(str.begin(), str.end(), bind2nd(equal_to(), ' ')); str = string(str.begin(), it); // tokenize string Tokenizer tok(str, ","); Tokenizer::iterator bl; for(bl=tok.begin(); bl!=tok.end();++bl) ParseBlock(*bl); // list::iterator iter; // for(iter=_blocks.begin();iter!=_blocks.end();++iter) { // cout << (*iter)._begin << ":" << (*iter)._stride << ":" << (*iter)._end << endl; // } } void RangeParser::ParseBlock(string str) { Tokenizer tokenizer(str, ":"); vector toks; block_t block; block._stride = 1; tokenizer.ToVector(toks); if(toks.size()>3 || toks.size() < 1) { throw runtime_error("invalid range"); } block._begin = block._end = ToNumber(toks[0]); if(toks.size() == 2) block._end = ToNumber(toks[1]); if(toks.size() == 3) { block._stride = ToNumber(toks[1]); block._end = ToNumber(toks[2]); } if(block._begin*block._stride > block._end*block._stride) { throw runtime_error(string("invalid range " + str + ": begin, end and stride do not form a closed interval")); } _blocks.push_back(block); } int RangeParser::ToNumber(string str) { return boost::lexical_cast(str); } RangeParser::iterator & RangeParser::iterator::operator++() { _current+=(*_block)._stride; if(_current > (*_block)._end) { ++_block; if(_block != _parent->_blocks.end()) _current = (*_block)._begin; else _current = -1; } return *this; } }} tools-1.4.1/src/libtools/spline.cc000066400000000000000000000023261315257650400171070ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { using namespace std; int Spline::GenerateGrid(double min, double max, double h) { int vec_size = (int) ((max - min) / h + 1.00000001); _r.resize(vec_size); int i; double r_init; for (r_init = min, i = 0; i < vec_size - 1; r_init += h) { _r[i++] = r_init; } _r[i] = max; _f.resize(_r.size(), false); _f2.resize(_r.size(), false); return _r.size(); } } } tools-1.4.1/src/libtools/statement.cc000066400000000000000000000034131315257650400176170ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include namespace votca { namespace tools { using namespace std; Statement::~Statement() { sqlite3_finalize(_stmt); } template<> void Statement::Bind(int col, const int &value) { if(sqlite3_bind_int(_stmt, col, value) != SQLITE_OK) throw std::runtime_error("sqlite_bind failed"); } template<> void Statement::Bind(int col, const double &value) { if(sqlite3_bind_double(_stmt, col, value) != SQLITE_OK) throw std::runtime_error("sqlite_bind failed"); } template<> int Statement::Column(int col) { return sqlite3_column_int(_stmt, col); } template<> double Statement::Column(int col) { return sqlite3_column_double(_stmt, col); } template<> string Statement::Column(int col) { return string((const char*)sqlite3_column_text(_stmt, col)); } template<> void Statement::Bind(int col, const string &value) { if(sqlite3_bind_text(_stmt, col, value.c_str(), -1, NULL) != SQLITE_OK) throw std::runtime_error("sqlite_bind failed"); } int Statement::Step() { return sqlite3_step(_stmt); } void Statement::Reset() { sqlite3_reset(_stmt); } }} tools-1.4.1/src/libtools/table.cc000066400000000000000000000124631315257650400167070ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include namespace votca { namespace tools { using namespace boost; using namespace std; void Table::resize(int N, bool preserve) { _x.resize(N, preserve); _y.resize(N, preserve); _flags.resize(N, preserve); if (_has_yerr) { _yerr.resize(N, preserve); } } void Table::Load(string filename) { ifstream in; in.open(filename.c_str()); if(!in) throw runtime_error(string("error, cannot open file ") + filename); setErrorDetails("file " + filename); in >> *this; in.close(); } void Table::Save(string filename) const { ofstream out; out.open(filename.c_str()); if(!out) throw runtime_error(string("error, cannot open file ") + filename); if (_has_comment) { string str = "# " + _comment_line; boost::replace_all(str, "\n", "\n# "); boost::replace_all(str, "\\n", "\n# "); out << str <>(istream &in, Table& t) { size_t N=0; bool bHasN=false; string line; int line_number=0; t.clear(); // read till the first data line while(getline(in, line)) { line_number++; string conversion_error = t.getErrorDetails() + ", line " + boost::lexical_cast(line_number); // remove comments and xmgrace stuff line = line.substr(0, line.find("#")); line = line.substr(0, line.find("@")); // tokenize string and put it to vector Tokenizer tok(line, " \t"); vector tokens; tok.ToVector(tokens); // skip empty lines if(tokens.size()==0) continue; // if first line is only 1 token, it's the size if(tokens.size() == 1) { N = lexical_cast(tokens[0], conversion_error); bHasN = true; } // it's the first data line with 2 or 3 entries else if(tokens.size() == 2) { t.push_back(lexical_cast(tokens[0], conversion_error), lexical_cast(tokens[1], conversion_error), 'i'); } else if(tokens.size() > 2) { char flag='i'; string sflag = tokens.back(); if(sflag == "i" || sflag == "o" || sflag == "u") flag = sflag.c_str()[0]; t.push_back(lexical_cast(tokens[0], conversion_error), lexical_cast(tokens[1], conversion_error), flag); } else throw runtime_error("error, wrong table format"); } // read the rest while(getline(in, line)) { line_number++; string conversion_error = t.getErrorDetails() + ", line " + boost::lexical_cast(line_number); // remove comments and xmgrace stuff line = line.substr(0, line.find("#")); line = line.substr(0, line.find("@")); // tokenize string and put it to vector Tokenizer tok(line, " \t"); vector tokens; tok.ToVector(tokens); // skip empty lines if(tokens.size()==0) continue; // it's a data line if(tokens.size() == 2) { t.push_back(lexical_cast(tokens[0], conversion_error), lexical_cast(tokens[1], conversion_error), 'i'); } else if(tokens.size() > 2) { char flag='i'; if(tokens[2] == "i" || tokens[2] == "o" || tokens[2] == "u") flag = tokens[2].c_str()[0]; t.push_back(lexical_cast(tokens[0], conversion_error), lexical_cast(tokens[1], conversion_error), flag); } // otherwise error else throw runtime_error("error, wrong table format"); // was size given and did we read N values? if(bHasN) if(--N == 0) break; } return in; } void Table::GenerateGridSpacing(double min, double max, double spacing) { int n = floor((max - min)/spacing + 1.000000001); resize(n); int i=0; for(double x=min; i 0) for(unsigned int i=1; i #include #include namespace votca { namespace tools { static void *runwrapper(void *arg) { Thread *thread = (Thread*) (arg); thread->Run(); pthread_exit(NULL); return NULL; } Thread::Thread() { } Thread::~Thread() { } void Thread::Start() { pthread_attr_t attr; pthread_attr_init(&attr); /* * according to the POSIX standard, threads are created in the joinable state * by default * however, some platforms do not obey * * explicitly create the thread in the joinable state * the main program can then wait for the thread by calling pthread_join(thread) * */ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); _finished = false; int rc = pthread_create(&_thread, &attr, runwrapper, (void *) this); if (rc) { throw std::runtime_error("ERROR; return code from pthread_create() is " + boost::lexical_cast(rc)); } } void Thread::WaitDone() { void * status; int rc = pthread_join(_thread, &status); if (rc) { throw std::runtime_error("ERROR; return code from pthread_join() is " + boost::lexical_cast(rc)); } _finished = true; } bool Thread::IsFinished() const { return _finished; } } } tools-1.4.1/src/libtools/tokenizer.cc000066400000000000000000000026571315257650400176360ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include namespace votca { namespace tools { int wildcmp(const char *wild, const char *string) { // Written by Jack Handy - jakkhandy@hotmail.com const char *cp = NULL, *mp = NULL; while ((*string) && (*wild != '*')) { if ((*wild != *string) && (*wild != '?')) { return 0; } wild++; string++; } while (*string) { if (*wild == '*') { if (!*++wild) { return 1; } mp = wild; cp = string+1; } else if ((*wild == *string) || (*wild == '?')) { wild++; string++; } else { wild = mp; string = cp++; } } while (*wild == '*') { wild++; } return !*wild; } }} tools-1.4.1/src/libtools/version.cc000066400000000000000000000021331315257650400172760ustar00rootroot00000000000000/* * Copyright 2009-2016 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include extern "C" { void VotcaToolsFromC(){ //do nothing - this just that we have a c function for autotools } } namespace votca { namespace tools { //defines gitversion #include "gitversion.h" static const std::string version_str = std::string(TOOLS_VERSION) + " " + gitversion + " (compiled " __DATE__ ", " __TIME__ ")"; const std::string &ToolsVersionStr() { return version_str; } }} tools-1.4.1/src/libtools/version_nb.cc000066400000000000000000000016231315257650400177600ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ // This file is for netbeans only #include namespace votca { namespace tools { static const std::string version_str = "VERSION NOT SET (compiled " __DATE__ ", " __TIME__ ")"; const std::string &ToolsVersionStr() { return version_str; } }} tools-1.4.1/src/tools/000077500000000000000000000000001315257650400146145ustar00rootroot00000000000000tools-1.4.1/src/tools/CMakeLists.txt000066400000000000000000000013451315257650400173570ustar00rootroot00000000000000foreach(PROG votca_property) file(GLOB ${PROG}_SOURCES ${PROG}*.cc) add_executable(${PROG} ${${PROG}_SOURCES}) target_link_libraries(${PROG} votca_tools) #not realy useful, re-enable whenever it is ready to replace csg_property install(TARGETS ${PROG} RUNTIME DESTINATION bin) if (BUILD_MANPAGES) add_custom_command(OUTPUT ${PROG}.man COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${PROG} --man > ${PROG}.man COMMENT "Building ${PROG} manpage" DEPENDS ${PROG}) add_custom_target(${PROG}_manpage DEPENDS ${PROG}.man) add_dependencies(manpages ${PROG}_manpage) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROG}.man DESTINATION ${MAN}/man1 RENAME ${PROG}.1) endif (BUILD_MANPAGES) endforeach(PROG) tools-1.4.1/src/tools/votca_property.cc000066400000000000000000000063541315257650400202130ustar00rootroot00000000000000/* * Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace votca::tools; namespace po = boost::program_options; class VotcaProperty : public Application { public: VotcaProperty(); ~VotcaProperty(); string ProgramName() { return "votca_property"; } void HelpText(ostream &out) {out << "Helper for parsing XML files"; } void Initialize() { format = "XML"; level = 1; AddProgramOptions() ("file", po::value(), "xml file to parse") ("format", po::value(), "output format [XML TXT TEX]") ("level", po::value(), "output from this level "); }; bool EvaluateOptions() { CheckRequired("file", "Missing XML file"); return true; }; void Run(){ file = _op_vm["file"].as (); if (_op_vm.count("format")) format = _op_vm["format"].as (); if (_op_vm.count("level")) level = _op_vm["level"].as (); try { Property p; map _mformat; map::iterator it; _mformat["XML"] = &XML; _mformat["TXT"] = &TXT; _mformat["TEX"] = &TEX; _mformat["HLP"] = &HLP; load_property_from_xml(p, file); it = _mformat.find( format ); if ( it != _mformat.end() ) { PropertyIOManipulator *piom = _mformat.find( format )->second; piom->setLevel(level); piom->setIndentation(""); piom->setColorScheme(); cout << *piom << p ; } else { cout << "format " << format << " not supported \n"; } //PropertyIOManipulator XML(PropertyIOManipulator::XML,0,"---"); //cout << XML << p; //cout << TXT << p; //cout << T2T << p; //cout << LOG << p; //cout << TEX << p; } catch(std::exception &error) { cerr << "an error occurred:\n" << error.what() << endl; } }; private: string file; string format; int level; }; VotcaProperty::VotcaProperty(void) {} VotcaProperty::~VotcaProperty(void) {} int main(int argc, char** argv) { VotcaProperty vp; return vp.Exec(argc, argv); }