PermutationMatrix.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 INRIA
3  */
4 
5 #ifndef __eigenpy_decompositions_permutation_matrix_hpp__
6 #define __eigenpy_decompositions_permutation_matrix_hpp__
7 
8 #include "eigenpy/eigenpy.hpp"
10 
11 namespace eigenpy {
12 
13 template <int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime,
14  typename StorageIndex_ = int>
16  : public boost::python::def_visitor<PermutationMatrixVisitor<
17  SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_> > {
18  typedef StorageIndex_ StorageIndex;
19  typedef Eigen::PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime,
22  typedef typename PermutationMatrix::DenseMatrixType DenseMatrixType;
24  typedef Eigen::Matrix<StorageIndex, SizeAtCompileTime, 1, 0,
25  MaxSizeAtCompileTime, 1>
27 
28  template <class PyClass>
29  void visit(PyClass &cl) const {
30  cl.def(bp::init<const Eigen::DenseIndex>(bp::args("self", "size"),
31  "Default constructor"))
32  .def(bp::init<VectorIndex>(
33  bp::args("self", "indices"),
34  "The indices array has the meaning that the permutations sends "
35  "each integer i to indices[i].\n"
36  "It is your responsibility to check that the indices array that "
37  "you passes actually describes a permutation, i.e., each value "
38  "between 0 and n-1 occurs exactly once, where n is the array's "
39  "size."))
40 
41  .def(
42  "indices",
43  +[](const PermutationMatrix &self) {
44  return VectorIndex(self.indices());
45  },
46  bp::arg("self"), "The stored array representing the permutation.")
47 
48  .def("applyTranspositionOnTheLeft",
49  &PermutationMatrix::applyTranspositionOnTheLeft,
50  bp::args("self", "i", "j"),
51  "Multiplies self by the transposition (ij) on the left.",
52  bp::return_self<>())
53  .def("applyTranspositionOnTheRight",
54  &PermutationMatrix::applyTranspositionOnTheRight,
55  bp::args("self", "i", "j"),
56  "Multiplies self by the transposition (ij) on the right.",
57  bp::return_self<>())
58 
59  .def("setIdentity",
60  (void(PermutationMatrix::*)()) & PermutationMatrix::setIdentity,
61  bp::arg("self"),
62  "Sets self to be the identity permutation matrix.")
63  .def("setIdentity",
64  (void(PermutationMatrix::*)(Eigen::DenseIndex)) &
65  PermutationMatrix::setIdentity,
66  bp::args("self", "size"),
67  "Sets self to be the identity permutation matrix of given size.")
68 
69  .def("toDenseMatrix", &PermutationMatrix::toDenseMatrix,
70  bp::arg("self"),
71  "Returns a numpy array object initialized from this permutation "
72  "matrix.")
73 
74  .def(
75  "transpose",
76  +[](const PermutationMatrix &self) -> PermutationMatrix {
77  return self.transpose();
78  },
79  bp::arg("self"), "Returns the tranpose permutation matrix.")
80  .def(
81  "inverse",
82  +[](const PermutationMatrix &self) -> PermutationMatrix {
83  return self.inverse();
84  },
85  bp::arg("self"), "Returns the inverse permutation matrix.")
86 
87  .def("resize", &PermutationMatrix::resize, bp::args("self", "size"),
88  "Resizes to given size.")
89 
90  .def(bp::self * bp::self)
91  .def(EigenBaseVisitor<Self>());
92  }
93 
94  static void expose(const std::string &name) {
95  bp::class_<PermutationMatrix>(name.c_str(),
96  "Permutation matrix.\n"
97  "This class represents a permutation matrix, "
98  "internally stored as a vector of integers.",
99  bp::no_init)
101  .def(PermutationMatrixVisitor());
102  }
103 };
104 
105 } // namespace eigenpy
106 
107 #endif // ifndef __eigenpy_decompositions_permutation_matrix_hpp__
eigenpy::PermutationMatrixVisitor::expose
static void expose(const std::string &name)
Definition: PermutationMatrix.hpp:94
eigenpy::PermutationMatrixVisitor::VectorIndex
Eigen::Matrix< StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1 > VectorIndex
Definition: PermutationMatrix.hpp:26
eigenpy::PermutationMatrixVisitor::visit
void visit(PyClass &cl) const
Definition: PermutationMatrix.hpp:29
eigenpy
Definition: alignment.hpp:14
eigenpy::EigenBaseVisitor
Definition: EigenBase.hpp:13
eigenpy::PermutationMatrixVisitor::DenseMatrixType
PermutationMatrix::DenseMatrixType DenseMatrixType
Definition: PermutationMatrix.hpp:22
eigenpy::PermutationMatrixVisitor::Self
PermutationMatrix Self
Definition: PermutationMatrix.hpp:23
eigenpy::IdVisitor
Add the Python method id to retrieving a unique id for a given object exposed with Boost....
Definition: id.hpp:18
eigenpy::PermutationMatrixVisitor::StorageIndex
StorageIndex_ StorageIndex
Definition: PermutationMatrix.hpp:18
setup.name
name
Definition: setup.in.py:179
eigenpy.hpp
eigenpy::PermutationMatrixVisitor::PermutationMatrix
Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex > PermutationMatrix
Definition: PermutationMatrix.hpp:21
eigenpy::PermutationMatrixVisitor
Definition: PermutationMatrix.hpp:15
EigenBase.hpp


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45