4 extern const u32 fast_div_tab[];
5 extern const byte fast_sqrt_tab[];
7 static inline uns isqr(int x)
12 static inline uns fast_div_u32_u8(uns x, uns y)
14 return ((u64)(x) * fast_div_tab[y]) >> 32;
17 static inline uns fast_sqrt_u16(uns x)
20 if (x < (1 << 10) - 3)
21 y = fast_sqrt_tab[(x + 3) >> 2] >> 3;
22 else if (x < (1 << 14) - 28)
23 y = fast_sqrt_tab[(x + 28) >> 6] >> 1;
25 y = fast_sqrt_tab[x >> 8];
26 return (x < y * y) ? y - 1 : y;
29 static inline uns fast_sqrt_u32(uns x)
34 if (x < (1 << 10) - 3)
35 y = fast_sqrt_tab[(x + 3) >> 2] >> 3;
36 else if (x < (1 << 14) - 28)
37 y = fast_sqrt_tab[(x + 28) >> 6] >> 1;
39 y = fast_sqrt_tab[x >> 8];
47 y = fast_sqrt_tab[x >> 12];
48 y = (fast_div_u32_u8(x, y) >> 3) + (y << 1);
52 y = fast_sqrt_tab[x >> 16];
53 y = (fast_div_u32_u8(x, y) >> 5) + (y << 3);
62 y = fast_sqrt_tab[x >> 18];
63 y = (fast_div_u32_u8(x, y) >> 6) + (y << 4);
67 y = fast_sqrt_tab[x >> 20];
68 y = (fast_div_u32_u8(x, y) >> 7) + (y << 5);
75 y = fast_sqrt_tab[x >> 22];
76 y = (fast_div_u32_u8(x, y) >> 8) + (y << 6);
80 y = fast_sqrt_tab[x >> 24];
81 y = (fast_div_u32_u8(x, y) >> 9) + (y << 7);
86 return (x < y * y) ? y - 1 : y;