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