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
f29fb6d2
Verified
Commit
f29fb6d2
authored
5 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
core: move EigenToPy to a dedicated file
parent
610feea9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
include/eigenpy/details.hpp
+1
-40
1 addition, 40 deletions
include/eigenpy/details.hpp
include/eigenpy/eigen-to-python.hpp
+52
-0
52 additions, 0 deletions
include/eigenpy/eigen-to-python.hpp
with
54 additions
and
40 deletions
CMakeLists.txt
+
1
−
0
View file @
f29fb6d2
...
@@ -107,6 +107,7 @@ SET(${PROJECT_NAME}_HEADERS
...
@@ -107,6 +107,7 @@ SET(${PROJECT_NAME}_HEADERS
include/eigenpy/details.hpp
include/eigenpy/details.hpp
include/eigenpy/fwd.hpp
include/eigenpy/fwd.hpp
include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-allocator.hpp
include/eigenpy/eigen-to-python.hpp
include/eigenpy/map.hpp
include/eigenpy/map.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/geometry-conversion.hpp
...
...
This diff is collapsed.
Click to expand it.
include/eigenpy/details.hpp
+
1
−
40
View file @
f29fb6d2
...
@@ -17,12 +17,12 @@
...
@@ -17,12 +17,12 @@
#include
"eigenpy/eigenpy.hpp"
#include
"eigenpy/eigenpy.hpp"
#include
"eigenpy/eigen-allocator.hpp"
#include
"eigenpy/eigen-allocator.hpp"
#include
"eigenpy/eigen-to-python.hpp"
#include
"eigenpy/registration.hpp"
#include
"eigenpy/registration.hpp"
#include
"eigenpy/map.hpp"
#include
"eigenpy/map.hpp"
#include
"eigenpy/exception.hpp"
#include
"eigenpy/exception.hpp"
#define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
namespace
boost
{
namespace
python
{
namespace
detail
{
namespace
boost
{
namespace
python
{
namespace
detail
{
...
@@ -59,45 +59,7 @@ namespace boost { namespace python { namespace detail {
...
@@ -59,45 +59,7 @@ namespace boost { namespace python { namespace detail {
namespace
eigenpy
namespace
eigenpy
{
{
namespace
bp
=
boost
::
python
;
/* --- TO PYTHON -------------------------------------------------------------- */
template
<
typename
MatType
>
struct
EigenToPy
{
static
PyObject
*
convert
(
MatType
const
&
mat
)
{
typedef
typename
MatType
::
Scalar
Scalar
;
assert
(
(
mat
.
rows
()
<
INT_MAX
)
&&
(
mat
.
cols
()
<
INT_MAX
)
&&
"Matrix range larger than int ... should never happen."
);
const
npy_intp
R
=
(
npy_intp
)
mat
.
rows
(),
C
=
(
npy_intp
)
mat
.
cols
();
PyArrayObject
*
pyArray
;
// Allocate Python memory
std
::
cout
<<
"basic convert"
<<
std
::
endl
;
if
(
(
((
!
(
C
==
1
)
!=
!
(
R
==
1
))
&&
!
MatType
::
IsVectorAtCompileTime
)
||
MatType
::
IsVectorAtCompileTime
)
&&
NumpyType
::
getType
()
==
ARRAY_TYPE
)
// Handle array with a single dimension
{
std
::
cout
<<
"mat1
\n
"
<<
mat
<<
std
::
endl
;
npy_intp
shape
[
1
]
=
{
C
==
1
?
R
:
C
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
1
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
);
}
else
{
npy_intp
shape
[
2
]
=
{
R
,
C
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
2
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
);
}
// Copy data
EigenAllocator
<
MatType
>::
copy
(
mat
,
pyArray
);
// Create an instance (either np.array or np.matrix)
return
NumpyType
::
getInstance
().
make
(
pyArray
).
ptr
();
}
};
/* --- FROM PYTHON ------------------------------------------------------------ */
/* --- FROM PYTHON ------------------------------------------------------------ */
...
@@ -341,7 +303,6 @@ namespace eigenpy
...
@@ -341,7 +303,6 @@ namespace eigenpy
&
EigenFromPy
<
MatType
>::
construct
,
bp
::
type_id
<
MatType
>
());
&
EigenFromPy
<
MatType
>::
construct
,
bp
::
type_id
<
MatType
>
());
}
}
};
};
#endif
template
<
typename
MatType
,
typename
EigenEquivalentType
>
template
<
typename
MatType
,
typename
EigenEquivalentType
>
...
...
This diff is collapsed.
Click to expand it.
include/eigenpy/eigen-to-python.hpp
0 → 100644
+
52
−
0
View file @
f29fb6d2
//
// Copyright (c) 2014-2020 CNRS INRIA
//
#ifndef __eigenpy_eigen_to_python_hpp__
#define __eigenpy_eigen_to_python_hpp__
#include
"eigenpy/fwd.hpp"
#include
"eigenpy/numpy-type.hpp"
#include
"eigenpy/eigen-allocator.hpp"
namespace
eigenpy
{
namespace
bp
=
boost
::
python
;
template
<
typename
MatType
>
struct
EigenToPy
{
static
PyObject
*
convert
(
MatType
const
&
mat
)
{
typedef
typename
MatType
::
Scalar
Scalar
;
assert
(
(
mat
.
rows
()
<
INT_MAX
)
&&
(
mat
.
cols
()
<
INT_MAX
)
&&
"Matrix range larger than int ... should never happen."
);
const
npy_intp
R
=
(
npy_intp
)
mat
.
rows
(),
C
=
(
npy_intp
)
mat
.
cols
();
PyArrayObject
*
pyArray
;
// Allocate Python memory
if
(
(
((
!
(
C
==
1
)
!=
!
(
R
==
1
))
&&
!
MatType
::
IsVectorAtCompileTime
)
||
MatType
::
IsVectorAtCompileTime
)
&&
NumpyType
::
getType
()
==
ARRAY_TYPE
)
// Handle array with a single dimension
{
npy_intp
shape
[
1
]
=
{
C
==
1
?
R
:
C
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
1
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
);
}
else
{
npy_intp
shape
[
2
]
=
{
R
,
C
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
2
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
);
}
// Copy data
EigenAllocator
<
MatType
>::
copy
(
mat
,
pyArray
);
// Create an instance (either np.array or np.matrix)
return
NumpyType
::
getInstance
().
make
(
pyArray
).
ptr
();
}
};
}
#endif // __eigenpy_eigen_to_python_hpp__
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