00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 inline long i2pow(long n) {
00014 return 0x0001 << n;
00015 };
00016
00017
00018
00019
00020 void dft(mdp_complex *fft_f, mdp_complex *f, long n, double sign,
00021 long offset=0, long coeff=1) {
00022 int i,j;
00023 mdp_complex phase=exp(2.0*Pi*I*sign/n);
00024 for(i=0; i<n; i++) {
00025 fft_f[offset+coeff*i]=0;
00026 for(j=0; j<n; j++)
00027 fft_f[offset+coeff*i]+=f[offset+coeff*j]*pow(phase,i*j);
00028 fft_f[offset+coeff*i]/=sqrt(n);
00029 }
00030 }
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 void fermi_field_fft(int t,
00056 fermi_field& psi_out,
00057 fermi_field& psi_in,
00058 int sign) {
00059
00060 if(psi_in.lattice().ndim!=4) error("fft3D requires TxXxXxX");
00061
00062 int i,x1,x2,x3,spin,color;
00063 int size=psi_in.lattice().size(1);
00064 if(psi_in.lattice().size(2)>size) size=psi_in.lattice().size(2);
00065 if(psi_in.lattice().size(3)>size) size=psi_in.lattice().size(3);
00066
00067 mdp_complex *v=new mdp_complex[size];
00068 mdp_complex *u=new mdp_complex[size];
00069
00070 mdp_site x(psi_in.lattice());
00071
00072 psi_out=psi_in;
00073
00074 for(spin=0; spin<psi_out.nspin; spin++)
00075 for(color=0; color<psi_out.nc; color++) {
00076 for(x2=0; x2<psi_out.lattice().size(2); x2++)
00077 for(x3=0; x3<psi_out.lattice().size(3); x3++) {
00078 for(i=0; i<psi_out.lattice().size(1); i++) {
00079 x.set(t,i,x2,x3);
00080 v[i]=psi_out(x,spin,color);
00081 }
00082 dft(u,v,psi_out.lattice().size(1),sign);
00083 for(i=0; i<psi_out.lattice().size(1); i++) {
00084 x.set(t,i,x2,x3);
00085 psi_out(x,spin,color)=u[i];
00086 }
00087 }
00088 for(x1=0; x1<psi_out.lattice().size(1); x1++)
00089 for(x3=0; x3<psi_out.lattice().size(3); x3++) {
00090 for(i=0; i<psi_out.lattice().size(2); i++) {
00091 x.set(t,x1,i,x3);
00092 v[i]=psi_out(x,spin,color);
00093 }
00094 dft(u,v,psi_out.lattice().size(2),sign);
00095 for(i=0; i<psi_out.lattice().size(2); i++) {
00096 x.set(t,x1,i,x3);
00097 psi_out(x,spin,color)=u[i];
00098 }
00099 }
00100
00101 for(x1=0; x1<psi_out.lattice().size(1); x1++)
00102 for(x2=0; x2<psi_out.lattice().size(2); x2++) {
00103 for(i=0; i<psi_out.lattice().size(3); i++) {
00104 x.set(t,x1,x2,i);
00105 v[i]=psi_out(x,spin,color);
00106 }
00107 dft(u,v,psi_out.lattice().size(3),sign);
00108 for(i=0; i<psi_out.lattice().size(3); i++) {
00109 x.set(t,x1,x2,i);
00110 psi_out(x,spin,color)=u[i];
00111 }
00112 }
00113 }
00114 delete[] u;
00115 delete[] v;
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177