MRPT  2.0.2
CMatrixFixed_impl.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/CMatrixFixed.h>
12 #include <Eigen/Dense>
13 
14 namespace mrpt::math
15 {
16 template <typename T, std::size_t ROWS, std::size_t COLS>
18 {
19  CMatrixFixed<float, ROWS, COLS> r(rows(), cols());
20  r.asEigen() = asEigen().template cast<float>();
21  return r;
22 }
23 
24 template <typename T, std::size_t ROWS, std::size_t COLS>
26  const
27 {
28  CMatrixFixed<double, ROWS, COLS> r(rows(), cols());
29  r.asEigen() = asEigen().template cast<double>();
30  return r;
31 }
32 
33 template <typename T, std::size_t ROWS, std::size_t COLS>
35  const CMatrixFixed<T, ROWS, 1>& b) const
36 {
37  if constexpr (ROWS == COLS)
38  {
39  auto ret = CMatrixFixed<T, ROWS, 1>(asEigen().llt().solve(b.asEigen()));
40  return ret;
41  }
42  else
43  {
44  throw std::invalid_argument(
45  "llt_solve(): only available for square matrices.");
46  }
47 }
48 template <typename T, std::size_t ROWS, std::size_t COLS>
50  const CMatrixFixed<T, ROWS, 1>& b) const
51 {
52  if constexpr (ROWS == COLS)
53  {
54  auto ret = CMatrixFixed<T, ROWS, 1>(asEigen().lu().solve(b.asEigen()));
55  return ret;
56  }
57  else
58  {
59  throw std::invalid_argument(
60  "lu_solve(): only available for square matrices.");
61  }
62 }
63 
64 } // namespace mrpt::math
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
CMatrixFixed< T, ROWS, 1 > llt_solve(const CMatrixFixed< T, ROWS, 1 > &b) const
Solves the linear system Ax=b, returns x, with A this symmetric matrix.
This base provides a set of functions for maths stuff.
CMatrixFixed< T, ROWS, 1 > lu_solve(const CMatrixFixed< T, ROWS, 1 > &b) const
Solves the linear system Ax=b, returns x, with A this asymmetric matrix.
CMatrixFixed< float, ROWS, COLS > cast_float() const
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
Definition: CMatrixFixed.h:251
CMatrixFixed< double, ROWS, COLS > cast_double() const



Page generated by Doxygen 1.8.14 for MRPT 2.0.2 Git: 9b4fd2465 Mon May 4 16:59:08 2020 +0200 at lun may 4 17:26:07 CEST 2020