ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bindings.hpp
Go to the documentation of this file.
1 #ifndef MATRIX_BINDINGS_H
2 #define MATRIX_BINDINGS_H
3 
4 #include <alps/numeric/real.hpp>
5 
6 namespace maquis { namespace bindings {
7 
8  template <typename O, typename I> struct binding {
9  static O convert(const I& m){ return static_cast<O>(m); }
10  };
11 
12  template<typename O, typename I> O matrix_cast(I const& input){
13  return binding<O,I>::convert(input);
14  }
15 
16  template <typename T>
17  struct binding< std::vector<T>, alps::numeric::diagonal_matrix<T> > {
18  static std::vector<T> convert(const alps::numeric::diagonal_matrix<T>& m){
19  return m.get_values();
20  }
21  };
22 
23  template <typename T, typename S, template<class M, class SS> class C>
24  struct binding< std::vector< std::vector<T> >, C<alps::numeric::diagonal_matrix<T>, S> > {
25  static std::vector< std::vector<T> > convert(const C<alps::numeric::diagonal_matrix<T>, S>& m){
26  std::vector< std::vector<T> > set;
27  for(size_t k = 0; k < m.n_blocks(); ++k){
28  set.push_back(m[k].get_values());
29  }
30  return set;
31  }
32  };
33 
34 } }
35 
36 namespace maquis {
37  template <class T>
38  inline typename alps::numeric::real_type<T>::type real(T f){
39  return alps::numeric::real(f);
40  }
41 
42  template<typename _InputIterator, typename _Tp>
43  inline _Tp
44  accumulate(_InputIterator __first, _InputIterator __last, _Tp __init){
45  return std::accumulate(__first, __last, __init);
46  }
47 
48  template<typename T>
49  T sqrt(T arg){
50  return std::sqrt(arg);
51  }
52 }
53 
54 #endif
static O convert(const I &m)
Definition: bindings.hpp:9
block_matrix< Matrix, SymmGroup > sqrt(block_matrix< Matrix, SymmGroup > m)
static std::vector< T > convert(const alps::numeric::diagonal_matrix< T > &m)
Definition: bindings.hpp:18
T sqrt(T arg)
Definition: bindings.hpp:49
static std::vector< std::vector< T > > convert(const C< alps::numeric::diagonal_matrix< T >, S > &m)
Definition: bindings.hpp:25
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
Definition: bindings.hpp:44
O matrix_cast(I const &input)
Definition: bindings.hpp:12
alps::numeric::real_type< T >::type real(T f)
Definition: bindings.hpp:38