#include "MatchedFilter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <complex>
#include <cstring>
#include <typeinfo>
Go to the source code of this file.
§ test_SampledData()
void test_SampledData |
( |
| ) |
|
Definition at line 38 of file MatchedFilterTest.cpp.
References os_, unit_assert, and x.
Referenced by main().
40 if (
os_) *
os_ <<
"test_SampledData()\n";
41 using namespace MatchedFilter;
44 sd.domain = make_pair(0.0, 2.0);
45 sd.samples.push_back(10);
46 sd.samples.push_back(11);
47 sd.samples.push_back(12);
48 sd.samples.push_back(13);
49 sd.samples.push_back(14);
51 if (
os_) *
os_ << sd << endl;
53 if (
os_) *
os_ <<
"domainWidth: " << sd.domainWidth() << endl;
56 if (
os_) *
os_ <<
"dx: " << sd.dx() << endl;
59 for (
unsigned int i=0; i<sd.samples.size(); i++)
61 if (
os_) *
os_ <<
"x(" << i <<
"): " << sd.x(i) << endl;
65 unsigned int count = 0;
66 for (
double x=-.2;
x<2.3;
x+=.1, count++)
KernelTraitsBase< Kernel >::space_type::abscissa_type x
§ OneMinusAbsComplex()
complex<double> OneMinusAbsComplex |
( |
double |
d | ) |
|
§ test_createFilter()
template<typename Kernel >
void test_createFilter |
( |
const Kernel & |
f | ) |
|
Definition at line 93 of file MatchedFilterTest.cpp.
References pwiz::math::MatchedFilter::details::createFilter(), ralab::base::filter::filter(), os_, and unit_assert.
Referenced by test_kernel().
95 using namespace MatchedFilter;
97 if (
os_) *
os_ <<
"test_createFilter() " <<
typeid(f).name() << endl;
103 typedef typename KernelTraits<Kernel>::filter_type filter_type;
104 typedef typename KernelTraits<Kernel>::abscissa_type abscissa_type;
105 typedef typename KernelTraits<Kernel>::ordinate_type ordinate_type;
111 copy(filter.begin(), filter.end(), ostream_iterator<ordinate_type>(*
os_,
" "));
115 unit_assert((
int)filter.size() == sampleRadius*2 + 1);
116 for (
int i=-sampleRadius; i<=sampleRadius; ++i)
117 unit_assert(filter[sampleRadius+i] == f(i*dx - shift));
KernelTraits< Kernel >::filter_type createFilter(const Kernel &kernel, int sampleRadius, typename KernelTraits< Kernel >::abscissa_type dx, typename KernelTraits< Kernel >::abscissa_type shift)
void filter(const TContainer &data, const TContainer &filter, TContainer &result, bool circular=false, uint32_t sides=2)
Applies linear convolution (filtering) to a univariate time series.
§ test_createFilters()
template<typename Kernel >
void test_createFilters |
( |
const Kernel & |
f | ) |
|
Definition at line 124 of file MatchedFilterTest.cpp.
References pwiz::math::MatchedFilter::details::createFilters(), pwiz::math::MatchedFilter::details::norm(), os_, unit_assert, and unit_assert_equal.
Referenced by test_kernel().
126 using namespace MatchedFilter;
128 if (
os_) *
os_ <<
"test_createFilters() " <<
typeid(f).name() << endl;
130 int sampleRadius = 2;
131 int subsampleFactor = 4;
134 typedef typename KernelTraits<Kernel>::filter_type filter_type;
135 typedef typename KernelTraits<Kernel>::ordinate_type ordinate_type;
142 unit_assert((
int)filters.size() == subsampleFactor);
144 for (
typename vector<filter_type>::const_iterator it=filters.begin(); it!=filters.end(); ++it)
148 copy(it->begin(), it->end(), ostream_iterator<ordinate_type>(*
os_,
" "));
153 unit_assert((
int)it->size() == sampleRadius*2 + 1);
157 for (
typename filter_type::const_iterator jt=it->begin(); jt!=it->end(); ++jt)
158 sum +=
norm(complex<double>(*jt));
#define unit_assert_equal(x, y, epsilon)
std::vector< typename KernelTraits< Kernel >::filter_type > createFilters(const Kernel &kernel, int sampleRadius, int subsampleFactor, typename KernelTraits< Kernel >::abscissa_type dx)
§ test_compute()
template<typename Kernel >
void test_compute |
( |
const Kernel & |
f | ) |
|
Definition at line 167 of file MatchedFilterTest.cpp.
References pwiz::math::MatchedFilter::computeCorrelationData(), os_, and unit_assert.
Referenced by test_kernel().
169 using namespace MatchedFilter;
171 if (
os_) *
os_ <<
"test_compute() " <<
typeid(f).name() << endl;
173 typename KernelTraits<Kernel>::sampled_data_type data;
174 data.domain = make_pair(0, 10);
175 data.samples.resize(11);
176 data.samples[5] = 1.;
178 if (
os_) *
os_ <<
"data: " << data << endl;
180 int sampleRadius = 2;
181 int sampleFactor = 4;
183 typedef typename KernelTraits<Kernel>::correlation_data_type CorrelationData;
185 CorrelationData correlationData =
188 if (
os_) *
os_ <<
"correlationData: " << correlationData << endl;
191 unit_assert(abs(correlationData.samples[20].dot - 1.) < 1e-12);
KernelTraits< Kernel >::correlation_data_type computeCorrelationData(const typename KernelTraits< Kernel >::sampled_data_type &data, const Kernel &kernel, int sampleRadius, int subsampleFactor)
§ test_kernel()
template<typename Kernel >
void test_kernel |
( |
const Kernel & |
kernel | ) |
|
Definition at line 196 of file MatchedFilterTest.cpp.
References os_, test_compute(), test_createFilter(), and test_createFilters().
Referenced by main().
198 if (
os_) *
os_ <<
"***************************************************************\n";
199 if (
os_) *
os_ <<
"test_kernel() " <<
typeid(kernel).name() << endl;
200 if (
os_) *
os_ <<
"***************************************************************\n";
void test_compute(const Kernel &f)
void test_createFilters(const Kernel &f)
void test_createFilter(const Kernel &f)
§ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
§ os_