15 #ifndef __Thea_MatVec_hpp__ 16 #define __Thea_MatVec_hpp__ 19 #include "MatrixFormat.hpp" 28 #include <Eigen/Geometry> 36 #else // nothing provided or THEA_COLUMN_MAJOR defined 51 #define THEA_DECL_MATRIX_TYPEDEFS(scalar, suffix) \ 52 typedef Eigen::Matrix< scalar, 2, 2, DEFAULT_MATRIX_LAYOUT | Eigen::DontAlign > Matrix2 ## suffix; \ 53 typedef Eigen::Matrix< scalar, 3, 3, DEFAULT_MATRIX_LAYOUT | Eigen::DontAlign > Matrix3 ## suffix; \ 54 typedef Eigen::Matrix< scalar, 4, 4, DEFAULT_MATRIX_LAYOUT | Eigen::DontAlign > Matrix4 ## suffix; \ 55 typedef Eigen::Matrix< scalar, 2, 1, MatrixLayout::COLUMN_MAJOR | Eigen::DontAlign > Vector2 ## suffix; \ 56 typedef Eigen::Matrix< scalar, 3, 1, MatrixLayout::COLUMN_MAJOR | Eigen::DontAlign > Vector3 ## suffix; \ 57 typedef Eigen::Matrix< scalar, 4, 1, MatrixLayout::COLUMN_MAJOR | Eigen::DontAlign > Vector4 ## suffix; \ 58 typedef Eigen::Matrix< scalar, 1, 2, MatrixLayout::ROW_MAJOR | Eigen::DontAlign > RowVector2 ## suffix; \ 59 typedef Eigen::Matrix< scalar, 1, 3, MatrixLayout::ROW_MAJOR | Eigen::DontAlign > RowVector3 ## suffix; \ 60 typedef Eigen::Matrix< scalar, 1, 4, MatrixLayout::ROW_MAJOR | Eigen::DontAlign > RowVector4 ## suffix; \ 61 typedef Eigen::Matrix< scalar, 2, Eigen::Dynamic, DEFAULT_MATRIX_LAYOUT > Matrix2X ## suffix; \ 62 typedef Eigen::Matrix< scalar, 3, Eigen::Dynamic, DEFAULT_MATRIX_LAYOUT > Matrix3X ## suffix; \ 63 typedef Eigen::Matrix< scalar, 4, Eigen::Dynamic, DEFAULT_MATRIX_LAYOUT > Matrix4X ## suffix; \ 64 typedef Eigen::Matrix< scalar, Eigen::Dynamic, 2, DEFAULT_MATRIX_LAYOUT > MatrixX2 ## suffix; \ 65 typedef Eigen::Matrix< scalar, Eigen::Dynamic, 3, DEFAULT_MATRIX_LAYOUT > MatrixX3 ## suffix; \ 66 typedef Eigen::Matrix< scalar, Eigen::Dynamic, 4, DEFAULT_MATRIX_LAYOUT > MatrixX4 ## suffix; 68 THEA_DECL_MATRIX_TYPEDEFS(Real, )
69 THEA_DECL_MATRIX_TYPEDEFS(
float, f)
70 THEA_DECL_MATRIX_TYPEDEFS(
double, d)
71 THEA_DECL_MATRIX_TYPEDEFS(
std::complex<
float>, cf)
72 THEA_DECL_MATRIX_TYPEDEFS(
std::complex<
double>, cd)
73 THEA_DECL_MATRIX_TYPEDEFS(
int, i)
75 #undef THEA_DECL_MATRIX_TYPEDEFS 80 #define THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(scalar, suffix) \ 81 typedef Eigen::Matrix< scalar, Eigen::Dynamic, Eigen::Dynamic, DEFAULT_MATRIX_LAYOUT > MatrixX ## suffix; \ 82 typedef Eigen::Matrix< scalar, Eigen::Dynamic, 1 , MatrixLayout::COLUMN_MAJOR > VectorX ## suffix; \ 83 typedef Eigen::Matrix< scalar, 1, Eigen::Dynamic, MatrixLayout::ROW_MAJOR > RowVectorX ## suffix; 85 THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(
float, f)
86 THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(
double, d)
87 THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(
std::complex<
float>, cf)
88 THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(
std::complex<
double>, cd)
89 THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS(
int, i)
91 #undef THEA_DECL_RESIZABLE_MATRIX_TYPEDEFS 107 template <
int Rows,
int Cols,
typename T = Real,
108 int Options = DEFAULT_MATRIX_LAYOUT,
109 int MaxRowsAtCompileTime = Rows,
110 int MaxColsAtCompileTime = Cols>
111 using Matrix = Eigen::Matrix<T, Rows, Cols,
112 Options | ((Options & Eigen::DontAlign) == 0 && (Rows == Eigen::Dynamic || Cols == Eigen::Dynamic)
113 ? Eigen::AutoAlign : Eigen::DontAlign),
114 MaxRowsAtCompileTime, MaxColsAtCompileTime>;
120 template <
typename T = Real,
121 int Options = DEFAULT_MATRIX_LAYOUT,
122 int MaxRowsAtCompileTime = Eigen::Dynamic,
123 int MaxColsAtCompileTime = Eigen::Dynamic>
124 using MatrixX = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime>;
140 template <
int Size,
typename T = Real,
142 int MaxRowsAtCompileTime = Size>
143 using Vector = Eigen::Matrix<T, Size, 1,
144 Options | ((Options & Eigen::DontAlign) == 0 && Size == Eigen::Dynamic
145 ? Eigen::AutoAlign : Eigen::DontAlign),
146 MaxRowsAtCompileTime, 1>;
152 template <
typename T = Real,
154 int MaxRowsAtCompileTime = Eigen::Dynamic>
155 using VectorX = Eigen::Matrix<T, Eigen::Dynamic, 1, Options, MaxRowsAtCompileTime, 1>;
171 template <
int Size,
typename T = Real,
173 int MaxColsAtCompileTime = Size>
174 using RowVector = Eigen::Matrix<T, 1, Size,
175 Options | ((Options & Eigen::DontAlign) == 0 && Size == Eigen::Dynamic
176 ? Eigen::AutoAlign : Eigen::DontAlign),
177 1, MaxColsAtCompileTime>;
183 template <
typename T = Real,
185 int MaxColsAtCompileTime = Eigen::Dynamic>
186 using RowVectorX = Eigen::Matrix<T, 1, Eigen::Dynamic, Options, 1, MaxColsAtCompileTime>;
192 #define THEA_DECL_MATRIX_MAP_TYPEDEFS(suffix) \ 193 typedef Eigen::Map< Matrix2 ## suffix > Matrix2 ## suffix ## Map; \ 194 typedef Eigen::Map< Matrix3 ## suffix > Matrix3 ## suffix ## Map; \ 195 typedef Eigen::Map< Matrix4 ## suffix > Matrix4 ## suffix ## Map; \ 196 typedef Eigen::Map< Vector2 ## suffix > Vector2 ## suffix ## Map; \ 197 typedef Eigen::Map< Vector3 ## suffix > Vector3 ## suffix ## Map; \ 198 typedef Eigen::Map< Vector4 ## suffix > Vector4 ## suffix ## Map; \ 199 typedef Eigen::Map< RowVector2 ## suffix > RowVector2 ## suffix ## Map; \ 200 typedef Eigen::Map< RowVector3 ## suffix > RowVector3 ## suffix ## Map; \ 201 typedef Eigen::Map< RowVector4 ## suffix > RowVector4 ## suffix ## Map; \ 202 typedef Eigen::Map< Matrix2X ## suffix > Matrix2X ## suffix ## Map; \ 203 typedef Eigen::Map< Matrix3X ## suffix > Matrix3X ## suffix ## Map; \ 204 typedef Eigen::Map< Matrix4X ## suffix > Matrix4X ## suffix ## Map; \ 205 typedef Eigen::Map< MatrixX2 ## suffix > MatrixX2 ## suffix ## Map; \ 206 typedef Eigen::Map< MatrixX3 ## suffix > MatrixX3 ## suffix ## Map; \ 207 typedef Eigen::Map< MatrixX4 ## suffix > MatrixX4 ## suffix ## Map; \ 209 typedef Eigen::Map< Matrix2 ## suffix const > Matrix2 ## suffix ## ConstMap; \ 210 typedef Eigen::Map< Matrix3 ## suffix const > Matrix3 ## suffix ## ConstMap; \ 211 typedef Eigen::Map< Matrix4 ## suffix const > Matrix4 ## suffix ## ConstMap; \ 212 typedef Eigen::Map< Vector2 ## suffix const > Vector2 ## suffix ## ConstMap; \ 213 typedef Eigen::Map< Vector3 ## suffix const > Vector3 ## suffix ## ConstMap; \ 214 typedef Eigen::Map< Vector4 ## suffix const > Vector4 ## suffix ## ConstMap; \ 215 typedef Eigen::Map< RowVector2 ## suffix const > RowVector2 ## suffix ## ConstMap; \ 216 typedef Eigen::Map< RowVector3 ## suffix const > RowVector3 ## suffix ## ConstMap; \ 217 typedef Eigen::Map< RowVector4 ## suffix const > RowVector4 ## suffix ## ConstMap; \ 218 typedef Eigen::Map< Matrix2X ## suffix const > Matrix2X ## suffix ## ConstMap; \ 219 typedef Eigen::Map< Matrix3X ## suffix const > Matrix3X ## suffix ## ConstMap; \ 220 typedef Eigen::Map< Matrix4X ## suffix const > Matrix4X ## suffix ## ConstMap; \ 221 typedef Eigen::Map< MatrixX2 ## suffix const > MatrixX2 ## suffix ## ConstMap; \ 222 typedef Eigen::Map< MatrixX3 ## suffix const > MatrixX3 ## suffix ## ConstMap; \ 223 typedef Eigen::Map< MatrixX4 ## suffix const > MatrixX4 ## suffix ## ConstMap; 225 THEA_DECL_MATRIX_MAP_TYPEDEFS()
226 THEA_DECL_MATRIX_MAP_TYPEDEFS(f)
227 THEA_DECL_MATRIX_MAP_TYPEDEFS(d)
228 THEA_DECL_MATRIX_MAP_TYPEDEFS(cf)
229 THEA_DECL_MATRIX_MAP_TYPEDEFS(cd)
230 THEA_DECL_MATRIX_MAP_TYPEDEFS(i)
232 #undef THEA_DECL_MATRIX_MAP_TYPEDEFS 234 #define THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(suffix) \ 235 typedef Eigen::Map< MatrixX ## suffix > MatrixX ## suffix ## Map; \ 236 typedef Eigen::Map< VectorX ## suffix > VectorX ## suffix ## Map; \ 237 typedef Eigen::Map< RowVectorX ## suffix > RowVectorX ## suffix ## Map; \ 239 typedef Eigen::Map< MatrixX ## suffix const > MatrixX ## suffix ## ConstMap; \ 240 typedef Eigen::Map< VectorX ## suffix const > VectorX ## suffix ## ConstMap; \ 241 typedef Eigen::Map< RowVectorX ## suffix const > RowVectorX ## suffix ## ConstMap; 243 THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(f)
244 THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(d)
245 THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(cf)
246 THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(cd)
247 THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS(i)
249 #undef THEA_DECL_RESIZABLE_MATRIX_MAP_TYPEDEFS 252 template <
int Rows,
int Cols,
typename T = Real,
253 int Options = DEFAULT_MATRIX_LAYOUT,
254 typename StrideType = Eigen::Stride<0, 0>,
255 int MapOptions = Eigen::Unaligned,
256 int MaxRowsAtCompileTime = Rows,
257 int MaxColsAtCompileTime = Cols >
258 using MatrixMap = Eigen::Map< Matrix<Rows, Cols, T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime>,
259 MapOptions, StrideType >;
262 template <
int Rows,
int Cols,
typename T = Real,
263 int Options = DEFAULT_MATRIX_LAYOUT,
264 typename StrideType = Eigen::Stride<0, 0>,
265 int MapOptions = Eigen::Unaligned,
266 int MaxRowsAtCompileTime = Rows,
267 int MaxColsAtCompileTime = Cols >
268 using MatrixConstMap = Eigen::Map< Matrix<Rows, Cols, T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime>
const,
269 MapOptions, StrideType >;
272 template <
int Size,
typename T = Real,
273 typename StrideType = Eigen::Stride<0, 0>,
274 int MapOptions = Eigen::Unaligned,
276 int MaxRowsAtCompileTime = Size >
277 using VectorMap = Eigen::Map< Vector<Size, T, Options, MaxRowsAtCompileTime>, MapOptions, StrideType >;
280 template <
int Size,
typename T = Real,
281 typename StrideType = Eigen::Stride<0, 0>,
282 int MapOptions = Eigen::Unaligned,
284 int MaxRowsAtCompileTime = Size >
285 using VectorConstMap = Eigen::Map< Vector<Size, T, Options, MaxRowsAtCompileTime>
const, MapOptions, StrideType >;
288 template <
int Size,
typename T = Real,
289 typename StrideType = Eigen::Stride<0, 0>,
290 int MapOptions = Eigen::Unaligned,
292 int MaxColsAtCompileTime = Size >
293 using RowVectorMap = Eigen::Map< RowVector<Size, T, Options, MaxColsAtCompileTime>, MapOptions, StrideType >;
296 template <
int Size,
typename T = Real,
297 typename StrideType = Eigen::Stride<0, 0>,
298 int MapOptions = Eigen::Unaligned,
300 int MaxColsAtCompileTime = Size >
301 using RowVectorConstMap = Eigen::Map< RowVector<Size, T, Options, MaxColsAtCompileTime>
const, MapOptions, StrideType >;
304 template <
typename T = Real,
305 int Options = DEFAULT_MATRIX_LAYOUT,
306 typename StrideType = Eigen::Stride<0, 0>,
307 int MapOptions = Eigen::Unaligned,
308 int MaxRowsAtCompileTime = Eigen::Dynamic,
309 int MaxColsAtCompileTime = Eigen::Dynamic >
310 using MatrixXMap = Eigen::Map< MatrixX<T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime>, MapOptions, StrideType >;
313 template <
typename T = Real,
314 int Options = DEFAULT_MATRIX_LAYOUT,
315 typename StrideType = Eigen::Stride<0, 0>,
316 int MapOptions = Eigen::Unaligned,
317 int MaxRowsAtCompileTime = Eigen::Dynamic,
318 int MaxColsAtCompileTime = Eigen::Dynamic >
319 using MatrixXConstMap = Eigen::Map< MatrixX<T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime>
const,
320 MapOptions, StrideType >;
323 template <
typename T = Real,
324 typename StrideType = Eigen::Stride<0, 0>,
325 int MapOptions = Eigen::Unaligned,
327 int MaxRowsAtCompileTime = Eigen::Dynamic >
328 using VectorXMap = Eigen::Map< VectorX<T, Options, MaxRowsAtCompileTime>, MapOptions, StrideType >;
331 template <
typename T = Real,
332 typename StrideType = Eigen::Stride<0, 0>,
333 int MapOptions = Eigen::Unaligned,
335 int MaxRowsAtCompileTime = Eigen::Dynamic >
336 using VectorXConstMap = Eigen::Map< VectorX<T, Options, MaxRowsAtCompileTime>
const, MapOptions, StrideType >;
339 template <
typename T = Real,
340 typename StrideType = Eigen::Stride<0, 0>,
341 int MapOptions = Eigen::Unaligned,
343 int MaxColsAtCompileTime = Eigen::Dynamic >
344 using RowVectorXMap = Eigen::Map< RowVectorX<T, Options, MaxColsAtCompileTime>, MapOptions, StrideType >;
347 template <
typename T = Real,
348 typename StrideType = Eigen::Stride<0, 0>,
349 int MapOptions = Eigen::Unaligned,
351 int MaxColsAtCompileTime = Eigen::Dynamic >
352 using RowVectorXConstMap = Eigen::Map< RowVectorX<T, Options, MaxColsAtCompileTime>
const, MapOptions, StrideType >;
359 template <
typename T = Real>
using Quaternion = Eigen::Quaternion<T>;
363 #include "MatrixUtil.hpp" Eigen::Matrix< T, Size, 1, Options|((Options &Eigen::DontAlign)==0 &&Size==Eigen::Dynamic?Eigen::AutoAlign:Eigen::DontAlign), MaxRowsAtCompileTime, 1 > Vector
General 1D dense column vector template, alias for Eigen::Matrix<T, Size, 1,...>, with a custom align...
Eigen::Map< Matrix< Rows, Cols, T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime >, MapOptions, StrideType > MatrixMap
Alias for Eigen::Map< Matrix<...> >.
Eigen::Map< RowVectorX< T, Options, MaxColsAtCompileTime >, MapOptions, StrideType > RowVectorXMap
Alias for Eigen::Map< RowVectorX<...> >.
Eigen::Quaternion< T > Quaternion
Alias for Eigen::Quaternion<...>.
Root namespace for the Thea library.
Eigen::Map< RowVector< Size, T, Options, MaxColsAtCompileTime >, MapOptions, StrideType > RowVectorMap
Alias for Eigen::Map< RowVector<...> >.
Eigen::Matrix< T, Eigen::Dynamic, 1, Options, MaxRowsAtCompileTime, 1 > VectorX
General 1D dense column vector template with dynamic resizing, alias for Eigen::Matrix<T, Eigen::Dynamic, 1,...> with a custom default layout (row or column major).
Eigen::Map< VectorX< T, Options, MaxRowsAtCompileTime >, MapOptions, StrideType > VectorXMap
Alias for Eigen::Map< VectorX<...> >.
Eigen::Map< Vector< Size, T, Options, MaxRowsAtCompileTime >, MapOptions, StrideType > VectorMap
Alias for Eigen::Map< Vector<...> >.
Eigen::Matrix< T, 1, Eigen::Dynamic, Options, 1, MaxColsAtCompileTime > RowVectorX
General 1D dense row vector template with dynamic resizing, alias for Eigen::Matrix<T, 1, Eigen::Dynamic,...> with a custom default layout (row or column major).
Eigen::Map< MatrixX< T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime >, MapOptions, StrideType > MatrixXMap
Alias for Eigen::Map< MatrixX<...> >.
Eigen::Matrix< T, 1, Size, Options|((Options &Eigen::DontAlign)==0 &&Size==Eigen::Dynamic?Eigen::AutoAlign:Eigen::DontAlign), 1, MaxColsAtCompileTime > RowVector
General 1D dense row vector template, alias for Eigen::Matrix<T, 1, Size,...>, with a custom alignmen...
Eigen::Map< MatrixX< T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > const, MapOptions, StrideType > MatrixXConstMap
Alias for Eigen::Map< MatrixX<...> const >.
Eigen::Map< RowVector< Size, T, Options, MaxColsAtCompileTime > const, MapOptions, StrideType > RowVectorConstMap
Alias for Eigen::Map< RowVector<...> const >.
Eigen::Map< Vector< Size, T, Options, MaxRowsAtCompileTime > const, MapOptions, StrideType > VectorConstMap
Alias for Eigen::Map< Vector<...> const >.
Eigen::Map< RowVectorX< T, Options, MaxColsAtCompileTime > const, MapOptions, StrideType > RowVectorXConstMap
Alias for Eigen::Map< RowVectorX<...> const >.
Eigen::Map< Matrix< Rows, Cols, T, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > const, MapOptions, StrideType > MatrixConstMap
Alias for Eigen::Map< Matrix<...> const >.
Eigen::Map< VectorX< T, Options, MaxRowsAtCompileTime > const, MapOptions, StrideType > VectorXConstMap
Alias for Eigen::Map< VectorX<...> const >.
Eigen::Matrix< T, Rows, Cols, Options|((Options &Eigen::DontAlign)==0 &&(Rows==Eigen::Dynamic||Cols==Eigen::Dynamic)?Eigen::AutoAlign:Eigen::DontAlign), MaxRowsAtCompileTime, MaxColsAtCompileTime > Matrix
General 2D dense matrix template, alias for Eigen::Matrix with a custom default layout (row or column...
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Options, MaxRowsAtCompileTime, MaxColsAtCompileTime > MatrixX
General 2D dense matrix template with dynamic resizing, alias for Eigen::Matrix with Eigen::Dynamic a...