9 #include <boost/test/unit_test.hpp>
31 using namespace Acts::VectorHelpers;
36 BOOST_AUTO_TEST_SUITE(Utilities)
39 Eigen::Matrix<int, 4, 3> mat;
40 mat << 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0;
43 std::bitset<4 * 3> exp{
"101001011010"};
45 BOOST_CHECK_EQUAL(exp, act);
47 Eigen::Matrix<int, 4, 3> cnv;
48 cnv = bitsetToMatrix<decltype(cnv)>(act);
50 BOOST_CHECK_EQUAL(mat, cnv);
54 double phi()
const {
return 42; }
62 BOOST_CHECK_EQUAL(
phi(s), 42
u);
80 mat << 1, 2, 3, 4, 5, 6, 7, 8, 9;
84 exp << -2, -1, 0, 4, 2, 0, -2, -1, 0;
92 mat << 1, 2, 3, 4, 5, 6, 7, 8, 9;
95 BOOST_CHECK(!out.empty());
99 BOOST_CHECK(!out.empty());
104 BOOST_CHECK(!out.empty());
109 std::vector<std::shared_ptr<int>>
vec;
110 vec = {std::make_shared<int>(5), std::make_shared<int>(9),
111 std::make_shared<int>(26), std::make_shared<int>(18473)};
115 std::vector<int*> exp = {
122 BOOST_CHECK_EQUAL_COLLECTIONS(unpacked.begin(), unpacked.end(), exp.begin(),
128 std::vector<std::shared_ptr<const int>>
vec;
129 vec = {std::make_shared<const int>(5), std::make_shared<const int>(9),
130 std::make_shared<const int>(26), std::make_shared<const int>(18473)};
134 std::vector<const int*> exp = {
141 BOOST_CHECK_EQUAL_COLLECTIONS(unpacked.begin(), unpacked.end(), exp.begin(),
166 constexpr
size_t imax = 20;
167 for (
size_t i = 0;
i < imax;
i++) {
168 size_t val = template_switch<functor, 0, imax>(
i);
169 BOOST_CHECK_EQUAL(val,
i *
i *
i);
181 using A =
typename Matrices::first_type;
182 using B =
typename Matrices::second_type;
185 for (std::size_t
i = 0;
i < 100; ++
i) {
192 BOOST_CHECK(ref.isApprox(res));
193 BOOST_CHECK(res.isApprox(ref));
198 std::vector<ActsScalar> ordered = {-3., -2., -1., 0., 1., 2., 3.};
201 CHECK_CLOSE_ABS(min0, -3., std::numeric_limits<ActsScalar>::epsilon());
204 std::vector<ActsScalar> unordered = {3., -3., -2., -1., 0., 1., 2.};
207 CHECK_CLOSE_ABS(min1, -3., std::numeric_limits<ActsScalar>::epsilon());
212 std::vector<ActsScalar> ordered = {-3., -2., -1., 0., 1., 2., 3.};
215 CHECK_CLOSE_ABS(range0, 6., std::numeric_limits<ActsScalar>::epsilon());
216 CHECK_CLOSE_ABS(medium0, 0., std::numeric_limits<ActsScalar>::epsilon());
218 std::vector<ActsScalar> unordered = {-2., -1., 0., 1., 2., 3., -3.};
221 CHECK_CLOSE_ABS(range1, 6., std::numeric_limits<ActsScalar>::epsilon());
222 CHECK_CLOSE_ABS(medium1, 0., std::numeric_limits<ActsScalar>::epsilon());
227 auto m = Eigen::Matrix3d::Zero().eval();
232 auto m = Eigen::Matrix3d::Identity().eval();
241 for (
size_t i = 0;
i < 3;
i++) {
245 double expect = (
i < 2) ? 0 : M_PI_2;
247 std::numeric_limits<ActsScalar>::epsilon());
249 std::numeric_limits<ActsScalar>::epsilon());
256 CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
257 CHECK_CLOSE_ABS(a1, M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
264 CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
265 CHECK_CLOSE_ABS(a1, M_PI_2, std::numeric_limits<ActsScalar>::epsilon());
272 CHECK_CLOSE_ABS(a0, M_PI_2, std::numeric_limits<ActsScalar>::epsilon());
273 CHECK_CLOSE_ABS(a1, M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
280 CHECK_CLOSE_ABS(a0, -M_PI_2, std::numeric_limits<ActsScalar>::epsilon());
281 CHECK_CLOSE_ABS(a1, -M_PI_2, std::numeric_limits<ActsScalar>::epsilon());
288 CHECK_CLOSE_ABS(a0, 3 * M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
289 CHECK_CLOSE_ABS(a1, 3 * M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
297 std::numeric_limits<ActsScalar>::epsilon());
299 std::numeric_limits<ActsScalar>::epsilon());
304 double s45 = std::sin(M_PI_4);
305 double c45 = std::cos(M_PI_4);
307 ref45 << c45, 0, s45, 0, 1, 0, -s45, 0, c45;
310 CHECK_CLOSE_ABS(a0, M_PI_4, std::numeric_limits<ActsScalar>::epsilon());
311 CHECK_CLOSE_ABS(a1, M_PI_2, std::numeric_limits<ActsScalar>::epsilon());
315 BOOST_AUTO_TEST_SUITE_END()