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>
33  MakeVectorX(std::initializer_list<ScalarType> ilist)
34  {
36  std::size_t i = 0;
37  for (const auto e : ilist)
38  {
39  r(i++) = e;
40  }
41  return r;
42  }
43 
45  MakeVectorXf(std::initializer_list<float> ilist)
46  {
47  return MakeVectorX<float>(ilist);
48  }
49 
50  template <class ScalarType, class... Ts>
53  {
54  return MakeVectorX<ScalarType>(std::initializer_list<ScalarType>{std::forward<Ts>(ts)...});
55  }
56 
57  template <class ScalarType, class... Ts>
60  {
61  return MakeVectorX<ScalarType>(
62  std::initializer_list<ScalarType>{static_cast<ScalarType>(std::forward<Ts>(ts))...});
63  }
64 
65  template <class ScalarType, class... Ts>
67  MakeVectorX(Ts&&... ts)
68  {
69  return MakeVectorX<ScalarType>(
70  std::initializer_list<ScalarType>{static_cast<ScalarType>(std::forward<Ts>(ts))...});
71  }
72 
74  MakeVectorXf(std::vector<float> vec)
75  {
77  std::size_t i = 0;
78  for (const auto e : vec)
79  {
80  r(i++) = e;
81  }
82  return r;
83  }
84 
85  /* Qt-Creator does not support variable amount of parameters. The following methods are only for Qt-Creator. */
87  MakeVectorXf(float f1)
88  {
89  return MakeVectorX<float>(f1);
90  }
91 
93  MakeVectorXf(float f1, float f2)
94  {
95  return MakeVectorX<float>(f1, f2);
96  }
97 
99  MakeVectorXf(float f1, float f2, float f3)
100  {
101  return MakeVectorX<float>(f1, f2, f3);
102  }
103 
105  MakeVectorXf(float f1, float f2, float f3, float f4)
106  {
107  return MakeVectorX<float>(f1, f2, f3, f4);
108  }
109 
111  MakeVectorXf(float f1, float f2, float f3, float f4, float f5)
112  {
113  return MakeVectorX<float>(f1, f2, f3, f4, f5);
114  }
115 
117  MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6)
118  {
119  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6);
120  }
121 
123  MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7)
124  {
125  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7);
126  }
127 
129  MakeVectorXf(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8)
130  {
131  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8);
132  }
133 
135  MakeVectorXf(float f1,
136  float f2,
137  float f3,
138  float f4,
139  float f5,
140  float f6,
141  float f7,
142  float f8,
143  float f9)
144  {
145  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8, f9);
146  }
147 
149  MakeVectorXf(float f1,
150  float f2,
151  float f3,
152  float f4,
153  float f5,
154  float f6,
155  float f7,
156  float f8,
157  float f9,
158  float f10)
159  {
160  return MakeVectorX<float>(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10);
161  }
162 
163 
164 } // namespace armarx
armarx::MakeVectorX
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorX(std::initializer_list< ScalarType > ilist)
Definition: EigenHelpers.h:33
armarx::MakeVectorXIgnoreNarrowing
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorXIgnoreNarrowing(Ts &&... ts)
Definition: EigenHelpers.h:59
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::MakeVectorXf
Eigen::Matrix< float, Eigen::Dynamic, 1 > MakeVectorXf(std::initializer_list< float > ilist)
Definition: EigenHelpers.h:45
armarx::MakeVectorXWarnNarrowing
Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > MakeVectorXWarnNarrowing(Ts &&... ts)
Definition: EigenHelpers.h:52
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27