Mercurial > octave-nkf
comparison liboctave/CMatrix.cc @ 4773:ccfbd6047a54
[project @ 2004-02-16 19:02:32 by jwe]
author | jwe |
---|---|
date | Mon, 16 Feb 2004 19:02:33 +0000 |
parents | 334a27c8f453 |
children | 4689ee5e88ec |
comparison
equal
deleted
inserted
replaced
4772:9eed17b2c8d1 | 4773:ccfbd6047a54 |
---|---|
54 #include "mx-dm-cm.h" | 54 #include "mx-dm-cm.h" |
55 #include "mx-cm-s.h" | 55 #include "mx-cm-s.h" |
56 #include "mx-inlines.cc" | 56 #include "mx-inlines.cc" |
57 #include "oct-cmplx.h" | 57 #include "oct-cmplx.h" |
58 | 58 |
59 #ifdef HAVE_FFTW | 59 #if defined (HAVE_FFTW3) |
60 #include "oct-fftw.h" | 60 #include "oct-fftw.h" |
61 #endif | 61 #endif |
62 | 62 |
63 // Fortran functions we call. | 63 // Fortran functions we call. |
64 | 64 |
1100 } | 1100 } |
1101 | 1101 |
1102 return retval; | 1102 return retval; |
1103 } | 1103 } |
1104 | 1104 |
1105 #ifdef HAVE_FFTW | 1105 #if defined (HAVE_FFTW3) |
1106 | 1106 |
1107 ComplexMatrix | 1107 ComplexMatrix |
1108 ComplexMatrix::fourier (void) const | 1108 ComplexMatrix::fourier (void) const |
1109 { | 1109 { |
1110 size_t nr = rows (); | 1110 size_t nr = rows (); |
1126 } | 1126 } |
1127 | 1127 |
1128 const Complex *in (data ()); | 1128 const Complex *in (data ()); |
1129 Complex *out (retval.fortran_vec ()); | 1129 Complex *out (retval.fortran_vec ()); |
1130 | 1130 |
1131 for (size_t i = 0; i < nsamples; i++) | 1131 octave_fftw::fft (in, out, npts, nsamples); |
1132 { | |
1133 OCTAVE_QUIT; | |
1134 | |
1135 octave_fftw::fft (&in[npts * i], &out[npts * i], npts); | |
1136 } | |
1137 | 1132 |
1138 return retval; | 1133 return retval; |
1139 } | 1134 } |
1140 | 1135 |
1141 ComplexMatrix | 1136 ComplexMatrix |
1160 } | 1155 } |
1161 | 1156 |
1162 const Complex *in (data ()); | 1157 const Complex *in (data ()); |
1163 Complex *out (retval.fortran_vec ()); | 1158 Complex *out (retval.fortran_vec ()); |
1164 | 1159 |
1165 for (size_t i = 0; i < nsamples; i++) | 1160 octave_fftw::ifft (in, out, npts, nsamples); |
1166 { | |
1167 OCTAVE_QUIT; | |
1168 | |
1169 octave_fftw::ifft (&in[npts * i], &out[npts * i], npts); | |
1170 } | |
1171 | 1161 |
1172 return retval; | 1162 return retval; |
1173 } | 1163 } |
1174 | 1164 |
1175 ComplexMatrix | 1165 ComplexMatrix |
1176 ComplexMatrix::fourier2d (void) const | 1166 ComplexMatrix::fourier2d (void) const |
1177 { | 1167 { |
1178 int nr = rows (); | 1168 dim_vector dv(rows (), cols ()); |
1179 int nc = cols (); | 1169 |
1180 | 1170 ComplexMatrix retval (rows (), cols ()); |
1181 ComplexMatrix retval (*this); | 1171 const Complex *in (data ()); |
1182 // Note the order of passing the rows and columns to account for | 1172 Complex *out (retval.fortran_vec ()); |
1183 // column-major storage. | 1173 |
1184 octave_fftw::fft2d (retval.fortran_vec (), nc, nr); | 1174 octave_fftw::fftNd (in, out, 2, dv); |
1185 | 1175 |
1186 return retval; | 1176 return retval; |
1187 } | 1177 } |
1188 | 1178 |
1189 ComplexMatrix | 1179 ComplexMatrix |
1190 ComplexMatrix::ifourier2d (void) const | 1180 ComplexMatrix::ifourier2d (void) const |
1191 { | 1181 { |
1192 int nr = rows (); | 1182 dim_vector dv(rows (), cols ()); |
1193 int nc = cols (); | 1183 |
1194 | 1184 ComplexMatrix retval (rows (), cols ()); |
1195 ComplexMatrix retval (*this); | 1185 const Complex *in (data ()); |
1196 // Note the order of passing the rows and columns to account for | 1186 Complex *out (retval.fortran_vec ()); |
1197 // column-major storage. | 1187 |
1198 octave_fftw::ifft2d (retval.fortran_vec (), nc, nr); | 1188 octave_fftw::ifftNd (in, out, 2, dv); |
1199 | 1189 |
1200 return retval; | 1190 return retval; |
1201 } | 1191 } |
1202 | 1192 |
1203 #else | 1193 #else |
1330 nn = 4*npts+15; | 1320 nn = 4*npts+15; |
1331 | 1321 |
1332 wsave.resize (nn); | 1322 wsave.resize (nn); |
1333 pwsave = wsave.fortran_vec (); | 1323 pwsave = wsave.fortran_vec (); |
1334 | 1324 |
1335 Array<Complex> row (npts); | 1325 Array<Complex> tmp (npts); |
1336 Complex *prow = row.fortran_vec (); | 1326 Complex *prow = tmp.fortran_vec (); |
1337 | 1327 |
1338 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1328 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1339 | 1329 |
1340 for (int j = 0; j < nsamples; j++) | 1330 for (int j = 0; j < nsamples; j++) |
1341 { | 1331 { |
1399 nn = 4*npts+15; | 1389 nn = 4*npts+15; |
1400 | 1390 |
1401 wsave.resize (nn); | 1391 wsave.resize (nn); |
1402 pwsave = wsave.fortran_vec (); | 1392 pwsave = wsave.fortran_vec (); |
1403 | 1393 |
1404 Array<Complex> row (npts); | 1394 Array<Complex> tmp (npts); |
1405 Complex *prow = row.fortran_vec (); | 1395 Complex *prow = tmp.fortran_vec (); |
1406 | 1396 |
1407 F77_FUNC (cffti, CFFTI) (npts, pwsave); | 1397 F77_FUNC (cffti, CFFTI) (npts, pwsave); |
1408 | 1398 |
1409 for (int j = 0; j < nsamples; j++) | 1399 for (int j = 0; j < nsamples; j++) |
1410 { | 1400 { |