c1-0 (779454), страница 2
Текст из файла (страница 2)
If you have written software of any appreciable complexitySample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).IBM PC compatible 486/334Chapter 1.PreliminariesPrevious Routines Omitted from This EditionName(s)Replacement(s)Commentmglin or mgfasbetter methodcosftcosft1 or cosft2choice of boundary conditionscel, el2rf, rd, rj, rcbetter algorithmsdes, desksran4 now uses psdeswas too slowmdian1, mdian2select, selipmore generalqcksrtsortname change (sort is now hpsort)rkqcrkqsbetter methodsmooftuse convlv with coefficients from savgolsparselinbcgmore generalthat is dependent on First Edition routines, we do not recommend blindly replacingthem by the corresponding routines in this book.
We do recommend that any newprogramming efforts use the new routines.About ReferencesYou will find references, and suggestions for further reading, listed at theend of most sections of this book. References are cited in the text by bracketednumbers like this [3].Because computer algorithms often circulate informally for quite some timebefore appearing in a published form, the task of uncovering “primary literature”is sometimes quite difficult. We have not attempted this, and we do not pretendto any degree of bibliographical completeness in this book. For topics where asubstantial secondary literature exists (discussion in textbooks, reviews, etc.) wehave consciously limited our references to a few of the more useful secondarysources, especially those with good references to the primary literature.
Where theexisting secondary literature is insufficient, we give references to a few primarysources that are intended to serve as starting points for further reading, not ascomplete bibliographies for the field.The order in which references are listed is not necessarily significant. It reflects acompromise between listing cited references in the order cited, and listing suggestionsfor further reading in a roughly prioritized order, with the most useful ones first.The remaining three sections of this chapter review some basic concepts ofprogramming (control structures, etc.), discuss a set of conventions specific to Cthat we have adopted in this book, and introduce some fundamental concepts innumerical analysis (roundoff error, etc.).
Thereafter, we plunge into the substantivematerial of the book.CITED REFERENCES AND FURTHER READING:Harbison, S.P., and Steele, G.L., Jr. 1991, C: A Reference Manual, 3rd ed. (Englewood Cliffs,NJ: Prentice-Hall). [1]Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited.
To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).adi1.1 Program Organization and Control Structures5Kernighan, B., and Ritchie, D. 1978, The C Programming Language (Englewood Cliffs, NJ:Prentice-Hall). [2] [Reference for K&R “traditional” C. Later editions of this book conformto the ANSI C standard.]Meeus, J.
1982, Astronomical Formulae for Calculators, 2nd ed., revised and enlarged (Richmond, VA: Willmann-Bell). [3]We sometimes like to point out the close analogies between computer programs,on the one hand, and written poetry or written musical scores, on the other. Allthree present themselves as visual media, symbols on a two-dimensional page orcomputer screen.
Yet, in all three cases, the visual, two-dimensional, frozen-in-timerepresentation communicates (or is supposed to communicate) something ratherdifferent, namely a process that unfolds in time. A poem is meant to be read; music,played; a program, executed as a sequential series of computer instructions.In all three cases, the target of the communication, in its visual form, is a humanbeing. The goal is to transfer to him/her, as efficiently as can be accomplished,the greatest degree of understanding, in advance, of how the process will unfold intime. In poetry, this human target is the reader.
In music, it is the performer. Inprogramming, it is the program user.Now, you may object that the target of communication of a program is nota human but a computer, that the program user is only an irrelevant intermediary,a lackey who feeds the machine. This is perhaps the case in the situation wherethe business executive pops a diskette into a desktop computer and feeds thatcomputer a black-box program in binary executable form.
The computer, in thiscase, doesn’t much care whether that program was written with “good programmingpractice” or not.We envision, however, that you, the readers of this book, are in quite a differentsituation. You need, or want, to know not just what a program does, but also howit does it, so that you can tinker with it and modify it to your particular application.You need others to be able to see what you have done, so that they can criticize oradmire. In such cases, where the desired goal is maintainable or reusable code, thetargets of a program’s communication are surely human, not machine.One key to achieving good programming practice is to recognize that programming, music, and poetry — all three being symbolic constructs of the humanbrain — are naturally structured into hierarchies that have many different nestedlevels.
Sounds (phonemes) form small meaningful units (morphemes) which in turnform words; words group into phrases, which group into sentences; sentences makeparagraphs, and these are organized into higher levels of meaning. Notes formmusical phrases, which form themes, counterpoints, harmonies, etc.; which formmovements, which form concertos, symphonies, and so on.The structure in programs is equally hierarchical. Appropriately, good programming practice brings different techniques to bear on the different levels [1-3].At a low level is the ascii character set. Then, constants, identifiers, operands,Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).1.1 Program Organization and ControlStructures.