Physics 6730 Introduction to Computing in Physics



Assignment 8

Exercise 1

We do 2D Fourier transforms in two steps: at each y do the FT in x to get the complex Fourier component at wave number index m. That component is then a function of m and y. Then at each m we do the FT in y to get the Fourier component at n, resulting in a complex function of m and n. When the data is real there are special identities. For the first FT the reflection property relates results at m and Nx-m so we keep only half of the complex values. (This is the same as with 1D FTs). In particular for m = 0 and m = Nx/2 the FT in x is real for all y. The second FT (in y) works with mostly complex values, except when m = 0 or Nx/2. When we do an FT of complex values there are no further identities beyond periodicity. But for m = 0 or Nx/2 the double FT obeys a reflection property relating n and Ny-n, and for the same m the double FT is real for n = 0 and Ny/2. The same arguments apply if we do the FT in y first.

Assignment 3

Some students have been having trouble with the Makefile for assignment 3. Here are some pointers: As for the params class, please be sure you define it at the top of the anhderivs.cc code, just as it is defined in the main program. And don't forget the extern qualifier in extern params p; in your anhderivs.cc file.

Assignment 2

In Exercise 3 you are asked to complete the code in neville.cc and bulirsch_stoer.cc in two places. In one place in each code you are asked to complete the declaration (construction) of q, which is a variable of type Mat_DP. I thought a few words of explanation might help those who did not take PHYCS 3730/6720 or who just wanted a review, and a guided tour of the Numerical Recipes header files might help everyone. I will also review these features of C++ in class on Monday, Feburary 2. Please, also see the handout on Numerical Recipes datatypes.

You should find the definition of Mat_DP in ~p6730/nr/recipes_cpp/utils/nrtypes_lib.h. The typedef statement in that header file makes it equivalent to the type NRMat<DP>. Near the top of the same file the type DP is made equivalent to double. The class NRMat<T> is in turn defined in ~p6730/nr/recipes_cpp/utils/nrutil_nr.h. The template feature there causes the dummy type T in that definition to be replaced by DP or double. For a review of this feature, see last semester's notes on templates used in conjunction with the standard library complex class. For another example of the use of templates, see the templates handout.

Objects in the class NRMat are rectangular matrices. Notice that there are five constructors. So the challenge here is to find the one that is appropriate and then use it correctly. The correct choice and usage is determined by what we are trying to do.

If you have understood the code in neville.cc and bulirsch_stoer.cc you know that we want to construct an interpolation matrix that will hold the rows and columns of the Neville or Bulirsch-Stoer table. As you may recall the table is really triangular, but the class NRMat is meant for rectangular arrays. So we simply construct a rectangular (actually square) matrix here and use only the rows and columns that we need.

So to answer the question, you need to decide what the matrix dimensions should be and then pick the constructor that creates a matrix with those dimensions. If you need to review the use of constructors, see the notes from last term on our custom complex and vector classes .


Physics 6730 Home Page
Physics Department Home Page

This page is maintained by:

Carleton DeTar Mail Form
Last modified 7 February 2004