BVB Source Codes

mars Show complex.hpp Source code

Return Download mars: download complex.hpp Source code - Download mars Source code - Type:.hpp
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file complex.hpp
  3. ///
  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)
  7.  
  8. #ifndef BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
  9. #define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006
  10.  
  11. #ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED
  12. # error Include this file before boost/accumulators/numeric/functional.hpp
  13. #endif
  14.  
  15. #include <complex>
  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>
  21.  
  22. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace numeric { namespace operators
  23. {
  24.     // So that the stats compile when Sample type is std::complex
  25.     template<typename T, typename U>
  26.     typename
  27.         disable_if<
  28.             mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
  29.           , std::complex<T>
  30.         >::type
  31.     operator *(std::complex<T> ri, U const &u)
  32.     {
  33.         // BUGBUG promote result to typeof(T()*u) ?
  34.         return ri *= static_cast<T>(u);
  35.     }
  36.  
  37.     template<typename T, typename U>
  38.     typename
  39.         disable_if<
  40.             mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> >
  41.           , std::complex<T>
  42.         >::type
  43.     operator /(std::complex<T> ri, U const &u)
  44.     {
  45.         // BUGBUG promote result to typeof(T()*u) ?
  46.         return ri /= static_cast<T>(u);
  47.     }
  48.  
  49. }}} // namespace mars_boost::numeric::operators
  50.  
  51. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace numeric
  52. {
  53.     namespace detail
  54.     {
  55.         template<typename T>
  56.         struct one_complex
  57.         {
  58.             static std::complex<T> const value;
  59.         };
  60.  
  61.         template<typename T>
  62.         std::complex<T> const one_complex<T>::value
  63.           = std::complex<T>(numeric::one<T>::value, numeric::one<T>::value);
  64.     }
  65.  
  66.     /// INTERNAL ONLY
  67.     ///
  68.     template<typename T>
  69.     struct one<std::complex<T> >
  70.       : detail::one_complex<T>
  71.     {
  72.         typedef one type;
  73.         typedef std::complex<T> value_type;
  74.         operator value_type const & () const
  75.         {
  76.             return detail::one_complex<T>::value;
  77.         }
  78.     };
  79.  
  80. }} // namespace mars_boost::numeric
  81.  
  82. #endif
  83.  
downloadcomplex.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top