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
a6af5709
Unverified
Commit
a6af5709
authored
5 years ago
by
Justin Carpentier
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #151 from jcarpent/devel
Fix issues when compiling in Release mode
parents
d86ce438
4ba344d1
No related branches found
Branches containing commit
Tags
v2.0.0
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/eigenpy/details.hpp
+31
-93
31 additions, 93 deletions
include/eigenpy/details.hpp
include/eigenpy/utils/is-approx.hpp
+10
-4
10 additions, 4 deletions
include/eigenpy/utils/is-approx.hpp
package.xml
+1
-1
1 addition, 1 deletion
package.xml
python/main.cpp
+9
-18
9 additions, 18 deletions
python/main.cpp
with
51 additions
and
116 deletions
include/eigenpy/details.hpp
+
31
−
93
View file @
a6af5709
...
@@ -17,95 +17,6 @@
...
@@ -17,95 +17,6 @@
#include
"eigenpy/map.hpp"
#include
"eigenpy/map.hpp"
#include
"eigenpy/exception.hpp"
#include
"eigenpy/exception.hpp"
namespace
boost
{
namespace
python
{
namespace
detail
{
template
<
class
MatType
>
struct
referent_size
<
Eigen
::
MatrixBase
<
MatType
>&>
{
BOOST_STATIC_CONSTANT
(
std
::
size_t
,
value
=
sizeof
(
MatType
));
};
template
<
class
MatType
>
struct
referent_size
<
Eigen
::
EigenBase
<
MatType
>&>
{
BOOST_STATIC_CONSTANT
(
std
::
size_t
,
value
=
sizeof
(
MatType
));
};
}}}
namespace
boost
{
namespace
python
{
namespace
converter
{
template
<
class
MatType
>
struct
implicit
<
Eigen
::
MatrixBase
<
MatType
>
,
MatType
>
{
typedef
Eigen
::
MatrixBase
<
MatType
>
Source
;
typedef
MatType
Target
;
static
void
*
convertible
(
PyObject
*
obj
)
{
// Find a converter which can produce a Source instance from
// obj. The user has told us that Source can be converted to
// Target, and instantiating construct() below, ensures that
// at compile-time.
return
implicit_rvalue_convertible_from_python
(
obj
,
registered
<
Source
>::
converters
)
?
obj
:
0
;
}
static
void
construct
(
PyObject
*
obj
,
rvalue_from_python_stage1_data
*
data
)
{
void
*
storage
=
((
rvalue_from_python_storage
<
Target
>*
)
data
)
->
storage
.
bytes
;
arg_from_python
<
Source
>
get_source
(
obj
);
bool
convertible
=
get_source
.
convertible
();
BOOST_VERIFY
(
convertible
);
new
(
storage
)
Target
(
get_source
().
derived
());
// record successful construction
data
->
convertible
=
storage
;
}
};
template
<
class
MatType
>
struct
implicit
<
MatType
,
Eigen
::
MatrixBase
<
MatType
>
>
{
typedef
MatType
Source
;
typedef
Eigen
::
MatrixBase
<
MatType
>
Target
;
static
void
*
convertible
(
PyObject
*
obj
)
{
// Find a converter which can produce a Source instance from
// obj. The user has told us that Source can be converted to
// Target, and instantiating construct() below, ensures that
// at compile-time.
return
implicit_rvalue_convertible_from_python
(
obj
,
registered
<
Source
>::
converters
)
?
obj
:
0
;
}
static
void
construct
(
PyObject
*
obj
,
rvalue_from_python_stage1_data
*
data
)
{
void
*
storage
=
reinterpret_cast
<
rvalue_from_python_storage
<
Target
>*>
(
reinterpret_cast
<
void
*>
(
data
))
->
storage
.
bytes
;
arg_from_python
<
Source
>
get_source
(
obj
);
bool
convertible
=
get_source
.
convertible
();
BOOST_VERIFY
(
convertible
);
new
(
storage
)
Source
(
get_source
());
// record successful construction
data
->
convertible
=
storage
;
}
};
template
<
class
MatType
>
struct
implicit
<
MatType
,
Eigen
::
EigenBase
<
MatType
>
>
:
implicit
<
MatType
,
Eigen
::
MatrixBase
<
MatType
>
>
{};
}}}
// namespace boost::python::converter
#define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
#define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
namespace
eigenpy
namespace
eigenpy
...
@@ -692,12 +603,39 @@ namespace eigenpy
...
@@ -692,12 +603,39 @@ namespace eigenpy
// Add also conversion to Eigen::MatrixBase<MatType>
// Add also conversion to Eigen::MatrixBase<MatType>
typedef
Eigen
::
MatrixBase
<
MatType
>
MatrixBase
;
typedef
Eigen
::
MatrixBase
<
MatType
>
MatrixBase
;
// bp::implicitly_convertible<MatTypeBase,MatType>();
EigenFromPy
<
MatrixBase
>::
registration
();
bp
::
implicitly_convertible
<
MatType
,
MatrixBase
>
();
// Add also conversion to Eigen::EigenBase<MatType>
// Add also conversion to Eigen::EigenBase<MatType>
typedef
Eigen
::
EigenBase
<
MatType
>
EigenBase
;
typedef
Eigen
::
EigenBase
<
MatType
>
EigenBase
;
bp
::
implicitly_convertible
<
MatType
,
EigenBase
>
();
EigenFromPy
<
EigenBase
>::
registration
();
}
};
template
<
typename
MatType
>
struct
EigenFromPy
<
Eigen
::
MatrixBase
<
MatType
>
>
:
EigenFromPy
<
MatType
>
{
typedef
EigenFromPy
<
MatType
>
EigenFromPyDerived
;
typedef
Eigen
::
MatrixBase
<
MatType
>
Base
;
static
void
registration
()
{
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
EigenFromPy
::
convertible
),
&
EigenFromPy
::
construct
,
bp
::
type_id
<
Base
>
());
}
};
template
<
typename
MatType
>
struct
EigenFromPy
<
Eigen
::
EigenBase
<
MatType
>
>
:
EigenFromPy
<
MatType
>
{
typedef
EigenFromPy
<
MatType
>
EigenFromPyDerived
;
typedef
Eigen
::
EigenBase
<
MatType
>
Base
;
static
void
registration
()
{
bp
::
converter
::
registry
::
push_back
(
reinterpret_cast
<
void
*
(
*
)(
_object
*
)
>
(
&
EigenFromPy
::
convertible
),
&
EigenFromPy
::
construct
,
bp
::
type_id
<
Base
>
());
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
include/eigenpy/utils/is-approx.hpp
+
10
−
4
View file @
a6af5709
...
@@ -10,11 +10,17 @@
...
@@ -10,11 +10,17 @@
namespace
eigenpy
namespace
eigenpy
{
{
template
<
typename
MatrixType1
,
typename
MatrixType2
>
template
<
typename
MatrixType1
,
typename
MatrixType2
>
inline
bool
is_approx
(
const
Eigen
::
MatrixBase
<
MatrixType1
>
&
mat1
,
inline
EIGEN_DONT_INLINE
bool
is_approx
(
const
MatrixType1
&
mat1
,
const
Eigen
::
MatrixBase
<
MatrixType2
>
&
mat2
,
const
MatrixType2
&
mat2
,
const
typename
MatrixType1
::
Scalar
&
prec
=
Eigen
::
NumTraits
<
typename
MatrixType1
::
Scalar
>::
dummy_precision
()
)
const
typename
MatrixType1
::
Scalar
&
prec
)
{
{
return
mat1
.
isApprox
(
mat2
,
prec
);
return
mat1
.
derived
().
isApprox
(
mat2
.
derived
(),
prec
);
}
template
<
typename
MatrixType1
,
typename
MatrixType2
>
inline
bool
is_approx
(
const
MatrixType1
&
mat1
,
const
MatrixType2
&
mat2
)
{
return
is_approx
(
mat1
,
mat2
,
Eigen
::
NumTraits
<
typename
MatrixType1
::
Scalar
>::
dummy_precision
());
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
package.xml
+
1
−
1
View file @
a6af5709
<?xml version="1.0"?>
<?xml version="1.0"?>
<package
format=
"2"
>
<package
format=
"2"
>
<name>
eigenpy
</name>
<name>
eigenpy
</name>
<version>
1.6.13
</version>
<version>
2.0.0
</version>
<description>
Bindings between Numpy and Eigen using Boost.Python
</description>
<description>
Bindings between Numpy and Eigen using Boost.Python
</description>
<maintainer
email=
"justin.carpentier@inria.fr"
>
Justin Carpentier
</maintainer>
<maintainer
email=
"justin.carpentier@inria.fr"
>
Justin Carpentier
</maintainer>
<maintainer
email=
"wolfgang.merkt@ed.ac.uk"
>
Wolfgang Merkt
</maintainer>
<maintainer
email=
"wolfgang.merkt@ed.ac.uk"
>
Wolfgang Merkt
</maintainer>
...
...
This diff is collapsed.
Click to expand it.
python/main.cpp
+
9
−
18
View file @
a6af5709
...
@@ -17,24 +17,8 @@
...
@@ -17,24 +17,8 @@
#include
<boost/python/scope.hpp>
#include
<boost/python/scope.hpp>
#define DEFINE_IS_APPROX(MatType) \
BOOST_PYTHON_FUNCTION_OVERLOADS(is_approx_overload##MatType,eigenpy::is_approx,2,3)
#define EXPOSE_IS_APPROX(MatType) \
bp::def("is_approx", \
(bool (*)(const Eigen::MatrixBase<MatType> &, \
const Eigen::MatrixBase<MatType> &, \
const MatType::Scalar &))eigenpy::is_approx<MatType,MatType>, \
is_approx_overload##MatType(bp::args("A","B","prec"), \
"Returns True if A is approximately equal to B, within the precision determined by prec."))
using
namespace
eigenpy
;
using
namespace
eigenpy
;
DEFINE_IS_APPROX
(
MatrixXd
)
DEFINE_IS_APPROX
(
MatrixXf
)
BOOST_PYTHON_MODULE
(
eigenpy
)
BOOST_PYTHON_MODULE
(
eigenpy
)
{
{
namespace
bp
=
boost
::
python
;
namespace
bp
=
boost
::
python
;
...
@@ -62,8 +46,15 @@ BOOST_PYTHON_MODULE(eigenpy)
...
@@ -62,8 +46,15 @@ BOOST_PYTHON_MODULE(eigenpy)
{
{
using
namespace
Eigen
;
using
namespace
Eigen
;
EXPOSE_IS_APPROX
(
MatrixXd
);
bp
::
def
(
"is_approx"
,(
bool
(
*
)(
const
MatrixXd
&
,
const
MatrixXd
&
,
const
double
&
))
&
is_approx
<
MatrixXd
,
MatrixXd
>
,
EXPOSE_IS_APPROX
(
MatrixXf
);
bp
::
args
(
"A"
,
"B"
,
"prec"
),
"Returns True if A is approximately equal to B, within the precision determined by prec."
);
bp
::
def
(
"is_approx"
,(
bool
(
*
)(
const
MatrixXd
&
,
const
MatrixXd
&
))
&
is_approx
<
MatrixXd
,
MatrixXd
>
,
bp
::
args
(
"A"
,
"B"
),
"Returns True if A is approximately equal to B.."
);
// EXPOSE_IS_APPROX(MatrixXd);
// EXPOSE_IS_APPROX(MatrixXf);
}
}
exposeDecompositions
();
exposeDecompositions
();
...
...
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