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
b869723e
Commit
b869723e
authored
6 years ago
by
jcarpent
Browse files
Options
Downloads
Patches
Plain Diff
[Conversion] Handle zero-size vector
parent
be1ef56b
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
include/eigenpy/map.hpp
+2
-0
2 additions, 0 deletions
include/eigenpy/map.hpp
unittest/matrix.cpp
+16
-1
16 additions, 1 deletion
unittest/matrix.cpp
unittest/python/test_matrix.py
+8
-0
8 additions, 0 deletions
unittest/python/test_matrix.py
with
26 additions
and
1 deletion
include/eigenpy/map.hpp
+
2
−
0
View file @
b869723e
...
@@ -94,6 +94,8 @@ namespace eigenpy
...
@@ -94,6 +94,8 @@ namespace eigenpy
int
rowMajor
;
int
rowMajor
;
if
(
PyArray_NDIM
(
pyArray
)
==
1
)
rowMajor
=
0
;
if
(
PyArray_NDIM
(
pyArray
)
==
1
)
rowMajor
=
0
;
else
if
(
PyArray_DIMS
(
pyArray
)[
0
]
==
0
)
rowMajor
=
0
;
// handle zero-size vector
else
if
(
PyArray_DIMS
(
pyArray
)[
1
]
==
0
)
rowMajor
=
1
;
// handle zero-size vector
else
rowMajor
=
(
PyArray_DIMS
(
pyArray
)[
0
]
>
PyArray_DIMS
(
pyArray
)[
1
])
?
0
:
1
;
else
rowMajor
=
(
PyArray_DIMS
(
pyArray
)[
0
]
>
PyArray_DIMS
(
pyArray
)[
1
])
?
0
:
1
;
assert
(
(
PyArray_DIMS
(
pyArray
)[
rowMajor
]
<
INT_MAX
)
assert
(
(
PyArray_DIMS
(
pyArray
)[
rowMajor
]
<
INT_MAX
)
...
...
This diff is collapsed.
Click to expand it.
unittest/matrix.cpp
+
16
−
1
View file @
b869723e
/*
/*
* Copyright 2014, Nicolas Mansard, LAAS-CNRS
* Copyright 2014,
2018,
Nicolas Mansard,
Justin Carpentier,
LAAS-CNRS
*
*
* This file is part of eigenpy.
* This file is part of eigenpy.
* eigenpy is free software: you can redistribute it and/or
* eigenpy is free software: you can redistribute it and/or
...
@@ -17,6 +17,18 @@
...
@@ -17,6 +17,18 @@
#include
"eigenpy/eigenpy.hpp"
#include
"eigenpy/eigenpy.hpp"
#include
<iostream>
#include
<iostream>
Eigen
::
VectorXd
emptyVector
()
{
Eigen
::
VectorXd
vec
;
vec
.
resize
(
0
);
return
vec
;
}
Eigen
::
MatrixXd
emptyMatrix
()
{
return
Eigen
::
MatrixXd
(
0
,
0
);
}
Eigen
::
MatrixXd
naturals
(
int
R
,
int
C
,
bool
verbose
)
Eigen
::
MatrixXd
naturals
(
int
R
,
int
C
,
bool
verbose
)
{
{
Eigen
::
MatrixXd
mat
(
R
,
C
);
Eigen
::
MatrixXd
mat
(
R
,
C
);
...
@@ -77,4 +89,7 @@ BOOST_PYTHON_MODULE(matrix)
...
@@ -77,4 +89,7 @@ BOOST_PYTHON_MODULE(matrix)
bp
::
def
(
"reflexV"
,
reflex
<
Eigen
::
VectorXd
>
);
bp
::
def
(
"reflexV"
,
reflex
<
Eigen
::
VectorXd
>
);
bp
::
def
(
"reflex33"
,
reflex
<
Eigen
::
Matrix3d
>
);
bp
::
def
(
"reflex33"
,
reflex
<
Eigen
::
Matrix3d
>
);
bp
::
def
(
"reflex3"
,
reflex
<
Eigen
::
Vector3d
>
);
bp
::
def
(
"reflex3"
,
reflex
<
Eigen
::
Vector3d
>
);
bp
::
def
(
"emptyVector"
,
emptyVector
);
bp
::
def
(
"emptyMatrix"
,
emptyMatrix
);
}
}
This diff is collapsed.
Click to expand it.
unittest/python/test_matrix.py
+
8
−
0
View file @
b869723e
...
@@ -5,6 +5,14 @@ import matrix as eigenpy
...
@@ -5,6 +5,14 @@ import matrix as eigenpy
verbose
=
True
verbose
=
True
if
verbose
:
print
(
"
===> From empty MatrixXd to Py
"
)
M
=
eigenpy
.
emptyMatrix
()
assert
M
.
shape
==
(
0
,
0
)
if
verbose
:
print
(
"
===> From empty VectorXd to Py
"
)
v
=
eigenpy
.
emptyVector
()
assert
v
.
shape
==
(
0
,
1
)
if
verbose
:
print
(
"
===> From MatrixXd to Py
"
)
if
verbose
:
print
(
"
===> From MatrixXd to Py
"
)
M
=
eigenpy
.
naturals
(
3
,
3
,
verbose
)
M
=
eigenpy
.
naturals
(
3
,
3
,
verbose
)
Mcheck
=
np
.
reshape
(
np
.
matrix
(
range
(
9
),
np
.
double
),[
3
,
3
])
Mcheck
=
np
.
reshape
(
np
.
matrix
(
range
(
9
),
np
.
double
),[
3
,
3
])
...
...
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