| 13 | |
| 14 | template<typename MatrixType> |
| 15 | void check_stdvector_matrix(const MatrixType& m) |
| 16 | { |
| 17 | typename MatrixType::Index rows = m.rows(); |
| 18 | typename MatrixType::Index cols = m.cols(); |
| 19 | MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); |
| 20 | std::vector<MatrixType,Eigen::aligned_allocator<MatrixType> > v(10, MatrixType(rows,cols)), w(20, y); |
| 21 | v[5] = x; |
| 22 | w[6] = v[5]; |
| 23 | VERIFY_IS_APPROX(w[6], v[5]); |
| 24 | v = w; |
| 25 | for(int i = 0; i < 20; i++) |
| 26 | { |
| 27 | VERIFY_IS_APPROX(w[i], v[i]); |
| 28 | } |
| 29 | |
| 30 | v.resize(21); |
| 31 | v[20] = x; |
| 32 | VERIFY_IS_APPROX(v[20], x); |
| 33 | v.resize(22,y); |
| 34 | VERIFY_IS_APPROX(v[21], y); |
| 35 | v.push_back(x); |
| 36 | VERIFY_IS_APPROX(v[22], x); |
| 37 | VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(MatrixType)); |
| 38 | |
| 39 | // do a lot of push_back such that the vector gets internally resized |
| 40 | // (with memory reallocation) |
| 41 | MatrixType* ref = &w[0]; |
| 42 | for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) |
| 43 | v.push_back(w[i%w.size()]); |
| 44 | for(unsigned int i=23; i<v.size(); ++i) |
| 45 | { |
| 46 | VERIFY(v[i]==w[(i-23)%w.size()]); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | template<typename TransformType> |
| 51 | void check_stdvector_transform(const TransformType&) |