File indexing completed on 2025-01-18 09:28:19
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
0009 #define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
0010
0011 #ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED
0012 # error Include this file before boost/accumulators/numeric/functional.hpp
0013 #endif
0014
0015 #include <complex>
0016 #include <boost/mpl/or.hpp>
0017 #include <boost/type_traits/is_same.hpp>
0018 #include <boost/utility/enable_if.hpp>
0019 #include <boost/typeof/std/complex.hpp>
0020 #include <boost/accumulators/numeric/functional_fwd.hpp>
0021
0022 namespace boost { namespace numeric { namespace operators
0023 {
0024
0025 template<typename T, typename U>
0026 typename
0027 disable_if<
0028 mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
0029 , std::complex<T>
0030 >::type
0031 operator *(std::complex<T> ri, U const &u)
0032 {
0033
0034 return ri *= static_cast<T>(u);
0035 }
0036
0037 template<typename T, typename U>
0038 typename
0039 disable_if<
0040 mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
0041 , std::complex<T>
0042 >::type
0043 operator /(std::complex<T> ri, U const &u)
0044 {
0045
0046 return ri /= static_cast<T>(u);
0047 }
0048
0049 }}}
0050
0051 namespace boost { namespace numeric
0052 {
0053 namespace detail
0054 {
0055 template<typename T>
0056 struct one_complex
0057 {
0058 static std::complex<T> const value;
0059 };
0060
0061 template<typename T>
0062 std::complex<T> const one_complex<T>::value
0063 = std::complex<T>(numeric::one<T>::value, numeric::one<T>::value);
0064 }
0065
0066
0067
0068 template<typename T>
0069 struct one<std::complex<T> >
0070 : detail::one_complex<T>
0071 {
0072 typedef one type;
0073 typedef std::complex<T> value_type;
0074 operator value_type const & () const
0075 {
0076 return detail::one_complex<T>::value;
0077 }
0078 };
0079
0080 }}
0081
0082 #endif