ALPSCore reference
special_functions.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: nobinning.h 3520 2009-12-11 16:49:53Z gamperl $ */
8 
9 
10 #pragma once
11 
12 #include <cmath>
13 #include <boost/accumulators/numeric/functional/vector.hpp>
14 #include <boost/math/special_functions.hpp>
15 
16 
17 namespace alps {
18  namespace numeric {
19 
20  // define special powers
21  template<class T>
22  inline T sq(T value) {
23  using boost::numeric::operators::operator*;
24  return value * value;
25  }
26 
27  template<class T>
28  inline T cb(T value) {
29  using boost::numeric::operators::operator*;
30  return value * value * value;
31  }
32 
33  template<class T>
34  inline T cbrt(T value) {
35  return std::pow(value,(T)(1./3.));
36  }
37 
38  // define norm and r
39  template <class T>
40  inline T norm(T x, T y=T(), T z=T()) {
41  using boost::numeric::operators::operator+;
42  return (sq(x) + sq(y) + sq(z));
43  }
44 
45  template <class T>
46  inline T r(T x, T y=T(), T z=T()) {
47  return std::sqrt(norm(x,y,z));
48  }
49  }
50 }
boost::array< T, N > cbrt(boost::array< T, N > arg)
boost::array< T, N > sqrt(boost::array< T, N > arg)
T norm(T x, T y=T(), T z=T())
std::vector< T > pow(std::vector< T > vec, U index)
boost::array< T, N > cb(boost::array< T, N > arg)
T r(T x, T y=T(), T z=T())
boost::array< T, N > sq(boost::array< T, N > arg)