ece 103 engineering programming chapter 55 c math library herbert g. mayer, psu cs status 6/4/2014...

6
ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material developed by Professor Phillip Wong @ PSU ECE

Upload: aldous-rice

Post on 13-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

ECE 103 Engineering ProgrammingChapter 55

C Math Library

Herbert G. Mayer, PSU CSStatus 6/4/2014

Initial content copied verbatim fromECE 103 material developed by

Professor Phillip Wong @ PSU ECE

Page 2: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

Syllabus Beyond <math.h> GNU Scientific Library

Page 3: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

3

Beyond <math.h>

The C90 Standard Library contains only elementary math functions:

sin atan2 log10 ldexp

cos sinh pow frexp

tan cosh sqrt modf

asin tanh ceil fmod

acos exp floor

atan log fabs

Page 4: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

4

C99 expands the number of built-in math functions:

More macros and constants are defined.

Complex numbers, operators, functions are supported.

acosh scalbln llround fdim

asinh cbrt rint fmax

atanh hypot lrint fmin

exp2 erf llrint fma

expm1 erfc nearbyint

ilogb tgamma remainder

log1p lgamma remquo

log2 trunc copysign

logb round NAN

scalbn lround nextafter

Page 5: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

5

Even more comprehensive math abilities can be added to C by using commercial or free libraries.

From Wikipedia article: List of numerical libraries

GNU Scientific Library - popular, free numerical analysis library implemented in C.

GNU Multi-Precision Library - for doing arbitrary precision arithmetic.

IMSL Numerical Libraries - cross-platform libraries containing a comprehensive set of mathematical and statistical functions.

LabWindows/CVI - libraries for analysis of measurement data, signal generation, windowing, filter functions, signal processing, linear algebra, array and complex operations, curve fitting and statistics.

NAG - collection of numerical analysis routines which can be called from user applications running on a wide variety of hardware platforms.

Alternative: Numerical Recipes (book with source code, also online version, not free)

http://www.nr.com

Page 6: ECE 103 Engineering Programming Chapter 55 C Math Library Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material

6

GNU Scientific LibraryFree to use: License = GPL

Homepage: http://www.gnu.org/software/gsl

Complex Numbers Chebyshev Approximation Random Distributions

Special Functions Discrete Hankel Transforms Histograms

Permutations Minimization Monte Carlo Integration

BLAS Support Physical Constants Differential Equations

Eigensystems Wavelets Numerical Differentiation

Quadrature Roots of Polynomials Series Acceleration

Quasi-Random Sequences Vectors and Matrices Root-Finding

Statistics Sorting Least-Squares Fitting

N-Tuples Linear Algebra IEEE Floating-Point

Simulated Annealing Fast Fourier Transforms Basis splines

Interpolation Random Numbers