Giter Site home page Giter Site logo

ampl / gsl Goto Github PK

View Code? Open in Web Editor NEW
524.0 43.0 205.0 13.62 MB

GNU Scientific Library with CMake build support and AMPL bindings

Home Page: https://gsl.ampl.com

License: GNU General Public License v3.0

Shell 2.78% C 78.24% C++ 2.03% CMake 0.29% Makefile 16.38% M4 0.18% Batchfile 0.03% Python 0.07%

gsl's Introduction

GSL - GNU Scientific Library

This is GSL, the GNU Scientific Library, a collection of numerical routines for scientific computing.

GSL is free software, you can redistribute it and/or modify it under the terms of the GNU General Public License.

The GNU General Public License does not permit this software to be redistributed in proprietary programs.

This library 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.

About this repository

This repository contains a copy of the latest stable version of GSL, with two main additions:

CMake build instructions

Build with AMPL bindings

To build the AMPL bindings:

  1. Make sure that the ASL submodule is initialized (in /ampl/thirdparty/asl).

  2. Create a build directory and move there:

    mkdir build
    cd build
    
  3. Initialize the build files with your desired generator, for example:

    cmake .. -G"Unix Makefiles"
    
  4. Build the resulting build files accordingly, for example:

    make .
    

Build without AMPL bindings

If building GSL without the AMPL bindings:

  1. Create a build directory and move there:

    mkdir build
    cd build
    
  2. Initialize the build files with your desired generator, defining the variable ```NO_AMPL_BINDINGS````

    cmake .. -G"Unix Makefiles" -DNO_AMPL_BINDINGS=1
    
  3. Build the resulting build files accordingly, for example:

    make .
    

Other build parameters

  1. Defining GSL_DISABLE_TESTS skips the test generation, for example:

    cmake .. -DGSL_DISABLE_TESTS=1
    
  2. There is experimental support to build only a subset of the GSL library; note that this is only supported when not building the AMPL bindings. To generate only some libraries of the GSL, define BUILDLIBS when calling cmake as a comma separated list of GSL directories. An example follows:

    cmake .. -DBUILDLIBS=ode-initval2,linalg -DNO_AMPL_BINDINGS=1
    

    All the dependencies are handled automatically; please note that the tests often have additional dependencies therefore, to fully benefit from this facility, disable them. For example:

    cmake .. -DBUILDLIBS=ode-initval2,linalg -DNO_AMPL_BINDINGS=1 -DGSL_DISABLE_TESTS=1
    
  3. Turn off building of documentation via:

    cmake .. -DDOCUMENTATION=OFF
    

Availability

The current stable version of GSL is always available from ftp.gnu.org in the directory /pub/gnu/gsl.

A list of mirror sites can be found at http://www.gnu.org/order/ftp.html

Installation

GSL follows the standard GNU installation procedure. Please consult the INSTALL file in this distribution for more detailed instructions.

For information about specific platforms and compilers see the "Compilation Notes" section in the INSTALL file.

More information about GSL

The project homepage is http://www.gnu.org/software/gsl/

See the NEWS file for recent changes to the library.

The GSL Manual has been published and can be ordered from most bookstores. The publication details are,

GNU Scientific Library Reference Manual - Revised Second Edition, M. Galassi et al, ISBN 0954161734 (620 pages, paperback).

The money raised from sales of the manual helps support the development of GSL.

A Japanese translation of the reference manual is available from the GSL website above (thanks to Daisuke TOMINAGA).

Reporting Bugs

A list of known bugs can be found in the BUGS file. Details of compilation problems can be found in the INSTALL file.

If you find a bug which is not listed in these files please report it to [email protected].

All bug reports should include:

   The version number of GSL, and where you obtained it.
   The hardware and operating system
   The compiler used, including version number and compilation options
   A description of the bug behaviour
   A short program which reproducibly exercises the bug

It is useful if you can check whether the same problem occurs when the library is compiled without optimization. Thank you.

Any errors or omissions in the manual can also be reported to the same address.

Contributing to GSL

If you are interested in participating in GSL development, please see the webpage at http://www.gnu.org/software/gsl/

gsl's People

Contributors

alvinhochun avatar amyspark avatar arindam-8 avatar brcha avatar chenlianghao avatar dilawar avatar fdabrandao avatar huntertracer avatar jdumas avatar jihadist avatar kinetictheory avatar lindkvis avatar mapgccv avatar martyngigg avatar neeilan avatar nicobako avatar opoplawski avatar psallandre avatar sh-zam avatar vanyossi avatar vitaut avatar yunglee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gsl's Issues

May I contribute my code?

Hello~
I am a CV engineer from China. I just implement the gaxpy LU decomposition (need extra memory space) in GSL according to the book Matrix Computations(4th edition).
So how can I contribute the code?

potential bugs?

Hello, my research group is developing a symbolic execution tool called YUSE to detect floating-point exceptions in numerical code. We've found inputs that cause some of the GSL 2.7.1 functions to throw floating-point exceptions. I've written this mail to see if you consider any of them (8 results) to be real bugs. If you could confirm whether any of these exceptions are useful or actual warnings, we would very appreciate it.

The purpose of our tool is to comprehensively detect floating-point exceptions in the program. For each category of floating-point exception we found, we listed 1 or 2. We describe the name of function, the type of exception thrown, the inputs that trigger the exception, and specific location of the code that causes the exception.

Category 1:invalid operation exception
1.The function gsl_sf_conicalP_xlt1_large_neg_mu_e throws an invalid exception when its input tau=1.0, mu=2.0, x=3.0 at line 221 in file /gsl-2.7.1/specfunc/legendre_con.c: double p = x/sqrt(beta2*(1.0-xx) + 1.0); Because the parameter of sqrt cannot be negative numbers, invalid exception occurs in this occasion.
2.The function gsl_cdf_laplace_Qinv throws an invalid exception when its input Q=-0.5 at line 67 in file /gsl-2.7.1/cdf/laplaceinv.c:x = -a * log(2
Q);Because the parameter of log cannot be negative numbers, invalid exception occurs in this occasion.

Category 2:overflow
3.The function gsl_sf_bessel_Knu_scaled_asymp_unif_e throws a overflow exception when its input nu=1.45e-192, x=1.0 at line 398 in file /gsl-2.7.1/specfunc/bessel.c: double root_term = hypot(1.0,z);
4.The function gsl_sf_conicalP_xlt1_large_neg_mu_e throws a overflow exception when its input tau =1.23e189,mu=1e-2 at line 219 in file /gsl-2.7.1/specfunc/legendre_con.c: double beta2 = beta*beta;

Category 3:underflow
5.The function gsl_sf_bessel_Jnu_asympx_e throws an underflow exception when its input nu=1.23e-189, x=1.0 at line 217 in file /gsl-2.7.1/specfunc/bessel.c: double mu = 4.0nunu;

Category 4:division-by-zero
6.The function gsl_sf_bessel_Knu_scaled_asympx_e throws an division-by-zero floating-point exception when its input x=0.0 at line 318 in file /gsl-2.7.1/specfunc/bessel.c: double r = nu/x;

Category 5:type conversion
7.The function gsl_ran_gamma_knuth throws an overflow caused by type conversion exception when its input a=1.23e189 at line 44 in file /gsl-2.7.1/randist/gamma.c: unsigned int na = floor (a);

Category 6:inexact(rounding error)
8.The function hyperg_1F1_1 throws a rounding error exception which cause the while loop to not terminate when its input b=x=1.23e189 at line 378 in file /gsl-2.7.1/specfunc/hyperg_1F1.c: while(bp > b+0.1) {.The loop at 378 will not terminate when x reaches 1.23e189 (a very large value),because bp -= 1.0 at line 380 makes bp – 1.0 is rounded to bp itself, thus the while condition at bp > b+0.1 at 378 is satisfied all the time and can not terminate.

For the 8 scenarios listed above, I think whether it would be better to do some check on the variable's(parameter’s) scope in advance when calling the function. If not, it would be dangerous according to invalid inputs and there will be problems where return values from the above questions are used. (For example, before calling the sqrt(x) function, put if(x<0){return;} in order to check, and so on.)

I am very sorry about that I have disturbed you in your busy schedule. If anyone could confirm whether any of these exceptions is actual, I would appreciate it. I am looking forward to your reply. Thank you very much.

Call CMakeLists.txt from another CMake project

Hello,

I am trying to call the CMakeLists.txt of the GSL from another project and I noticed the line 691:

file(READ "${CMAKE_SOURCE_DIR}/gsl-config.in" GSL_CONFIG_FILE)

The CMAKE_SOURCE_DIR is the directoy where the top-level CMakeLists.txt is located, which in my case means the directory of my project, where there is no gsl-config.in. I think it should be replaced by CMAKE_CURRENT_SOURCE_DIR which in any case is the directory where gsl-config.in is.

Best regards,

Simon

Wrong hessian order in amplgsl_hypot3

I use the following code to build a model via pyomo and check hessian via IPOPT.
import pyomo.environ as pyo
import pyomo.core.base.external as external
import pyomo.common.gsl as gsl

dll = gsl.find_GSL()
model = pyo.ConcreteModel()
model.test_indices = pyo.RangeSet(0, 2)
x0 = [-0.2, 0.3, 0.1]
model.x = pyo.Var(model.test_indices, domain=pyo.Reals, initialize=lambda m, i: x0[i])
model.gsl_hypot3 = external.ExternalFunction(library=dll, function="gsl_hypot3")
model.cons = pyo.Constraint(rule=lambda m: (m.gsl_hypot3(m.x[0], m.x[1], m.x[2]) <= 100))
model.obj = pyo.Objective(rule=lambda m: m.x[0] + m.x[1] + m.x[2], sense=pyo.minimize)
optimizer = pyo.SolverFactory("ipopt")
optimizer.options["derivative_test"] = "second-order"
results = optimizer.solve(model, tee=True)

Then, IPOPT will report warnings like:

Starting derivative checker for second derivatives with obj_factor or lambda[i] set to 1.5.

\* 1-th constr_hess[ 1, 3] = 1.2351616171153007e-01 v ~ -5.4190095373535634e-02 [ 3.279e+00]
\* 1-th constr_hess[ 2, 2] = -5.4190094682647579e-02 v ~ 1.2351616144287625e-01 [ 1.439e+00]
\* 1-th constr_hess[ 3, 1] = 1.2351616171153007e-01 v ~ -5.4190087606698210e-02 [ 3.279e+00]
After checking the source code of amplgsl_hypot3 function in amplgsl.cc, I found that the original hessian order is incorrect, which does not accord with the instruction in funcadd.h: In this case, the function should set al->hes[i + j*(j+1)/2] to the partial derivative of the function with respect to al->ra[i] and al->ra[j] for all 0 <= i <= j < al->nr. In amplgsl_hypot3, the terms in hes[2] and hes[3] should be swaped. I also submit new code at #75. May the code be merged? Thanks! @4er4er4er @fdabrandao @mapgccv

I only wish to build a subset of GSL's routines; how do I do this via CMake?

I have a project that only requires a handful of routines from GSL---for example, those in gsl/ode-initval2.

Is there a "clean" way (via some CMake options/variables?) to only build certain folders, and only include those in the final static lib libgsl.a?

Currently, my project's build time is dominated by GSL; it seems inefficient to build the entire library when I'm only using a small subset of it.

copy-headers.cmake not found

Hello,

I had troubles to compile the GSL on my Windows 10 with Visual Studio 2015 and 2017. Errors occured during the build step:
Error processing file: copy-headers.cmake
leading to
Cannot open include file: 'gsl/gsl_*.h': No such file or directory
because headers had not been copied in the gsl/ directory.

The solution I have found is to replace line 592 of the CMakeLists.txt:
COMMAND ${CMAKE_COMMAND} -P copy-headers.cmake)
by
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/copy-headers.cmake)

Regards,

Simon

Add version information for Extended Function Library

Rick Stone of Delta Air Lines asked the following:

is there a way to tell the version (or date) of AMPL’s version of the GSL (GNU Scientific Library)? I can look up the latest version of the GSL itself from GNU, but that doesn’t mean AMPL has matched it as yet. Is there a change log?

Dave Gay added the following suggestion:

The amplgsl.dll in

https://ampl.com/resources/extended-function-library/

was created in April 2019, whereas

https://www.gnu.org/savannah-checkouts/gnu/gsl/gsl.html

says the current stable version is GSL-2.7, released on 1 June 2021. It would be a good idea for our Extended Function Library page and perhaps the *.zip files available there for download to show the GSL version they are built from.

Clarify cmake build instructions

It seems the purpose of this project is to provide a cmake for the project. However, the INSTALL file does not give instructions on how to build with cmake. Although this may seem obvious, it makes one uncertain of whether or not cmake will work and/or whether the old configure/make/make install will work in the project. Also, there's a deeply nested submodule that needs to get an init and update before one can start the build. Such documentation might expose the use of NO_AMPL_BINDINGS and explain what the impact of setting this flag is. Do certain GSL features require the AMPL bindings or is this an extension of the GSL feature set?

Shared lib instead of static ?

Hi,

I'm trying to build the library for Windows 64-bit, using Microsoft VS2013. I have successfully built static version of library. How can I build shared version (.dll) instead ?

Kind regards !

Undefined Symbol Issue `cblas_dcopy`

When I use gsl_multifit.h library for fitting I get the error
./newnew: symbol lookup error: /usr/local/lib/libgsl.so.27: undefined symbol: cblas_dcopy
Help me trouble shooting the issue. I use pop-os 22.04 os and gsl-2.7

Msvc runtime errors

Default build without any options is ok. But if I try to change runtime options I will receive link errors.
CMake options didn't work as expected. I provided options
BUILD_DYNRT_LIBS:BOOL=ON and MSVC_RUNTIME_DYNAMIC:BOOL=ON
but received error
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in gsl-test.cc.obj
I also provided additional option BUILD_MT_LIBS:BOOL=ON but error was the same.
Looks like missing runtime flag for some targets.

sinc function not available

It appears that the GSL trigonometric functions have not been included. Many are built into AMPL anyway, but not all.

In particular one user needs sinc(x) = (if x != 0 then sin(x)/x else 1). This function can be implemented in AMPL using an if-then-else, but in the user's example that becomes awkward due to the large number of terms that use sinc and the complexity of the expressions that are arguments to sinc.

change path to gsl

Hello I would like to change the location of my gsl from
/home/gssctest/ScienceTools-v11r5p3-fssc-20180124/external/x86_64-unknown-linux-gnu-libc2.17

to

/home/szakirov/Desktop/SRMP/ScienceTools-v11r5p3-fssc-20180124-x86_64-unknown-linux-gnu-libc2.17/x86_64-unknown-linux-gnu-libc2.17/include

How do I do this?

Fix for CVE-2020-35357 is not present in master (and not in v2.7.0)

The fix for CVE-2020-35357 which affects the quantile_from_sorted_data is not present in this repository. It also seems to be missing from v2.7.0 which is listed as the fix.

In addition, should the value of n not be checked as well?

[1] https://github.com/ampl/gsl/blob/master/statistics/quantiles_source.c
[2] https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-35357
[3] https://git.savannah.gnu.org/cgit/gsl.git/commit/?id=989a193268b963aa1047814f7f1402084fb7d859

How to build without sudoer right?

In "build" step, the process interrput with the following information:

[100%] Built target spmatrix_test
[100%] Building C object CMakeFiles/splinalg_test.dir/splinalg/test.c.o
[100%] Linking C executable bin/splinalg_test
[100%] Built target splinalg_test
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libgsl.a
CMake Error at cmake_install.cmake:46 (file):
file INSTALL cannot copy file "/public/home/dy/bin/gsl/build/libgsl.a" to
"/usr/local/lib/libgsl.a": Permission denied.

Unfortunately, I have no sudoer right, and I used
opam install gpl
which also meet with the same error

Let opam run your package manager to install the required system packages?
(answer 'n' for other options) [Y/n] y

  • /usr/bin/sudo "yum" "install" "gsl-devel"
    [sudo] password for dy:
  • dy is not in the sudoers file. This incident will be reported.
    [ERROR] System package install failed with exit code 1 at command:
    sudo yum install gsl-devel

However, I can install gsl without build step by my own prefix
So, how should I do to change the prefix in build step?

gsl installation issue

I am trying for gsl-2.4 installation by following steps

cd gsl-2.4
./configure
make
make install 

Making install in gsl
make[2]: Nothing to be done for install-exec-am'. make[2]: Nothing to be done for install-data-am'.
Making install in utils
make[2]: Nothing to be done for install-exec-am'. make[2]: Nothing to be done for install-data-am'.
Making install in sys
make[2]: Nothing to be done for `install-exec-am'.
.././install-sh -c -d '/usr/local/include/gsl'
mkdir: /usr/local/include: Permission denied
mkdir: /usr/local/include: No such file or directory
make[2]: *** [install-pkgincludeHEADERS] Error 1
make[1]: *** [install-am] Error 2
make: *** [install-recursive] Error 1

Still not able to install, what will be next step?

Linking error on Windows

Hello!
I am trying to compile examples from this page.
Operating system: Windows 10
Compiler: msvs 2019
Build system: cmake
GSL: tried both 2.4 and 2.6 from conda

cmake_minimum_required(VERSION 3.15)
project(test)

find_package(GSL REQUIRED)

add_executable(test)
target_sources(test PRIVATE main.cpp)
target_include_directories(test PRIVATE "${GSL_INCLUDE_DIRS}")
target_link_libraries(test "${GSL_LIBRARIES}")
#include <stdio.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv2.h>

int
func (double t, const double y[], double f[],
      void *params)
{
    (void)(t); /* avoid unused parameter warning */
    double mu = *(double *)params;
    f[0] = y[1];
    f[1] = -y[0] - mu*y[1]*(y[0]*y[0] - 1);
    return GSL_SUCCESS;
}

int
jac (double t, const double y[], double *dfdy,
     double dfdt[], void *params)
{
    (void)(t); /* avoid unused parameter warning */
    double mu = *(double *)params;
    gsl_matrix_view dfdy_mat
            = gsl_matrix_view_array (dfdy, 2, 2);
    gsl_matrix * m = &dfdy_mat.matrix;
    gsl_matrix_set (m, 0, 0, 0.0);
    gsl_matrix_set (m, 0, 1, 1.0);
    gsl_matrix_set (m, 1, 0, -2.0*mu*y[0]*y[1] - 1.0);
    gsl_matrix_set (m, 1, 1, -mu*(y[0]*y[0] - 1.0));
    dfdt[0] = 0.0;
    dfdt[1] = 0.0;
    return GSL_SUCCESS;
}

int
main (void)
{
    double mu = 10;
    gsl_odeiv2_system sys = {func, jac, 2, &mu};

    gsl_odeiv2_driver * d =
            gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_rk8pd,
                                           1e-6, 1e-6, 0.0);
    int i;
    double t = 0.0, t1 = 100.0;
    double y[2] = { 1.0, 0.0 };

    for (i = 1; i <= 100; i++)
    {
        double ti = i * t1 / 100.0;
        int status = gsl_odeiv2_driver_apply (d, &t, ti, y);

        if (status != GSL_SUCCESS)
        {
            printf ("error, return value=%d\n", status);
            break;
        }

        printf ("%.5e %.5e %.5e\n", t, y[0], y[1]);
    }

    gsl_odeiv2_driver_free (d);
    return 0;
}

I am getting this error:
error LNK2001: unresolved external symbol gsl_odeiv2_step_rk8pd

The same example works fine on Linux.
The basic example from here works fine on Windows, so the problem is just the example above.
Can you please point out what is wrong?
Thanks

Problems with building shared libraries with VS14?

I'm trying to compile GSL with shared library support using visual studio community 2015. This is to provide windows support in the conda recipe: conda-forge/gsl-feedstock#7

The issue I'm having is as follows. I run:

cmake . -DBUILD_SHARED_LIB=1
msbuild GSL.sln

I then get an error:

"C:\jk-work\gsl\GSL.sln" (default target) (1) ->
"C:\jk-work\gsl\ALL_BUILD.vcxproj.metaproj" (default target) (2) ->
"C:\jk-work\gsl\block_test.vcxproj.metaproj" (default target) (4) ->
"C:\jk-work\gsl\gsl.vcxproj.metaproj" (default target) (5) ->
"C:\jk-work\gsl\gsl.vcxproj" (default target) (10) ->
(Link target) ->
  gsl.def : error LNK2001: unresolved external symbol gsl_multilarge_nlinear_df
 [C:\jk-work\gsl\gsl.vcxproj]
  gsl.def : error LNK2001: unresolved external symbol gsl_multilarge_nlinear_fd
fvv [C:\jk-work\gsl\gsl.vcxproj]
  C:/jk-work/gsl/Debug/gsl.lib : fatal error LNK1120: 2 unresolved externals [C
:\jk-work\gsl\gsl.vcxproj]

    288 Warning(s)
    3 Error(s)

Apologies if I'm doing something stupid here; I'm a windows noob!

no "make install"

the CMake file builds but doesn't install anything.

The following does the trick for me:

install(TARGETS gsl gslcblas
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
)

install(FILES ${GSL_HEADER_PATHS} DESTINATION include/gsl)

GSL Versioning

Hey guys;

Should we use e020de7 as GSL v2.6 and e11f1c7 as GSL v2.7?

Or should we wait for an official tag on the Releases page?

A recommend repair of gsl_sf_angle_restrict_symm_err_e

The program try to reduce input into the [-pi,pi],I found inaccuracy when the input is slight smaller than -2kpi.

For example, with the input -226.19467105845234

gsl_sf_angle_restrict_symm_err_e(-226.19467105845234) = 1.27704742478e-11
while I use the higher precision the right result should be 1.27701649912052602689124836895e-11
the relative error is 2.421711882e-5

A recommend repair is:
replace:
if(r > M_PI) { r = (((r-2P1)-2P2)-2P3); } / r-TwoPi /
else if (r < -M_PI) r = (((r+2
P1)+2P2)+2P3); /* r+TwoPi */

with:
if(r > M_PI) { r = (((theta-(y+2)*P1)-(y+2)*P2)-(y+2)P3); } / r-TwoPi */
else if (r < -M_PI) r = (((theta+(2-y)*P1)+(2-y)*P2)+(2-y)P3); / r+TwoPi */

In this way to avoid the inaccuracy introduced in the previous sentence: double r = ((theta - yP1) - yP2) - y*P3;

PS:
int gsl_sf_angle_restrict_symm_err_e(const double theta, gsl_sf_result * result)
{
/* synthetic extended precision constants /
const double P1 = 4 * 7.8539812564849853515625e-01;
const double P2 = 4 * 3.7748947079307981766760e-08;
const double P3 = 4 * 2.6951514290790594840552e-15;
const double TwoPi = 2
(P1 + P2 + P3);

const double y = GSL_SIGN(theta) * 2 * floor(fabs(theta)/TwoPi);
double r = ((theta - yP1) - yP2) - y*P3;

if(r > M_PI) { r = (((r-2P1)-2P2)-2P3); } / r-TwoPi /
else if (r < -M_PI) r = (((r+2
P1)+2P2)+2P3); /* r+TwoPi */

/* To avoid round error in the double r = ((theta - yP1) - yP2) - y*P3;
if(r > M_PI) { r = (((theta-(y+2)*P1)-(y+2)*P2)-(y+2)P3); } / r-TwoPi */
else if (r < -M_PI) r = (((theta+(2-y)*P1)+(2-y)*P2)+(2-y)P3); / r+TwoPi */
}
*/

result->val = r;

if(fabs(theta) > 0.0625/GSL_DBL_EPSILON) {
result->val = GSL_NAN;
result->err = GSL_NAN;
GSL_ERROR ("error", GSL_ELOSS);
}
else if(fabs(theta) > 0.0625/GSL_SQRT_DBL_EPSILON) {
result->err = 2.0 * GSL_DBL_EPSILON * fabs(result->val - theta);
return GSL_SUCCESS;
}
else {
double delta = fabs(result->val - theta);
result->err = 2.0 * GSL_DBL_EPSILON * ((delta < M_PI) ? delta : M_PI);
return GSL_SUCCESS;
}
}

[Installation Issue] Compile error in Ubuntu 18.04

Hello, I can successfully install gsl on Ubuntu 16.04.
But when I move to Ubuntu 18.04, -lm flag seems to be disappear and error happens like:

gsl-2.5/siman/siman_tsp.c:83: undefined reference to `sincos'

note. This is not the error when using gsl, but compiling it.

Most versions of Visual Studio do not support %zu

Microsoft Visual Studio 2010 does not support the printf/scanf format specifier %zu and it leads to errors such as:

  52/53 Test #52: spmatrix_test ....................***Failed    2.41 sec
  gsl: spmatrix\spio.c:178: ERROR: fscanf failed reading header
  Default GSL error handler invoked.

Even though %zu is the correct format specifier for size_t, it can be replaced by %lu on 32-bit platforms, and by %llu on 64-bit platforms.

can not link

wingslf.obj : error LNK2001: 无法解析的外部符号 gsl_wavelet_daubechies
1>wingslf.obj : error LNK2001: 无法解析的外部符号 gsl_wavelet_haar
1>wingslf.obj : error LNK2001: 无法解析的外部符号 gsl_wavelet_bspline
1>D:\work\TTHS\code\win
gslf\x64\Debug\wingslf.exe : fatal error LNK1120: 3 个无法解析的外部命令

Which dll to use? Where to find the corresponding lib or dll.a?

I'd build the GSL shared library under MSys2:

pacman -S git cmake ninja gcc

git clone https://github.com/ampl/gsl.git
cd gsl
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS:BOOL=ON -G "Ninja" ..
cmake --build .
ctest --output-on-failure

Everything goes fine, thank you very much for providing this excellent CMake support.

My questions now:

  • In directory bin/, I find amplgsl.dll and msys-gsl.dll. What is the relation between these two? Do I need to link to both of them?

  • Where are the corresponding lib or dll.a files? In the build main directory, I find libgsl.dll.a. Why yet another name?

(windows) make check fails on spmatrix

In windows with MSYS2+minGW64 and running make -i check results in the following failure:

make[1]: Entering directory '/home/Soren/gsl/spmatrix'
make  test.exe
make[2]: Entering directory '/home/Soren/gsl/spmatrix'
gcc -DHAVE_CONFIG_H -I. -I..  -I..   -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o test.c
mv -f .deps/test.Tpo .deps/test.Po
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2   -o test.exe test.o libgslspmatrix.la ../bst/libgslbst.la ../test/libgsltest.la ../matrix/libgslmatrix.la ../vector/libgslvector.la ../blas/libgslblas.la ../cblas/libgslcblas.la ../block/libgslblock.la  ../sys/libgslsys.la ../err/libgslerr.la ../utils/libutils.la ../rng/libgslrng.la -lm
libtool: link: gcc -g -O2 -o .libs/test.exe test.o  ./.libs/libgslspmatrix.a ../bst/.libs/libgslbst.a ../test/.libs/libgsltest.a ../matrix/.libs/libgslmatrix.a ../vector/.libs/libgslvector.a ../blas/.libs/libgslblas.a ../cblas/.libs/libgslcblas.dll.a ../block/.libs/libgslblock.a ../sys/.libs/libgslsys.a ../err/.libs/libgslerr.a ../utils/.libs/libutils.a ../rng/.libs/libgslrng.a -L/mingw64/lib
make[2]: Leaving directory '/home/Soren/gsl/spmatrix'
make  check-TESTS
make[2]: Entering directory '/home/Soren/gsl/spmatrix'
make[3]: Entering directory '/home/Soren/gsl/spmatrix'
FAIL: test.exe
make[4]: Entering directory '/home/Soren/gsl/spmatrix'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/Soren/gsl/spmatrix'
============================================================================
Testsuite summary for gsl 2.6
============================================================================
# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See spmatrix/test-suite.log
============================================================================
make[3]: [Makefile:728: test-suite.log] Error 1 (ignored)
make[3]: Leaving directory '/home/Soren/gsl/spmatrix'
make[2]: Leaving directory '/home/Soren/gsl/spmatrix'
make[1]: Leaving directory '/home/Soren/gsl/spmatrix'
Making check in splinalg
make[1]: Entering directory '/home/Soren/gsl/splinalg'
make  test.exe
make[2]: Entering directory '/home/Soren/gsl/splinalg'

The contents of test-suite.log is:

======================================
   gsl 2.6: spmatrix/test-suite.log
======================================

# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: test
==========

FAIL: gsl_spmatrix_long_double_fscanf[53,107](COO) [289]
FAIL: gsl_spmatrix_long_double_fscanf[53,107](CSC) [290]
FAIL: gsl_spmatrix_long_double_fscanf[53,107](CSR) [291]
FAIL: gsl_spmatrix_complex_long_double_fscanf[53,107](COO) [1313]
FAIL: gsl_spmatrix_complex_long_double_fscanf[53,107](CSC) [1314]
FAIL: gsl_spmatrix_complex_long_double_fscanf[53,107](CSR) [1315]
FAIL: gsl_spmatrix_long_double_fscanf[40,20](COO) [1607]
FAIL: gsl_spmatrix_long_double_fscanf[40,20](CSC) [1608]
FAIL: gsl_spmatrix_long_double_fscanf[40,20](CSR) [1609]
FAIL: gsl_spmatrix_complex_long_double_fscanf[40,20](COO) [2631]
FAIL: gsl_spmatrix_complex_long_double_fscanf[40,20](CSC) [2632]
FAIL: gsl_spmatrix_complex_long_double_fscanf[40,20](CSR) [2633]
FAIL: gsl_spmatrix_long_double_fscanf[30,30](COO) [2925]
FAIL: gsl_spmatrix_long_double_fscanf[30,30](CSC) [2926]
FAIL: gsl_spmatrix_long_double_fscanf[30,30](CSR) [2927]
FAIL: gsl_spmatrix_complex_long_double_fscanf[30,30](COO) [3949]
FAIL: gsl_spmatrix_complex_long_double_fscanf[30,30](CSC) [3950]
FAIL: gsl_spmatrix_complex_long_double_fscanf[30,30](CSR) [3951]

The rest of the make runs fine, spmatrix is the only point of failure.

copy-headers.cmake fails with whitespace directories

Using Visual Studio 2017 and Cmake 3.11.2

During compile time, the copy-headers.cmake routine fails if your source directory has whitespaces:
i.e.
bad-copy-headers.cmake.log

VS output
VS_error.log

Solution is to add '\' before each whitespace in the directory enumeration, i.e.
good-copy-headers.cmake.log
Manually doing a search & replace operation makes the build work again.

or source the project in a directory without whitespaces. I'm not sure how this would be done in CMakeLists.txt:584

v2.6 release?

Thank you for the awesome project!

Can you please make a 2.6 release in Github releases? The last official release is 2.5

gsl-hsitogramm manuel to be updated

My gsl version is :

gsl-config --version
2.5

In the gsl-randist manual, we can find :
gsl-randist 0 10000 cauchy 30 | gsl-histogram -- -100 100 200 > histogram.dat

but in the gsl-histogramm, we have :
gsl-randist 0 10000 cauchy 30 | gsl-histogram -100 100 200 > histogram.dat
Which is faulty as -100 is taken as an option...

easy fix, big help !
Yves

Wrong installation path for headers when CMAKE_INSTALL_PREFIX set

Hello,

I'm working with windows 10 and Visual Studio 2017. I noticed that when the CMAKE_INSTALL_PREFIX is set, the headers are installed at the root of my machine. Removing the / before include/gsl at line 684 of the CMakeLists.txt solved the problem. The line then become:
install(FILES ${GSL_HEADER_PATHS} DESTINATION include/gsl)

Regards,

Simon

eigen_test fails on Ubuntu Lucid x86

Log:

18/51 Test #18: eigen_test .......................***Failed    0.34 sec
FAIL: gen, direct eigenvalue(4) imag, random (-0.481216772353650846 observed vs 0.481216772353650846 expected) [877968]
FAIL: gen, direct eigenvalue(5) imag, random (0.481216772353650901 observed vs -0.481216772353650846 expected) [877970]
FAIL: gen, direct eigenvalue(15) imag, random (6.85872455924790447 observed vs -6.85872455924790536 expected) [877990]
FAIL: gen, direct eigenvalue(16) imag, random (-6.85872455924790536 observed vs 6.85872455924790625 expected) [877992]

Assessment of the difficulty in porting CPU architecture for the GSL

Hello everyone! I am working on implementing a tool to assess the complexity of CPU architecture porting. It primarily focuses on RISC-V architecture porting. As part of my dataset, I have collected the gsl project. I would like to gather community opinions to support my assessment. I appreciate your help and response! Based on scanning tools, the porting complexity is determined to be simple, with a small amount of code related to the CPU architecture in the project. (referring to the overall workload from adapting the project to a specific architecture to achieving full functionality on that architecture). Is this assessment accurate? I look forward to your help and response.
各位好!我在实现一个关于CPU架构的移植工作复杂度评估的工具,主要面向riscv架构移植,我收集gsl项目作为我的数据集之一,需要收集社区的意见作为支撑,期待您的帮助和回答!通过扫描工具得出其移植复杂度为简单,工程中与CPU架构相关的代码量较少,(这里指的是从工程尚未适配某架构到实现某架构的较完整功能的总体工作量)这样的判断是否准确?期待您的帮助与回答

(windows) not correctly detected by cmake

Hi,

For the purpose of compiling something with cmake.
I've installed the repository on windows via MinGW.
With these commands precisely:

./configure --prefix=C:/MinGW
make
make install

But when i'm trying to compile a project with cmake, it gives me this error:
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message): Could NOT find GSL (missing: GSL_LIBRARY GSL_CBLAS_LIBRARY) (found version "2.5")

Is there something i did wrong with the installation ?
Because it does find the version but not the rest.
I've also tried to install with cmake gui and visual studio, but with this method it wouldn't even find the version.

Can't compile with VS 2015 with option -DGSL_SHARED=ON (8 unresolved externals)

I just wanted to get dll files. Compilation to *.lib files went just fine, but compilation to shared library failed.

Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol gsl_sf_legendre_sphPlm_array gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_sf_legendre_sphPlm_deriv_array gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_sf_legendre_Plm_deriv_array gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_sf_legendre_Plm_array gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_sf_legendre_array_size gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_multifit_fdfsolver_dif_fdf gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_bspline_deriv_free gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK2001 unresolved external symbol gsl_bspline_deriv_alloc gsl C:\Users\Speedziarz\Downloads\gsl-master\gsl.def 1
Error LNK1120 8 unresolved externals gsl C:\Users\Speedziarz\Downloads\gsl-master\Release\gsl.lib 1

Another thing is that it would be nice to have an option to compile to x64 too (VS listed only Win32 configuration).

Building failure under mingw810_64

I am trying to build the Windows 10 GSL shared library under mingw810_64 (x86_64-w64-mingw32) in this way:
mkdir build
cd build
cmake .. -G"MinGW Makefiles" -DNO_AMPL_BINDINGS=1 -DBUILD_SHARED_LIBS:BOOL=ON
cmake –build .

Many warnings and errors appear during the building process and, while the libgslcblas.dll is working, the libgsl.dll does not work.
The first cmake command produces few warnings. One of them is : Performing Test C_EXTERN_INLINE – Failed
The second cmake command produces many almost identical warning as:
[ 35%] Building C object CMakeFiles/gsl.dir/specfunc/gamma.c.obj
In file included from C:/gsl-2.7/build/gsl/gsl_math.h:23,
from C:\gsl-2.7\specfunc\gamma.c:23:
C:/gsl-2.7/build/gsl/gsl_sys.h:45:5: warning: 'gsl_finite' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
int gsl_finite (const double x);
^~~~~~~~~~

The obj files are produced but, after the linking into libgsl.dll, the sys_test.exe compilation gives a long list of errors as:
undefined reference to `gsl_xxxxx'
If the option -DBUILD_SHARED_LIBS:BOOL=ON is removed the situation improves and the ctest command:
ctest --output-on-failure
reports:
91% tests passed, 5 tests failed out of 55
Total Test time (real) = 54.09 sec
The following tests FAILED:
6 - block_test (Failed)
7 - vector_test (Failed)
8 - vector_test_static (Failed)
9 - matrix_test (Failed)
10 - matrix_test_static (Failed)
Errors while running CTest

Is there anything I can try to get a working libgsl.dll?

using the library in a memory contained space

I want to use the multifit_nlin module on a microcontroller - do you have any suggestions on how to approach this?

Most obviously I dont want to link the whole library but rather the least possible amount of this. I have used the library in an application finding a curve fit to given data, now I want to port it into a preexisting nrf-project. I have embedded the include path for the headerfiles but am now thinking about how to add src files/maybe just build an .a file with all the necessary functionalities. The problem is though, I dont know which files to add exactly or if everything is so dependent that I cannot just erase files.
As I said I am basically just doing #include <gsl/gsl_multifit_nlin.h>

any suggestions or experiences with working with GSL on uCs would be appreciated

Can't set GSL_RNG_SEED and GSL_RNG_TYPE within an AMPL session

Testing under Windows, the example at the bottom of http://ampl.github.io/amplgsl/rng.html appears to give the same random results regardless of the seed setting:

ampl: option GSL_RNG_TYPE 'taus';
ampl: option GSL_RNG_SEED 123;
ampl: include gsl.ampl;
ampl: print gsl_ran_gaussian(1);
0.1339186081186759
ampl: print gsl_ran_gaussian(1);
-0.0881009918314384
ampl: print gsl_ran_gaussian(1);
1.6744084062537739
ampl: quit
sw:
sw: ampl
ampl: option GSL_RNG_TYPE 'taus';
ampl: option GSL_RNG_SEED 237;
ampl: include gsl.ampl;
ampl: print gsl_ran_gaussian(1);
0.1339186081186759
ampl: print gsl_ran_gaussian(1);
-0.0881009918314384
ampl: print gsl_ran_gaussian(1);
1.6744084062537739
ampl:

Also in http://ampl.github.io/amplgsl/rng.html it is stated that

In AMPL version 20120830 and later the standard randseed option can be used instead of GSL_RNG_SEED to specify the random number generator seed.

But changes to AMPL's option randseed do not appear to affect the seed used for the GSL random functions, even if they are made before loading gsl.ampl. It does work to invoke set GSL_RNG_SEED=1 before starting the AMPL process.

Similar comments apply to GSL_RNG_TYPE.

building static libs fails during install

building static libraries with VS2008 and VS2010 fails during installation since it tries to copy PDB files which do not exist.
The commit in question is 651b6af
Going back to 8f07f98 (which I tagged v2.1-static) works for my application which expects static .lib files for linkage.

Bessel function

linking problem with the following message : LINK2019 gslsfbesselJ0 not reference in main.
I will investigate and respond.

gsl_complex_exp not found

Hi,

I have been able to build with mingw-w64. with cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DNO_AMPL_BINDINGS=1 -DBUILD_SHARED_LIBS=ON ../../gsl

I need the dll to use it with gsl-shell but it says: cannot resolve symbol gsl_complex_exp. (I have also checked with Dependencies.exe) Perhaps GSL_VAR is missing in the header? How can this be solved?

Also would like to know how to link OpenBlas with gsl.

Best Regards
Victor Bombi

Add gsl_stats_ functions?

The following request came from Bill Ketterer at Smith Group Asset Management:

I noticed that AMPL can be bound to the GNU Scientific Library.

Although not listed, I was wondering if I would be able to access gsl_stats_spearman?

If yes, would the syntax be something like:
gsl_stats_spearman {i in set} ( var1[i] , var2[i] ) ;

More generally, we could consider providing access to as many of the gsl_stats_ functions in the GNU Scientific Library as would make sense in AMPL. These are functions of vectors rather than scalars, but that doesn't necessarily rule out creating AMPL user-defined functions for them. (Mainly they would be used for computing functions of known values, rather than for optimizing over.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.