📄 gsl-design.texi
字号:
\input texinfo @c -*-texinfo-*-@c %**start of header@setfilename gsl-design.info@settitle GNU Scientific Library@finalout@c -@setchapternewpage odd@c %**end of header@dircategory Scientific software@direntry* GSL-design: (GSL-design). GNU Scientific Library -- Design@end direntry@comment @include version-design.texi@set GSL @i{GNU Scientific Library}@ifinfoThis file documents the @value{GSL}.Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2004 The GSL Project.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through TeX and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that the entireresulting derived work is distributed under the terms of a permissionnotice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translation approvedby the Foundation.@end ifinfo@titlepage@title GNU Scientific Library -- Design document@comment @subtitle Edition @value{EDITION}, for gsl Version @value{VERSION}@comment @subtitle @value{UPDATED}@author Mark Galassi Los Alamos National Laboratory@author James Theiler Astrophysics and Radiation Measurements Group, Los Alamos National Laboratory@author Brian Gough Network Theory Limited@page@vskip 0pt plus 1filllCopyright @copyright{} 1996,1997,1998,1999,2000,2001,2004 The GSL Project.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.Permission is granted to copy and distribute modified versions of thismanual under the conditions for verbatim copying, provided that the entireresulting derived work is distributed under the terms of a permissionnotice identical to this one.Permission is granted to copy and distribute translations of this manualinto another language, under the above conditions for modified versions,except that this permission notice may be stated in a translation approvedby the Foundation.@end titlepage@contents@node Top, Motivation, (dir), (dir)@top About GSL@ifinfoThis file documents the design of @value{GSL}, a collection of numericalroutines for scientific computing.More information about GSL can be found at the project homepage,@uref{http://www.gnu.org/software/gsl/}.@end ifinfoThe @value{GSL} is a library of scientific subroutines. It aims toprovide a convenient interface to routines that do standard (and not sostandard) tasks that arise in scientific research. More than that, italso provides the source code. Users are welcome to alter, adjust,modify, and improve the interfaces and/or implementations of whicheverroutines might be needed for a particular purpose.GSL is intended to provide a free equivalent to existing proprietarynumerical libraries written in C or Fortran, such as NAG, IMSL's CNL,IBM's ESSL, and SGI's SCSL.The target platform is a low-end desktop workstation. The goal is toprovide something which is generally useful, and the library is aimed atgeneral users rather than specialists.@menu* Motivation:: * Contributing:: * Design:: * Copying:: @end menu@node Motivation, Contributing, Top, Top@chapter Motivation@cindex numerical analysis@cindex free softwareThere is a need for scientists and engineers to have a numerical librarythat:@itemize @bullet@itemis free (in the sense of freedom, not in the sense of gratis; see theGNU General Public License), so that people can use that library,redistribute it, modify it @dots{}@itemis written in C using modern coding conventions, calling conventions,scoping @dots{}@itemis clearly and pedagogically documented; preferably with TeXinfo, so asto allow online info, WWW and TeX output.@itemuses top quality state-of-the-art algorithms.@itemis portable and configurable using @emph{autoconf} and @emph{automake}.@itembasically, is GNUlitically correct.@end itemizeThere are strengths and weaknesses with existing libraries:@emph{Netlib} (http://www.netlib.org/) is probably the most advanced setof numerical algorithms available on the net, maintained by AT&T.Unfortunately most of the software is written in Fortran, with strangecalling conventions in many places. It is also not very well collected,so it is a lot of work to get started with netlib.@emph{GAMS} (http://gams.nist.gov/) is an extremely well organized setof pointers to scientific software, but like netlib, the individualroutines vary in their quality and their level of documentation.@emph{Numerical Recipes} (http://www.nr.com,http://cfata2.harvard.edu/nr/) is an excellent book: it explains thealgorithms in a very clear way. Unfortunately the authors released thesource code under a license which allows you to use it, but prevents youfrom re-distributing it. Thus Numerical Recipes is not @emph{free} inthe sense of @emph{freedom}. On top of that, the implementation suffersfrom @emph{fortranitis} and otherlimitations. [http://www.lysator.liu.se/c/num-recipes-in-c.html]@emph{SLATEC} is a large public domain collection of numerical routinesin Fortran written under a Department of Energy program in the1970's. The routines are well tested and have a reasonable overalldesign (given the limitations of that era). GSL should aim to be amodern version of SLATEC.@emph{NSWC} is the Naval Surface Warfare Center numerical library. Itis a large public-domain Fortran library, containing a lot ofhigh-quality code. Documentation for the library is hard to find, onlya few photocopies of the printed manual are still in circulation.@emph{NAG} and @emph{IMSL} both sell high-quality libraries which areproprietary. The NAG library is more advanced and has wider scope thanIMSL. The IMSL library leans more towards ease-of-use and makesextensive use of variable length argument lists to emulate "defaultarguments".@emph{ESSL} and @emph{SCSL} are proprietary libraries from IBM and SGI.@emph{Forth Scientific Library} [see the URLhttp://www.taygeta.com/fsl/sciforth.html]. Mainly of interest to Forthusers.@emph{Numerical Algorithms with C} G. Engeln-Mullges, F. Uhlig. A nicenumerical library written in ANSI C with an accompanyingtextbook. Source code is available but the library is not free software.@emph{NUMAL} A C version of the NUMAL library has been written byH.T. Lau and is published as a book and disk with the title "A NumericalLibrary in C for Scientists and Engineers". Source code is available butthe library is not free software.@emph{C Mathematical Function Handbook} by Louis Baker. A library offunction approximations and methods corresponding to those in the"Handbook of Mathematical Functions" by Abramowitz and Stegun. Sourcecode is available but the library is not free software.@emph{CCMATH} by Daniel A. Atkinson. A C numerical library coveringsimilar areas to GSL. The code is quite terse. Earlier versions wereunder the GPL but unfortunately it has changed to the LGPL in recentversions.@emph{CEPHES} A useful collection of high-quality special functionswritten in C. Not GPL'ed.@emph{WNLIB} A small collection of numerical routines written in C byWill Naylor. Public domain.@emph{MESHACH} A comprehensive matrix-vector linear algebra librarywritten in C. Freely available but not GPL'ed (non-commercial license).@emph{CERNLIB} is a large high-quality Fortran library developed at CERNover many years. It was originally non-free software but has recentlybeen released under the GPL.@emph{COLT} is a free numerical library in Java developed at CERN byWolfgang Hoschek. It is under a BSD-style license.The long-term goal will be to provide a framework to which the realnumerical experts (or their graduate students) will contribute. @node Contributing, Design, Motivation, Top@chapter ContributingThis design document was originally written in 1996. As of 2004, GSLitself is essentially feature complete, the developers are not activelyworking on any major new functionality.The main emphasis is now on ensuring the stability of the existingfunctions, improving consistency, tidying up a few problem areas andfixing any bugs that are reported. Potential contributors areencouraged to gain familiarity with the library by investigating andfixing known problems listed in the @file{BUGS} file in the CVSrepository.Adding large amounts of new code is difficult because it leads todifferences in the maturity of different parts of the library. Tomaintain stability, any new functionality is encouraged as@dfn{packages}, built on top of GSL and maintained independently by theauthor, as in other free software projects (such as the Perl CPANarchive and TeX CTAN archive, etc).@menu* Packages:: @end menu@node Packages, , Contributing, Contributing@section PackagesThe design of GSL permits extensions to be used alongside the existinglibrary easily by simple linking. For example, additional random numbergenerators can be provided in a separate library:@example$ tar xvfz rngextra-0.1.tar.gz$ cd rngextra-0.1$ ./configure; make; make check; make install$ ...$ gcc -Wall main.c -lrngextra -lgsl -lgslcblas -lm@end exampleThe points below summarise the package design guidelines. These areintended to ensure that packages are consistent with GSL itself, to makelife easier for the end-user and make it possible to distribute popularwell-tested packages as part of the core GSL in future.@itemize @bullet@item Follow the GSL and GNU coding standards described in this documentThis means using the standard GNU packaging tools, such as Automake,providing documentation in Texinfo format, and a test suite. The testsuite should run using @samp{make check}, and use the test functionsprovided in GSL to produce the output with @code{PASS:}/@code{FAIL:}lines. It is not essential to use libtool since packages are likely tobe small, a static library is sufficient and simpler to build.@item Use a new unique prefix for the package (do not use @samp{gsl_} -- this is reserved for internal use).For example, a package of additional random number generators might usethe prefix @code{rngextra}.@example#include <rngextra.h>gsl_rng * r = gsl_rng_alloc (rngextra_lsfr32);@end example@item Use a meaningful version number which reflects the state of developmentGenerally, @code{0.x} are alpha versions, which provide no guarantees.Following that, @code{0.9.x} are beta versions, which should be essentiallycomplete, subject only to minor changes and bug fixes. The first majorrelease is @code{1.0}. Any version number of @code{1.0} or highershould be suitable for production use with a well-defined API.The API must not change in a major release and should bebackwards-compatible in its behavior (excluding actual bug-fixes), sothat existing code do not have to be modified. Note that the APIincludes all exported definitions, including data-structures definedwith @code{struct}. If you need to change the API in a package, itrequires a new major release (e.g. @code{2.0}).@item Use the GNU General Public License (GPL)Follow the normal procedures of obtaining a copyright disclaimer if youwould like to have the package considered for inclusion in GSL itself inthe future (@pxref{Legal issues}).@end itemizePost announcements of your package releases to@email{gsl-discuss@@sources.redhat.com} so that information about themcan be added to the GSL webpages.For security, sign your package with GPG (@code{gpg --detach-sign@var{file}}).An example package @samp{rngextra} containing two additional randomnumber generators can be found at@url{http://www.network-theory.co.uk/download/rngextra/}.@node Design, Copying, Contributing, Top@chapter Design@menu* Language for implementation:: * Interface to other languages:: * What routines are implemented:: * What routines are not implemented:: * Design of Numerical Libraries:: * Code Reuse:: * Standards and conventions:: * Background and Preparation:: * Choice of Algorithms:: * Documentation:: * Namespace:: * Header files:: * Target system:: * Function Names:: * Object-orientation:: * Comments:: * Minimal structs:: * Algorithm decomposition:: * Memory allocation and ownership:: * Memory layout:: * Linear Algebra Levels:: * Error estimates:: * Exceptions and Error handling:: * Persistence:: * Using Return Values:: * Variable Names:: * Datatype widths:: * size_t:: * Arrays vs Pointers:: * Pointers:: * Constness:: * Pseudo-templates:: * Arbitrary Constants:: * Test suites:: * Compilation:: * Thread-safety:: * Legal issues:: * Non-UNIX portability:: * Compatibility with other libraries:: * Parallelism:: * Precision:: * Miscellaneous:: @end menu@node Language for implementation, Interface to other languages, Design, Design@section Language for implementation@strong{One language only (C)}Advantages: simpler, compiler available and quite universal.@node Interface to other languages, What routines are implemented, Language for implementation, Design@section Interface to other languagesWrapper packages are supplied as "extra" packages; not as part of the"core". They are maintained separately by independent contributors.Use standard tools to make wrappers: swig, g-wrap@node What routines are implemented, What routines are not implemented, Interface to other languages, Design@section What routines are implementedAnything which is in any of the existing libraries. Obviously it makessense to prioritize and write code for the most important areas first.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -