MCPcopy Create free account
hub / github.com/avaxman/Directional / test_pruning

Function test_pruning

external/eigen/test/sparse_vector.cpp:177–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175
176}
177void test_pruning() {
178 using SparseVectorType = SparseVector<double, 0, int>;
179
180 SparseVectorType vec;
181 auto init_vec = [&](){;
182 vec.resize(10);
183 vec.insert(3) = 0.1;
184 vec.insert(5) = 1.0;
185 vec.insert(8) = -0.1;
186 vec.insert(9) = -0.2;
187 };
188 init_vec();
189
190 VERIFY_IS_EQUAL(vec.nonZeros(), 4);
191 VERIFY_IS_EQUAL(vec.prune(0.1, 1.0), 2);
192 VERIFY_IS_EQUAL(vec.nonZeros(), 2);
193 VERIFY_IS_EQUAL(vec.coeff(5), 1.0);
194 VERIFY_IS_EQUAL(vec.coeff(9), -0.2);
195
196 init_vec();
197 VERIFY_IS_EQUAL(vec.prune([](double v) { return v >= 0; }), 2);
198 VERIFY_IS_EQUAL(vec.nonZeros(), 2);
199 VERIFY_IS_EQUAL(vec.coeff(3), 0.1);
200 VERIFY_IS_EQUAL(vec.coeff(5), 1.0);
201}
202
203EIGEN_DECLARE_TEST(sparse_vector)
204{

Callers 1

EIGEN_DECLARE_TESTFunction · 0.85

Calls 4

resizeMethod · 0.45
nonZerosMethod · 0.45
pruneMethod · 0.45
coeffMethod · 0.45

Tested by

no test coverage detected