William H. Press

Mentioned 2

Updates the full mathematical and explanatory contents of Numerical recipes in C and incorporates completely new C++ versions of the numerical recipes.

Mentioned in questions and answers.

Can anybody recommend a good introduction book on Monte Carlo algorithms in c++? Preferably with applications to physics, and even more preferably, the kind of physics being quantum mechanics.

Thanks!

Why not using C# instead ?

I would recommend you the book of George Levy http://www.amazon.fr/Computational-Finance-Using-C/dp/0750669195. This book deals with financial mathematics and so with Monte-Carlo methods..

Numerical Recipes in C (or C++ now!).

If you don't mind a book with a finance slant to it, my initial assessment of Monte Carlo Frameworks: Building Customisable High-Performance C++ Applications is very positive.

I am new in fast fourier transform (FFT) and does not have much idea, how it calculate in programming language such as C++. Here is method of FFT2D

```
void FFT2D(Complex<double> *f, Complex<double> *F, int width, int height);
It takes an input image f of size width * height and output the transformed
coefficients into F.
```

Hints: Image pixels are stored as three separate image color (R, G, B) planes, with each of them being represented by a 1D array of complex numbers. Suppose an image is of size width W and height H, then the color component values (R, G and B) of the pixels at image location (m, n) can be found as R[m + n * W], G(m + n * W) and B[m + n * W], where R, G, B are the three arrays of complex numbers. The 1D array for the transformed coefficients is also represents in the same manner.

What I need to implement the processing for one color component only and the programming template will process the R, G, B separately based on implemented functions. The template will also pad the image with zeros so that each input image is of size 2m * 2n.

```
If I called from another class, I have to pass R, G, B separately
Suppose:
Complex<double> *R = new Complex<double>[width * height];
Let, width = 4096 and height 4096
FFT2D(R, output F, width, height) for compute “R” color component;
FFT2D(G, output F, width, height) for compute “G” color component;
FFT2D(B, output F, width, height) for compute “B” color component;
We have template of calculated FFT1D function:
void FFT1D(Complex<double> *fx, Complex<double> *Fu, int twoK, int stride)
Hint: it outputs the frequency coefficients in the array Fu.
```

** FFT1D is calling from inside a function of FFT2D**. I found several different type of code in C, C++, and Java and C #of FFT2D. Most of them have implemented using 2D array structure; they assign real and imaginary part to 2D array structure in loop of rows and columns. However, in my case is 1D array structure of color component.

Let's, do some code and this is inside FFT2D function:

```
Complex<double> *outPutMap = new Complex<double>[width * height];
for (int i = 0; i < height; i++){
# for(int j = 0; j < width; j++){
# outPutMap[i + j * width] = f[i + j * width];
# I don’t understand how to implement in here for color component and how
# it assign a value for real and imaginary part
# }
}
```

Before, calling a FFTID, it also required calculate a value of twoK as in book, M = 2K

If you have any idea or any reference please let me know.

Thank you

Regards Ichiro

I would suggest you get hold of a book such as [Numerical Recipes][1] .

http://www.amazon.com/Numerical-Recipes-Art-Scientific-Computing/dp/0521750334

FFT, Simpsons Rule, Fouriers Algorith should all be there. I had read from an author named Rajaram .. it was in C.

Realated tags