EigenHelpers.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <Eigen/Core>
27 
28 namespace armarx
29 {
30 
31  template<class ScalarType>
32  inline Eigen::Matrix<ScalarType, Eigen::Dynamic, 1> MakeVectorX(std::initializer_list<ScalarType> ilist)
33  {
35  std::size_t i = 0;
36  for (const auto e : ilist)
37  {
38  r(i++) = e;
39  }
40  return r;
41  }
42  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(std::initializer_list<float> ilist)
43  {
44  return MakeVectorX<float>(ilist);
45  }
46 
47  template<class ScalarType, class...Ts>
49  {
50  return MakeVectorX<ScalarType>(std::initializer_list<ScalarType> {std::forward<Ts>(ts)...});
51  }
52  template<class ScalarType, class...Ts>
54  {
55  return MakeVectorX<ScalarType>(std::initializer_list<ScalarType> {static_cast<ScalarType>(std::forward<Ts>(ts))...});
56  }
57  template<class ScalarType, class...Ts>
59  {
60  return MakeVectorX<ScalarType>(std::initializer_list<ScalarType> {static_cast<ScalarType>(std::forward<Ts>(ts))...});
61  }
62 
64  {
66  std::size_t i = 0;
67  for (const auto e : vec)
68  {
69  r(i++) = e;
70  }
71  return r;
72  }
73 
74  /* Qt-Creator does not support variable amount of parameters. The following methods are only for Qt-Creator. */
76  {
77  return MakeVectorX<float>(f1);
78  }
80  {
81  return MakeVectorX<float>(f1, f2);
82  }
83  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3)
84  {
85  return MakeVectorX<float>(f1, f2, f3);
86  }
87  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4)
88  {
89  return MakeVectorX<float>(f1, f2, f3, f4);
90  }
91  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5)
92  {
93  return MakeVectorX<float>(f1, f2, f3, f4, f5);
94  }
95  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6)
96  {
97  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6);
98  }
99  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7)
100  {
101  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7);
102  }
103  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8)
104  {
105  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8);
106  }
107  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
108  {
109  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8, f9);
110  }
111  inline Eigen::Matrix<float, Eigen::Dynamic, 1> MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10)
112  {
113  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10);
114  }
115 
116 
117 }
armarx::MakeVectorX
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorX(std::initializer_list< ScalarType > ilist)
Definition: EigenHelpers.h:32
armarx::MakeVectorXIgnoreNarrowing
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorXIgnoreNarrowing(Ts &&...ts)
Definition: EigenHelpers.h:53
armarx::MakeVectorXWarnNarrowing
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorXWarnNarrowing(Ts &&...ts)
Definition: EigenHelpers.h:48
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::MakeVectorXf
Eigen::Matrix< float, Eigen::Dynamic, 1 > MakeVectorXf(std::initializer_list< float > ilist)
Definition: EigenHelpers.h:42
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28