1 ///////////////////////////////////////////////////////////////////////////////
4 // Copyright 2005 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
9 #define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
11 #ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED
12 # error Include this file before boost/accumulators/numeric/functional.hpp
16 #include <boost/mpl/or.hpp>
17 #include <boost/type_traits/is_same.hpp>
18 #include <boost/utility/enable_if.hpp>
19 #include <boost/typeof/std/complex.hpp>
20 #include <boost/accumulators/numeric/functional_fwd.hpp>
22 namespace boost { namespace numeric { namespace operators
24 // So that the stats compile when Sample type is std::complex
25 template<typename T, typename U>
28 mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
31 operator *(std::complex<T> ri, U const &u)
33 // BUGBUG promote result to typeof(T()*u) ?
34 return ri *= static_cast<T>(u);
37 template<typename T, typename U>
40 mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
43 operator /(std::complex<T> ri, U const &u)
45 // BUGBUG promote result to typeof(T()*u) ?
46 return ri /= static_cast<T>(u);
49 }}} // namespace boost::numeric::operators
51 namespace boost { namespace numeric
58 static std::complex<T> const value;
62 std::complex<T> const one_complex<T>::value
63 = std::complex<T>(numeric::one<T>::value, numeric::one<T>::value);
69 struct one<std::complex<T> >
70 : detail::one_complex<T>
73 typedef std::complex<T> value_type;
74 operator value_type const & () const
76 return detail::one_complex<T>::value;
80 }} // namespace boost::numeric