WaveBlocksND
squeeze.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 
4 namespace waveblocks {
5  namespace utilities {
6  template<int D, class T>
7  struct Squeeze {
8  static const T& apply(const T& in) {return in;}
9  static T& apply(T& in) {return in;}
10  };
11 
12  template<class T>
13  struct Squeeze<1,T> {
14  static const typename std::remove_reference<decltype(std::declval<T>()[0])>::type& apply(const T& in) {return in[0];}
15  static decltype(std::declval<T>()[0]) apply(T& in) {return in[0];}
16  };
17 
18  template<int D>
19  struct Squeeze<D, CMatrix<D,Eigen::Dynamic>> {
20  static CMatrix<D,1> apply(const CMatrix<D,Eigen::Dynamic>& nodes, int l) {
21  return nodes.template block<D,1>(0,l);
22  }
23  };
24 
25  template<>
26  struct Squeeze<1, CMatrix<1,Eigen::Dynamic>> {
27  static const complex_t& apply(const CMatrix<1,Eigen::Dynamic>& nodes, int l) {
28  return nodes(0,l);
29  }
30  };
31 
32  template<int D, class T>
33  struct Unsqueeze {
34  static const T& apply(const T& t) {
35  return t;
36  }
37  };
38 
39  template<class T>
40  struct Unsqueeze<1,T> {
41  static T apply(const typename std::remove_reference<decltype(std::declval<T>()[0])>::type& t) {
42  T result;
43  result[0] = t;
44  return result;
45  }
46  };
47  }
48 }
Definition: coefficients_file_parser.cpp:10
static T apply(const typename std::remove_reference< decltype(std::declval< T >()[0])>::type &t)
Definition: squeeze.hpp:41
Basis< N, D, 1 > Eigen
Collection of types associated with a matrix potential in eigen basis.
Definition: bases.hpp:47
std::complex< real_t > complex_t
Definition: types.hpp:15
static const complex_t & apply(const CMatrix< 1, Eigen::Dynamic > &nodes, int l)
Definition: squeeze.hpp:27
Definition: squeeze.hpp:33
static CMatrix< D, 1 > apply(const CMatrix< D, Eigen::Dynamic > &nodes, int l)
Definition: squeeze.hpp:20
static const T & apply(const T &t)
Definition: squeeze.hpp:34
static const T & apply(const T &in)
Definition: squeeze.hpp:8
Eigen::Matrix< complex_t, R, C > CMatrix
Definition: types.hpp:19
Definition: squeeze.hpp:7
static const std::remove_reference< decltype(std::declval< T >)[0])>::type & apply(const T &in)
Definition: squeeze.hpp:14
static T & apply(T &in)
Definition: squeeze.hpp:9