From 3c3e3f71b3fd17f72e98bc2c037241d8836d53a8 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de> Date: Wed, 30 Jan 2013 22:37:20 +0100 Subject: [PATCH] function voigt from libcerf successfully integrated --- pub/CHANGELOG | 4 +++- pub/config.h.in | 6 +++++ pub/configure | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ pub/configure.ac | 5 +++- pub/src/func.cpp | 7 ++++++ 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/pub/CHANGELOG b/pub/CHANGELOG index 73e199f2..5ca2521e 100644 --- a/pub/CHANGELOG +++ b/pub/CHANGELOG @@ -1,7 +1,9 @@ -Release +Release, comes with fridalibs- - bugfixes: - reenable external curves (nPar() becomes nP) +- new functionality: + - function voigt(t,sigma,gamma); requires libcerf - distribution: - directory doc renamed man diff --git a/pub/config.h.in b/pub/config.h.in index 0ea3561f..c8d2b438 100644 --- a/pub/config.h.in +++ b/pub/config.h.in @@ -18,6 +18,9 @@ */ #undef HAVE_ALLOCA_H +/* Define to 1 if you have the <cerf.h> header file. */ +#undef HAVE_CERF_H + /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H @@ -54,6 +57,9 @@ /* Define to 1 if you have the <kww.h> header file. */ #undef HAVE_KWW_H +/* Define to 1 if you have the `cerf' library (-lcerf). */ +#undef HAVE_LIBCERF + /* Define to 1 if you have the <libintl.h> header file. */ #undef HAVE_LIBINTL_H diff --git a/pub/configure b/pub/configure index 4058130e..0bb6005a 100755 --- a/pub/configure +++ b/pub/configure @@ -5560,6 +5560,20 @@ fi done +for ac_header in cerf.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "cerf.h" "ac_cv_header_cerf_h" "$ac_includes_default" +if test "x$ac_cv_header_cerf_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CERF_H 1 +_ACEOF + +else + as_fn_error $? "Cannot find cerf.h." "$LINENO" 5 +fi + +done + # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! @@ -6682,6 +6696,54 @@ else $as_echo "$as_me: WARNING: libkww not found or out of sync" >&2;} fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for voigt in -lcerf" >&5 +$as_echo_n "checking for voigt in -lcerf... " >&6; } +if ${ac_cv_lib_cerf_voigt+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcerf $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char voigt (); +int +main () +{ +return voigt (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_cerf_voigt=yes +else + ac_cv_lib_cerf_voigt=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cerf_voigt" >&5 +$as_echo "$ac_cv_lib_cerf_voigt" >&6; } +if test "x$ac_cv_lib_cerf_voigt" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCERF 1 +_ACEOF + + LIBS="-lcerf $LIBS" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libcerf not found or out of sync" >&5 +$as_echo "$as_me: WARNING: libcerf not found or out of sync" >&2;} +fi + ############################################################################### ## Check for facilities needed at run time ## diff --git a/pub/configure.ac b/pub/configure.ac index 3fdbafce..f4a5d1eb 100644 --- a/pub/configure.ac +++ b/pub/configure.ac @@ -75,7 +75,8 @@ AC_CHECK_HEADERS([gsl/gsl_rng.h gsl/gsl_randist.h gsl/gsl_math.h \ gsl/gsl_errno.h gsl/gsl_integration.h gsl/gsl_roots.h \ gsl/gsl_sf.h gsl/gsl_sf_debye.h],, AC_MSG_ERROR([Cannot find required gsl headers.])) -AC_CHECK_HEADERS([kww.h],, AC_MSG_ERROR([Cannot find kww.h.])) +AC_CHECK_HEADERS([kww.h],, AC_MSG_ERROR([Cannot find kww.h.])) +AC_CHECK_HEADERS([cerf.h],, AC_MSG_ERROR([Cannot find cerf.h.])) AC_FUNC_ALLOCA AC_FUNC_MALLOC @@ -109,6 +110,8 @@ AC_CHECK_LIB([lmmin], [lmmin], , [AC_MSG_WARN(liblmmin not found or out of sync)]) AC_CHECK_LIB([kww], [kwwp], , [AC_MSG_WARN(libkww not found or out of sync)]) +AC_CHECK_LIB([cerf], [voigt], , + [AC_MSG_WARN(libcerf not found or out of sync)]) ############################################################################### ## Check for facilities needed at run time ## diff --git a/pub/src/func.cpp b/pub/src/func.cpp index a36ffa50..9436b67c 100644 --- a/pub/src/func.cpp +++ b/pub/src/func.cpp @@ -16,6 +16,7 @@ #include <trivia/rng.hpp> #include <kww.h> +#include <cerf.h> #include "defs.h" #include "func.h" @@ -223,6 +224,10 @@ double func_kwwp( double v, double t, double b ){ if( b<0.1 || b>2.0 ) return 0; return 1/PI*kwwp( v*t, b ); } +double func_voigt( double v, double s, double g ){ + return (s||g) ? voigt(v,s,g) : 0; +} + double func_zorn( double v, double vavg, double s ) { if( s<=0 || s>=1 ) return 0; return (1-s)*(v+s*vavg*vavg/(1-s*vavg)); } @@ -491,6 +496,8 @@ void NFunctions::initialize(void) { "(w,tau,b): Fourier sine transform (t->w) of exp((t/tau)^b)" ).register_me(); CFunc( "kwwp", func_kwwp, 0, 0, "(w,tau,b): primitive of Fourier cosine transform (t->w) of exp((t/tau)^b)" ).register_me(); + CFunc( "voigt", func_voigt, 0, 0, + "(x,sigma,gamma): convolution of Gaussian(x,sigma) and Lorentzian(x,gamma)" ).register_me(); CFunc( "zorn", func_zorn, 0, 0, "(I,<I>,s): Zorn's multiple-scattering corrected elastic intensity" ).register_me(); CFunc( "zorn2", func_zorn_gauss, 0, 0, -- GitLab