Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
eigenpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
eigenpy
Commits
52f88cc8
Commit
52f88cc8
authored
1 year ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
decompositions: expose PermutationMatrix
parent
b8727f20
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/eigenpy/decompositions/PermutationMatrix.hpp
+106
-0
106 additions, 0 deletions
include/eigenpy/decompositions/PermutationMatrix.hpp
src/decompositions/decompositions.cpp
+3
-0
3 additions, 0 deletions
src/decompositions/decompositions.cpp
with
109 additions
and
0 deletions
include/eigenpy/decompositions/PermutationMatrix.hpp
0 → 100644
+
106
−
0
View file @
52f88cc8
/*
* Copyright 2024 INRIA
*/
#ifndef __eigenpy_decomposition_permutation_matrix_hpp__
#define __eigenpy_decomposition_permutation_matrix_hpp__
#include
"eigenpy/eigenpy.hpp"
#include
"eigenpy/eigen/EigenBase.hpp"
namespace
eigenpy
{
template
<
int
SizeAtCompileTime
,
int
MaxSizeAtCompileTime
=
SizeAtCompileTime
,
typename
StorageIndex_
=
EIGEN_DEFAULT_DENSE_INDEX_TYPE
>
struct
PermutationMatrixVisitor
:
public
boost
::
python
::
def_visitor
<
PermutationMatrixVisitor
<
SizeAtCompileTime
,
MaxSizeAtCompileTime
,
StorageIndex_
>
>
{
typedef
StorageIndex_
StorageIndex
;
typedef
Eigen
::
PermutationMatrix
<
SizeAtCompileTime
,
MaxSizeAtCompileTime
,
StorageIndex
>
PermutationMatrix
;
typedef
typename
PermutationMatrix
::
DenseMatrixType
DenseMatrixType
;
typedef
PermutationMatrix
Self
;
typedef
Eigen
::
Matrix
<
StorageIndex
,
SizeAtCompileTime
,
1
,
0
,
MaxSizeAtCompileTime
,
1
>
VectorIndex
;
template
<
class
PyClass
>
void
visit
(
PyClass
&
cl
)
const
{
cl
.
def
(
bp
::
init
<
const
Eigen
::
DenseIndex
>
(
bp
::
args
(
"self"
,
"size"
),
"Default constructor"
))
.
def
(
bp
::
init
<
VectorIndex
>
(
bp
::
args
(
"self"
,
"indices"
),
"The indices array has the meaning that the permutations sends "
"each integer i to indices[i].
\n
"
"It is your responsibility to check that the indices array that "
"you passes actually describes a permutation, i.e., each value "
"between 0 and n-1 occurs exactly once, where n is the array's "
"size."
))
.
def
(
"indices"
,
+
[](
const
PermutationMatrix
&
self
)
{
return
VectorIndex
(
self
.
indices
());
},
bp
::
arg
(
"self"
),
"The stored array representing the permutation."
)
.
def
(
"applyTranspositionOnTheLeft"
,
&
PermutationMatrix
::
applyTranspositionOnTheLeft
,
bp
::
args
(
"self"
,
"i"
,
"j"
),
"Multiplies self by the transposition (ij) on the left."
,
bp
::
return_self
<>
())
.
def
(
"applyTranspositionOnTheRight"
,
&
PermutationMatrix
::
applyTranspositionOnTheRight
,
bp
::
args
(
"self"
,
"i"
,
"j"
),
"Multiplies self by the transposition (ij) on the right."
,
bp
::
return_self
<>
())
.
def
(
"setIdentity"
,
(
void
(
PermutationMatrix
::*
)())
&
PermutationMatrix
::
setIdentity
,
bp
::
arg
(
"self"
),
"Sets self to be the identity permutation matrix."
)
.
def
(
"setIdentity"
,
(
void
(
PermutationMatrix
::*
)(
Eigen
::
DenseIndex
))
&
PermutationMatrix
::
setIdentity
,
bp
::
args
(
"self"
,
"size"
),
"Sets self to be the identity permutation matrix of given size."
)
.
def
(
"toDenseMatrix"
,
&
PermutationMatrix
::
toDenseMatrix
,
bp
::
arg
(
"self"
),
"Returns a numpy array object initialized from this permutation "
"matrix."
)
.
def
(
"transpose"
,
+
[](
const
PermutationMatrix
&
self
)
->
PermutationMatrix
{
return
self
.
transpose
();
},
bp
::
arg
(
"self"
),
"Returns the tranpose permutation matrix."
)
.
def
(
"inverse"
,
+
[](
const
PermutationMatrix
&
self
)
->
PermutationMatrix
{
return
self
.
inverse
();
},
bp
::
arg
(
"self"
),
"Returns the inverse permutation matrix."
)
.
def
(
"resize"
,
&
PermutationMatrix
::
resize
,
bp
::
args
(
"self"
,
"size"
),
"Resizes to given size."
)
.
def
(
bp
::
self
*
bp
::
self
)
.
def
(
EigenBaseVisitor
<
Self
>
());
}
static
void
expose
(
const
std
::
string
&
name
)
{
bp
::
class_
<
PermutationMatrix
>
(
name
.
c_str
(),
"Permutation matrix.
\n
"
"This class represents a permutation matrix, "
"internally stored as a vector of integers."
,
bp
::
no_init
)
.
def
(
PermutationMatrixVisitor
());
}
};
}
// namespace eigenpy
#endif // ifndef __eigenpy_decomposition_permutation_matrix_hpp__
This diff is collapsed.
Click to expand it.
src/decompositions/decompositions.cpp
+
3
−
0
View file @
52f88cc8
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include
"eigenpy/decompositions/EigenSolver.hpp"
#include
"eigenpy/decompositions/EigenSolver.hpp"
#include
"eigenpy/decompositions/LDLT.hpp"
#include
"eigenpy/decompositions/LDLT.hpp"
#include
"eigenpy/decompositions/LLT.hpp"
#include
"eigenpy/decompositions/LLT.hpp"
#include
"eigenpy/decompositions/PermutationMatrix.hpp"
#include
"eigenpy/decompositions/sparse/LLT.hpp"
#include
"eigenpy/decompositions/sparse/LLT.hpp"
#include
"eigenpy/decompositions/sparse/LDLT.hpp"
#include
"eigenpy/decompositions/sparse/LDLT.hpp"
#include
"eigenpy/decompositions/SelfAdjointEigenSolver.hpp"
#include
"eigenpy/decompositions/SelfAdjointEigenSolver.hpp"
...
@@ -45,5 +46,7 @@ void exposeDecompositions() {
...
@@ -45,5 +46,7 @@ void exposeDecompositions() {
SimplicialLLTVisitor
<
ColMajorSparseMatrix
>::
expose
(
"SimplicialLLT"
);
SimplicialLLTVisitor
<
ColMajorSparseMatrix
>::
expose
(
"SimplicialLLT"
);
SimplicialLDLTVisitor
<
ColMajorSparseMatrix
>::
expose
(
"SimplicialLDLT"
);
SimplicialLDLTVisitor
<
ColMajorSparseMatrix
>::
expose
(
"SimplicialLDLT"
);
}
}
PermutationMatrixVisitor
<
Eigen
::
Dynamic
>::
expose
(
"PermutationMatrix"
);
}
}
}
// namespace eigenpy
}
// namespace eigenpy
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment