Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file complex.hpp Chris@16: /// Chris@16: // Copyright 2005 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 Chris@16: #define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 Chris@16: Chris@16: #ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED Chris@16: # error Include this file before boost/accumulators/numeric/functional.hpp Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace numeric { namespace operators Chris@16: { Chris@16: // So that the stats compile when Sample type is std::complex Chris@16: template Chris@16: typename Chris@16: disable_if< Chris@16: mpl::or_, is_same, U> > Chris@16: , std::complex Chris@16: >::type Chris@16: operator *(std::complex ri, U const &u) Chris@16: { Chris@16: // BUGBUG promote result to typeof(T()*u) ? Chris@16: return ri *= static_cast(u); Chris@16: } Chris@16: Chris@16: template Chris@16: typename Chris@16: disable_if< Chris@16: mpl::or_, is_same, U> > Chris@16: , std::complex Chris@16: >::type Chris@16: operator /(std::complex ri, U const &u) Chris@16: { Chris@16: // BUGBUG promote result to typeof(T()*u) ? Chris@16: return ri /= static_cast(u); Chris@16: } Chris@16: Chris@16: }}} // namespace boost::numeric::operators Chris@16: Chris@16: namespace boost { namespace numeric Chris@16: { Chris@16: namespace detail Chris@16: { Chris@16: template Chris@16: struct one_complex Chris@16: { Chris@16: static std::complex const value; Chris@16: }; Chris@16: Chris@16: template Chris@16: std::complex const one_complex::value Chris@16: = std::complex(numeric::one::value, numeric::one::value); Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: /// Chris@16: template Chris@16: struct one > Chris@16: : detail::one_complex Chris@16: { Chris@16: typedef one type; Chris@16: typedef std::complex value_type; Chris@16: operator value_type const & () const Chris@16: { Chris@16: return detail::one_complex::value; Chris@16: } Chris@16: }; Chris@16: Chris@16: }} // namespace boost::numeric Chris@16: Chris@16: #endif