proto-1.0 249: Add (some) missing traits in color

ChangeLog | 15 +++++++++++++++ ntg/color/color.hh | 36 ++++++++++++++++++++++++++++++++++++ ntg/vect/cplx.hh | 15 +++++++++++---- 3 files changed, 62 insertions(+), 4 deletions(-) Index: integre/ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add (some) missing traits in color. * ntg/color/color.hh (optraits<color<ncomps, qbits, color_system> >::cmp_eq): New. (operator_traits<operator_cmp, color<ncomps1, qbits1, color_system1>, color<ncomps2, qbits2, color_system2> >): New traits. * ntg/vect/cplx.hh (cplx<rect, T>::to_polar): Move definition of this method outside the class, after the definition of cplx<polar, T>, in order to pacify G++ 4.0 (which requires the complete definition of cplx<polar, T> to instantiate cplx<rect, T>::to_polar. Index: integre/ntg/core/internal/global_ops_defs.hh Index: integre/ntg/vect/cplx.hh --- integre/ntg/vect/cplx.hh (révision 248) +++ integre/ntg/vect/cplx.hh (copie de travail) @@ -323,11 +323,10 @@ return cplx<rect, T>(-this->val_[0], -this->val_[1]); } + // Declaration of to_polar (definition is given after + // cplx<polar, T> definition. const cplx<polar, float_d> - to_polar() const - { - return cplx<polar, float_d>(magn(), angle()); - } + to_polar() const; }; @@ -422,6 +421,14 @@ }; + /// Definition of cplx<rect, T>::to_polar. + template <class T> + const cplx<polar, float_d> + cplx<rect, T>::to_polar() const + { + return cplx<polar, float_d>(magn(), angle()); + } + template<class T> inline std::ostream& operator<<(std::ostream& ostr, const cplx<rect, T>& rhs) Index: integre/ntg/color/color.hh --- integre/ntg/color/color.hh (révision 248) +++ integre/ntg/color/color.hh (copie de travail) @@ -267,6 +267,27 @@ typedef color<ncomps, qbits, color_system> self; typedef typename typetraits<self>::storage_type storage_type; + /* FIXME: Copied and pasted from optraits<vec>. There are + obvious lacks in these traits; Maybe we could inherit from + optraits<vect_value> or something like that? */ + public: + template <class T1, class T2> + inline static bool + cmp_eq (const T1& lhs, const T2& rhs) + { + ntg_is_a(T1, ntg::vectorial)::ensure(); + ntg_is_a(T2, ntg::vectorial)::ensure(); + ntg_assert(lhs.size() == rhs.size()); + + typedef ntg_return_type(cmp, T1, T2) tmp_type; + + unsigned s = lhs.size(); + for (unsigned i = 0; i < s; ++i) + if (lhs[i] != rhs[i]) + return false; + return true; + } + public: static unsigned max_print_width () { @@ -283,6 +304,21 @@ } }; + template<unsigned ncomps1, unsigned qbits1, + template <unsigned> class color_system1, + unsigned ncomps2, unsigned qbits2, + template <unsigned> class color_system2> + struct operator_traits<operator_cmp, + color<ncomps1, qbits1, color_system1>, + color<ncomps2, qbits2, color_system2> > + { + enum { commutative = true }; + typedef color<ncomps1, qbits1, color_system1> ret; + typedef color<ncomps1, qbits1, color_system1> impl; + }; + + // FIXME: Add missing operator_traits for color. + template <typename T> struct default_less;
participants (1)
-
Roland Levillain