11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX B. PROGRAM LISTINGS 233<br />

/*<br />

Complex.c<br />

By Andrew Botros, 2000-2004<br />

Listing B.9: Complex.c<br />

Hyperbolic trig fns <strong>and</strong> expz added by Paul Dickens, 2005<br />

Complex arithmetic library.<br />

Refer to Complex.h for interface details.<br />

Refer to the following for algebraic expressions:<br />

Brown, J.W., Churchill, R.W., 1996.<br />

Complex Variables <strong>and</strong> Applications.<br />

6th ed. McGraw-Hill, New York,<br />

*/<br />

#include <br />

#include <br />

#include <br />

#include "Complex.h"<br />

/* zero, one, j <strong>and</strong> inf defined for convenience */<br />

complex zero = {0.0, 0.0};<br />

complex j = {0.0, 1.0};<br />

complex one = {1.0, 0.0};<br />

complex inf = {DBL_MAX, 0.0};<br />

double modz(complex z) {<br />

return sqrt(z.Re*z.Re + z.Im*z.Im);<br />

}<br />

double argz(complex z) {<br />

return atan2(z.Im, z.Re);<br />

}<br />

complex real(double x) {<br />

complex z = {x, 0.0};<br />

return z;<br />

}<br />

complex imaginary(double y) {<br />

complex z = {0.0, y};<br />

return z;<br />

}<br />

int equalz(complex z1, complex z2) {<br />

return (z1.Re == z2.Re) && (z1.Im == z2.Im);<br />

}<br />

complex addz(complex z1, complex z2) {<br />

complex z;<br />

z.Re = z1.Re + z2.Re;<br />

z.Im = z1.Im + z2.Im;<br />

return z;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!