9 #ifndef ALPS_NUMERIC_REAL_HPP 10 #define ALPS_NUMERIC_REAL_HPP 12 #include <type_traits> 13 #include <boost/static_assert.hpp> 14 #include <boost/type_traits/is_fundamental.hpp> 19 namespace alps {
namespace numeric {
38 typedef std::vector<typename real_type<T>::type>
type;
54 template <
typename T,
bool>
59 struct real_impl<T, true>{
60 static inline T apply(T x)
68 struct real_impl<T, false>{
71 return real_hook<T>::apply(x);
79 struct real_hook<
std::complex<T> >{
80 static inline T apply(std::complex<T>
const& x)
89 struct real_hook<
std::vector<T> >{
90 static inline std::vector<T>
const& apply(std::vector<T>
const& x)
97 struct real_hook<
std::vector<std::complex<T> > >{
98 static inline std::vector<T> apply(std::vector<std::complex<T> >
const& x)
101 re.reserve(x.size());
103 static_cast<T (*)(std::complex<T>
const &)
>(&real_hook<std::complex<T> >::apply));
109 template <
typename T>
110 struct real_hook<
std::vector<std::vector<T> > >{
111 static inline std::vector<std::vector<T> >
const& apply(std::vector<std::vector<T> >
const& x)
117 template <
typename T>
118 struct real_hook<
std::vector<std::vector<std::complex<T> > > >{
119 static inline std::vector<std::vector<T> > apply(std::vector<std::vector<std::complex<T> > >
const& x)
121 std::vector<std::vector<T> > re;
122 re.reserve(x.size());
124 static_cast<std::vector<T> (*)(std::vector<std::complex<T>
> const &)>(&real_hook<std::vector<std::complex<T> > >::apply));
135 return detail::real_impl<T, std::is_fundamental<T>::value>::apply(x);
142 #endif // ALPS_MATH_HPP
mean_result< T > transform(no_prop, const transformer< T > &tf, const InResult &in)
real_type< T >::type real(T x)
real_type< T >::type real(T)
BOOST_STATIC_ASSERT((boost::is_fundamental< T >::value))
std::vector< typename real_type< T >::type > type