1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef __INCLUDE_RTE_APPROX_H__
6 #define __INCLUDE_RTE_APPROX_H__
14 * RTE Rational Approximation
16 * Given a rational number alpha with 0 < alpha < 1 and a precision d, the goal
17 * is to find positive integers p, q such that alpha - d < p/q < alpha + d, and
25 * Find best rational approximation
28 * Rational number to approximate
30 * Precision for the rational approximation
32 * Pointer to pre-allocated space where the numerator of the rational
33 * approximation will be stored when operation is successful
35 * Pointer to pre-allocated space where the denominator of the rational
36 * approximation will be stored when operation is successful
38 * 0 upon success, error code otherwise
40 int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
46 #endif /* __INCLUDE_RTE_APPROX_H__ */