Introduction to GSL - Virginia Tech

Introduction to GSL - Virginia Tech

Introduction to GSL CS 3414 From GNU Scientific Library Reference Manual at http://sources.redhat.com/gsl/ref/gsl-ref_toc.html http://www.gnu.org/software/gsl/manual/html_node/ What is GSL? The GNU Scientific Library GNU is a recursive acronym for "GNU's Not Unix!, a project started in 1983 by Richard Stallman

GNU is an operating system (HURD kernel) and an extensive collection of computer software GSL is a numerical library for C and C++ programmers GSL is free software distributed under the terms of the GNU General Public License The combination of GNU software and the Linux kernel is commonly known as Linux Functionality

GSL provides a well-defined C language Applications Programming Interface (API) for common numerical functions, such as: Random Numbers Least-Squares Fitting Fast Fourier Transforms Root-Finding Minimization Etc. http://www.gnu.org/software/gsl/manual/html_node/ GSL is thread-safe (the library can be used in

multi-threaded programs) Compiling and Linking The library header files are installed in their own gsl directory. You should write include statements with a gsl/ directory prefix like: #include Compile: gcc -c example.c Link: gcc example.o -lgsl -lgslcblas -lm

One dimensional Root-Finding The header file `gsl_roots.h' contains prototypes for the root finding functions and related declarations. The library provides low level components for a variety of iterative solvers and convergence tests. These can be combined by the user to achieve the desired solution, with full access to the

intermediate steps of the iteration. Root Finding Algorithms Two classes of algorithms root bracketing algorithms begin with a bounded region known to contain a root uses only function evaluations (not derivatives) guaranteed to converge root polishing algorithms

improve an initial guess to the root require both the function and its derivative to be supplied by the user converge only if started close enough to a root Framework The user provides a high-level driver for the algorithms. The library provides the individual functions necessary for each of the steps.

There are three main phases of the iteration. The steps are, initialize solver state, s, for algorithm T update s using the iteration T test s for convergence, and repeat iteration if necessary The state for solver is held in a gsl_root_fsolver struct (a declaration for a grouped list of variables in C) or in gsl_root_fdfsolver struct.

Initializing the Solver gsl_root_fsolver * gsl_root_fsolver_alloc (const gsl_root_fsolver_type * T ) This function returns a pointer to a newly allocated instance of a solver of type T void gsl_root_fsolver_free (gsl_root_fsolver * s) This function frees all the memory associated with the solver s.

Providing the function to solve Data Type: gsl_function This data type defines a general function with parameters. double (* function) (double x, void * params) this function should return the value f(x,params) for argument x and parameters params void * params

a pointer to the parameters of the function Iteration int gsl_root_fsolver_iterate (gsl_root_fsolver * s) perform a single iteration of the solver to update its state s double gsl_root_fsolver_root (const gsl_root_fsolver * s)

The solver maintains a current best estimate of the root at all times. Search Stopping Parameters A root finding procedure should stop when one of the following conditions is true: A root has been found to within the userspecified precision. A user-specified maximum number of iterations has been reached. An error has occurred.

Precision Test int gsl_root_test_interval (double x_lower, double x_upper, double epsabs, double epsrel) |a - b| < epsabs + epsrel min(|a|,|b|) Root Bracketing Algorithms bisection algorithm gsl_root_fsolver_bisection

false position algorithm gsl_root_fsolver_falsepos Brent-Dekker method gsl_root_fsolver_brent Root Finding Algorithms using Derivatives Newton's Method gsl_root_fdfsolver_newton secant method (a simplified version of Newton's method which does not require the computation of the derivative on every step) - gsl_root_fdfsolver_secant

Steffenson Method gsl_root_fdfsolver_steffenson Resource Read GNU Scientific Library Reference Manual at http://sources.redhat.com/gsl/ref/gslref_toc.html

Recently Viewed Presentations

  • Apresentação do PowerPoint

    Apresentação do PowerPoint

    ELECTRIC POWER GENERATION Source: Brazilian Energy Balance 2009 - EPE/MME, Key World Energy Statistics 2009 - IEA * ETHANOL Sugarcane Ethanol Facility CARS AND LIGHT COMMERCIAL VEHICLES FUEL CONSUMPTION Source: ANP 2009, FIESP 2009 By Adding 10% of ethanol to...
  • Lecture 5 - Athabasca University

    Lecture 5 - Athabasca University

    NPV = PV(ATOCF) + PV(S) + PV(NWC N) + PV(CCATS) - C 0 - NWC. 0 Basic NPV rule: Accept a project if its NPV > 0. Steps to calculating NPV. Identify the cash outflows and cash inflows incremental to...
  • Temporal expression of Ca-ATPase in the hypodermis of

    Temporal expression of Ca-ATPase in the hypodermis of

    AK R31: GAT ACC GTC CTG CAT CTC CTT The PCR product was run on an agarose gel, stained with ethidium bromide, photographed, and the appropriate band was cut from the gel and extracted using the QiaQuick kit and protocol...
  • The Konus-FG cosmic gamma-ray burst experiment for GAMMA-400 ...

    The Konus-FG cosmic gamma-ray burst experiment for GAMMA-400 ...

    Broadband observations of the naked-eye gamma-ray burst GRB080319B The ultra-luminous GRB110918A Konus-Wind and Helicon (CORONAS-F) simultaneous observations of giant flare from SGR1806-20 on December 27, 2004 Konus-Wind and Helicon (CORONAS-F) simultaneous observations of giant flare from SGR1806-20 on December 27,...
  • From Amphibians to Reptiles

    From Amphibians to Reptiles

    Amphibians begin. Evolved from Sarcopterygii-rhipistidians. Late Devonian (about 400 mya) Early amphibians. Acanthostega. Ichthyostega. The amphibians arose from their ancestor, the rhipidistian group of the class Sarcopterygii, in the late Devonian period about 400 million year ago.
  • Molecular Pathology - prime.edu.pk

    Molecular Pathology - prime.edu.pk

    Lecture Objectives. By the end of this lecture, students should be able to appreciate the possibility of atypical patterns of inheritance with special emphasis on:
  • Night - ERWC

    Night - ERWC

    Night Review ... Faith 7: Recalling the actions of Rabbi Eliahou's son, Elie prays to the God he no longer believes in, that he have the strength to never do what the rabbi's son had done in abandoning his father....
  • Proddage Generic Material

    Proddage Generic Material

    Map or model matching can be used to 'snap' a users location to a particular feature e.g. a road, depending on the data from the other navigation sensors. Radar Electromagnetic sensor characterized by RAdio Detection And Ranging, from which the...