rte_approx.h(3)

πŸ’– rte_approx.h πŸ’–

hiii bestie, welcome to the rte_approx.h page β€” it's part of the Library Functions Manual, section 3, and it's literally the cutest lil corner of DPDK where we do rational approximation math. no cap. let's get into it πŸ¦‹


✨ NAME ✨

rte_approx.h

that's it, that's the name, she's self-titled and she knows it πŸ’…


🌸 SYNOPSIS 🌸

the one and only thing you gotta include:

#include <stdint.h>

πŸŽ€ Functions πŸŽ€

two icons, both of them:

int rte_approx (double alpha, double d, uint32_t *p, uint32_t *q)
int rte_approx_64 (double alpha, double d, uint64_t *p, uint64_t *q)

πŸ’œ Detailed Description πŸ’œ

RTE Rational Approximation

ok so picture this: you hand me a rational number alpha, where 0 < alpha < 1, plus a precision d. the goal, the mission, the whole vibe, is to find positive integers p and q such that

alpha - d < p/q < alpha + d

and, and this is the important part, q is minimal. minimal denominator, maximal slay. ✨

πŸ“Œ Definition in file rte_approx.h.


🧚 Function Documentation 🧚

int rte_approx (double alpha, double d, uint32_t * p, uint32_t * q)

Find best rational approximation β€” the 32-bit girly 🫢

Parameters

  • alpha β€” the rational number you want to approximate
  • d β€” the precision you want for the rational approximation
  • p β€” pointer to pre-allocated space where the numerator of the rational approximation will be stored when the operation is successful
  • q β€” pointer to pre-allocated space where the denominator of the rational approximation will be stored when the operation is successful

Returns

0 upon success, error code otherwise 😭 (yes we do error codes here, it's giving responsible)


int rte_approx_64 (double alpha, double d, uint64_t * p, uint64_t * q)

Find best rational approximation (64 bit version) β€” same energy, bigger numbers, main character vibes πŸ‘‘

Parameters

  • alpha β€” the rational number you want to approximate
  • d β€” the precision you want for the rational approximation
  • p β€” pointer to pre-allocated space where the numerator of the rational approximation will be stored when the operation is successful
  • q β€” pointer to pre-allocated space where the denominator of the rational approximation will be stored when the operation is successful

Returns

0 upon success, error code otherwise πŸ’€ (same deal, stay safe out there)


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for DPDK from the source code. so technically Doxygen wrote this, not a person, and honestly? it ate. πŸ€–βœ¨


aaaand that's the whole page, bestie!! this was rte_approx.h from DPDK, Version 25.11.3 β€” mwah, go approximate something gorgeous, ily πŸ’–πŸŽ€πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from