7 #include <unsupported/Eigen/FFT> 18 int beg = ceil((subdomain.first - domain.first) / bin);
19 int end = nsamples- ceil((domain.second - subdomain.second) / bin);
23 std::pair<double,double>
26 const int n = wf.size();
28 return std::make_pair<double,double>(0,0);
31 return std::make_pair<double,double>(wf[0],0);
36 std::vector<double> wfd(wf.begin(), wf.end());
40 const double mean = wsum/
n;
41 const double rms = sqrt( (w2sum - wsum*wsum/n) / n );
43 return std::make_pair(mean,rms);
89 std::nth_element(wave.begin(), wave.begin()+wave.size()*percentage, wave.end());
90 return wave.at(wave.size()*percentage);
94 const auto mm = std::minmax_element(wave.begin(), wave.end());
95 const auto vmin = *
mm.first;
96 const auto vmax = *
mm.second;
97 const int nbins = wave.size();
98 const auto binsize = (vmax-vmin)/nbins;
100 for (
auto val : wave) {
101 int bin =
int(round((
val - vmin)/binsize));
107 const int imed = wave.size() * percentage;
109 for (
int ind=0; ind<
nbins; ++ind) {
112 float ret = vmin + ind*binsize;
117 return vmin + (vmax-vmin)*percentage;
123 const int size = wave.size();
126 for (
int ind=0; ind <
size; ++ind) {
137 return std::make_pair(imin, imax);
143 auto v = Eigen::Map<Eigen::VectorXf>(wave.data(), wave.size());
144 Eigen::FFT<Waveform::real_t> trans;
145 Eigen::VectorXcf ret = trans.fwd(v);
146 return compseq_t(ret.data(), ret.data()+ret.size());
151 Eigen::FFT<Waveform::real_t> trans;
152 auto v = Eigen::Map<Eigen::VectorXcf>(spec.data(), spec.size());
155 return realseq_t(ret.data(), ret.data()+ret.size());
163 size_t n1_orig = in1.size(), n2_orig = in2.size();
164 size_t n_out = n1_orig + n2_orig - 1;
166 in1.resize(n_out, 0);
167 in2.resize(n_out, 0);
169 auto v1 = Eigen::Map<Eigen::VectorXf>(in1.data(), in1.size());
170 auto v2 = Eigen::Map<Eigen::VectorXf>(in2.data(), in2.size());
172 Eigen::FFT<Waveform::real_t> trans;
174 Eigen::VectorXcf s1 = trans.fwd(v1);
175 Eigen::VectorXcf s2 = trans.fwd(v2);
176 Eigen::VectorXcf s12 = (s1.array() * s2.array()).matrix();
177 Eigen::VectorXf vret;
178 trans.inv(vret, s12);
179 realseq_t ret(vret.data(), vret.data()+vret.size());
192 size_t sizes[3] = {wave.size(), newres.size(), oldres.size()};
193 size_t n_out = sizes[0]+sizes[1]+sizes[2] - *std::min_element(sizes, sizes+3) - 1;
195 wave.resize(n_out, 0);
196 newres.resize(n_out, 0);
197 oldres.resize(n_out, 0);
199 auto v1 = Eigen::Map<Eigen::VectorXf>(wave.data(), wave.size());
200 auto v2 = Eigen::Map<Eigen::VectorXf>(newres.data(), newres.size());
201 auto v3 = Eigen::Map<Eigen::VectorXf>(oldres.data(), oldres.size());
203 Eigen::FFT<Waveform::real_t> trans;
205 Eigen::VectorXcf s1 = trans.fwd(v1);
206 Eigen::VectorXcf s2 = trans.fwd(v2);
207 Eigen::VectorXcf s3 = trans.fwd(v3);
209 Eigen::VectorXcf s123 = (s1.array() * s2.array() / s3.array()).matrix();
211 Eigen::VectorXf vret;
212 trans.inv(vret, s123);
213 realseq_t ret(vret.data(), vret.data()+vret.size());
215 ret.resize(sizes[0]);
226 sort(
tmp.begin(),
tmp.end());
228 out.push_back(last_br);
230 for (
size_t ind=1; ind<
tmp.size(); ++ind) {
232 if (out.back().second >= this_br.first) {
233 out.back().second = this_br.second;
236 out.push_back(this_br);
247 out.reserve(br1.size() + br2.size());
248 out.insert(out.end(), br1.begin(), br1.end());
249 out.insert(out.end(), br2.begin(), br2.end());
262 for (
auto const &it : two) {
264 out[ch] =
merge(out[ch], it.second);
273 for (
auto const& it: two){
276 if (name_map.find(name)!=name_map.end()){
277 mapped_name = name_map[
name];
281 if (one.find(mapped_name) != one.end()){
282 one[mapped_name] =
merge(one[mapped_name],it.second);
284 one[mapped_name] = it.second;
291 const size_t nbins = 1<<16;
292 std::vector<unsigned int>
hist(nbins, 0);
293 for (
unsigned short val : vals) {
296 auto it = std::max_element(hist.begin(), hist.end());
297 return it - hist.begin();
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
internal::named_arg< T, char > arg(string_view name, const T &arg)
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
QTextStream & bin(QTextStream &s)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)