40 lines
449 B
C
40 lines
449 B
C
#ifndef UCORE_MATH_H_
|
|
#define UCORE_MATH_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
uint32_t
|
|
uc_gcd_32(uint32_t a, uint32_t b);
|
|
|
|
uint64_t
|
|
uc_gcd_64(uint64_t a, uint64_t b);
|
|
|
|
uint32_t
|
|
uc_phi_32(uint32_t N);
|
|
|
|
uint64_t
|
|
uc_phi_64(uint64_t N);
|
|
|
|
static inline uint32_t
|
|
uc_nextpow2(uint32_t x)
|
|
{
|
|
x--;
|
|
x |= x >> 1;
|
|
x |= x >> 2;
|
|
x |= x >> 4;
|
|
x |= x >> 8;
|
|
x |= x >> 16;
|
|
x++;
|
|
|
|
return x;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|