15 ss <<
"array(" << nrows <<
"," << ncols<<
")";
16 em(ss.str() +
": constructing");
17 array_xxf arr = Eigen::ArrayXXf::Random(nrows, ncols);
18 em(ss.str() +
": constructed");
30 const int nrows = 3000;
31 const int ncols = 10000;
34 em(
"array by value: returned");
37 for (
int ind=0; ind<100; ++ind) {
40 em(
"array by value: 100 dups");
43 em(
"array by value: left scope");
48 const int nrows = 3000;
49 const int ncols = 10000;
55 em(
"ret: out of scope");
60 template<
typename arrtype>
61 bool same(
const arrtype&
a1,
const arrtype&
a2,
double eps=1.0
e-6)
63 double n1 = a1.matrix().squaredNorm();
64 double n2 = a2.matrix().squaredNorm();
69 cerr <<
"norm2=0, norm1=" << n2 <<
endl;
74 cerr <<
"differ: " << diff <<
" n1=" << n1 <<
" n2=" << n2 <<
endl;
81 const int nrows = 300;
82 const int ncols = 1000;
85 em(
"test_partial: make array");
88 auto spec_rc =
dft_rc(arr);
89 auto spec_cc =
dft_cc(spec_rc);
90 em(
"test_partial: forward");
92 auto arr2 =
idft(spec);
93 auto arr2_cc =
idft_cc(spec_cc);
94 auto arr2_cr =
idft_cr(arr2_cc);
95 em(
"test_partial: reverse");
101 const int nrounds = 100;
103 for (
int count = 0; count < nrounds; ++count) {
104 auto spec =
dft(arr);
105 auto orig =
idft(spec);
107 em(
"test_partial: direct round trip");
108 for (
int count = 0; count < nrounds; ++count) {
109 auto spec_rc =
dft_rc(arr);
110 auto spec_cc =
dft_cc(spec_rc);
111 auto arr2_cc =
idft_cc(spec_cc);
112 auto arr2_cr =
idft_cr(arr2_cc);
114 em(
"test_partial: partial round trip");
119 const int nrows = 300;
120 const int ncols = 1000;
122 const int nrounds = 100;
125 em(
"dft: make array");
126 for (
int count = 0; count < nrounds; ++count) {
128 auto spec =
dft(arr);
129 auto orig =
idft(spec);
132 em(
"dft with floats");
133 #ifdef WCT_HACK_FOR_FFTW_NO_SP 134 for (
int count = 0; count < nrounds; ++count) {
135 auto spec = dftd(arr);
136 auto orig = idftd(spec);
138 em(
"dft up/down cast through doubles");
144 const int nrows = 300;
145 const int ncols = 1000;
149 em(
"deconv: got array");
151 em(
"deconv: got filter");
152 auto deco =
deconv(arr, filt);
158 double norm = diff.matrix().norm();
160 cerr <<
"got norm of diff " << norm <<
endl;
166 array_xxf arr1(3,2), arr2(3,2), arr3(3,2);
176 cerr <<
"arr3 before NaN zeroing\n" << arr3 <<
endl;
178 for (
int irow=0; irow<arr3.rows(); ++irow) {
179 for (
int icol=0; icol<arr3.cols(); ++icol) {
180 float val = arr3(irow,icol);
182 arr3(irow,icol) = -0.0;
185 arr3(irow,icol) = 0.0;
189 cerr <<
"arr3 after NaN zeroing\n" << arr3 <<
endl;
195 array_xxc arr1(3,2), arr2(3,2), arr3(3,2);
205 cerr <<
"arr3 before NaN zeroing\n" << arr3 <<
endl;
207 for (
int irow=0; irow<arr3.rows(); ++irow) {
208 for (
int icol=0; icol<arr3.cols(); ++icol) {
209 float val =
abs(arr3(irow,icol));
211 arr3(irow,icol) = -0.0;
214 arr3(irow,icol) = 0.0;
218 cerr <<
"arr3 after NaN zeroing\n" << arr3 <<
endl;
array_xxf dup(const array_xxf &arr)
void test_division_complex(ExecMon &em)
array_xxc dft_cc(const array_xxc &arr, int dim=1)
array_xxf idft_cr(const array_xxc &arr, int dim=0)
void test_division(ExecMon &em)
void test_copy(ExecMon &em)
Eigen::ArrayXXcf array_xxc
A complex, 2D array.
array_xxc dft_rc(const array_xxf &arr, int dim=0)
void test_return(ExecMon &em)
array_xxc idft_cc(const array_xxc &arr, int dim=1)
void test_dft(ExecMon &em)
void test_deconv(ExecMon &em)
array_xxf deconv(const array_xxf &arr, const array_xxc &filter)
auto norm(Vector const &v)
Return norm of the specified vector.
bool same(const arrtype &a1, const arrtype &a2, double eps=1.0e-6)
array_xxf my_great_array(ExecMon &em, int nrows, int ncols)
void test_partial(ExecMon &em)
array_xxf idft(const array_xxc &arr)
unsigned nrows(sqlite3 *db, std::string const &tablename)
array_xxc dft(const array_xxf &arr)
std::string summary() const
Return summary up to now.
QTextStream & endl(QTextStream &s)
Eigen::ArrayXXf array_xxf
A real, 2D array.