root / synthbench / euroben-ports / base / C-MPI / mod2f / .svn / text-base / twiddle.c.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (1.2 kB)
1 |
#include <mpi.h> |
---|---|
2 |
#include <math.h> |
3 |
#include "mpiargs.h" |
4 |
#include <stdio.h> |
5 |
|
6 |
void twiddle( int m, int n, double **ar, double **ai ) |
7 |
// --------------------------------------------------------------------- |
8 |
// --- 'twiddle' does a complex multiplication with the appropriate |
9 |
// twiddle factors for the elements of 'ar' & 'ai' which represent |
10 |
// the Real and Imaginary parts of a 1-D 'm*(n*nodes)' length FFT, |
11 |
// factored as a sequence of 'n*nodes' FFTs of length 'm'. 'nodes' |
12 |
// is the number of processors over which the 'm'-length FFTs are |
13 |
// distributed. |
14 |
// --------------------------------------------------------------------- |
15 |
{ |
16 |
int i, j, nbase; |
17 |
double arg, fac, fr, fi, temp; |
18 |
// --------------------------------------------------------------------- |
19 |
fac = 8.0*atan( 1.0 )/(m*n*nodes); |
20 |
nbase = me*m; |
21 |
for( i = 0; i < m; i++ ) { |
22 |
for( j = 0; j < n; j++ ) { |
23 |
arg = ( j*( nbase + i ) )*fac; |
24 |
fr = cos( arg ); |
25 |
fi = sin( arg ); |
26 |
//printf( "me =%2d; i =%2d; j =%2d; fr =%7.3f; fi =%7.3f\n", me, i, j, fr, fi ); |
27 |
temp = ar[i][j]*fr - ai[i][j]*fi; |
28 |
ai[i][j] = ar[i][j]*fi + ai[i][j]*fr; |
29 |
ar[i][j] = temp; |
30 |
} |
31 |
} |
32 |
} |