MCPcopy Create free account
hub / github.com/PX4/eigen / test_sparse_basic

Function test_sparse_basic

test/sparse_basic.cpp:644–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642
643
644void test_sparse_basic()
645{
646 for(int i = 0; i < g_repeat; i++) {
647 int r = Eigen::internal::random<int>(1,200), c = Eigen::internal::random<int>(1,200);
648 if(Eigen::internal::random<int>(0,4) == 0) {
649 r = c; // check square matrices in 25% of tries
650 }
651 EIGEN_UNUSED_VARIABLE(r+c);
652 CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(1, 1)) ));
653 CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(8, 8)) ));
654 CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, ColMajor>(r, c)) ));
655 CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double>, RowMajor>(r, c)) ));
656 CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(r, c)) ));
657 CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,ColMajor,long int>(r, c)) ));
658 CALL_SUBTEST_5(( sparse_basic(SparseMatrix<double,RowMajor,long int>(r, c)) ));
659
660 r = Eigen::internal::random<int>(1,100);
661 c = Eigen::internal::random<int>(1,100);
662 if(Eigen::internal::random<int>(0,4) == 0) {
663 r = c; // check square matrices in 25% of tries
664 }
665
666 CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,ColMajor,short int>(short(r), short(c))) ));
667 CALL_SUBTEST_6(( sparse_basic(SparseMatrix<double,RowMajor,short int>(short(r), short(c))) ));
668 }
669
670 // Regression test for bug 900: (manually insert higher values here, if you have enough RAM):
671 CALL_SUBTEST_3((big_sparse_triplet<SparseMatrix<float, RowMajor, int> >(10000, 10000, 0.125)));
672 CALL_SUBTEST_4((big_sparse_triplet<SparseMatrix<double, ColMajor, long int> >(10000, 10000, 0.125)));
673
674 // Regression test for bug 1105
675#ifdef EIGEN_TEST_PART_7
676 {
677 int n = Eigen::internal::random<int>(200,600);
678 SparseMatrix<std::complex<double>,0, long> mat(n, n);
679 std::complex<double> val;
680
681 for(int i=0; i<n; ++i)
682 {
683 mat.coeffRef(i, i%(n/10)) = val;
684 VERIFY(mat.data().allocatedSize()<20*n);
685 }
686 }
687#endif
688}

Callers

nothing calls this directly

Calls 4

sparse_basicFunction · 0.85
coeffRefMethod · 0.45
allocatedSizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected