/* * u128_u: u128 user mode, because not all architectures support a real int128 * type * * We don't use this version in userspace, because in userspace we link with * Rust and rustc has issues with u128.
*/
/** * fast_divpow2() - fast approximation for n / (1 << d) * @n: numerator * @d: the power of 2 denominator. * * note: this rounds towards 0.
*/ staticinline s64 fast_divpow2(s64 n, u8 d)
{ return (n + ((n < 0) ? ((1 << d) - 1) : 0)) >> d;
}
/** * mean_and_variance_update() - update a mean_and_variance struct @s1 with a new sample @v1 * and return it. * @s1: the mean_and_variance to update. * @v1: the new sample. * * see linked pdf equation 12.
*/ staticinlinevoid
mean_and_variance_update(struct mean_and_variance *s, s64 v)
{
s->n++;
s->sum += v;
s->sum_squares = u128_add(s->sum_squares, u128_square(abs(v)));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.