| 27 | |
| 28 | template<typename MatrixType> |
| 29 | void check_stdvector_matrix(const MatrixType& m) |
| 30 | { |
| 31 | typename MatrixType::Index rows = m.rows(); |
| 32 | typename MatrixType::Index cols = m.cols(); |
| 33 | MatrixType x = MatrixType::Random(rows,cols), y = MatrixType::Random(rows,cols); |
| 34 | std::vector<MatrixType> v(10, MatrixType(rows,cols)), w(20, y); |
| 35 | v[5] = x; |
| 36 | w[6] = v[5]; |
| 37 | VERIFY_IS_APPROX(w[6], v[5]); |
| 38 | v = w; |
| 39 | for(int i = 0; i < 20; i++) |
| 40 | { |
| 41 | VERIFY_IS_APPROX(w[i], v[i]); |
| 42 | } |
| 43 | |
| 44 | v.resize(21); |
| 45 | v[20] = x; |
| 46 | VERIFY_IS_APPROX(v[20], x); |
| 47 | v.resize(22,y); |
| 48 | VERIFY_IS_APPROX(v[21], y); |
| 49 | v.push_back(x); |
| 50 | VERIFY_IS_APPROX(v[22], x); |
| 51 | VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(MatrixType)); |
| 52 | |
| 53 | // do a lot of push_back such that the vector gets internally resized |
| 54 | // (with memory reallocation) |
| 55 | MatrixType* ref = &w[0]; |
| 56 | for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i) |
| 57 | v.push_back(w[i%w.size()]); |
| 58 | for(unsigned int i=23; i<v.size(); ++i) |
| 59 | { |
| 60 | VERIFY(v[i]==w[(i-23)%w.size()]); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | template<typename TransformType> |
| 65 | void check_stdvector_transform(const TransformType&) |