diff --git a/CMakeLists.txt b/CMakeLists.txt index 4929ce93a..0abd74123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,363 +1,367 @@ project(labplot2) # minimum 3.2.0 for FindGSL.cmake cmake_minimum_required(VERSION 3.2.0) set(KF5_MIN_VERSION "5.16.0") find_package(ECM 1.3.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) # build type: "release", "debug", "debugfull" string (TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE) find_package(Qt5 ${QT_MIN_VERSION} NO_MODULE REQUIRED COMPONENTS Concurrent Gui PrintSupport Sql Svg Widgets Test SerialPort ) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive Completion Config ConfigWidgets CoreAddons DocTools I18n IconThemes TextWidgets WidgetsAddons XmlGui OPTIONAL_COMPONENTS NewStuff Service Parts SyntaxHighlighting ) IF (Qt5SerialPort_FOUND) MESSAGE (STATUS "Found Qt5 SerialPort") ELSE () MESSAGE (STATUS "Qt5 SerialPort not found") ENDIF () IF (KF5NewStuff_FOUND) MESSAGE (STATUS "Found KF5 new stuff") add_definitions (-DHAVE_KF5_NEW_STUFF) ELSE () MESSAGE (STATUS "KF5 new stuff not found") ENDIF () IF (KF5SyntaxHighlighting_FOUND) MESSAGE (STATUS "Found KF5 syntax highlighting") add_definitions (-DHAVE_KF5_SYNTAX_HIGHLIGHTING) ELSE () MESSAGE (STATUS "KF5 syntax highlighting not found") ENDIF () find_package(BISON REQUIRED) include(FeatureSummary) include(ECMAddAppIcon) include(ECMInstallIcons) include(KDEInstallDirs) include(KDECompilerSettings) include(KDECMakeSettings) ### compiler flags ###################################### set (GENERIC_FLAGS "-Wall -Wextra -Wundef -Wpointer-arith -Wunreachable-code -Wunused -Wdeprecated-declarations -fno-omit-frame-pointer -fstack-protector") set (GENERIC_GNU_FLAGS "-O2 -Wcast-align -Wswitch-enum -fvisibility=default") set (GENERIC_C_FLAGS "-std=c99 ${GENERIC_FLAGS} -fno-exceptions") # liborigin needs exceptions set (GENERIC_CXX_FLAGS "-std=c++11 ${GENERIC_FLAGS} -fexceptions") if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") message(STATUS "GNU C compiler detected, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERIC_C_FLAGS} ${GENERIC_GNU_FLAGS}") elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") message(STATUS "Clang C compiler detected, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE ${GENERIC_C_FLAGS} ${GENERIC_GNU_FLAGS}") elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Intel") message(STATUS "Intel C compiler detected, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -O3 ${GENERIC_C_FLAGS}") elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "PGI") message(STATUS "PGI C compiler detected, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -O3 -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -Minform=inform -Mbounds -Mchkstk") # " x" postfix to work around a bug in CMake that causes "MSVC" to translate to something completely different elseif (("${CMAKE_C_COMPILER_ID} x" MATCHES "MSVC") OR MSVC) message(STATUS "MSVC C compiler detected, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -W3") set(MSVC_FOUND TRUE) else () message(STATUS "UNKNOWN C compiler, adding compile flags") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERIC_C_FLAGS}") endif() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") message(STATUS "GNU C++ compiler detected, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERIC_CXX_FLAGS} ${GENERIC_GNU_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") message(STATUS "Clang C++ compiler detected, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE ${GENERIC_CXX_FLAGS} ${GENERIC_GNU_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") message(STATUS "Intel C++ compiler detected, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE ${GENERIC_CXX_FLAGS}") #-std=c++0x comes with cmake's general flags, depricated in icc, remove it string(REPLACE "-std=c++0x" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "PGI") message(STATUS "PGI C++ compiler detected, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -O3 -std=c++11 -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -Minform=inform -Mbounds -Mchkstk") # " x" postfix to work around a bug in CMake that causes "MSVC" to translate to something completely different elseif (("${CMAKE_CXX_COMPILER_ID} x" MATCHES "MSVC") OR MSVC) message(STATUS "MSVC C++ compiler detected, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -W3") set(MSVC_FOUND TRUE) else () message(STATUS "UNKNOWN C++ compiler, adding compile flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERIC_CXX_FLAGS}") endif () ##########################################################ESC[m add_definitions (${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS}) include_directories (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) add_definitions (-DLVERSION=\"2.5.0\") # add_definitions (-DLDEBUG='1') set(BUILD_SHARED_LIBS true) cmake_policy(SET CMP0002 OLD) IF (CMAKE_VERSION VERSION_EQUAL "3.3" OR CMAKE_VERSION VERSION_GREATER "3.3") cmake_policy(SET CMP0063 NEW) ENDIF() ### Options ###################################### option(ENABLE_CANTOR "Build with Cantor support" ON) option(ENABLE_FFTW "Build with FFTW support" ON) option(ENABLE_HDF5 "Build with HDF5 support" ON) option(ENABLE_NETCDF "Build with NetCDF support" ON) option(ENABLE_FITS "Build with FITS support" ON) option(ENABLE_LIBCERF "Build with libcerf support" ON) option(ENABLE_LIBORIGIN "Build with liborigin support" ON) option(ENABLE_ROOT "Build with ROOT (CERN) support" ON) option(ENABLE_TESTS "Build with tests" ON) ### OS macros #################################### IF (WIN32) add_definitions (-DHAVE_WINDOWS) ENDIF () ### GSL (required) ############################### FIND_PACKAGE(GSL REQUIRED) ### liborigin (included) ############################### IF (ENABLE_LIBORIGIN) add_definitions (-DHAVE_LIBORIGIN) IF (CMAKE_BUILD_TYPE STREQUAL "debug" OR CMAKE_BUILD_TYPE STREQUAL "debugfull") MESSAGE (STATUS "Origin project import (through internal liborigin) enabled (parser logging enabled)") SET (ENABLE_ORIGIN_PARSER_LOG TRUE) ELSE () MESSAGE (STATUS "Origin project import (through internal liborigin) enabled (parser logging disabled)") ENDIF () ELSE () MESSAGE (STATUS "Origin project import disabled") ENDIF () ### Cantorlibs (optional) ############################### IF (ENABLE_CANTOR) FIND_LIBRARY (CANTOR_LIBS cantorlibs) FIND_PATH (CANTOR_INCLUDE_DIR cantor/worksheetaccess.h /usr/include /usr/local/include ) IF (CANTOR_LIBS AND CANTOR_INCLUDE_DIR AND KF5Service_FOUND AND KF5Parts_FOUND) SET (CANTOR_LIBS_FOUND TRUE) ELSE () SET (CANTOR_LIBS_FOUND FALSE) SET (CANTOR_LIBS "") ENDIF() IF (CANTOR_LIBS_FOUND) MESSAGE (STATUS "Found Cantor Library: ${CANTOR_INCLUDE_DIR} ${CANTOR_LIBS}") add_definitions (-DHAVE_CANTOR_LIBS) ELSE () MESSAGE (STATUS "Cantor Library not found.") ENDIF () ELSE () MESSAGE (STATUS "Cantor Library DISABLED.") ENDIF () ### FFTW (optional) ##################################### IF (ENABLE_FFTW) FIND_LIBRARY (FFTW_LIBRARIES fftw3 PATHS /usr/lib /usr/local/lib ) FIND_PATH (FFTW_INCLUDE_DIR fftw3.h /usr/include /usr/local/include ) IF (FFTW_LIBRARIES AND FFTW_INCLUDE_DIR) SET (FFTW_FOUND TRUE) ELSE () SET (FFTW_FOUND FALSE) ENDIF () IF (FFTW_FOUND) MESSAGE (STATUS "Found FFTW 3 Library: ${FFTW_INCLUDE_DIR} ${FFTW_LIBRARIES}") add_definitions (-DHAVE_FFTW3) ELSE () MESSAGE (STATUS "FFTW 3 Library not found.") ENDIF () ELSE () MESSAGE (STATUS "FFTW 3 Library DISABLED.") ENDIF () ### HDF5 (optional) ############################## IF (ENABLE_HDF5) FIND_PACKAGE(HDF5 COMPONENTS C) IF (HDF5_FOUND) add_definitions (-DHAVE_HDF5) include_directories (${HDF5_INCLUDE_DIRS}) ELSE () MESSAGE (STATUS "Hierarchical Data Format (HDF5) Library not found.") ENDIF () ELSE () MESSAGE (STATUS "Hierarchical Data Format (HDF5) Library DISABLED.") ENDIF () ### NETCDF (optional) ############################# IF (ENABLE_NETCDF) FIND_LIBRARY (NETCDF_LIBRARY netcdf PATHS /usr/lib /usr/local/lib ) FIND_PATH (NETCDF_INCLUDE_DIR netcdf.h /usr/include /usr/local/include ) IF (NETCDF_LIBRARY AND NETCDF_INCLUDE_DIR) SET (NETCDF_FOUND TRUE) ELSE () SET (NETCDF_FOUND FALSE) ENDIF () IF (NETCDF_FOUND) MESSAGE (STATUS "Found Network Common Data Format (NetCDF) Library: ${NETCDF_INCLUDE_DIR} ${NETCDF_LIBRARY}") add_definitions (-DHAVE_NETCDF) ELSE () MESSAGE (STATUS "Network Common Data Format (NetCDF) Library not found.") ENDIF () ELSE () MESSAGE (STATUS "Network Common Data Format (NetCDF) Library DISABLED.") ENDIF () ### FITS (optional) ############################### IF (ENABLE_FITS) FIND_LIBRARY (CFITSIO_LIBRARY cfitsio PATHS /usr/lib /usr/local/lib $ENV{CFITSIO} ) FIND_PATH (CFITSIO_INCLUDE_DIR fitsio.h /usr/include /usr/include/cfitsio /usr/local/include $ENV{CFITSIO} ) IF (CFITSIO_LIBRARY AND CFITSIO_INCLUDE_DIR) SET (CFITSIO_FOUND TRUE) ELSE () SET (CFITSIO_FOUND FALSE) ENDIF () IF (CFITSIO_FOUND) MESSAGE (STATUS "Found Flexible Image Transport System Data Format (FITS) Library: ${CFITSIO_INCLUDE_DIR} ${CFITSIO_LIBRARY}") add_definitions (-DHAVE_FITS) include_directories (${CFITSIO_INCLUDE_DIR}) ELSE () MESSAGE (STATUS "Flexible Image Transport System Data Format (FITS) Library not found.") ENDIF () ELSE () MESSAGE (STATUS "Flexible Image Transport System Data Format (FITS) Library DISABLED.") ENDIF () ### LIBCERF (optional) ############################# IF (ENABLE_LIBCERF) FIND_LIBRARY (LIBCERF_LIBRARY cerf PATHS /usr/lib /usr/local/lib ) FIND_PATH (LIBCERF_INCLUDE_DIR cerf.h /usr/include /usr/local/include ) IF (LIBCERF_LIBRARY AND LIBCERF_INCLUDE_DIR) SET (LIBCERF_FOUND TRUE) ELSE () SET (LIBCERF_FOUND FALSE) ENDIF () IF (LIBCERF_FOUND) MESSAGE (STATUS "Found libcerf Library: ${LIBCERF_INCLUDE_DIR} ${LIBCERF_LIBRARY}") add_definitions (-DHAVE_LIBCERF) ELSE () MESSAGE (STATUS "libcerf Library not found.") ENDIF () ELSE () MESSAGE (STATUS "libcerf Library DISABLED.") ENDIF () IF (ENABLE_ROOT) FIND_PACKAGE(ZLIB) FIND_LIBRARY(LZ4_LIBRARY lz4 PATHS /usr/lib /usr/local/lib ) FIND_PATH (LZ4_INCLUDE_DIR lz4.h /usr/include /usr/local/include ) IF (LZ4_LIBRARY AND LZ4_INCLUDE_DIR) SET (LZ4_FOUND TRUE) MESSAGE (STATUS "Found LZ4 library: ${LZ4_INCLUDE_DIR} ${LZ4_LIBRARY}") ELSE () SET (LZ4_FOUND FALSE) ENDIF () IF (ZLIB_FOUND AND LZ4_FOUND) add_definitions (-DHAVE_ZIP) ELSE () MESSAGE (STATUS "ZIP libraries not found.") ENDIF () ELSE () MESSAGE (STATUS "ROOT (CERN) importer DISABLED.") ENDIF () +################################################# +include(CheckFunctionExists) + +CHECK_FUNCTION_EXISTS(random HAVE_RANDOM_FUNCTION) ################################################# FIND_PATH (XLOCALE_INCLUDE_DIR xlocale.h /usr/include /usr/local/include ) IF (XLOCALE_INCLUDE_DIR) add_definitions (-DHAVE_XLOCALE) include_directories (${XLOCALE_INCLUDE_DIR}) ENDIF() add_subdirectory(data) add_subdirectory(doc) add_subdirectory(icons) add_subdirectory(src) IF (ENABLE_LIBORIGIN) add_subdirectory(liborigin) ENDIF () if (ENABLE_TESTS) enable_testing(true) add_subdirectory(tests) endif() install(FILES org.kde.labplot2.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) feature_summary(WHAT ALL) diff --git a/src/backend/nsl/nsl_sf_basic.c b/src/backend/nsl/nsl_sf_basic.c index 44ce569c2..e4ed524cf 100644 --- a/src/backend/nsl/nsl_sf_basic.c +++ b/src/backend/nsl/nsl_sf_basic.c @@ -1,277 +1,277 @@ /*************************************************************************** File : nsl_sf_basic.c Project : LabPlot Description : NSL special basic functions -------------------------------------------------------------------- Copyright : (C) 2018 by Stefan Gerlach (stefan.gerlach@uni.kn) ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * ***************************************************************************/ #include "nsl_sf_basic.h" #include #include #include #include #include #ifdef HAVE_LIBCERF #include #elif !defined(_MSC_VER) #include "Faddeeva.h" #endif /* stdlib.h */ double nsl_sf_rand(void) { return rand(); } -#if defined(_MSC_VER) // MSVC has no random() function -double nsl_sf_random(void) { return rand(); } -double nsl_sf_drand(void) { return rand()/(double)RAND_MAX; } -#else +#if defined(HAVE_RANDOM_FUNCTION) double nsl_sf_random(void) { return random(); } double nsl_sf_drand(void) { return random()/(double)RAND_MAX; } +#else +double nsl_sf_random(void) { return rand(); } +double nsl_sf_drand(void) { return rand()/(double)RAND_MAX; } #endif double nsl_sf_sgn(double x) { #ifndef _WIN32 return copysign(1.0, x); #else if (x > 0) return 1; else if (x < 0) return -1; else return 0; #endif } double nsl_sf_theta(double x) { if (x >= 0) return 1; else return 0; } double nsl_sf_sec(double x) { return 1./cos(x); } double nsl_sf_csc(double x) { return 1./sin(x); } double nsl_sf_cot(double x) { return 1./tan(x); } double nsl_sf_asec(double x) { return acos(1./x); } double nsl_sf_acsc(double x) { return asin(1./x); } double nsl_sf_acot(double x) { if (x > 0) return atan(1./x); else return atan(1./x) + M_PI; } double nsl_sf_sech(double x) { return 1./cosh(x); } double nsl_sf_csch(double x) { return 1./sinh(x); } double nsl_sf_coth(double x) { return 1./tanh(x); } double nsl_sf_asech(double x) { return gsl_acosh(1./x); } double nsl_sf_acsch(double x) { return gsl_asinh(1./x); } double nsl_sf_acoth(double x) { return gsl_atanh(1./x); } double nsl_sf_harmonic(double x) { // check if x is a negative integer if (x < 0 && !gsl_fcmp(round(x) - x, 0., 1.e-16)) return GSL_POSINF; return gsl_sf_psi(x + 1) + M_EULER; } /* error functions and related */ double nsl_sf_erfcx(double x) { #ifdef HAVE_LIBCERF return erfcx(x); #elif defined(_MSC_VER) return 0.; // not supported yet #else return Faddeeva_erfcx_re(x); #endif } double nsl_sf_erfi(double x) { #ifdef HAVE_LIBCERF return erfi(x); #elif defined(_MSC_VER) return 0.; // not supported yet #else return Faddeeva_erfi_re(x); #endif } double nsl_sf_im_w_of_x(double x) { #ifdef HAVE_LIBCERF return im_w_of_x(x); #elif defined(_MSC_VER) return 0.; // not supported yet #else return Faddeeva_w_im(x); #endif } #if !defined(_MSC_VER) double nsl_sf_im_w_of_z(complex double z) { #ifdef HAVE_LIBCERF return cimag(w_of_z(z)); #else return cimag(Faddeeva_w(z, 0)); #endif } #endif double nsl_sf_dawson(double x) { #ifdef HAVE_LIBCERF return dawson(x); #elif defined(_MSC_VER) return 0.; // not supported yet #else return Faddeeva_Dawson_re(x); #endif } double nsl_sf_voigt(double x, double sigma, double gamma) { #ifdef HAVE_LIBCERF return voigt(x, sigma, gamma); #elif defined(_MSC_VER) return 0.; // not supported yet #else double complex z = (x + I*gamma)/(sqrt(2.)*sigma); return creal(Faddeeva_w(z, 0))/(sqrt(2.*M_PI)*sigma); #endif } double nsl_sf_pseudovoigt(double x, double eta, double sigma, double gamma) { if (sigma == 0 || gamma == 0) return 0; //TODO: what if eta < 0 or > 1? return (1. - eta) * gsl_ran_gaussian_pdf(x, sigma) + eta * gsl_ran_cauchy_pdf(x, gamma); } double nsl_sf_pseudovoigt1(double x, double eta, double w) { // 2w - FWHM, sigma_G = w/sqrt(2ln(2)) return nsl_sf_pseudovoigt(x, eta, w/sqrt(2.*log(2.)), w); } /* wrapper for GSL functions with integer parameters */ #define MODE GSL_PREC_DOUBLE /* mathematical functions */ double nsl_sf_ldexp(double x, double expo) { return gsl_ldexp(x, (int)round(expo)); } double nsl_sf_powint(double x, double n) { return gsl_sf_pow_int(x, (int)round(n)); } /* Airy functions */ double nsl_sf_airy_Ai(double x) { return gsl_sf_airy_Ai(x, MODE); } double nsl_sf_airy_Bi(double x) { return gsl_sf_airy_Bi(x, MODE); } double nsl_sf_airy_Ais(double x) { return gsl_sf_airy_Ai_scaled(x, MODE); } double nsl_sf_airy_Bis(double x) { return gsl_sf_airy_Bi_scaled(x, MODE); } double nsl_sf_airy_Aid(double x) { return gsl_sf_airy_Ai_deriv(x, MODE); } double nsl_sf_airy_Bid(double x) { return gsl_sf_airy_Bi_deriv(x, MODE); } double nsl_sf_airy_Aids(double x) { return gsl_sf_airy_Ai_deriv_scaled(x, MODE); } double nsl_sf_airy_Bids(double x) { return gsl_sf_airy_Bi_deriv_scaled(x, MODE); } double nsl_sf_airy_0_Ai(double s) { return gsl_sf_airy_zero_Ai((unsigned int)round(s)); } double nsl_sf_airy_0_Bi(double s) { return gsl_sf_airy_zero_Bi((unsigned int)round(s)); } double nsl_sf_airy_0_Aid(double s) { return gsl_sf_airy_zero_Ai_deriv((unsigned int)round(s)); } double nsl_sf_airy_0_Bid(double s) { return gsl_sf_airy_zero_Bi_deriv((unsigned int)round(s)); } /* Bessel functions */ double nsl_sf_bessel_Jn(double n, double x) { return gsl_sf_bessel_Jn((int)round(n), x); } double nsl_sf_bessel_Yn(double n, double x) { return gsl_sf_bessel_Yn((int)round(n), x); } double nsl_sf_bessel_In(double n, double x) { return gsl_sf_bessel_In((int)round(n), x); } double nsl_sf_bessel_Ins(double n, double x) { return gsl_sf_bessel_In_scaled((int)round(n), x); } double nsl_sf_bessel_Kn(double n, double x) { return gsl_sf_bessel_Kn((int)round(n), x); } double nsl_sf_bessel_Kns(double n, double x) { return gsl_sf_bessel_Kn_scaled((int)round(n), x); } double nsl_sf_bessel_jl(double l, double x) { return gsl_sf_bessel_jl((int)round(l), x); } double nsl_sf_bessel_yl(double l, double x) { return gsl_sf_bessel_yl((int)round(l), x); } double nsl_sf_bessel_ils(double l, double x) { return gsl_sf_bessel_il_scaled((int)round(l), x); } double nsl_sf_bessel_kls(double l, double x) { return gsl_sf_bessel_kl_scaled((int)round(l), x); } double nsl_sf_bessel_0_J0(double s) { return gsl_sf_bessel_zero_J0((unsigned int)round(s)); } double nsl_sf_bessel_0_J1(double s) { return gsl_sf_bessel_zero_J1((unsigned int)round(s)); } double nsl_sf_bessel_0_Jnu(double nu, double s) { return gsl_sf_bessel_zero_Jnu(nu, (unsigned int)round(s)); } double nsl_sf_hydrogenicR(double n, double l, double z, double r) { return gsl_sf_hydrogenicR((int)round(n), (int)round(l), z, r); } /* elliptic integrals */ double nsl_sf_ellint_Kc(double x) { return gsl_sf_ellint_Kcomp(x, MODE); } double nsl_sf_ellint_Ec(double x) { return gsl_sf_ellint_Ecomp(x, MODE); } double nsl_sf_ellint_Pc(double x, double n) { return gsl_sf_ellint_Pcomp(x, n, MODE); } double nsl_sf_ellint_F(double phi, double k) { return gsl_sf_ellint_F(phi, k, MODE); } double nsl_sf_ellint_E(double phi, double k) { return gsl_sf_ellint_E(phi, k, MODE); } double nsl_sf_ellint_P(double phi, double k, double n) { return gsl_sf_ellint_P(phi, k, n, MODE); } double nsl_sf_ellint_D(double phi, double k) { #if GSL_MAJOR_VERSION >= 2 return gsl_sf_ellint_D(phi,k,MODE); #else return gsl_sf_ellint_D(phi,k,0.0,MODE); #endif } double nsl_sf_ellint_RC(double x, double y) { return gsl_sf_ellint_RC(x, y, MODE); } double nsl_sf_ellint_RD(double x, double y, double z) { return gsl_sf_ellint_RD(x, y, z, MODE); } double nsl_sf_ellint_RF(double x, double y, double z) { return gsl_sf_ellint_RF(x, y, z, MODE); } double nsl_sf_ellint_RJ(double x, double y, double z, double p) { return gsl_sf_ellint_RJ(x, y, z, p, MODE); } double nsl_sf_exprel_n(double n, double x) { return gsl_sf_exprel_n((int)round(n), x); } double nsl_sf_fermi_dirac_int(double j, double x) { return gsl_sf_fermi_dirac_int((int)round(j), x); } /* Gamma */ double nsl_sf_fact(double n) { return gsl_sf_fact((unsigned int)round(n)); } double nsl_sf_doublefact(double n) { return gsl_sf_doublefact((unsigned int)round(n)); } double nsl_sf_lnfact(double n) { return gsl_sf_lnfact((unsigned int)round(n)); } double nsl_sf_lndoublefact(double n) { return gsl_sf_lndoublefact((unsigned int)round(n)); } double nsl_sf_choose(double n, double m) { return gsl_sf_choose((unsigned int)round(n), (unsigned int)round(m)); } double nsl_sf_lnchoose(double n, double m) { return gsl_sf_lnchoose((unsigned int)round(n), (unsigned int)round(m)); } double nsl_sf_taylorcoeff(double n, double x) { return gsl_sf_taylorcoeff((int)round(n), x); } double nsl_sf_gegenpoly_n(double n, double l, double x) { return gsl_sf_gegenpoly_n((int)round(n), l, x); } #if (GSL_MAJOR_VERSION > 2) || (GSL_MAJOR_VERSION == 2) && (GSL_MINOR_VERSION >= 4) double nsl_sf_hermite_prob(double n, double x) { return gsl_sf_hermite_prob(round(n), x); } double nsl_sf_hermite_phys(double n, double x) { return gsl_sf_hermite_phys(round(n), x); } double nsl_sf_hermite_func(double n, double x) { return gsl_sf_hermite_func(round(n), x); } double nsl_sf_hermite_prob_der(double m, double n, double x) { return gsl_sf_hermite_prob_der(round(m), round(n), x); } double nsl_sf_hermite_phys_der(double m, double n, double x) { return gsl_sf_hermite_phys_der(round(m), round(n), x); } double nsl_sf_hermite_func_der(double m, double n, double x) { return gsl_sf_hermite_func_der(round(m), round(n), x); } #endif double nsl_sf_hyperg_1F1i(double m, double n, double x) { return gsl_sf_hyperg_1F1_int((int)round(m), (int)round(n), x); } double nsl_sf_hyperg_Ui(double m, double n, double x) { return gsl_sf_hyperg_U_int((int)round(m), (int)round(n), x); } double nsl_sf_laguerre_n(double n, double a, double x) { return gsl_sf_laguerre_n((int)round(n), a, x); } double nsl_sf_legendre_Pl(double l, double x) { return gsl_sf_legendre_Pl((int)round(l), x); } double nsl_sf_legendre_Ql(double l, double x) { return gsl_sf_legendre_Ql((int)round(l), x); } double nsl_sf_legendre_Plm(double l, double m, double x) { return gsl_sf_legendre_Plm((int)round(l), (int)round(m), x); } double nsl_sf_legendre_sphPlm(double l, double m, double x) { return gsl_sf_legendre_sphPlm((int)round(l), (int)round(m), x); } double nsl_sf_conicalP_sphreg(double l, double L, double x) { return gsl_sf_conicalP_sph_reg((int)round(l), L, x); } double nsl_sf_conicalP_cylreg(double m, double l, double x) { return gsl_sf_conicalP_sph_reg((int)round(m), l, x); } double nsl_sf_legendre_H3d(double l, double L, double e) { return gsl_sf_legendre_H3d((int)round(l), L, e); } double nsl_sf_psiint(double n) { return gsl_sf_psi_int((int)round(n)); } double nsl_sf_psi1int(double n) { return gsl_sf_psi_1_int((int)round(n)); } double nsl_sf_psin(double n, double x) { return gsl_sf_psi_n((int)round(n), x); } double nsl_sf_zetaint(double n) { return gsl_sf_zeta_int((int)round(n)); } double nsl_sf_zetam1int(double n) { return gsl_sf_zetam1_int((int)round(n)); } double nsl_sf_etaint(double n) { return gsl_sf_eta_int((int)round(n)); } /* random number distributions */ double nsl_sf_poisson(double k, double m) { return gsl_ran_poisson_pdf((unsigned int)round(k), m); } double nsl_sf_bernoulli(double k, double p) { return gsl_ran_bernoulli_pdf((unsigned int)round(k), p); } double nsl_sf_binomial(double k, double p, double n) { return gsl_ran_binomial_pdf((unsigned int)round(k), p, (unsigned int)round(n)); } double nsl_sf_negative_binomial(double k, double p, double n) { return gsl_ran_negative_binomial_pdf((unsigned int)round(k), p, n); } double nsl_sf_pascal(double k, double p, double n) { return gsl_ran_pascal_pdf((unsigned int)round(k), p, (unsigned int)round(n)); } double nsl_sf_geometric(double k, double p) { return gsl_ran_geometric_pdf((unsigned int)round(k), p); } double nsl_sf_hypergeometric(double k, double n1, double n2, double t) { return gsl_ran_hypergeometric_pdf((unsigned int)round(k), (unsigned int)round(n1), (unsigned int)round(n2), (unsigned int)round(t)); } double nsl_sf_logarithmic(double k, double p) { return gsl_ran_logarithmic_pdf((unsigned int)round(k), p); }