lib: remove librte_ prefix from directory names
[dpdk.git] / lib / sched / rte_approx.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef __INCLUDE_RTE_APPROX_H__
6 #define __INCLUDE_RTE_APPROX_H__
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /**
13  * @file
14  * RTE Rational Approximation
15  *
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
18  * q is minimal.
19  *
20  ***/
21
22 #include <stdint.h>
23
24 /**
25  * Find best rational approximation
26  *
27  * @param alpha
28  *   Rational number to approximate
29  * @param d
30  *   Precision for the rational approximation
31  * @param p
32  *   Pointer to pre-allocated space where the numerator of the rational
33  *   approximation will be stored when operation is successful
34  * @param q
35  *   Pointer to pre-allocated space where the denominator of the rational
36  *   approximation will be stored when operation is successful
37  * @return
38  *   0 upon success, error code otherwise
39  */
40 int rte_approx(double alpha, double d, uint32_t *p, uint32_t *q);
41
42 /**
43  * Find best rational approximation (64 bit version)
44  *
45  * @param alpha
46  *   Rational number to approximate
47  * @param d
48  *   Precision for the rational approximation
49  * @param p
50  *   Pointer to pre-allocated space where the numerator of the rational
51  *   approximation will be stored when operation is successful
52  * @param q
53  *   Pointer to pre-allocated space where the denominator of the rational
54  *   approximation will be stored when operation is successful
55  * @return
56  *   0 upon success, error code otherwise
57  */
58 int rte_approx_64(double alpha, double d, uint64_t *p, uint64_t *q);
59
60 #ifdef __cplusplus
61 }
62 #endif
63
64 #endif /* __INCLUDE_RTE_APPROX_H__ */