ALPSCore reference
set_negative_0.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
7 /* $Id$ */
8 
9 #ifndef ALPS_NUEMRIC_SET_NEGATIVE_0_HPP
10 #define ALPS_NUEMRIC_SET_NEGATIVE_0_HPP
11 
13 #include <complex>
14 #include <type_traits>
15 
16 namespace alps { namespace numeric {
17 
18 template <class T>
19 inline typename std::enable_if<!is_sequence<T>::value,void>::type
21 {
22  if (x<T())
23  x=T();
24 }
25 
26 template <class T>
27 inline void set_negative_0(std::complex<T>& x)
28 {
29  if (std::real(x)<0. || std::imag(x)<0.)
30  x=0.;
31 }
32 
33 template <class T>
34 inline typename std::enable_if<is_sequence<T>::value,void>::type
36 {
37  for(std::size_t i=0; i!=a.size(); ++i)
38  set_negative_0(a[i]);
39 }
40 
41 
42 
43 } } // end namespace alps::numeric
44 
45 #endif // ALPS_NUEMRIC_SET_NEGATIVE_0_HPP
std::enable_if<!is_sequence< T >::value, void >::type set_negative_0(T &x)
real_type< T >::type real(T)