MCPcopy Create free account
hub / github.com/PX4/eigen / check_stdlist_matrix

Function check_stdlist_matrix

test/stdlist_overload.cpp:45–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template<typename MatrixType>
45void check_stdlist_matrix(const MatrixType& m)
46{
47 typename MatrixType::Index rows = m.rows();
48 typename MatrixType::Index cols = m.cols();
49 MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols);
50 std::list<MatrixType> v(10, MatrixType(rows,cols)), w(20, y);
51 typename std::list<MatrixType>::iterator itv = get(v, 5);
52 typename std::list<MatrixType>::iterator itw = get(w, 6);
53 *itv = x;
54 *itw = *itv;
55 VERIFY_IS_APPROX(*itw, *itv);
56 v = w;
57 itv = v.begin();
58 itw = w.begin();
59 for(int i = 0; i < 20; i++)
60 {
61 VERIFY_IS_APPROX(*itw, *itv);
62 ++itv;
63 ++itw;
64 }
65
66 v.resize(21);
67 set(v, 20, x);
68 VERIFY_IS_APPROX(*get(v, 20), x);
69 v.resize(22,y);
70 VERIFY_IS_APPROX(*get(v, 21), y);
71 v.push_back(x);
72 VERIFY_IS_APPROX(*get(v, 22), x);
73
74 // do a lot of push_back such that the list gets internally resized
75 // (with memory reallocation)
76 MatrixType* ref = &(*get(w, 0));
77 for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i)
78 v.push_back(*get(w, i%w.size()));
79 for(unsigned int i=23; i<v.size(); ++i)
80 {
81 VERIFY((*get(v, i))==(*get(w, (i-23)%w.size())));
82 }
83}
84
85template<typename TransformType>
86void check_stdlist_transform(const TransformType&)

Callers 1

test_stdlist_overloadFunction · 0.70

Calls 8

beginMethod · 0.80
getFunction · 0.70
setFunction · 0.70
rowsMethod · 0.45
colsMethod · 0.45
resizeMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_stdlist_overloadFunction · 0.56