Skip to content

Commit

Permalink
Fix (final?) issue on clang4.0, add ceres test
Browse files Browse the repository at this point in the history
  • Loading branch information
pettni committed Oct 18, 2020
1 parent c60488f commit d8c0ca3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
4 changes: 2 additions & 2 deletions include/manif/impl/composite/Composite.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ Composite<_Scalar, _T...>::coeffs() const
return data_;
}

} // namespace manif
} // namespace manif

#endif // _MANIF_MANIF_COMPOSITE_H_
#endif // _MANIF_MANIF_COMPOSITE_H_
42 changes: 26 additions & 16 deletions include/manif/impl/composite/Composite_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ struct intseq

// join two intseqs
template<typename _Seq1, typename _Seq2>
struct intseq_join;
struct intseq_join
{
using type = std::false_type;
};

template<typename _Int, template<typename, _Int ...> class _IntSeq, _Int ... _I1, _Int ... _I2>
struct intseq_join<_IntSeq<_Int, _I1...>, _IntSeq<_Int, _I2...>>
Expand All @@ -47,28 +50,28 @@ using intseq_join_t = typename intseq_join<_Seq1, _Seq2>::type;

// create intseq of given length
template<typename _Int, size_t _N>
struct make_intseq;
struct make_intseq
{
using type =
typename intseq_join<typename make_intseq<_Int, _N - 1>::type, intseq<_Int, _N - 1>>::type;
};

template<typename _Int>
struct make_intseq<_Int, 0>
{
using type = intseq<_Int>;
};

template<typename _Int, size_t _N>
struct make_intseq
{
using type =
typename intseq_join<typename make_intseq<_Int, _N - 1>::type, intseq<_Int, _N - 1>>::type;
};

template<typename _Int, size_t _N>
using make_intseq_t = typename make_intseq<_Int, _N>::type;


// extract element from integer sequence
template<size_t _Idx, typename _Seq>
struct intseq_element;
struct intseq_element
{
static constexpr typename _Seq::value_type value = 0;
};

template<typename _Int, template<typename, _Int ...> class _IntSeq, _Int _I, _Int ... _Is>
struct intseq_element<0, _IntSeq<_Int, _I, _Is...>>
Expand All @@ -79,9 +82,7 @@ struct intseq_element<0, _IntSeq<_Int, _I, _Is...>>
template<
typename _Int,
template<typename, _Int ...> class _IntSeq,
_Int _I,
_Int ... _Is,
size_t _Idx>
_Int _I, _Int ... _Is, size_t _Idx>
struct intseq_element<_Idx, _IntSeq<_Int, _I, _Is...>>
{
static constexpr _Int value = intseq_element<_Idx - 1, _IntSeq<_Int, _Is...>>::value;
Expand All @@ -94,7 +95,10 @@ struct intseq_element<_Idx, _IntSeq<_Int, _I, _Is...>>

// sum an integer sequence
template<typename _Seq>
struct intseq_sum;
struct intseq_sum
{
static constexpr typename _Seq::value_type value = 0;
};

template<typename _Int, template<typename, _Int ...> class _IntSeq>
struct intseq_sum<_IntSeq<_Int>>
Expand All @@ -115,7 +119,10 @@ struct intseq_sum<_IntSeq<_Int, I, Is...>>

// prefix-sum an integer sequence
template<typename _Int, typename _Collected, typename _Remaining, _Int Sum>
struct intseq_psum_impl;
struct intseq_psum_impl
{
using type = std::false_type;
};

template<
typename _Int,
Expand All @@ -134,7 +141,10 @@ struct intseq_psum_impl<_Int, _IntSeq<_Int, _Cur...>, _IntSeq<_Int, _First, _Rem
{};

template<class _Seq>
struct intseq_psum;
struct intseq_psum
{
using type = std::false_type;
};

template<typename _Int, template<typename, _Int ...> class _IntSeq, _Int ... _I>
struct intseq_psum<_IntSeq<_Int, _I...>>
Expand Down
5 changes: 5 additions & 0 deletions test/ceres/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ manif_add_gtest(gtest_so3_ceres gtest_so3_ceres.cpp)

manif_add_gtest(gtest_se3_ceres gtest_se3_ceres.cpp)

manif_add_gtest(gtest_composite_ceres gtest_composite_ceres.cpp)

set(CXX_11_TEST_TARGETS_CERES
# SO2
gtest_so2_ceres
Expand All @@ -22,6 +24,9 @@ set(CXX_11_TEST_TARGETS_CERES

# SE3
gtest_se3_ceres

# Composite
gtest_composite_ceres
)

foreach(target ${CXX_11_TEST_TARGETS_CERES})
Expand Down
20 changes: 20 additions & 0 deletions test/ceres/gtest_composite_ceres.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "manif/Composite.h"
#include "manif/Rn.h"
#include "manif/SO2.h"
#include "manif/SO3.h"

#include "ceres_test_utils.h"

#include <ceres/ceres.h>

using namespace manif;

using Group = Composite<double, SO3, R3, SO2, R2>;

MANIF_TEST_JACOBIANS_CERES(Group);

int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit d8c0ca3

Please sign in to comment.