5 #include <unsupported/Eigen/FFT> 14 using namespace Eigen;
34 Eigen::ArrayXf
vec2arr(
const std::vector<float>& v)
36 Eigen::ArrayXf ret(v.size());
37 for (
size_t ind=0; ind<v.size(); ++ind) {
47 cerr <<
"filter.arr = " << arr <<
endl;
49 cerr <<
"filter.ret = " << ret <<
endl;
55 auto tmp = arr.row(ind);
56 em(
"after assignment to auto type");
57 Eigen::ArrayXf ret = arr.row(ind);
58 em(
"after assignment to explicit type");
62 template <
typename Derived>
64 template <
typename Derived>
75 template <
typename Derived>
77 int i,
int j,
int p,
int q)
80 auto b = dense->block(i,j,p,q);
81 cerr << em(
"made block") <<
endl;
82 cerr <<
" " <<
b.rows() <<
" X " <<
b.cols() <<
endl;
88 const int nrows = arr.rows();
89 const int ncols = arr.cols();
93 Eigen::MatrixXf in = arr.matrix();
94 em(
"fft: convert to matrix");
95 Eigen::MatrixXcf matc(nrows, ncols);
96 em(
"fft: made temp complex matrix");
98 Eigen::FFT< float > fft;
99 em(
"fft: made fft object");
101 for (
int irow = 0; irow <
nrows; ++irow) {
102 Eigen::VectorXcf fspec(ncols);
103 fft.fwd(fspec, in.row(irow));
104 matc.row(irow) = fspec;
106 em(
"fft: first dimension");
108 for (
int icol = 0; icol < ncols; ++icol) {
109 Eigen::VectorXcf pspec(nrows);
110 fft.fwd(pspec, matc.col(icol));
111 matc.col(icol) = pspec;
113 em(
"fft: second dimension");
116 em(
"fft: make shared for return");
118 em(
"fft: set shared for return");
120 em(
"fft: nullify return");
131 cerr <<
"shared array is " << ba->rows() <<
" X " << ba->cols() <<
endl;
133 cerr <<
"block: " <<
b.rows() <<
" X " <<
b.cols() <<
endl;
144 em(
"made big array");
147 cerr << part.rows() <<
" X " << part.cols() <<
"\n";
148 auto part2 = part * 10;
150 auto part3 = part2 * 0;
153 em(
"select row again");
155 for (
int ind=0; ind<part4.rows(); ++ind) {
156 if (part4(ind) == 0.00001) {
160 cerr <<
"got zero " << nzero <<
" times out of " << part3.rows() <<
endl;
166 (*shared_bigass) = bigass;
170 em(
"passed as const shared pointer");
172 shared_bigass =
nullptr;
173 em(
"nullified shared");
181 std::vector<float> v{1.0,1.0,2.0,3.0,4.0,4.0,4.0,3.0};
186 ArrayXf ar2(v.size());
191 ar2 << 1.0,1.0,2.0,3.0,4.0,4.0,4.0,3.0;
194 ArrayXf ar3 = Map<ArrayXf>(v.data(), v.size());
196 ArrayXXf table(ar1.size(), 3);
202 cerr <<
"Tmp col:\n" << tmp <<
".\n";
204 cerr <<
"Table:\n" << table <<
".\n";
206 ArrayXf one_row = table.row(0);
207 cerr <<
"One row:\n" << one_row <<
".\n";
209 ArrayXf one_col = table.col(0);
210 cerr <<
"One col:\n" << one_col <<
".\n";
215 VectorXf v1 = ar1.matrix();
217 for (
size_t ind=0; ind < v.size(); ++ind) {
218 Assert(v[ind] == ar1(ind));
219 Assert(v[ind] == ar2(ind));
220 Assert(v[ind] == ar3(ind));
221 Assert(v[ind] == v1(ind));
224 cerr << ar1.size() <<
" " << ar1.sum() <<
" " << ar1.prod() <<
" " << v1.norm() <<
" " << v1.squaredNorm() <<
endl;
226 float sigma = sqrt(v1.squaredNorm()/n - ar1.mean()*ar1.mean());
227 cerr << ar1.mean() <<
" +/- " << sigma <<
endl;
230 float minV = ar1.minCoeff(&minI);
231 float maxV = ar1.maxCoeff(&maxI);
236 cerr << minV <<
"@" << minI
238 << maxV <<
"@" << maxI
241 em(
"testing bigass");
void do_fft(WireCell::ExecMon &em, const array_xxf &arr)
std::shared_ptr< const Eigen::DenseBase< Derived > > const_shared_dense
Eigen::ArrayXf select_row(const Eigen::ArrayXXf &arr, int ind, WireCell::ExecMon &em)
Eigen::ArrayXXcf array_xxc
std::shared_ptr< Eigen::DenseBase< Derived > > shared_dense
void take_pointer(WireCell::ExecMon &em, const_shared_array_xxf ba)
Eigen::ArrayXXf array_xxf
Eigen::Block< const Derived > return_block(WireCell::ExecMon &em, const_shared_dense< Derived > dense, int i, int j, int p, int q)
void test_bigass(WireCell::ExecMon &em)
Eigen::ArrayXf vec2arr(const std::vector< float > &v)
shared_dense< array_xxc > shared_array_xxc
const_shared_dense< array_xxf > const_shared_array_xxf
shared_dense< array_xxf > shared_array_xxf
Eigen::ArrayXf filter_array(const Eigen::ArrayXf &arr)
unsigned nrows(sqlite3 *db, std::string const &tablename)
std::string summary() const
Return summary up to now.
QTextStream & endl(QTextStream &s)