Developer Documentation

VectorT_dummy_data.hpp
1 #pragma once
2
3 #include <valarray>
4 #include <complex>
5
6 template<typename T>
7 T make_dummy_component() {
8 return T();
9 }
10
11 template<> std::valarray<double> make_dummy_component();
12
13 template<typename Vec>
14 Vec make_dummy_vector() {
15 return Vec(make_dummy_component<typename Vec::value_type>());
16 }
17
18 template<typename Scalar>
19 double observe_dummy_component(const Scalar& _s) {
20 return _s;
21 }
22
23 template<typename T>
24 double observe_dummy_component(const std::valarray<T>& _s) {
25 return _s.sum();
26 }
27
28 template<typename T>
29 double observe_dummy_component(const std::complex<T>& _s) {
30 return _s.real() + _s.imag();
31 }
32
33 template<typename Vec>
34 double observe_dummy_vector(const Vec& _vec) {
35 double result = 0.0;
36 for (int dim = 0; dim < _vec.dim(); ++dim) {
37 result += observe_dummy_component(_vec[dim]);
38 }
39 return result;
40 }