mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -14,13 +14,13 @@
|
||||
|
||||
using namespace Eigen::internal;
|
||||
using Eigen::internal::tuple_impl::tuple;
|
||||
|
||||
void basic_tuple_test() {
|
||||
|
||||
void basic_tuple_test() {
|
||||
// Construction.
|
||||
tuple<> tuple0 {};
|
||||
tuple<int> tuple1 {1};
|
||||
tuple<int, float> tuple2 {3, 5.0f};
|
||||
tuple<int, float, double> tuple3 {7, 11.0f, 13.0};
|
||||
tuple<> tuple0{};
|
||||
tuple<int> tuple1{1};
|
||||
tuple<int, float> tuple2{3, 5.0f};
|
||||
tuple<int, float, double> tuple3{7, 11.0f, 13.0};
|
||||
// Default construction.
|
||||
tuple<> tuple0default;
|
||||
EIGEN_UNUSED_VARIABLE(tuple0default)
|
||||
@@ -30,7 +30,7 @@ void basic_tuple_test() {
|
||||
EIGEN_UNUSED_VARIABLE(tuple2default)
|
||||
tuple<int, float, double> tuple3default;
|
||||
EIGEN_UNUSED_VARIABLE(tuple3default)
|
||||
|
||||
|
||||
// Assignment.
|
||||
tuple<> tuple0b = tuple0;
|
||||
EIGEN_UNUSED_VARIABLE(tuple0b)
|
||||
@@ -40,18 +40,18 @@ void basic_tuple_test() {
|
||||
EIGEN_UNUSED_VARIABLE(tuple2b)
|
||||
decltype(tuple3) tuple3b = tuple3;
|
||||
EIGEN_UNUSED_VARIABLE(tuple3b)
|
||||
|
||||
|
||||
// get.
|
||||
VERIFY_IS_EQUAL(tuple_impl::get<0>(tuple3), 7);
|
||||
VERIFY_IS_EQUAL(tuple_impl::get<1>(tuple3), 11.0f);
|
||||
VERIFY_IS_EQUAL(tuple_impl::get<2>(tuple3), 13.0);
|
||||
|
||||
|
||||
// tuple_impl::tuple_size.
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple0)>::value, size_t(0));
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple1)>::value, size_t(1));
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple2)>::value, size_t(2));
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple3)>::value, size_t(3));
|
||||
|
||||
|
||||
// tuple_impl::tuple_cat.
|
||||
auto tuple2cat3 = tuple_impl::tuple_cat(tuple2, tuple3);
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple2cat3)>::value, size_t(5));
|
||||
@@ -65,32 +65,29 @@ void basic_tuple_test() {
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(emptycat)>::value, size_t(0));
|
||||
auto tuple0cat1cat2cat3 = tuple_impl::tuple_cat(tuple0, tuple1, tuple2, tuple3);
|
||||
VERIFY_IS_EQUAL(tuple_impl::tuple_size<decltype(tuple0cat1cat2cat3)>::value, size_t(6));
|
||||
|
||||
|
||||
// make_tuple.
|
||||
// The tuple types should uses values for the second and fourth parameters.
|
||||
double tmp = 20;
|
||||
auto tuple_make = tuple_impl::make_tuple(int(10), tmp, float(20.0f), tuple0);
|
||||
VERIFY( (std::is_same<decltype(tuple_make), tuple<int, double, float, tuple<> > >::value) );
|
||||
VERIFY((std::is_same<decltype(tuple_make), tuple<int, double, float, tuple<> > >::value));
|
||||
VERIFY_IS_EQUAL(tuple_impl::get<1>(tuple_make), tmp);
|
||||
|
||||
|
||||
// forward_as_tuple.
|
||||
// The tuple types should uses references for the second and fourth parameters.
|
||||
auto tuple_forward = tuple_impl::forward_as_tuple(int(10), tmp, float(20.0f), tuple0);
|
||||
VERIFY( (std::is_same<decltype(tuple_forward), tuple<int, double&, float, tuple<>& > >::value) );
|
||||
VERIFY((std::is_same<decltype(tuple_forward), tuple<int, double&, float, tuple<>&> >::value));
|
||||
VERIFY_IS_EQUAL(tuple_impl::get<1>(tuple_forward), tmp);
|
||||
|
||||
|
||||
// tie.
|
||||
auto tuple_tie = tuple_impl::tie(tuple0, tuple1, tuple2, tuple3);
|
||||
VERIFY( (std::is_same<decltype(tuple_tie),
|
||||
tuple<decltype(tuple0)&,
|
||||
decltype(tuple1)&,
|
||||
decltype(tuple2)&,
|
||||
decltype(tuple3)&> >::value) );
|
||||
VERIFY_IS_EQUAL( (tuple_impl::get<1>(tuple_impl::get<2>(tuple_tie))), 5.0f );
|
||||
VERIFY((std::is_same<decltype(tuple_tie),
|
||||
tuple<decltype(tuple0)&, decltype(tuple1)&, decltype(tuple2)&, decltype(tuple3)&> >::value));
|
||||
VERIFY_IS_EQUAL((tuple_impl::get<1>(tuple_impl::get<2>(tuple_tie))), 5.0f);
|
||||
// Modify value and ensure tuple2 is updated.
|
||||
tuple_impl::get<1>(tuple_impl::get<2>(tuple_tie)) = 10.0f;
|
||||
VERIFY_IS_EQUAL( (tuple_impl::get<1>(tuple2)), 10.0f );
|
||||
|
||||
VERIFY_IS_EQUAL((tuple_impl::get<1>(tuple2)), 10.0f);
|
||||
|
||||
// Assignment.
|
||||
int x = -1;
|
||||
float y = -1;
|
||||
@@ -110,14 +107,13 @@ void eigen_tuple_test() {
|
||||
tuple<Eigen::Matrix3d, Eigen::MatrixXd> tuple;
|
||||
tuple_impl::get<0>(tuple).setRandom();
|
||||
tuple_impl::get<1>(tuple).setRandom(10, 10);
|
||||
|
||||
|
||||
auto tuple_tie = tuple_impl::tie(tuple_impl::get<0>(tuple), tuple_impl::get<1>(tuple));
|
||||
tuple_impl::get<1>(tuple_tie).setIdentity();
|
||||
VERIFY(tuple_impl::get<1>(tuple).isIdentity());
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(tuple)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(tuple) {
|
||||
CALL_SUBTEST(basic_tuple_test());
|
||||
CALL_SUBTEST(eigen_tuple_test());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user