Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
339241f8
Verified
Commit
339241f8
authored
Jan 29, 2020
by
Justin Carpentier
Browse files
utils: add is_approx function and expose it
parent
78e31bec
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
339241f8
#
# Copyright (c) 2014-2019 CNRS
# Copyright (c) 2018-20
19
INRIA
# Copyright (c) 2018-20
20
INRIA
#
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.6
)
...
...
@@ -73,6 +73,7 @@ SEARCH_FOR_BOOST()
# ----------------------------------------------------
SET
(
${
PROJECT_NAME
}
_UTILS_HEADERS
include/eigenpy/utils/scalar-name.hpp
include/eigenpy/utils/is-approx.hpp
)
SET
(
${
PROJECT_NAME
}
_SOLVERS_HEADERS
...
...
include/eigenpy/utils/is-approx.hpp
0 → 100644
View file @
339241f8
/*
* Copyright 2020 INRIA
*/
#ifndef __eigenpy_utils_scalar_is_approx_hpp__
#define __eigenpy_utils_scalar_is_approx_hpp__
#include
<Eigen/Core>
namespace
eigenpy
{
template
<
typename
MatrixType1
,
typename
MatrixType2
>
inline
bool
is_approx
(
const
Eigen
::
MatrixBase
<
MatrixType1
>
&
mat1
,
const
Eigen
::
MatrixBase
<
MatrixType2
>
&
mat2
,
const
typename
MatrixType1
::
Scalar
&
prec
=
Eigen
::
NumTraits
<
typename
MatrixType1
::
Scalar
>::
dummy_precision
())
{
return
mat1
.
isApprox
(
mat2
,
prec
);
}
}
#endif // ifndef __eigenpy_utils_scalar_is_approx_hpp__
python/main.cpp
View file @
339241f8
...
...
@@ -13,10 +13,28 @@
#include
"eigenpy/solvers/preconditioners.hpp"
#include
"eigenpy/decompositions/decompositions.hpp"
#include
"eigenpy/utils/is-approx.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
;
DEFINE_IS_APPROX
(
MatrixXd
)
DEFINE_IS_APPROX
(
MatrixXf
)
BOOST_PYTHON_MODULE
(
eigenpy
)
{
namespace
bp
=
boost
::
python
;
...
...
@@ -42,5 +60,11 @@ BOOST_PYTHON_MODULE(eigenpy)
register_symbolic_link_to_registered_type
<
Eigen
::
ComputationInfo
>
();
}
{
using
namespace
Eigen
;
EXPOSE_IS_APPROX
(
MatrixXd
);
EXPOSE_IS_APPROX
(
MatrixXf
);
}
exposeDecompositions
();
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment