[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]

| Numeric and Promote Traits of FixedPoint |
--- | --- | ---

The numeric and promote traits for FixedPoint follow the general specifications for Numeric and Promotion Traits and AlgebraicRing. They are implemented in terms of the traits of the basic types by partial template specialization:

        template <unsigned IntBits1, unsigned FracBits1, unsigned IntBits2, unsigned FracBits2>
        class FixedPointTraits<FixedPoint<IntBits1, FracBits1>, FixedPoint<IntBits2, FracBits2> >
        {
            typedef FixedPoint<PlusMinusIntBits, MaxFracBits>               PlusType;
            typedef FixedPoint<PlusMinusIntBits, MaxFracBits>               MinusType;
            typedef FixedPoint<IntBits1 + IntBits2, FracBits1 + FracBits2>  MultipliesType;
        };

        template <unsigned IntBits, unsigned FracBits>
        struct NumericTraits<FixedPoint<IntBits, FracBits> >
        {
            typedef FixedPoint<IntBits, FracBits> Type;
                // Promote undefined because it depends on the layout, use FixedPointTraits
                // RealPromote in AlgebraicRing -- multiplication with double is not supported.
                // ComplexPromote in AlgebraicRing -- multiplication with double is not supported.
            typedef Type ValueType;

            typedef VigraFalseType isIntegral;
            typedef VigraTrueType  isScalar;
            typedef VigraTrueType  isSigned;
            typedef VigraTrueType  isOrdered;
            typedef VigraFalseType isComplex;

            ... // etc.
        };

        template <unsigned IntBits, unsigned FracBits>
        struct SquareRootTraits<FixedPoint<IntBits, FracBits> >
        {
            typedef FixedPoint<IntBits, FracBits>      Type;
            typedef FixedPoint<SRIntBits, SRFracBits>  SquareRootResult;
            typedef Type                               SquareRootArgument;
        };

        template <unsigned IntBits, unsigned FracBits>
        struct NormTraits<FixedPoint<IntBits, FracBits> >
        {
            typedef FixedPoint<IntBits, FracBits>         Type;
            typedef typename
                FixedPointTraits<FixedPoint<IntBits, FracBits>, FixedPoint<IntBits, FracBits> >::MultipliesType
                                                          SquaredNormType;
            typedef Type                                  NormType;
        };

        template <unsigned IntBits1, unsigned FracBits1, unsigned IntBits2, unsigned FracBits2>
        struct PromoteTraits<FixedPoint<IntBits1, FracBits1>,
                             FixedPoint<IntBits2, FracBits2> >
        {
            typedef typename
                FixedPointTraits<FixedPoint<IntBits1, FracBits1>, FixedPoint<IntBits2, FracBits2> >::PlusType
                Promote;
        };

#include "vigra/fixedpoint.hxx"
Namespace: vigra

© Ullrich Köthe (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.5.0 (7 Dec 2006)