| 16 | |
| 17 | template<typename SetterType,typename DenseType, typename Scalar, int Options> |
| 18 | bool test_random_setter(SparseMatrix<Scalar,Options>& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords) |
| 19 | { |
| 20 | { |
| 21 | sm.setZero(); |
| 22 | SetterType w(sm); |
| 23 | std::vector<Vector2i> remaining = nonzeroCoords; |
| 24 | while(!remaining.empty()) |
| 25 | { |
| 26 | int i = internal::random<int>(0,static_cast<int>(remaining.size())-1); |
| 27 | w(remaining[i].x(),remaining[i].y()) = ref.coeff(remaining[i].x(),remaining[i].y()); |
| 28 | remaining[i] = remaining.back(); |
| 29 | remaining.pop_back(); |
| 30 | } |
| 31 | } |
| 32 | return sm.isApprox(ref); |
| 33 | } |
| 34 | |
| 35 | template<typename SetterType,typename DenseType, typename T> |
| 36 | bool test_random_setter(DynamicSparseMatrix<T>& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords) |