expose-linalg.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 INRIA
3 //
4 
7 
10 
11 namespace pinocchio
12 {
13  namespace python
14  {
15  namespace bp = boost::python;
16 
17  template<typename MatrixType>
18  typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixType) inv(const Eigen::MatrixBase<MatrixType> & mat)
19  {
20  typename PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixType) res(mat.rows(), mat.cols());
21  inverse(mat, res);
22  return res;
23  }
24 
25  void exposeLinalg()
26  {
27  using namespace Eigen;
28 
29  {
30  // using the rpy scope
31  bp::scope current_scope = getOrCreatePythonNamespace("linalg");
32 
33 #ifndef PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED
34  bp::def(
35  "computeLargestEigenvector",
37  const context::MatrixXs &, const int,
38  const context::Scalar))&computeLargestEigenvector<context::MatrixXs>,
39  (bp::arg("mat"), bp::arg("max_it") = 10, bp::arg("rel_tol") = 1e-8),
40  "Compute the lagest eigenvector of a given matrix according to a given eigenvector "
41  "estimate.");
42 
43  bp::def(
44  "retrieveLargestEigenvalue", &retrieveLargestEigenvalue<context::MatrixXs>,
45  bp::arg("eigenvector"),
46  "Compute the lagest eigenvalue of a given matrix. This is taking the eigenvector "
47  "computed by the function computeLargestEigenvector.");
48 #endif // PINOCCHIO_PYTHON_SKIP_CASADI_UNSUPPORTED
49 
50  bp::def("inv", &inv<context::MatrixXs>, "Computes the inverse of a matrix.");
51 #ifdef PINOCCHIO_PYTHON_INTERFACE_MAIN_MODULE
52  bp::def(
53  "inv", &inv<Matrix<long double, Dynamic, Dynamic>>, "Computes the inverse of a matrix.");
54 #endif
55  }
56  }
57 
58  } // namespace python
59 } // namespace pinocchio
boost::python
Eigen
pinocchio::python::PINOCCHIO_EIGEN_PLAIN_TYPE
PINOCCHIO_EIGEN_PLAIN_TYPE(MatrixType) inv(const Eigen
Definition: expose-linalg.cpp:18
pinocchio::python::getOrCreatePythonNamespace
boost::python::object getOrCreatePythonNamespace(const std::string &submodule_name)
Helper to create or simply return an existing namespace in Python.
Definition: namespace.hpp:34
pinocchio::context::VectorXs
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, Options > VectorXs
Definition: context/generic.hpp:47
matrix.hpp
pinocchio::context::MatrixXs
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic, Options > MatrixXs
Definition: context/generic.hpp:49
python
mat
mat
pinocchio::inverse
void inverse(const Eigen::MatrixBase< MatrixIn > &m_in, const Eigen::MatrixBase< MatrixOut > &dest)
Definition: math/matrix.hpp:273
fwd.hpp
pinocchio::python::exposeLinalg
void exposeLinalg()
Definition: expose-linalg.cpp:25
eigenvalues.hpp
pinocchio::python::res
ReturnType res
Definition: bindings/python/spatial/explog.hpp:68
pinocchio::python::context::Scalar
PINOCCHIO_PYTHON_SCALAR_TYPE Scalar
Definition: bindings/python/context/generic.hpp:37
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
namespace.hpp


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:09