MRPT  2.0.3
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
mrpt::math::CMatrixFixed::cast_double
CMatrixFixed< double, ROWS, COLS > cast_double() const
Definition: CMatrixFixed_impl.h:25
mrpt::math::CMatrixFixed::cast_float
CMatrixFixed< float, ROWS, COLS > cast_float() const
Definition: CMatrixFixed_impl.h:17
CMatrixFixed.h
mrpt::math::CMatrixFixed::llt_solve
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.
Definition: CMatrixFixed_impl.h:34
mrpt::math::CMatrixFixed
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
mrpt::math::CMatrixFixed::lu_solve
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.
Definition: CMatrixFixed_impl.h:49
mrpt::math::CMatrixFixed::asEigen
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object
Definition: CMatrixFixed.h:251
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:11



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020