[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | 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 (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.9.0 (Tue Nov 6 2012)