units
Use physical dimensions at compile-time or run-time.
Namespaces | Classes | Typedefs | Functions
vnix Namespace Reference

Thomas E. Vaughan's public software. More...

Namespaces

 impl
 
 mv
 
 rat
 Classes and functions supporting a model of a fixed-precision rational number.
 
 units
 Classes and functions supporting a model of physically dimensioned quantities.
 

Classes

struct  int_types
 Smallest integer types for holding certain number of bits. More...
 
struct  int_types< 16 >
 Terminal specialization of int_types for 16-bit integer. More...
 
struct  int_types< 32 >
 Terminal specialization of int_types for 32-bit integer. More...
 
struct  int_types< 64 >
 Terminal specialization of int_types for 64-bit integer. More...
 
struct  int_types< 8 >
 Terminal specialization of int_types for eight-bit integer. More...
 

Typedefs

template<typename U , typename V >
using gcd_promoted = decltype(U()%V())
 Output-type resulting from modular division of input-types. More...
 
template<unsigned NB, unsigned DB>
using rational = rat::rational< NB, DB >
 Bring class rational into vnix namespace. More...
 
using rat8_t = rational< 5, 3 >
 Rational with five bits for numerator and three for denominator. More...
 
using rat16_t = rational< 9, 7 >
 Rational with nine bits for numerator and seven for denominator. More...
 
using rat32_t = rational< 17, 15 >
 Rational with 17 bits for numerator and 15 for denominator. More...
 
using rat64_t = rational< 33, 31 >
 Rational with 33 bits for numerator and 31 for denominator. More...
 

Functions

template<typename A , typename B >
constexpr gcd_promoted< A, B > gcd (A a, B b)
 Greatest common divisor of two numbers; only absolute values are used. More...
 
template<typename I >
constexpr I bit (unsigned n)
 Word with specified bit set. More...
 
template<typename I >
constexpr I bit_range (unsigned n1, unsigned n2)
 Word with specified range of bits set. More...
 

Detailed Description

Thomas E. Vaughan's public software.

Typedef Documentation

template<typename U , typename V >
using vnix::gcd_promoted = typedef decltype(U() % V())

Output-type resulting from modular division of input-types.

Template Parameters
UOne input type.
VOther input type.

Definition at line 16 of file gcd.hpp.

using vnix::rat16_t = typedef rational<9, 7>

Rational with nine bits for numerator and seven for denominator.

Definition at line 24 of file rat.hpp.

using vnix::rat32_t = typedef rational<17, 15>

Rational with 17 bits for numerator and 15 for denominator.

Definition at line 27 of file rat.hpp.

using vnix::rat64_t = typedef rational<33, 31>

Rational with 33 bits for numerator and 31 for denominator.

Definition at line 30 of file rat.hpp.

using vnix::rat8_t = typedef rational<5, 3>

Rational with five bits for numerator and three for denominator.

Definition at line 21 of file rat.hpp.

template<unsigned NB, unsigned DB>
using vnix::rational = typedef rat::rational<NB, DB>

Bring class rational into vnix namespace.

Template Parameters
NBNumber of bits for numerator.
DBNumber of bits for denominator.

Definition at line 17 of file rat.hpp.

Function Documentation

template<typename I >
constexpr I vnix::bit ( unsigned  n)

Word with specified bit set.

Template Parameters
IType of integer word.
Parameters
nOffset of bit in word.

Definition at line 15 of file bit-range.hpp.

15 { return I(1) << n; }

Here is the caller graph for this function:

template<typename I >
constexpr I vnix::bit_range ( unsigned  n1,
unsigned  n2 
)

Word with specified range of bits set.

Template Parameters
IType of integer word.
Parameters
n1Offset of bit at one end of range.
n2Offset of bit at other end of range.

Definition at line 22 of file bit-range.hpp.

22  {
23  if (n1 < n2) { return bit<I>(n1) | bit_range<I>(n1 + 1, n2); }
24  if (n2 < n1) { return bit<I>(n2) | bit_range<I>(n2 + 1, n1); }
25  return bit<I>(n1);
26 }

Here is the caller graph for this function:

template<typename A , typename B >
constexpr gcd_promoted<A, B> vnix::gcd ( a,
b 
)

Greatest common divisor of two numbers; only absolute values are used.

Parameters
aFirst number.
bSecond number.
Returns
Greatest common divisor.

Definition at line 40 of file gcd.hpp.

40  {
41  if (a < 0) { a = -a; }
42  if (b == 0) { return a; }
43  if (b < 0) { b = -b; }
44  return impl::basic_gcd(b, a % b);
45 }
constexpr gcd_promoted< A, B > basic_gcd(A a, B b)
Greatest common divisor of two nonnegative numbers.
Definition: gcd.hpp:27

Here is the caller graph for this function: