Boost logo

Ublas :

From: Tsai Dung-Bang (dbtsai_at_[hidden])
Date: 2007-11-23 10:42:09


Dear all

Finally, I got this work by using

#include <boost/numeric/ublas/traits.hpp>
typedef typename type_traits<value_type>::real_value value_real_type

And I also readied ublas/traits.hpp, what it does is exactly what
Daniele said, it uses template specialization for determining the
type.

But, in that traits.hpp, it only defines

    template<>
    struct type_traits<std::complex<float> > :
complex_traits<std::complex<float> >
    template<>
    struct type_traits<std::complex<float> > :
complex_traits<std::complex<double> >
    template<>
    struct type_traits<std::complex<float> > :
complex_traits<std::complex<long double> >
, what if we encounter some floating type T which is not belong to these types?

Maybe we should also define

    template<typename T>
    struct type_traits<std::complex<T> > : complex_traits<std::complex<T> >{
        typedef type_traits<std::complex<T> > self_type;
        typedef std::complex<T> value_type;
        typedef const value_type &const_reference;
        typedef value_type &reference;
        typedef T real_type;
        typedef value_type precision_type;
    };
such that all of general complex type could work in this type_traits.

Best Wishes,

Tsai, Dung-Bang 蔡東邦
-----------------------------------
Department of Physics
National Taiwan University
No. 1, Sec. 4, Roosevelt Road
Taipei 10617, Taiwan
TEL: +886-2-3366-5134