MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / matches

Method matches

lib/data/fluxpattern.cc:48–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48bool FluxPattern::matches(const unsigned* end, FluxMatch& match) const
49{
50 const double clockDecodeThreshold =
51 globalConfig()->decoder().bit_error_threshold();
52 const unsigned* start = end - _intervals.size();
53 unsigned candidatelength = std::accumulate(start, end - _lowzero, 0);
54 if (!candidatelength)
55 return false;
56 match.clock = (double)candidatelength / (double)_length;
57
58 unsigned exactIntervals = _intervals.size() - _lowzero;
59 for (unsigned i = 0; i < exactIntervals; i++)
60 {
61 double ii = match.clock * (double)_intervals[i];
62 double ci = (double)start[i];
63 double error = fabs((ii - ci) / match.clock);
64 if (error > clockDecodeThreshold)
65 return false;
66 }
67
68 if (_lowzero)
69 {
70 double ii = match.clock * (double)_intervals[exactIntervals];
71 double ci = (double)start[exactIntervals];
72 double error = (ii - ci) / match.clock;
73 if (error > clockDecodeThreshold)
74 return false;
75 }
76
77 match.matcher = this;
78 match.intervals = _intervals.size();
79 match.zeroes = _highzeroes;
80 return true;
81}
82
83FluxMatchers::FluxMatchers(
84 const std::initializer_list<const FluxMatcher*> matchers):

Calls 1

sizeMethod · 0.45