mcs::units::static_rational< N, D > Class Template Reference

compile time rational number More...

#include <static_rational.hpp>

List of all members.

Public Types

typedef static_rational< N,
D > 
this_type
typedef static_rational< Numerator,
Denominator
type
 static_rational<N,D> reduced by GCD

Public Member Functions

 static_rational ()

Static Public Member Functions

static integer_type numerator ()
static integer_type denominator ()

Static Public Attributes

static const integer_type Numerator = N/den
static const integer_type Denominator = D/den

Static Private Attributes

static const integer_type nabs = static_abs<N>::value
static const integer_type dabs = static_abs<D>::value
static const integer_type den
 greatest common divisor of N and D


Detailed Description

template<integer_type N, integer_type D = 1>
class mcs::units::static_rational< N, D >

compile time rational number

This is an implementation of a compile time rational number, where static_rational<N,D> represents a rational number with numerator N and denominator D. Because of the potential for ambiguity arising from multiple equivalent values of static_rational (e.g. static_rational<6,2> == static_rational<3>), static_rationals should always be accessed through static_rational<N,D>::type. Template specialization prevents instantiation of zero denominators (i.e. static_rational<N,0>). The following compile-time arithmetic operators are provided for static_rational variables only (no operators are defined between long and static_rational):

Neither static_power nor static_root are defined for static_rational. This is because template types may not be floating point values, while powers and roots of rational numbers produce floating point values.

Definition at line 74 of file static_rational.hpp.


Member Typedef Documentation

template<integer_type N, integer_type D = 1>
typedef static_rational<N,D> mcs::units::static_rational< N, D >::this_type

Definition at line 89 of file static_rational.hpp.

template<integer_type N, integer_type D = 1>
typedef static_rational<Numerator,Denominator> mcs::units::static_rational< N, D >::type

static_rational<N,D> reduced by GCD

Definition at line 92 of file static_rational.hpp.


Constructor & Destructor Documentation

template<integer_type N, integer_type D = 1>
mcs::units::static_rational< N, D >::static_rational (  )  [inline]

Definition at line 97 of file static_rational.hpp.

00097 { }


Member Function Documentation

template<integer_type N, integer_type D = 1>
static integer_type mcs::units::static_rational< N, D >::numerator (  )  [inline, static]

Definition at line 94 of file static_rational.hpp.

References mcs::units::static_rational< N, D >::Numerator.

00094 { return Numerator; }

template<integer_type N, integer_type D = 1>
static integer_type mcs::units::static_rational< N, D >::denominator (  )  [inline, static]

Definition at line 95 of file static_rational.hpp.

References mcs::units::static_rational< N, D >::Denominator.

00095 { return Denominator; }


Member Data Documentation

template<integer_type N, integer_type D = 1>
const integer_type mcs::units::static_rational< N, D >::nabs = static_abs<N>::value [static, private]

Definition at line 77 of file static_rational.hpp.

template<integer_type N, integer_type D = 1>
const integer_type mcs::units::static_rational< N, D >::dabs = static_abs<D>::value [static, private]

Definition at line 78 of file static_rational.hpp.

template<integer_type N, integer_type D = 1>
const integer_type mcs::units::static_rational< N, D >::den [static, private]

Initial value:

 
            static_cast<integer_type>(boost::math::static_gcd<nabs,dabs>::value)
greatest common divisor of N and D

Definition at line 82 of file static_rational.hpp.

template<integer_type N, integer_type D = 1>
const integer_type mcs::units::static_rational< N, D >::Numerator = N/den [static]

Definition at line 86 of file static_rational.hpp.

Referenced by mcs::units::static_rational< N, D >::numerator().

template<integer_type N, integer_type D = 1>
const integer_type mcs::units::static_rational< N, D >::Denominator = D/den [static]

Definition at line 87 of file static_rational.hpp.

Referenced by mcs::units::static_rational< N, D >::denominator().


The documentation for this class was generated from the following file:
Generated on Mon Apr 2 22:25:07 2007 for physical_svn by  doxygen 1.5.1-p1
hosted on SourceForge.net Logo