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
b95cb9bc
Verified
Commit
b95cb9bc
authored
5 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
core: add NumpyAllocator
parent
1fb4cf40
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
CMakeLists.txt
+2
-1
2 additions, 1 deletion
CMakeLists.txt
include/eigenpy/numpy-allocator.hpp
+76
-0
76 additions, 0 deletions
include/eigenpy/numpy-allocator.hpp
with
78 additions
and
1 deletion
CMakeLists.txt
+
2
−
1
View file @
b95cb9bc
...
@@ -113,8 +113,9 @@ SET(${PROJECT_NAME}_HEADERS
...
@@ -113,8 +113,9 @@ SET(${PROJECT_NAME}_HEADERS
include/eigenpy/geometry.hpp
include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/geometry-conversion.hpp
include/eigenpy/memory.hpp
include/eigenpy/memory.hpp
include/eigenpy/numpy-type.hpp
include/eigenpy/numpy.hpp
include/eigenpy/numpy.hpp
include/eigenpy/numpy-allocator.hpp
include/eigenpy/numpy-type.hpp
include/eigenpy/registration.hpp
include/eigenpy/registration.hpp
include/eigenpy/angle-axis.hpp
include/eigenpy/angle-axis.hpp
include/eigenpy/quaternion.hpp
include/eigenpy/quaternion.hpp
...
...
This diff is collapsed.
Click to expand it.
include/eigenpy/numpy-allocator.hpp
0 → 100644
+
76
−
0
View file @
b95cb9bc
/*
* Copyright 2020 INRIA
*/
#ifndef __eigenpy_numpy_allocator_hpp__
#define __eigenpy_numpy_allocator_hpp__
#include
"eigenpy/fwd.hpp"
#include
"eigenpy/numpy-type.hpp"
#include
"eigenpy/eigen-allocator.hpp"
namespace
eigenpy
{
template
<
typename
MatType
>
struct
NumpyAllocator
{
template
<
typename
SimilarMatrixType
>
static
PyArrayObject
*
allocate
(
const
Eigen
::
MatrixBase
<
SimilarMatrixType
>
&
mat
,
npy_intp
nd
,
npy_intp
*
shape
)
{
typedef
typename
SimilarMatrixType
::
Scalar
Scalar
;
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
nd
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
);
// Copy data
EigenAllocator
<
SimilarMatrixType
>::
copy
(
mat
,
pyArray
);
return
pyArray
;
}
};
template
<
typename
MatType
>
struct
NumpyAllocator
<
MatType
&>
{
template
<
typename
SimilarMatrixType
>
static
PyArrayObject
*
allocate
(
Eigen
::
PlainObjectBase
<
SimilarMatrixType
>
&
mat
,
npy_intp
nd
,
npy_intp
*
shape
)
{
typedef
typename
SimilarMatrixType
::
Scalar
Scalar
;
enum
{
NPY_ARRAY_MEMORY_CONTIGUOUS
=
SimilarMatrixType
::
IsRowMajor
?
NPY_ARRAY_CARRAY
:
NPY_ARRAY_FARRAY
};
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
PyArray_New
(
&
PyArray_Type
,
nd
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
,
NULL
,
mat
.
data
(),
0
,
NPY_ARRAY_MEMORY_CONTIGUOUS
|
NPY_ARRAY_ALIGNED
,
NULL
);
return
pyArray
;
}
};
template
<
typename
MatType
>
struct
NumpyAllocator
<
const
MatType
&>
{
template
<
typename
SimilarMatrixType
>
static
PyArrayObject
*
allocate
(
const
Eigen
::
PlainObjectBase
<
SimilarMatrixType
>
&
mat
,
npy_intp
nd
,
npy_intp
*
shape
)
{
typedef
typename
SimilarMatrixType
::
Scalar
Scalar
;
enum
{
NPY_ARRAY_MEMORY_CONTIGUOUS_RO
=
SimilarMatrixType
::
IsRowMajor
?
NPY_ARRAY_CARRAY_RO
:
NPY_ARRAY_FARRAY_RO
};
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
PyArray_New
(
&
PyArray_Type
,
nd
,
shape
,
NumpyEquivalentType
<
Scalar
>::
type_code
,
NULL
,
mat
.
data
(),
0
,
NPY_ARRAY_MEMORY_CONTIGUOUS_RO
|
NPY_ARRAY_ALIGNED
,
NULL
);
return
pyArray
;
}
};
}
#endif // ifndef __eigenpy_numpy_allocator_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