Skip to content
GitLab
Menu
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
pinocchio
Commits
2bcdd4ef
Verified
Commit
2bcdd4ef
authored
Oct 07, 2019
by
Justin Carpentier
Browse files
test/tensor: add test of Eigen::Tensor
parent
60f3750d
Changes
2
Hide whitespace changes
Inline
Side-by-side
unittest/CMakeLists.txt
View file @
2bcdd4ef
...
@@ -43,6 +43,7 @@ ENDMACRO(ADD_PINOCCHIO_UNIT_TEST)
...
@@ -43,6 +43,7 @@ ENDMACRO(ADD_PINOCCHIO_UNIT_TEST)
# Math components
# Math components
ADD_PINOCCHIO_UNIT_TEST
(
eigen-basic-op
)
ADD_PINOCCHIO_UNIT_TEST
(
eigen-basic-op
)
ADD_PINOCCHIO_UNIT_TEST
(
eigen-tensor
)
ADD_PINOCCHIO_UNIT_TEST
(
sincos
)
ADD_PINOCCHIO_UNIT_TEST
(
sincos
)
ADD_PINOCCHIO_UNIT_TEST
(
quaternion
)
ADD_PINOCCHIO_UNIT_TEST
(
quaternion
)
ADD_PINOCCHIO_UNIT_TEST
(
rotation
)
ADD_PINOCCHIO_UNIT_TEST
(
rotation
)
...
...
unittest/eigen-tensor.cpp
0 → 100644
View file @
2bcdd4ef
//
// Copyright (c) 2019 INRIA
//
#include <Eigen/Core>
#include "pinocchio/multibody/model.hpp"
#include <boost/test/unit_test.hpp>
#include <boost/utility/binary.hpp>
#include <unsupported/Eigen/CXX11/Tensor>
#include <iostream>
BOOST_AUTO_TEST_SUITE
(
BOOST_TEST_MODULE
)
BOOST_AUTO_TEST_CASE
(
test_emulate_tensors
)
{
typedef
Eigen
::
Tensor
<
double
,
3
>
Tensor
;
const
Eigen
::
DenseIndex
x_dim
=
6
,
y_dim
=
20
,
z_dim
=
20
;
Tensor
tensor1
(
x_dim
,
y_dim
,
z_dim
);
BOOST_CHECK
(
tensor1
.
size
()
==
x_dim
*
y_dim
*
z_dim
);
BOOST_CHECK
(
tensor1
.
dimension
(
0
)
==
x_dim
);
BOOST_CHECK
(
tensor1
.
dimension
(
1
)
==
y_dim
);
BOOST_CHECK
(
tensor1
.
dimension
(
2
)
==
z_dim
);
double
*
data
=
tensor1
.
data
();
for
(
Eigen
::
DenseIndex
k
=
0
;
k
<
tensor1
.
size
();
++
k
)
data
[
k
]
=
k
;
for
(
Eigen
::
DenseIndex
k
=
0
;
k
<
z_dim
;
++
k
)
{
for
(
Eigen
::
DenseIndex
j
=
0
;
j
<
y_dim
;
++
j
)
{
for
(
Eigen
::
DenseIndex
i
=
0
;
i
<
x_dim
;
++
i
)
{
BOOST_CHECK
(
tensor1
(
i
,
j
,
k
)
==
i
+
j
*
x_dim
+
k
*
(
x_dim
*
y_dim
));
}
}
}
}
BOOST_AUTO_TEST_SUITE_END
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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