ProteoWizard
Functions
pwiz::math::MatchedFilter::details Namespace Reference

Functions

template<typename Kernel >
KernelTraits< Kernel >::filter_type createFilter (const Kernel &kernel, int sampleRadius, typename KernelTraits< Kernel >::abscissa_type dx, typename KernelTraits< Kernel >::abscissa_type shift)
 
double norm (double d)
 
double conj (double d)
 
template<typename Filter >
void normalizeFilter (Filter &filter)
 
template<typename Kernel >
std::vector< typename KernelTraits< Kernel >::filter_type > createFilters (const Kernel &kernel, int sampleRadius, int subsampleFactor, typename KernelTraits< Kernel >::abscissa_type dx)
 
template<typename Kernel >
void computeCorrelation (typename KernelTraits< Kernel >::samples_type::const_iterator samples, typename KernelTraits< Kernel >::samples_type::const_iterator samplesEnd, typename KernelTraits< Kernel >::samples_type::const_iterator filter, typename KernelTraits< Kernel >::correlation_type &result)
 

Function Documentation

◆ createFilter()

template<typename Kernel >
KernelTraits< Kernel >::filter_type pwiz::math::MatchedFilter::details::createFilter ( const Kernel &  kernel,
int  sampleRadius,
typename KernelTraits< Kernel >::abscissa_type  dx,
typename KernelTraits< Kernel >::abscissa_type  shift 
)

Definition at line 206 of file MatchedFilter.hpp.

210{
211 checkKernelConcept<Kernel>();
212
213 typename KernelTraits<Kernel>::filter_type filter;
214 for (int i=-sampleRadius; i<=sampleRadius; i++)
215 filter.push_back(kernel(i*dx - shift));
216 return filter;
217}

Referenced by createFilters().

◆ norm()

double pwiz::math::MatchedFilter::details::norm ( double  d)
inline

Definition at line 221 of file MatchedFilter.hpp.

221{return d*d;}

References norm().

Referenced by computeCorrelation(), norm(), and normalizeFilter().

◆ conj()

double pwiz::math::MatchedFilter::details::conj ( double  d)
inline

Definition at line 222 of file MatchedFilter.hpp.

222{return d;}

Referenced by computeCorrelation().

◆ normalizeFilter()

template<typename Filter >
void pwiz::math::MatchedFilter::details::normalizeFilter ( Filter &  filter)

Definition at line 226 of file MatchedFilter.hpp.

227{
228 double normalization = 0;
229 for (typename Filter::const_iterator it=filter.begin(); it!=filter.end(); ++it)
230 normalization += norm(*it);
231 normalization = sqrt(normalization);
232
233 for (typename Filter::iterator it=filter.begin(); it!=filter.end(); ++it)
234 *it /= normalization;
235}

References norm().

◆ createFilters()

template<typename Kernel >
std::vector< typename KernelTraits< Kernel >::filter_type > pwiz::math::MatchedFilter::details::createFilters ( const Kernel &  kernel,
int  sampleRadius,
int  subsampleFactor,
typename KernelTraits< Kernel >::abscissa_type  dx 
)

Definition at line 240 of file MatchedFilter.hpp.

244{
245 checkKernelConcept<Kernel>();
246
247 typedef typename KernelTraits<Kernel>::filter_type filter_type;
248 std::vector<filter_type> filters;
249
250 for (int i=0; i<subsampleFactor; i++)
251 filters.push_back(createFilter(kernel, sampleRadius, dx, dx*i/subsampleFactor));
252
253 for_each(filters.begin(), filters.end(), normalizeFilter<filter_type>);
254
255 return filters;
256}
KernelTraits< Kernel >::filter_type createFilter(const Kernel &kernel, int sampleRadius, typename KernelTraits< Kernel >::abscissa_type dx, typename KernelTraits< Kernel >::abscissa_type shift)

References createFilter().

Referenced by pwiz::math::MatchedFilter::computeCorrelationData().

◆ computeCorrelation()

template<typename Kernel >
void pwiz::math::MatchedFilter::details::computeCorrelation ( typename KernelTraits< Kernel >::samples_type::const_iterator  samples,
typename KernelTraits< Kernel >::samples_type::const_iterator  samplesEnd,
typename KernelTraits< Kernel >::samples_type::const_iterator  filter,
typename KernelTraits< Kernel >::correlation_type &  result 
)

Definition at line 261 of file MatchedFilter.hpp.

265{
266 checkKernelConcept<Kernel>();
267 result.dot = 0;
268 double normData = 0;
269
270 for (; samples!=samplesEnd; ++samples, ++filter)
271 {
272 result.dot += (*samples) * conj(*filter);
273 normData += norm(*samples);
274 }
275
276 double normDot = norm(result.dot);
277 result.e2 = (std::max)(normData - normDot, 0.);
278 result.tan2angle = normDot>0 ? result.e2/normDot : std::numeric_limits<double>::infinity();
279}

References conj(), and norm().