正在加载图片...
Appendix C: Complex Arithmetic http://www.nr.com Sample page The functions listed below are used by the Recipes cisi,frenel,hypdrv, hypgeo,hypser,laguer,zroots,and fixrts for complex arithmetic.A complex or call number is defined to be a structure containing two float values,the real (r)and imaginary (.i)parts.Complex arguments are passed and returned by value.See additional discussion in 81.2 -800-872 On the diskette,this Appendix is in the file complex.c. #include <math.h> typedef struct FCOMPLEX {float r,i;}fcomplex; fcomplex Cadd(fcomplex a,fcomplex b) fcomplex ci c.r=a.r+b.r; c.i=a.i+b.i; return c; fcomplex Csub(fcomplex a,fcomplex b) fcomplex ci c.r=a.r-b.r; c.i=a.i-b.i; Copyright(C)1988-1992 by Cambridge University Press.Programs Copyright(C)1988-1992 by Numerical Recipes Software. from NUMERICAL RECIPES IN C:THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) return c; fcomplex Cmul(fcomplex a, fcomplex b) fcomplex c; c.r=a.r*b.r-a.1*b.1; 7423(North America only),or send email to directcustserv@cambridge.org(outside North America). c.i=a.i*b.r+a.r*b.i; return c; fcomplex Complex(float re,float im) fcomplex c; c.r=re; c.isim; return c; fcomplex Conjg(fcomplex z) fcomplex ci C,工=Z.r; 948Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). Appendix C: Complex Arithmetic The functions listed below are used by the Recipes cisi, frenel, hypdrv, hypgeo, hypser, laguer, zroots, and fixrts for complex arithmetic. A complex number is defined to be a structure containing two float values, the real (.r) and imaginary (.i) parts. Complex arguments are passed and returned by value. See additional discussion in §1.2. On the diskette, this Appendix is in the file complex.c. #include <math.h> typedef struct FCOMPLEX {float r,i;} fcomplex; fcomplex Cadd(fcomplex a, fcomplex b) { fcomplex c; c.r=a.r+b.r; c.i=a.i+b.i; return c; } fcomplex Csub(fcomplex a, fcomplex b) { fcomplex c; c.r=a.r-b.r; c.i=a.i-b.i; return c; } fcomplex Cmul(fcomplex a, fcomplex b) { fcomplex c; c.r=a.r*b.r-a.i*b.i; c.i=a.i*b.r+a.r*b.i; return c; } fcomplex Complex(float re, float im) { fcomplex c; c.r=re; c.i=im; return c; } fcomplex Conjg(fcomplex z) { fcomplex c; c.r=z.r; 948
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有