Two of the most common tasks in scientific computing are interpolation of discrete data and approximation by known functions of the numerical solution, the source terms, and the boundary or initial conditions. Therefore, we need to perform these tasks both accurately and efficiently. The data are not always nicely distributed on a uniform lattice or grid, and thus we must learn how to manage these situations as well. We often use polynomials to represent discrete data as they are easy to "manipulate,'' i.e., differentiate and integrate. However, sines and cosines as well as special functions, called wavelets, are very effective means to perform interpolation and approximation, and they have very interesting properties.
In this section, we will study different such representations and their corresponding C++ implementations. We consider cases where the data are just sufficient to determine exactly the representation (deterministic case) as well as cases where the data are more than the information needed (overdetermined case).
Finally, we will present a more detailed discussion of MPI_Send and MPI_Recv, the two fundamental building blocks of MPI.
- Section 3.1.2: double NewtonDiffTable(int npts, double *xpts, double *funcvals, double * newton_coeffs) function definition
- Section 3.1.2: double NewtonDiffFunction(int start_index, int ending_index, double * xpts, double * funcvals) function definition
- Section 3.1.2: double NewtonInterpolant(double x, int npts, double * xpts, double * newton_coeffs) function definition
- Section 3.1.3: double LagrangePoly(double x, int pt, int npts, double * xpts) function definition
- Section 3.1.3: double LagrangeInterpolant(double x, int npts, double *xpts, double * funcvals) function definition
- Section 3.1.5: double ChebyshevPoly(int degree, double x) function definition
- Section 3.1.7: void LS_ComputeCoeffs(int npts, double *xpts, double *funcvals, int ndeg, double *alpha, double *beta, double *lcoeffs) function definition
- Section 3.1.7: double LS_OrthoPoly(int j, double x, double *alpha, double *beta) function definition
- Section 3.1.8: SCVector class declaration
- Section 3.1.8: SCVector class definition
- Section 3.1.8: LSPoly class declaration
- Section 3.1.8: LSPoly class definition
- Section 3.1.10: double Square_2dInterpolant(SCPoint x, int npts, double *funcvals) function definition
Go to the file SCchapter3.h for function/class declarations
Go to the file SCchapter3.cpp for function/class definitionsIn the case that an entire program (meaning that a main() function is provided) is presented in the text, we classify this as a driver program. Unlike the functions/classes above, driver programs are complete C++ programs which can be compiled and executed. As you read through the book, you will see that driver programs are often times created by using functions/classes which are in the SCchapter files. We denote driver programs which are explicitly given in the text of the book in red. In some chapters, we present very few driver programs explicitly in the text, however we provide some example driver programs which demonstrate how to use the functions/classes with in SCchapter files. Such driver programs are denoted in black.
Section 3.1.2: Static array allocation, initialization, and printing | chapter3c0.cpp |
Section 3.1.2: Dynamic array allocation, initialization, and printing | chapter3c1.cpp |
Section 3.1.2: Dynamic array allocation with initialization accomplished by a library function (CreateGrid_EvenlySpaced) | chapter3c2.cpp |
Section 3.1.2: Program accomplishing Newton interpolation | chapter3c3.cpp |
Section 3.1.3: Program accomplishing Lagrange interpolation | chapter3c4.cpp |
Section 3.1.7: Program accomplishing Least Squares approximation (using functions) | chapter3c5.cpp |
Section 3.1.8: Program accomplishing Least Squares approximation (using classes) | chapter3c6.cpp |
Section 3.4: MPI - Program using MPI_Send and MPI_Recv | chapter3c7P.cpp |