preCICE v3.1.1
Loading...
Searching...
No Matches
EigenHelperFunctionsTest.cpp
Go to the documentation of this file.
1#include <Eigen/Core>
2#include <iosfwd>
3#include <string>
4#include "math/constants.hpp"
6#include "testing/Testing.hpp"
8#include "utils/String.hpp"
9#include "utils/algorithm.hpp"
10
11using namespace precice;
12using namespace precice::utils;
13
14BOOST_AUTO_TEST_SUITE(UtilsTests)
15BOOST_AUTO_TEST_SUITE(EigenHelperFunctionsTests)
16
18{
19 PRECICE_TEST(1_rank);
20 Eigen::VectorXd a(7);
21 a << 1, 2, 3, 4, 5, 6, 7;
22 Eigen::RowVectorXd b(3);
23 b << 1, 2, 3;
24 BOOST_TEST(firstN(a, 3) == b);
25}
26
28
30{
31 PRECICE_TEST(1_rank);
32 Eigen::VectorXd a{7};
33 a << 1, 2, 3, 4, 5, 6, 0;
35 oss << previewRange(2, a);
36 std::string str{oss.str()};
37 BOOST_TEST(str == "[1, 2, ... , 6, 0] min:0 max:6");
38}
39
41
43{
44 PRECICE_TEST(1_rank);
46
47 Eigen::VectorXd a(8);
48 a << 1, 2, 3, 4, 5, 6, 7, 9;
49
50 Eigen::VectorXd b(8);
51 b << 1, 2, 3, 4, 5, 6, 8, 0;
52
53 BOOST_TEST(componentWiseLess(a, b));
54 BOOST_TEST(!componentWiseLess(b, a));
55 BOOST_TEST(cwl(a, b));
56 BOOST_TEST(!cwl(b, a));
57
58 Eigen::VectorXd c = b;
59
60 BOOST_TEST(!componentWiseLess(c, b));
61 BOOST_TEST(!componentWiseLess(b, c));
62 BOOST_TEST(!cwl(c, b));
63 BOOST_TEST(!cwl(b, c));
64}
65
BOOST_AUTO_TEST_CASE(FirstN)
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END()
#define PRECICE_TEST(...)
Definition Testing.hpp:27
contains precice-related utilities.
const RangePreview< Iter > previewRange(Size n, const Range &range)
auto firstN(const Eigen::PlainObjectBase< Derived > &val, unsigned n) -> const Eigen::Map< const Eigen::Matrix< typename Derived::Scalar, 1, Eigen::Dynamic > >
bool componentWiseLess(const Eigen::PlainObjectBase< DerivedLHS > &lhs, const Eigen::PlainObjectBase< DerivedRHS > &rhs)
Main namespace of the precice library.
T str(T... args)
The RangePreview object used as a lazy proxy struct for proviewing the content of a Range.