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

Namespaces

Defines

Typedefs

Functions

Variables


Define Documentation

#define I   typename signed_of_helper<U>::type

Definition at line 757 of file int.hpp.

#define INT_FLOOR_SQRT_DECLARE (  ) 
Value:
inline I floor_sqrt (const I& x) {                                      \
    return int_floor_sqrt_helper<I>::floor_sqrt (x); }

Definition at line 472 of file int.hpp.

#define INT_GCD_DECLARE (  ) 
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 (  ) 
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 (  ) 
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 (  ) 
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) >= 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) >= 8*sizeof(C)) ? ((C) 0) : (((C) a) >> ((n)/2)) >> ((n)-(n)/2))

Definition at line 121 of file int.hpp.

#define UINT_GCD_DECLARE (  ) 
Value:
inline I gcd (const I a, const I b) {                                   \
    return unsigned_int_gcd_helper::gcd (a, b); }

Definition at line 698 of file int.hpp.

#define UNSIGNED_INT_FLOOR_SQRT_DECLARE (  ) 
Value:
inline I floor_sqrt (const I& x) {                                      \
    return unsigned_int_floor_sqrt_helper<I>::floor_sqrt (x); }

Definition at line 496 of file int.hpp.

#define UNSIGNED_INT_RECONSTRUCT_DECLARE (  ) 
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.


Generated on 6 Dec 2012 for basix by  doxygen 1.6.1