5 #ifndef __eigenpy_decompositions_permutation_matrix_hpp__
6 #define __eigenpy_decompositions_permutation_matrix_hpp__
13 template <
int SizeAtCompileTime,
int MaxSizeAtCompileTime = SizeAtCompileTime,
14 typename StorageIndex_ =
int>
16 :
public boost::python::def_visitor<PermutationMatrixVisitor<
17 SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_> > {
19 typedef Eigen::PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime,
24 typedef Eigen::Matrix<
StorageIndex, SizeAtCompileTime, 1, 0,
25 MaxSizeAtCompileTime, 1>
28 template <
class PyClass>
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 "
46 bp::arg(
"self"),
"The stored array representing the permutation.")
48 .def(
"applyTranspositionOnTheLeft",
49 &PermutationMatrix::applyTranspositionOnTheLeft,
50 bp::args(
"self",
"i",
"j"),
51 "Multiplies self by the transposition (ij) on the left.",
53 .def(
"applyTranspositionOnTheRight",
54 &PermutationMatrix::applyTranspositionOnTheRight,
55 bp::args(
"self",
"i",
"j"),
56 "Multiplies self by the transposition (ij) on the right.",
62 "Sets self to be the identity permutation matrix.")
65 PermutationMatrix::setIdentity,
66 bp::args(
"self",
"size"),
67 "Sets self to be the identity permutation matrix of given size.")
69 .def(
"toDenseMatrix", &PermutationMatrix::toDenseMatrix,
71 "Returns a numpy array object initialized from this permutation "
77 return self.transpose();
79 bp::arg(
"self"),
"Returns the tranpose permutation matrix.")
83 return self.inverse();
85 bp::arg(
"self"),
"Returns the inverse permutation matrix.")
87 .def(
"resize", &PermutationMatrix::resize, bp::args(
"self",
"size"),
88 "Resizes to given size.")
90 .def(bp::self * bp::self)
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.",
107 #endif // ifndef __eigenpy_decompositions_permutation_matrix_hpp__