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
aacf9982
Unverified
Commit
aacf9982
authored
5 years ago
by
Justin Carpentier
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #64 from jcarpent/devel
core: fix dimensions of vecrtor for Array conversion
parents
25addde4
8cf80abd
Branches
Branches containing commit
Tags
v1.5.2
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/eigenpy/details.hpp
+32
-7
32 additions, 7 deletions
include/eigenpy/details.hpp
with
32 additions
and
7 deletions
include/eigenpy/details.hpp
+
32
−
7
View file @
aacf9982
...
...
@@ -44,6 +44,12 @@ namespace eigenpy
namespace
bp
=
boost
::
python
;
enum
NP_TYPE
{
MATRIX_TYPE
,
ARRAY_TYPE
};
struct
NumpyType
{
...
...
@@ -75,19 +81,26 @@ namespace eigenpy
{
PyTypeObject
*
obj_type
=
PyType_Check
(
obj
.
ptr
())
?
reinterpret_cast
<
PyTypeObject
*>
(
obj
.
ptr
())
:
obj
.
ptr
()
->
ob_type
;
if
(
PyType_IsSubtype
(
obj_type
,
getInstance
().
NumpyMatrixType
))
getInstance
().
CurrentNumpyType
=
getInstance
().
NumpyMatrix
Object
;
switchTo
NumpyMatrix
()
;
else
if
(
PyType_IsSubtype
(
obj_type
,
getInstance
().
NumpyArrayType
))
getInstance
().
CurrentNumpyType
=
getInstance
().
NumpyArray
Object
;
switchTo
NumpyArray
()
;
}
static
void
switchToNumpyArray
()
{
getInstance
().
CurrentNumpyType
=
getInstance
().
NumpyArrayObject
;
getInstance
().
np_type
=
ARRAY_TYPE
;
}
static
void
switchToNumpyMatrix
()
{
getInstance
().
CurrentNumpyType
=
getInstance
().
NumpyMatrixObject
;
getInstance
().
np_type
=
MATRIX_TYPE
;
}
static
NP_TYPE
getType
()
{
return
getInstance
().
np_type
;
}
protected
:
...
...
@@ -117,8 +130,12 @@ namespace eigenpy
bp
::
object
NumpyMatrixObject
;
PyTypeObject
*
NumpyMatrixType
;
//bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
bp
::
object
NumpyArrayObject
;
PyTypeObject
*
NumpyArrayType
;
static
NP_TYPE
np_type
;
};
NP_TYPE
NumpyType
::
np_type
=
MATRIX_TYPE
;
template
<
typename
MatType
>
struct
EigenObjectAllocator
{
...
...
@@ -189,7 +206,6 @@ namespace eigenpy
}
};
#endif
/* --- TO PYTHON -------------------------------------------------------------- */
template
<
typename
MatType
>
struct
EigenToPy
...
...
@@ -201,12 +217,21 @@ namespace eigenpy
&&
"Matrix range larger than int ... should never happen."
);
const
int
R
=
(
int
)
mat
.
rows
(),
C
=
(
int
)
mat
.
cols
();
npy_intp
shape
[
2
]
=
{
R
,
C
};
PyArrayObject
*
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
2
,
shape
,
NumpyEquivalentType
<
T
>::
type_code
);
PyArrayObject
*
pyArray
;
if
(
C
==
1
&&
NumpyType
::
getType
()
==
ARRAY_TYPE
)
{
npy_intp
shape
[
1
]
=
{
R
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
1
,
shape
,
NumpyEquivalentType
<
T
>::
type_code
);
}
else
{
npy_intp
shape
[
2
]
=
{
R
,
C
};
pyArray
=
(
PyArrayObject
*
)
PyArray_SimpleNew
(
2
,
shape
,
NumpyEquivalentType
<
T
>::
type_code
);
}
EigenObjectAllocator
<
MatType
>::
convert
(
mat
,
pyArray
);
return
NumpyType
::
getInstance
().
make
(
pyArray
).
ptr
();
}
};
...
...
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