Main /
Lagrange Interpolation example from the Numerical Recipes Book
- See the course page for links to the Book and the software.
- Read about Lagrange Interpolation in Numerical Recipes Chapter 3.1
(actually they use the related Neville's Algorithm. - In a unix shell, in a unique folder dedicated to only this example, do the following :
- Place in this folder the Neville's Algorithm software which is called
polint.c. - You also need the include files
nr.handnrutil.has well asnrutil.c. - Take the examaple driver routine
xpolint.calso from the Numerical Recipes site. - Also download the generic Makefile. You only need to edit theoutput file name ... if you wish.
- Browse all of these files.
- Now
makethe executable - Run it
- Check you agree that the output is what was expected from the code
- Edit
xpolint.cto swap the functions that are to be interpolated with your own choices,makeagain. - You should rename
xpolint.ctoxpolint.cppto cause the compiler to use cpp as the base language.
- Place in this folder the Neville's Algorithm software which is called
There you go .... you implemented a development cycle involving several sources and made some of your own modifications ... !
Note ... if you are using the software for the c-code in a c++ compile environment, then wrap the
c-code in the headers nr.h and nrutil.h in this code segment
#ifdef __cplusplus
extern "C" {
#endif
.... the c-code is here ....
#ifdef __cplusplus } //extern "C" #endif
