下一个 >


image

GNU Scientific Library


Reference Manual Edition 1.10, for GSL Version 1.10

10 September 2007


 

Mark GalassiJim DaviesJames TheilerBrian GoughGerard JungmanMichael BoothFabrice RossiTable of Contents1 Introduction 12 Using the library 43 Error Handling 114 Mathematical Functions 165 Complex Numbers 216 Polynomials 287 Special Functions 328 Vectors and Matrices 749 Permutations 9810 Combinations 10511 Sorting 10912 BLAS Support 11513 Linear Algebra 12714 Eigensystems 14215 Fast Fourier Transforms (FFTs) 15616 Numerical Integration 17317 Random Number Generation 18318 Quasi-Random Sequences 19919 Random Number Distributions 20220 Statistics 24721 Histograms 25722 N-tuples 27523 Monte Carlo Integration 28124 Simulated Annealing 29225 Ordinary Differential Equations 30026 Interpolation 31027 Numerical Differentiation 31728 Chebyshev Approximations 32029 Series Acceleration 32430 Wavelet Transforms 32831 Discrete Hankel Transforms 33532 One dimensional Root-Finding 33734 Multidimensional Root-Finding 35835 Multidimensional Minimization 37236 Least-Squares Fitting 38338 Basis Splines 40539 Physical Constants 41040 IEEE floating-point arithmetic 419Appendix A Debugging Numerical ProgramsAppendix B Contributors to GSL 429Free Software Needs Free Documentation 4461 Introduction1.1 Routines available in GSL1.2 GSL is Free Software1.3 Obtaining GSL1.4 No Warranty1.5 Reporting Bugs1.6 Further Information1.7 Conventions used in this manual2 Using the library2.1 An Example Program2.2 Compiling and Linking2.2.1 Linking programs with the library2.2.2 Linking with an alternative BLAS library2.3 Shared Libraries2.4 ANSI C Compliance2.5 Inline functions2.6 Long double2.7 Portability functions2.8 Alternative optimized functions2.9 Support for different numeric types2.10 Compatibility with C++2.11 Aliasing of arrays2.12 Thread-safety2.13 Deprecated Functions2.14 Code Reuse3 Error Handling3.1 Error Reporting3.2 Error Codes3.3 Error Handlersgsl_error_handler_t * gsl_set_error_handler [Function]3.4 Using GSL error reporting in your own functions3.5 Examples4 Mathematical Functions4.1 Mathematical Constants4.2 Infinities and Not-a-numberGSL_POSINF4.3 Elementary Functions4.4 Small integer powers4.5 Testing the Sign of Numbers4.6 Testing for Odd and Even Numbers4.7 Maximum and Minimum functions4.8 Approximate Comparison of Floating Point Numbers5 Complex Numbers5.1 Complex numbers5.2 Properties of complex numbers5.3 Complex arithmetic operators5.4 Elementary Complex Functions5.5 Complex Trigonometric Functions5.6 Inverse Complex Trigonometric Functions5.7 Complex Hyperbolic Functions5.8 Inverse Complex Hyperbolic Functions5.9 References and Further Reading6 Polynomials6.1 Polynomial Evaluation6.2 Divided Difference Representation of Polynomials6.3 Quadratic Equations6.4 Cubic Equations6.5 General Polynomial Equationsvoid gsl_poly_complex_workspace_free6.6 Examples6.7 References and Further Reading7 Special Functions7.1 Usage7.2 The gsl sf result struct7.3 Modes7.4 Airy Functions and Derivatives7.4.1 Airy Functions7.4.2 Derivatives of Airy Functions7.4.3 Zeros of Airy Functions7.4.4 Zeros of Derivatives of Airy Functions7.5 Bessel Functions7.5.1 Regular Cylindrical Bessel Functions7.5.2 Irregular Cylindrical Bessel Functions7.5.3 Regular Modified Cylindrical Bessel Functions7.5.4 Irregular Modified Cylindrical Bessel Functions7.5.5 Regular Spherical Bessel Functions7.5.6 Irregular Spherical Bessel Functions7.5.7 Regular Modified Spherical Bessel Functions7.5.8 Irregular Modified Spherical Bessel Functions7.5.9 Regular Bessel Function—Fractional Order7.5.10 Irregular Bessel Functions—Fractional Order7.5.11 Regular Modified Bessel Functions—Fractional Order7.5.12 Irregular Modified Bessel Functions—Fractional Order7.5.13 Zeros of Regular Bessel Functions7.6 Clausen Functions7.7 Coulomb Functions7.7.1 Normalized Hydrogenic Bound States7.7.2 Coulomb Wave Functions7.7.3 Coulomb Wave Function Normalization Constant7.8 Coupling Coefficients7.8.1 3-j Symbols7.8.2 6-j Symbols7.8.3 9-j Symbols7.9 Dawson Function7.10 Debye Functions7.11 Dilogarithm7.11.1 Real Argument7.11.2 Complex Argument7.12 Elementary Operations7.13 Elliptic Integrals7.13.1 Definition of Legendre Forms7.13.2 Definition of Carlson Forms7.13.3 Legendre Form of Complete Elliptic Integrals7.13.4 Legendre Form of Incomplete Elliptic Integrals7.13.5 Carlson Forms7.14 Elliptic Functions (Jacobi)7.15 Error Functions7.15.1 Error Function7.15.2 Complementary Error Function7.15.3 Log Complementary Error Function7.15.4 Probability functions7.16 Exponential Functions7.16.1 Exponential Function7.16.2 Relative Exponential Functions7.16.3 Exponentiation With Error Estimate7.17 Exponential Integrals7.17.1 Exponential Integral7.17.2 Ei(x)7.17.3 Hyperbolic Integrals7.17.4 Ei 3(x)7.17.5 Trigonometric Integrals7.17.6 Arctangent Integral7.18 Fermi-Dirac Function7.18.1 Complete Fermi-Dirac Integrals7.18.2 Incomplete Fermi-Dirac Integrals7.19 Gamma and Beta Functions7.19.1 Gamma Functions7.19.2 Factorials7.19.3 Pochhammer Symbol7.19.4 Incomplete Gamma Functions7.19.5 Beta Functions7.19.6 Incomplete Beta Function7.20 Gegenbauer Functionsresult )result )result )7.21 Hypergeometric Functionsresult )result )result )result )result )7.22 Laguerre Functionsresult )7.23 Lambert W Functions7.24 Legendre Functions and Spherical Harmonics7.24.1 Legendre Polynomials7.24.2 Associated Legendre Polynomials and Spherical Harmonics7.24.3 Conical Functions7.24.4 Radial Functions for Hyperbolic Space7.25 Logarithm and Related Functions7.26 Mathieu Functions7.26.1 Mathieu Function Workspace7.26.2 Mathieu Function Characteristic Values7.26.3 Angular Mathieu Functions7.26.4 Radial Mathieu Functions7.27 Power Function7.28 Psi (Digamma) Function7.28.1 Digamma Function7.28.2 Trigamma Function7.28.3 Polygamma Function7.29 Synchrotron Functions7.30 Transport Functions7.31 Trigonometric Functions7.31.1 Circular Trigonometric Functions7.31.2 Trigonometric Functions for Complex Arguments7.31.3 Hyperbolic Trigonometric Functions7.31.4 Conversion Functions7.31.5 Restriction Functions7.31.6 Trigonometric Functions With Error Estimates7.32 Zeta Functions7.32.1 Riemann Zeta Function7.32.2 Riemann Zeta Function Minus One7.32.3 Hurwitz Zeta Function7.32.4 Eta Function7.33 Examples7.34 References and Further Reading8 Vectors and Matrices8.1 Data types8.2 Blocks8.2.1 Block allocation8.2.2 Reading and writing blocks8.2.3 Example programs for blocks8.3 Vectors8.3.1 Vector allocation8.3.2 Accessing vector elements8.3.3 Initializing vector elements8.3.4 Reading and writing vectors8.3.5 Vector views8.3.6 Copying vectors8.3.7 Exchanging elements8.3.8 Vector operations8.3.9 Finding maximum and minimum elements of vectors8.3.10 Vector properties8.3.11 Example programs for vectors8.4 Matrices8.4.1 Matrix allocation8.4.2 Accessing matrix elements8.4.3 Initializing matrix elements8.4.4 Reading and writing matrices8.4.5 Matrix views8.4.6 Creating row and column views8.4.7 Copying matrices8.4.8 Copying rows and columns8.4.9 Exchanging rows and columns8.4.10 Matrix operations8.4.11 Finding maximum and minimum elements of matrices8.4.12 Matrix properties8.4.13 Example programs for matrices8.5 References and Further Reading9 Permutations9.1 The Permutation struct9.2 Permutation allocation9.3 Accessing permutation elements9.4 Permutation properties9.5 Permutation functions9.6 Applying Permutations9.7 Reading and writing permutations9.8 Permutations in cyclic form9.9 Examples9.10 References and Further Reading10 Combinations10.1 The Combination struct10.2 Combination allocation10.3 Accessing combination elements10.4 Combination properties10.5 Combination functions10.6 Reading and writing combinations10.7 Examples10.8 References and Further Reading11 Sorting11.1 Sorting objects11.2 Sorting vectors11.3 Selecting the k smallest or largest elements11.4 Computing the rank11.5 Examples11.6 References and Further Reading12 BLAS Support12.1 GSL BLAS Interface12.1.1 Level 112.1.2 Level 212.1.3 Level 312.2 Examples12.3 References and Further Reading13 Linear Algebra13.1 LU Decompositionsignum )residual )residual )13.2 QR Decomposition13.3 QR Decomposition with Column Pivoting13.4 Singular Value Decomposition13.5 Cholesky Decomposition13.6 Tridiagonal Decomposition of Real Symmetric Matrices13.7 Tridiagonal Decomposition of Hermitian Matrices13.8 Hessenberg Decomposition of Real Matricestau )13.9 Hessenberg-Triangular Decomposition of Real Matrices13.10 Bidiagonalization13.11 Householder Transformationsgsl_complex gsl_linalg_complex_householder_transform13.12 Householder solver for linear systems13.13 Tridiagonal Systems13.14 Balancing13.15 Examples13.16 References and Further Reading14 Eigensystems14.1 Real Symmetric Matrices14.2 Complex Hermitian Matrices14.3 Real Nonsymmetric Matricesgsl_eigen_nonsymm_workspace * gsl_eigen_nonsymm_alloc [Function]gsl_eigen_nonsymmv_workspace * gsl_eigen_nonsymmv_alloc [Function]14.4 Real Generalized Symmetric-Definite Eigensystemsgsl_eigen_gensymm_workspace * gsl_eigen_gensymm_alloc [Function]gsl_eigen_gensymmv_workspace * gsl_eigen_gensymmv_alloc [Function]14.5 Complex Generalized Hermitian-Definite Eigensystemsgsl_eigen_genherm_workspace * gsl_eigen_genherm_alloc [Function]gsl_eigen_genhermv_workspace * gsl_eigen_genhermv_alloc [Function]14.6 Real Generalized Nonsymmetric Eigensystems14.7 Sorting Eigenvalues and Eigenvectors14.8 Examples14.9 References and Further Reading15 Fast Fourier Transforms (FFTs)15.1 Mathematical Definitions15.2 Overview of complex data FFTs15.3 Radix-2 FFT routines for complex dataint gsl_fft_complex_radix2_dif_forwardint gsl_fft_complex_radix2_dif_transform15.4 Mixed-radix FFT routines for complex datawavetable )workspace )15.5 Overview of real data FFTs15.6 Radix-2 FFT routines for real data15.7 Mixed-radix FFT routines for real datagsl_fft_real_wavetable * gsl_fft_real_wavetable_allocgsl_fft_halfcomplex_wavetable * gsl_fft_halfcomplex_wavetable_alloc (size t n )gsl_fft_real_workspace * gsl_fft_real_workspace_alloc [Function]15.8 References and Further Reading16 Numerical Integration16.1 Introduction16.1.1 Integrands without weight functions16.1.2 Integrands with weight functions16.1.3 Integrands with singular weight functions16.2 QNG non-adaptive Gauss-Kronrod integrationneval )16.3 QAG adaptive integration16.4 QAGS adaptive integration with singularities16.5 QAGP adaptive integration with known singular points16.6 QAGI adaptive integration on infinite intervals16.7 QAWC adaptive integration for Cauchy principal values16.8 QAWS adaptive integration for singular functions16.9 QAWO adaptive integration for oscillatory functionsint gsl_integration_qawo_table_set_length [Function]16.10 QAWF adaptive integration for Fourier integrals16.11 Error codes16.12 Examples16.13 References and Further Reading17 Random Number Generation17.1 General comments on random numbers17.2 The Random Number Generator Interface17.3 Random number generator initialization17.4 Sampling from a random number generator17.5 Auxiliary random number generator functions17.6 Random number environment variables17.7 Copying random number generator state17.8 Reading and writing random number generator state17.9 Random number generator algorithmsgsl_rng_ranlxs0 gsl_rng_ranlxs1 gsl_rng_ranlxs2gsl_rng_ranlxd1 gsl_rng_ranlxd2gsl_rng_ranlux gsl_rng_ranlux389gsl_rng_taus gsl_rng_taus217.10 Unix random number generatorsgsl_rng_rand [Generator]gsl_rng_random_bsd gsl_rng_random_libc5 gsl_rng_random_glibc2gsl_rng_rand48 [Generator]17.11 Other random number generatorsgsl_rng_ranf [Generator]gsl_rng_vax [Generator]gsl_rng_randugsl_rng_uni gsl_rng_uni32gsl_rng_knuthran2002 gsl_rng_knuthrangsl_rng_borosh13 gsl_rng_fishman18 gsl_rng_fishman20 gsl_rng_lecuyer21 gsl_rng_waterman1417.12 Performance17.13 Examples17.14 References and Further Reading17.15 Acknowledgements18 Quasi-Random Sequences18.1 Quasi-random number generator initialization18.2 Sampling from a quasi-random number generator18.3 Auxiliary quasi-random number generator functions18.4 Saving and resorting quasi-random number generator state18.5 Quasi-random number generator algorithmsgsl_qrng_niederreiter_218.6 Examples18.7 References19 Random Number Distributions19.1 Introduction19.2 The Gaussian Distributionsigma )sigma )19.3 The Gaussian Tail Distributionsigma )sigma )19.4 The Bivariate Gaussian Distribution19.5 The Exponential Distribution19.8 The Cauchy Distribution19.9 The Rayleigh Distribution19.10 The Rayleigh Tail Distributionsigma )sigma )19.11 The Landau Distribution19.12 The Levy alpha-Stable Distributions19.13 The Levy skew alpha-Stable Distribution19.14 The Gamma Distribution19.15 The Flat (Uniform) Distribution19.16 The Lognormal Distributionsigma )sigma )sigma )sigma )19.17 The Chi-squared Distribution19.18 The F-distribution19.19 The t-distribution19.20 The Beta Distribution19.21 The Logistic Distribution19.22 The Pareto Distribution19.23 Spherical Vector Distributions19.24 The Weibull Distribution19.26 The Type-2 Gumbel Distribution19.27 The Dirichlet Distribution19.28 General Discrete Distributions19.29 The Poisson Distribution19.30 The Bernoulli Distribution19.31 The Binomial Distribution19.32 The Multinomial Distribution19.33 The Negative Binomial Distribution19.34 The Pascal Distribution19.35 The Geometric Distribution19.36 The Hypergeometric Distribution19.37 The Logarithmic Distribution19.38 Shuffling and Samplingsize )19.39 Examples19.40 References and Further Reading20 Statistics20.1 Mean, Standard Deviation and Variance20.2 Absolute deviation20.3 Higher moments (skewness and kurtosis)20.4 Autocorrelation20.5 Covariance20.6 Correlation20.7 Weighted Samplesmean )20.8 Maximum and Minimum values20.9 Median and Percentiles20.10 Examples20.11 References and Further Reading21 Histograms21.1 The histogram struct21.2 Histogram allocation21.3 Copying Histograms21.4 Updating and accessing histogram elementsweight )21.5 Searching histogram ranges21.6 Histogram Statistics21.7 Histogram Operations21.8 Reading and writing histograms21.9 Resampling from histograms21.10 The histogram probability distribution struct21.11 Example programs for histograms21.12 Two dimensional histograms21.13 The 2D histogram structgsl_histogram2d21.14 2D Histogram allocation21.15 Copying 2D Histograms21.16 Updating and accessing 2D histogram elements21.17 Searching 2D histogram ranges21.18 2D Histogram Statistics21.19 2D Histogram Operations21.20 Reading and writing 2D histograms21.21 Resampling from 2D histograms21.22 Example programs for 2D histograms22 N-tuples22.1 The ntuple struct22.2 Creating ntuples22.3 Opening an existing ntuple file22.4 Writing ntuples22.5 Reading ntuples22.6 Closing an ntuple file22.7 Histogramming ntuple values22.8 Examples22.9 References and Further Reading23 Monte Carlo Integration23.1 Interface23.2 PLAIN Monte Carlo23.3 MISER23.4 VEGASdouble result double sigmaint verbose FILE * ostream23.5 Examples23.6 References and Further Reading24 Simulated Annealing24.1 Simulated Annealing algorithm24.2 Simulated Annealing functionsgsl_siman_Efunc_tgsl_siman_step_tgsl_siman_print_tgsl_siman_copy_tgsl_siman_copy_construct_tgsl_siman_destroy_t24.3 Examples24.3.1 Trivial example24.3.2 Traveling Salesman Problem24.4 References and Further Reading25 Ordinary Differential Equations25.1 Defining the ODE System25.2 Stepping Functionsgsl_odeiv_step_rk2gsl_odeiv_step_rk4gsl_odeiv_step_rkf45gsl_odeiv_step_rkckgsl_odeiv_step_rk8pdgsl_odeiv_step_rk2impgsl_odeiv_step_rk4impgsl_odeiv_step_bsimpgsl_odeiv_step_gear1gsl_odeiv_step_gear225.3 Adaptive Step-size Control25.4 Evolution25.5 Examples25.6 References and Further Reading26 Interpolation26.1 Introduction26.2 Interpolation Functionssize )26.3 Interpolation Typesgsl_interp_linear26.4 Index Look-up and Acceleration26.5 Evaluation of Interpolating Functions26.6 Higher-level Interfacesize )26.7 Examples0.826.8 References and Further Reading27 Numerical Differentiation27.1 Functions27.2 Examples27.3 References and Further Reading28 Chebyshev Approximations28.1 Definitions28.2 Creation and Calculation of Chebyshev Series28.3 Chebyshev Series Evaluation28.4 Derivatives and Integrals28.5 Examples28.6 References and Further Reading29 Series Acceleration29.1 Acceleration functionsabserr )29.2 Acceleration functions without error estimation29.3 Examples29.4 References and Further Reading30 Wavelet Transforms30.1 Definitions30.2 Initializationgsl_wavelet_daubechies gsl_wavelet_daubechies_centeredgsl_wavelet_haar gsl_wavelet_haar_centeredgsl_wavelet_bspline gsl_wavelet_bspline_centered30.3 Transform Functions30.3.1 Wavelet transforms in one dimension30.3.2 Wavelet transforms in two dimension30.4 Examples30.5 References and Further Reading31 Discrete Hankel Transforms31.1 Definitions31.2 Functions31.3 References and Further Reading32 One dimensional Root-Finding32.1 Overview32.2 Caveats32.3 Initializing the Solver32.4 Providing the function to solvegsl_function_fdf32.5 Search Bounds and Guesses32.6 Iteration32.7 Search Stopping Parameters32.8 Root Bracketing Algorithms32.9 Root Finding Algorithms using Derivatives32.10 Examples32.11 References and Further Reading33 One dimensional Minimization33.1 Overview33.2 Caveats33.3 Initializing the Minimizer33.4 Providing the function to minimize33.5 Iteration33.6 Stopping Parameters33.7 Minimization Algorithms33.8 Examples33.9 References and Further Reading34 Multidimensional Root-Finding34.1 Overview34.2 Initializing the Solvergsl_multiroot_fdfsolver * gsl_multiroot_fdfsolver_alloc [Function]34.3 Providing the function to solve34.4 Iteration34.5 Search Stopping Parametersepsabs )34.6 Algorithms using Derivativesgsl_multiroot_fdfsolver_gnewton34.7 Algorithms without Derivatives34.8 Examples34.9 References and Further Reading35 Multidimensional Minimization35.1 Overview35.2 Caveats35.3 Initializing the Multidimensional Minimizergsl_multimin_fminimizer * gsl_multimin_fminimizer_alloc35.4 Providing a function to minimize35.5 Iterationint gsl_multimin_fdfminimizer_iterate35.6 Stopping Criteriaepsabs )35.7 Algorithmsgsl_multimin_fdfminimizer_vector_bfgs2 gsl_multimin_fdfminimizer_vector_bfgs35.8 Examples35.9 References and Further Reading36 Least-Squares Fitting36.1 Overview36.2 Linear regression36.3 Linear fitting without a constant termsumsq )36.4 Multi-parameter fittinggsl_multifit_linear_workspace * gsl_multifit_linear_alloc [Function]36.5 Examples36.6 References and Further Reading37 Nonlinear Least-Squares Fitting37.1 Overview37.2 Initializing the Solvergsl_multifit_fdfsolver * gsl_multifit_fdfsolver_alloc [Function]37.3 Providing the Function to be Minimized37.4 Iteration37.5 Search Stopping Parametersepsabs )37.6 Minimization Algorithms using Derivatives37.7 Minimization Algorithms without Derivatives37.8 Computing the covariance matrix of best fit parameters37.9 Examples37.10 References and Further Reading38 Basis Splines38.1 Overview38.2 Initializing the B-splines solver38.3 Constructing the knots vector38.4 Evaluation of B-splines38.5 Example programs for B-splines38.6 References and Further Reading39 Physical Constants39.1 Fundamental Constants39.2 Astronomy and Astrophysics39.3 Atomic and Nuclear Physics39.4 Measurement of Time39.5 Imperial Units39.6 Speed and Nautical Units39.7 Printers Units39.8 Volume, Area and Length39.9 Mass and Weight39.10 Thermal Energy and Power39.11 Pressure39.12 Viscosity39.13 Light and Illumination39.14 Radioactivity39.15 Force and Energy39.16 Prefixes39.17 Examples39.18 References and Further Reading40 IEEE floating-point arithmetic40.1 Representation of floating point numbers40.2 Setting up your IEEE environment40.3 References and Further ReadingAppendix A Debugging Numerical ProgramsA.1 Using gdbA.2 Examining floating point registersA.3 Handling floating point exceptionsA.4 GCC warning options for numerical programsA.5 References and Further ReadingAppendix B Contributors to GSLMark GalassiJames TheilerJim DaviesBrian GoughReid PriedhorskyGerard JungmanMike BoothJorma Olavi Ta¨htinenThomas WalterFabrice RossiCarlo PerassiSzymon JaroszewiczNicolas DarnisJason H. StoverIvo AlxneitTuomo KeskitaloLowell JohnsonPatrick AlkenAppendix C Autoconf MacrosAppendix D GSL CBLAS LibraryD.1 Level 1incx )incx )incx )incx )incx )incx )incx )D.3 Level 3D.4 ExamplesFree Software Needs Free DocumentationGNU General Public LicensePreambleTERMS AND CONDITIONSEND OF TERMS AND CONDITIONSGNU Free Documentation LicenseADDENDUM: How to use this License for your documentsFunction IndexGVariable IndexACDEIMORSVType IndexConcept Index$2369ABCDEFGHIJKLMNOPQRSTUVWZ