Changeset 1394 in Sophya for trunk/SophyaLib/NTools/fftpserver.cc
- Timestamp:
- Feb 12, 2001, 6:09:27 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/fftpserver.cc
r1390 r1394 28 28 FFTPackServer::FFTPackServer() 29 29 : FFTServerInterface("FFTPackServer using extended FFTPack (C-version) package") 30 , ckR4( true, true) , ckR8(true, true)30 , ckR4("FFTPackServer: ", true, true) , ckR8("FFTPackServer: ", true, true) 31 31 { 32 32 //the working array and its size for the different … … 72 72 73 73 74 75 74 void FFTPackServer::FFTForward(TArray< complex<r_4> > const & in, TArray< complex<r_4> > & out) 76 75 { 77 76 ckR4.CheckResize(in, out); 78 77 out = in; 78 cout << out << endl; 79 79 fftf(out.Size(), out.Data()); 80 80 if (getNormalize()) out *= (1./(r_4)(in.Size())); … … 93 93 TArray< r_4 > inout(in, false); 94 94 fftf(inout.Size(), inout.Data()); 95 ckR4.ReShapetoCompl(inout, out);95 ReShapetoCompl(inout, out); 96 96 if (getNormalize()) out *= complex<r_4>((1./(r_4)(in.Size())), 0.); 97 97 } … … 100 100 { 101 101 ckR4.CheckResize(in, out); 102 ckR4.ReShapetoReal(in, out);102 ReShapetoReal(in, out); 103 103 fftb(out.Size(), out.Data()); 104 104 } … … 110 110 TArray< r_8 > inout(in, false); 111 111 fftf(inout.Size(), inout.Data()); 112 ckR8.ReShapetoCompl(inout, out);112 ReShapetoCompl(inout, out); 113 113 if (getNormalize()) out *= complex<r_8>((1./(r_8)(in.Size())), 0.); 114 114 } … … 117 117 { 118 118 ckR8.CheckResize(in, out); 119 ckR8.ReShapetoReal(in, out); 120 fftb(out.Size(), out.Data()); 121 } 122 123 119 ReShapetoReal(in, out); 120 fftb(out.Size(), out.Data()); 121 } 122 123 124 template <class T> 125 void FFTPack_ReShapetoReal(TArray< complex<T> > const & ina, TArray< T > & outa) 126 { 127 TVector< complex<T> > in(ina); 128 TVector< T > out(outa); 129 sa_size_t n = in.NElts(); 130 T thr = FFTArrayChecker<T>::ZeroThreshold(); 131 sa_size_t ncs = ( (in(n-1).imag() < -thr) || (in(n-1).imag() > thr) ) ? 132 ncs = 2*n-1 : ncs = 2*n-2; 133 134 if (out.NElts() != ncs) 135 throw SzMismatchError("FFTPack_ReShapetoReal() - Wrong output array size !"); 136 // cerr << "DEBUG-FFTPack_ReShapetoReal() ncs = " << ncs 137 // << " out.NElts()= " << out.NElts() << endl; 138 139 sa_size_t k; 140 141 out(0) = in(0).real(); 142 for(k=1;k<n-1;k++) { 143 out(2*k-1) = in(k).real(); 144 out(2*k) = in(k).imag(); 145 } 146 if (ncs == n*2-2) out(ncs-1) = in(n-1).real(); 147 else { out(ncs-2) = in(n-1).real(); out(ncs-1) = in(n-1).imag(); } 148 149 return; 150 } 151 152 template <class T> 153 void FFTPack_ReShapetoCompl(TArray< T > const & ina, TArray< complex<T> > & outa) 154 { 155 TVector< T > in(ina); 156 TVector< complex<T> > out(outa); 157 sa_size_t n = in.NElts(); 158 sa_size_t ncs = n/2+1; 159 sa_size_t nc = (n%2 != 0) ? n/2+1 : n/2; 160 if (out.NElts() != ncs) 161 throw SzMismatchError("FFTPack_ReShapetoCompl() - Wrong output array size !"); 162 163 out(0) = complex<T> (in(0),0.); 164 for(int k=1;k<nc;k++) 165 out(k) = complex<r_4> (in(2*k-1), in(2*k)); 166 if (n%2 == 0) out(ncs-1) = complex<T>(in(n-1), 0.); 167 168 return; 169 } 170 171 void FFTPackServer::ReShapetoReal(TArray< complex<r_8> > const & in, TArray< r_8 > & out) 172 { 173 FFTPack_ReShapetoReal<r_8>(in, out); 174 } 175 176 void FFTPackServer::ReShapetoCompl(TArray< r_8 > const & in, TArray< complex<r_8> > & out) 177 { 178 FFTPack_ReShapetoCompl<r_8>(in, out); 179 } 180 181 void FFTPackServer::ReShapetoReal(TArray< complex<r_4> > const & in, TArray< r_4 > & out) 182 { 183 FFTPack_ReShapetoReal<r_4>(in, out); 184 } 185 186 void FFTPackServer::ReShapetoCompl(TArray< r_4 > const & in, TArray< complex<r_4> > & out) 187 { 188 FFTPack_ReShapetoCompl<r_4>(in, out); 189 } 124 190 125 191 void FFTPackServer::checkint_rfft(int_4 l)
Note:
See TracChangeset
for help on using the changeset viewer.