include/basix/int.hpp File Reference
#include "basix/port.hpp"
#include "basix/basix-config.hpp"
#include "stdint.h"
Go to the source code of this file.
Classes
- struct unsigned_int_with_size_at_least_helper< s >
- Get int type of size at least s, void if impossible. More...
- struct if_helper< b, T, E >
- struct if_helper< false, T, E >
- struct unsigned_int_with_double_size_helper< C >
- Get int with double size. More...
- struct signed_of_helper< C >
- Get the corresponding signed integer type. More...
- struct signed_of_helper< double >
- struct signed_of_helper< char >
- struct signed_of_helper< signed char >
- struct signed_of_helper< short int >
- struct signed_of_helper< int >
- struct signed_of_helper< long int >
- struct signed_of_helper< long long int >
- struct signed_of_helper< unsigned char >
- struct signed_of_helper< short unsigned int >
- struct signed_of_helper< unsigned int >
- struct signed_of_helper< long unsigned int >
- struct signed_of_helper< long long unsigned int >
- struct unsigned_of_helper< C >
- Get the unsigned corresponding integer type. More...
- struct unsigned_of_helper< char >
- struct unsigned_of_helper< signed char >
- struct unsigned_of_helper< short int >
- struct unsigned_of_helper< int >
- struct unsigned_of_helper< long int >
- struct unsigned_of_helper< long long int >
- struct unsigned_of_helper< unsigned char >
- struct unsigned_of_helper< short unsigned int >
- struct unsigned_of_helper< unsigned int >
- struct unsigned_of_helper< long unsigned int >
- struct unsigned_of_helper< long long unsigned int >
- struct is_signed_helper< C >
- Tell if the integer type is signed. More...
- struct is_signed_helper< signed char >
- struct is_signed_helper< char >
- struct is_signed_helper< short int >
- struct is_signed_helper< int >
- struct is_signed_helper< long int >
- struct is_signed_helper< long long int >
- struct int_bitsize_helper_rec< uC, s, x >
- Store the bitsize of abs (p) in field value. More...
- struct int_bitsize_helper_rec< uC, 1, x >
- struct int_bitsize_helper_rec< uC, 0, x >
- struct int_bitsize_helper< C, p >
- class long_int_mul_op< C >
- struct long_int_rshift_op< C >
- struct long_int_lshift_op< C >
- struct long_int_sub_op< C >
- struct long_int_ge_op< C >
- struct int_floor_sqrt_helper< I >
- struct unsigned_int_floor_sqrt_helper< I >
- struct int_gcd_helper
- struct unsigned_int_gcd_helper
- struct int_reconstruct_helper< I >
- struct unsigned_int_reconstruct_helper< U >
- struct unsigned_stdint_of_size_at_least_helper< s >
- struct if_helper< b, T, E >
- struct if_helper< false, T, E >
- struct signed_stdint_of_size_at_least_helper< s >
- struct if_helper< b, T, E >
- struct if_helper< false, T, E >
- struct stdint_of_helper< C >
- struct if_helper< b, T, E >
- struct if_helper< false, T, E >
Namespaces
Defines
Typedefs
Functions
- bool is_int (const double_int &x)
- int as_int (const double_int &x)
- void set_default (int &x)
- void set_default (nat &x)
- void set_default (long int &x)
- void set_default (long unsigned int &x)
- void set_maximal (int &x)
- void set_minimal (int &x)
- void set_maximal (nat &x)
- void set_minimal (nat &x)
- void set_maximal (long int &x)
- void set_minimal (long int &x)
- void set_maximal (long unsigned int &x)
- void set_minimal (long unsigned int &x)
- void set_maximal (long long int &x)
- void set_minimal (long long int &x)
- void set_maximal (long long unsigned int &x)
- void set_minimal (long long unsigned int &x)
- nat log_2 (nat p)
- nat next_power_of_two (nat p)
- bool is_power_of_two (nat p)
- nat log_3 (nat p)
- nat next_power_of_three (nat p)
- template<typename C > static nat bit_size (const C &p)
- Return the bitsize of abs (p).
- signed char floor_sqrt (const signed char &x)
- short int floor_sqrt (const short int &x)
- int floor_sqrt (const int &x)
- long int floor_sqrt (const long int &x)
- long long int floor_sqrt (const long long int &x)
- unsigned char floor_sqrt (const unsigned char &x)
- unsigned short int floor_sqrt (const unsigned short int &x)
- unsigned int floor_sqrt (const unsigned int &x)
- unsigned long int floor_sqrt (const unsigned long int &x)
- unsigned long long int floor_sqrt (const unsigned long long int &x)
- bool divides (const signed char &n, const signed char &m)
- signed char rem (const signed char &n, const signed char &m, signed char &q)
- signed char quo (const signed char &n, const signed char &m)
- signed char rem (const signed char &n, const signed char &m)
- bool divides (const short int &n, const short int &m)
- short int rem (const short int &n, const short int &m, short int &q)
- short int quo (const short int &n, const short int &m)
- short int rem (const short int &n, const short int &m)
- bool divides (const int &n, const int &m)
- int rem (const int &n, const int &m, int &q)
- int quo (const int &n, const int &m)
- int rem (const int &n, const int &m)
- bool divides (const long int &n, const long int &m)
- long int rem (const long int &n, const long int &m, long int &q)
- long int quo (const long int &n, const long int &m)
- long int rem (const long int &n, const long int &m)
- bool divides (const long long int &n, const long long int &m)
- long long int rem (const long long int &n, const long long int &m, long long int &q)
- long long int quo (const long long int &n, const long long int &m)
- long long int rem (const long long int &n, const long long int &m)
- bool divides (const unsigned char &n, const unsigned char &m)
- unsigned char rem (const unsigned char &n, const unsigned char &m)
- unsigned char quo (const unsigned char &n, const unsigned char &m)
- unsigned char rem (const unsigned char &n, const unsigned char &m, unsigned char &q)
- bool divides (const unsigned short int &n, const unsigned short int &m)
- unsigned short int rem (const unsigned short int &n, const unsigned short int &m)
- unsigned short int quo (const unsigned short int &n, const unsigned short int &m)
- unsigned short int rem (const unsigned short int &n, const unsigned short int &m, unsigned short int &q)
- bool divides (const unsigned int &n, const unsigned int &m)
- unsigned int rem (const unsigned int &n, const unsigned int &m)
- unsigned int quo (const unsigned int &n, const unsigned int &m)
- unsigned int rem (const unsigned int &n, const unsigned int &m, unsigned int &q)
- bool divides (const unsigned long int &n, const unsigned long int &m)
- unsigned long int rem (const unsigned long int &n, const unsigned long int &m)
- unsigned long int quo (const unsigned long int &n, const unsigned long int &m)
- unsigned long int rem (const unsigned long int &n, const unsigned long int &m, unsigned long int &q)
- bool divides (const unsigned long long int &n, const unsigned long long int &m)
- unsigned long long int rem (const unsigned long long int &n, const unsigned long long int &m)
- unsigned long long int quo (const unsigned long long int &n, const unsigned long long int &m)
- unsigned long long int rem (const unsigned long long int &n, const unsigned long long int &m, unsigned long long int &q)
- signed char gcd (const signed char a, const signed char b)
- signed char gcd (const signed char a, const signed char b, signed char &co_a)
- signed char gcd (const signed char a, const signed char b, signed char &co_a, signed char &co_b)
- short int gcd (const short int a, const short int b)
- short int gcd (const short int a, const short int b, short int &co_a)
- short int gcd (const short int a, const short int b, short int &co_a, short int &co_b)
- int gcd (const int a, const int b)
- int gcd (const int a, const int b, int &co_a)
- int gcd (const int a, const int b, int &co_a, int &co_b)
- long int gcd (const long int a, const long int b)
- long int gcd (const long int a, const long int b, long int &co_a)
- long int gcd (const long int a, const long int b, long int &co_a, long int &co_b)
- long long int gcd (const long long int a, const long long int b)
- long long int gcd (const long long int a, const long long int b, long long int &co_a)
- long long int gcd (const long long int a, const long long int b, long long int &co_a, long long int &co_b)
- unsigned char gcd (const unsigned char a, const unsigned char b)
- unsigned short int gcd (const unsigned short int a, const unsigned short int b)
- unsigned int gcd (const unsigned int a, const unsigned int b)
- unsigned long int gcd (const unsigned long int a, const unsigned long int b)
- unsigned long long int gcd (const unsigned long long int a, const unsigned long long int b)
- bool reconstruct (signed char &n, signed char &d, const signed char &u, const signed char &m, const signed char &N, const signed char &D)
- bool reconstruct (signed char &n, signed char &d, const signed char &u, const signed char &m)
- bool reconstruct (signed short int &n, signed short int &d, const signed short int &u, const signed short int &m, const signed short int &N, const signed short int &D)
- bool reconstruct (signed short int &n, signed short int &d, const signed short int &u, const signed short int &m)
- bool reconstruct (signed int &n, signed int &d, const signed int &u, const signed int &m, const signed int &N, const signed int &D)
- bool reconstruct (signed int &n, signed int &d, const signed int &u, const signed int &m)
- bool reconstruct (signed long int &n, signed long int &d, const signed long int &u, const signed long int &m, const signed long int &N, const signed long int &D)
- bool reconstruct (signed long int &n, signed long int &d, const signed long int &u, const signed long int &m)
- bool reconstruct (signed long long int &n, signed long long int &d, const signed long long int &u, const signed long long int &m, const signed long long int &N, const signed long long int &D)
- bool reconstruct (signed long long int &n, signed long long int &d, const signed long long int &u, const signed long long int &m)
- bool reconstruct (signed_of_helper< unsigned char >::type &n, signed_of_helper< unsigned char >::type &d, const unsigned char &u, const unsigned char &m, const unsigned char &N, const unsigned char &D)
- bool reconstruct (signed_of_helper< unsigned char >::type &n, signed_of_helper< unsigned char >::type &d, const unsigned char &u, const unsigned char &m)
- bool reconstruct (signed_of_helper< unsigned short int >::type &n, signed_of_helper< unsigned short int >::type &d, const unsigned short int &u, const unsigned short int &m, const unsigned short int &N, const unsigned short int &D)
- bool reconstruct (signed_of_helper< unsigned short int >::type &n, signed_of_helper< unsigned short int >::type &d, const unsigned short int &u, const unsigned short int &m)
- bool reconstruct (signed_of_helper< unsigned int >::type &n, signed_of_helper< unsigned int >::type &d, const unsigned int &u, const unsigned int &m, const unsigned int &N, const unsigned int &D)
- bool reconstruct (signed_of_helper< unsigned int >::type &n, signed_of_helper< unsigned int >::type &d, const unsigned int &u, const unsigned int &m)
- bool reconstruct (signed_of_helper< unsigned long int >::type &n, signed_of_helper< unsigned long int >::type &d, const unsigned long int &u, const unsigned long int &m, const unsigned long int &N, const unsigned long int &D)
- bool reconstruct (signed_of_helper< unsigned long int >::type &n, signed_of_helper< unsigned long int >::type &d, const unsigned long int &u, const unsigned long int &m)
- bool reconstruct (signed_of_helper< unsigned long long int >::type &n, signed_of_helper< unsigned long long int >::type &d, const unsigned long long int &u, const unsigned long long int &m, const unsigned long long int &N, const unsigned long long int &D)
- bool reconstruct (signed_of_helper< unsigned long long int >::type &n, signed_of_helper< unsigned long long int >::type &d, const unsigned long long int &u, const unsigned long long int &m)
Variables
Define Documentation
#define I typename signed_of_helper<U>::type |
#define INT_FLOOR_SQRT_DECLARE |
( |
I |
|
) |
|
#define INT_GCD_DECLARE |
( |
I |
|
) |
|
Value:inline I gcd (const I a, const I b) { \
return int_gcd_helper::gcd (a, b); } \
\
inline I gcd (const I a, const I b, I& co_a) { \
return int_gcd_helper::gcd (a, b, co_a); } \
\
inline I gcd (const I a, const I b, I& co_a, I& co_b) { \
return int_gcd_helper::gcd (a, b, co_a, co_b); }
Definition at line 681 of file int.hpp.
#define INT_RECONSTRUCT_DECLARE |
( |
I |
|
) |
|
Value:inline bool reconstruct (I& n, I& d, const I& u, const I& m, \
const I& N, const I& D) { \
return int_reconstruct_helper<I>::reconstruct (n, d, u, m, N, D); } \
inline bool reconstruct (I& n, I& d, const I& u, const I& m) { \
I N= floor_sqrt (m >> 1); \
return int_reconstruct_helper<I>::reconstruct (n, d, u, m, N, N); }
Definition at line 742 of file int.hpp.
#define INT_SIGNED_DIV_DECLARE |
( |
I |
|
) |
|
Value:inline bool divides (const I& n, const I& m) { return (m % n) == 0; } \
inline I rem (const I& n, const I& m, I& q) { \
I _q= 0; \
if (m == 0) { q= 0; return n; } \
if (m < 0) { \
I r= rem (n, -m, _q); \
q= -_q; \
if (r == 0) return r; \
q--; return r + m; \
} \
if (n < 0) { \
_q= (-n) / m; _q= -_q; \
I r= n - _q * m; q= _q; \
if (r == 0) return r; \
q--; return r + m; \
} \
_q= n / m; I r= n - _q * m; q= _q; return r; } \
inline I quo (const I& n, const I& m) { \
if (m == 0) return 0; \
if (m < 0) { \
I q, r= rem (n, -m, q); \
q= -q; \
if (r != 0) q--; \
return q; \
} \
if (n < 0) { \
I q= n / m; \
I r= n - q * m; \
if (r != 0) q--; \
return q; \
} \
return n / m; } \
inline I rem (const I& n, const I& m) { \
if (m == 0) { return n; } \
if (m < 0) { \
I r= rem (n, -m); \
if (r == 0) return r; \
return r + m; \
} \
if (n < 0) { \
I r= n % m; \
if (r == 0) return r; \
return r + m; \
} \
return n % m; }
Definition at line 511 of file int.hpp.
#define INT_UNSIGNED_DIV_DECLARE |
( |
I |
|
) |
|
Value:inline bool divides (const I& n, const I& m) { return (m % n) == 0; } \
inline I rem (const I& n, const I& m) { return m == 0 ? n : n % m; } \
inline I quo (const I& n, const I& m) { return m == 0 ? 0 : n / m; } \
inline I rem (const I& n, const I& m, I& q) { \
I _q= quo (n, m); I _r= n - _q * m; q= _q; return _r; }
Definition at line 564 of file int.hpp.
#define MMX_SAFE_LEFT_SHIFT_INT |
( |
C, |
|
|
a, |
|
|
n |
|
) |
(((n) >= 8*sizeof(C)) ? ((C) 0) : (((C) a) << ((n)/2)) << ((n)-(n)/2)) |
Hereafter C must a genuine C/C++ int type, signed or not.
Definition at line 118 of file int.hpp.
#define MMX_SAFE_RIGHT_SHIFT_INT |
( |
C, |
|
|
a, |
|
|
n |
|
) |
(((n) >= 8*sizeof(C)) ? ((C) 0) : (((C) a) >> ((n)/2)) >> ((n)-(n)/2)) |
#define UINT_GCD_DECLARE |
( |
I |
|
) |
|
#define UNSIGNED_INT_FLOOR_SQRT_DECLARE |
( |
I |
|
) |
|
#define UNSIGNED_INT_RECONSTRUCT_DECLARE |
( |
U |
|
) |
|
Value:inline bool reconstruct (signed_of_helper<U>::type& n, \
signed_of_helper<U>::type& d, \
const U& u, const U& m, \
const U& N, const U& D) { \
return unsigned_int_reconstruct_helper<U> \
::reconstruct (n, d, u, m, N, D); } \
inline bool reconstruct (signed_of_helper<U>::type& n, \
signed_of_helper<U>::type& d, \
const U& u, const U& m) { \
U N= floor_sqrt (m >> 1); \
return unsigned_int_reconstruct_helper<U>:: \
reconstruct (n, d, u, m, N, N); }
Definition at line 787 of file int.hpp.