···37373838#define leng 4096
3939#define power2 12
4040-#undef RH_DEBUG
41404241struct m_relation_history
4342{
···101100 int64_t diff_prediction_ns = 0;
102101 diff_prediction_ns = at_timestamp_ns - newest_in_buffer;
103102 double delta_s = time_ns_to_s(diff_prediction_ns);
104104-#ifdef RH_DEBUG
105105- U_LOG_E("Extrapolating %f s after the head of the buffer!", delta_s);
106106-#endif
103103+104104+ U_LOG_T("Extrapolating %f s after the head of the buffer!", delta_s);
105105+107106 m_predict_relation(&rh->impl[0]->relation, delta_s, out_relation);
108107 goto end;
109108···113112 int64_t diff_prediction_ns = 0;
114113 diff_prediction_ns = at_timestamp_ns - oldest_in_buffer;
115114 double delta_s = time_ns_to_s(diff_prediction_ns);
116116-#ifdef RH_DEBUG
117117- U_LOG_E("Extrapolating %f s before the tail of the buffer!", delta_s);
118118-#endif
115115+ U_LOG_T("Extrapolating %f s before the tail of the buffer!", delta_s);
119116 m_predict_relation(&rh->impl[rh->impl.length() - 1]->relation, delta_s, out_relation);
120117 goto end;
121118 }
122122-#ifdef RH_DEBUG
123123- U_LOG_E("Interpolating within buffer!");
124124-#endif
119119+ U_LOG_T("Interpolating within buffer!");
125120#if 0
126121 // Very slow - O(n) - but easier to read
127122 int idx = 0;
···133128 break;
134129 }
135130 }
136136- U_LOG_E("Correct answer is %i", idx);
131131+ U_LOG_T("Correct answer is %i", idx);
137132#else
138133139134 // Fast - O(log(n)) - but hard to read
···148143 // different place for each power). Bit-shift it and it either doubles or halves. In our case it
149144 // halves. step should always be equivalent to pow(2,i). If it's not that's very very bad.
150145 step = step >> 1;
151151-#ifdef RH_DEBUG
152146 assert(step == (int)pow(2, i));
153153-#endif
147147+154148155149 if (idx >= rh->impl.length()) {
156150 // We'd be looking at an uninitialized value. Go back closer to the head of the buffer.