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

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.

Referenced by createFilters(), and test_createFilter().

{
checkKernelConcept<Kernel>();
typename KernelTraits<Kernel>::filter_type filter;
for (int i=-sampleRadius; i<=sampleRadius; i++)
filter.push_back(kernel(i*dx - shift));
return filter;
}
double pwiz::math::MatchedFilter::details::norm ( double  d)
inline

Definition at line 221 of file MatchedFilter.hpp.

Referenced by computeCorrelation(), and normalizeFilter().

{return d*d;}
double pwiz::math::MatchedFilter::details::conj ( double  d)
inline
template<typename Filter >
void pwiz::math::MatchedFilter::details::normalizeFilter ( Filter &  filter)

Definition at line 226 of file MatchedFilter.hpp.

References norm().

{
double normalization = 0;
for (typename Filter::const_iterator it=filter.begin(); it!=filter.end(); ++it)
normalization += norm(*it);
normalization = sqrt(normalization);
for (typename Filter::iterator it=filter.begin(); it!=filter.end(); ++it)
*it /= normalization;
}
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.

References createFilter().

Referenced by pwiz::math::MatchedFilter::computeCorrelationData(), and test_createFilters().

{
checkKernelConcept<Kernel>();
typedef typename KernelTraits<Kernel>::filter_type filter_type;
std::vector<filter_type> filters;
for (int i=0; i<subsampleFactor; i++)
filters.push_back(createFilter(kernel, sampleRadius, dx, dx*i/subsampleFactor));
for_each(filters.begin(), filters.end(), normalizeFilter<filter_type>);
return filters;
}
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.

References conj(), pwiz::math::MatchedFilter::Correlation< Y >::dot, pwiz::math::MatchedFilter::Correlation< Y >::e2, max(), norm(), and pwiz::math::MatchedFilter::Correlation< Y >::tan2angle.

{
checkKernelConcept<Kernel>();
result.dot = 0;
double normData = 0;
for (; samples!=samplesEnd; ++samples, ++filter)
{
result.dot += (*samples) * conj(*filter);
normData += norm(*samples);
}
double normDot = norm(result.dot);
result.e2 = (std::max)(normData - normDot, 0.);
result.tan2angle = normDot>0 ? result.e2/normDot : std::numeric_limits<double>::infinity();
}