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
339241f8
Verified
Commit
339241f8
authored
5 years ago
by
Justin Carpentier
Browse files
Options
Downloads
Patches
Plain Diff
utils: add is_approx function and expose it
parent
78e31bec
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+2
-1
2 additions, 1 deletion
CMakeLists.txt
include/eigenpy/utils/is-approx.hpp
+21
-0
21 additions, 0 deletions
include/eigenpy/utils/is-approx.hpp
python/main.cpp
+24
-0
24 additions, 0 deletions
python/main.cpp
with
47 additions
and
1 deletion
CMakeLists.txt
+
2
−
1
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
...
...
This diff is collapsed.
Click to expand it.
include/eigenpy/utils/is-approx.hpp
0 → 100644
+
21
−
0
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__
This diff is collapsed.
Click to expand it.
python/main.cpp
+
24
−
0
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
();
}
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