MPI-IS / Grassmann-Averages-PCA

Robust and scalable PCA using Grassmann averages, in C++ with Matlab bindings
https://ps.is.tuebingen.mpg.de/research_projects/robust-pca
BSD 3-Clause "New" or "Revised" License
29 stars 4 forks source link

Issues compiling tests #2

Open reynoldscem opened 2 years ago

reynoldscem commented 2 years ago

Hi,

I'm having difficulty compiling the tests for the project. I've tried a few different versions of boost, but none earlier than 1.55.

I cannot compile CMakeFiles/GrassmannAveragesPCA_test.dir/test/test_row_proxy.cpp.o which fails with the following:

In file included from /usr/include/boost/iterator/iterator_adaptor.hpp:15,
                 from /home/creynolds/Grassmann-Averages-PCA/include/private/boost_ublas_row_iterator.hpp:14,
                 from /home/creynolds/Grassmann-Averages-PCA/test/test_row_proxy.cpp:16:
/usr/include/boost/iterator/iterator_facade.hpp: In instantiation of ‘static void boost::iterators::iterator_core_access::decrement(Facade&) [with Facade = grassmann_averages_pca::details::ublas_helpers::row_iter<boost::numeric::ublas::matrix<double> >]’:
/usr/include/boost/iterator/iterator_facade.hpp:699:44:   required from ‘Derived& boost::iterators::detail::iterator_facade_base<Derived, Value, CategoryOrTraversal, Reference, Difference, true, false>::operator--() [with Derived = grassmann_averages_pca::details::ublas_helpers::row_iter<boost::numeric::ublas::matrix<double> >; Value = boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double> >; CategoryOrTraversal = std::random_access_iterator_tag; Reference = boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double> >; Difference = long int]’
/usr/include/c++/11/bits/stl_iterator_base_funcs.h:183:2:   required from ‘void std::__advance(_RandomAccessIterator&, _Distance, std::random_access_iterator_tag) [with _RandomAccessIterator = grassmann_averages_pca::details::ublas_helpers::row_iter<boost::numeric::ublas::matrix<double> >; _Distance = long int]’
/usr/include/c++/11/bits/stl_iterator_base_funcs.h:206:21:   required from ‘void std::advance(_InputIterator&, _Distance) [with _InputIterator = grassmann_averages_pca::details::ublas_helpers::row_iter<boost::numeric::ublas::matrix<double> >; _Distance = int]’
/home/creynolds/Grassmann-Averages-PCA/test/test_row_proxy.cpp:73:15:   required from here
/usr/include/boost/iterator/iterator_facade.hpp:562:13: error: ‘class grassmann_averages_pca::details::ublas_helpers::row_iter<boost::numeric::ublas::matrix<double> >’ has no member named ‘decrement’; did you mean ‘increment’?
  562 |           f.decrement();
      |           ~~^~~~~~~~~
      |           increment
make[2]: *** [CMakeFiles/GrassmannAveragesPCA_test.dir/build.make:132: CMakeFiles/GrassmannAveragesPCA_test.dir/test/test_row_proxy.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:951: CMakeFiles/GrassmannAveragesPCA_test.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Any advice would be greatly appreciated.

raffienficiaud commented 2 years ago

Thanks for the report. Would you please try adding those lines to the file include/private/boost_ublas_row_iterator.hpp? eg. ~after increment and report here?

        void decrement()
        {
          assert(matrix);
          assert(index < matrix->size1() && index >= 0);
          index--;
        }

(disclaimer: I have not tested this at all, but you get the idea.)

reynoldscem commented 2 years ago

Funnily enough I tried (essentially) this just after putting the report in, and it seems to compile and run all tests just fine.

I am unsure whether I understand correctly what the assert is meant to ensure, I'd presumed keeping the index in bounds? If so is index < matrix->size1() && index >= 0 the right boundary condition? It seems to let index go to -1 which I'd have thought out of bounds?

Anyway thank you for the reply, especially so swift and on an older project! I will see if your assert instead of what I added breaks the tests or not.

Out of curiosity, do you have any insight on why this error has come about? Has boosts API changed? Something else?

Thanks for the report. Would you please try adding those lines to the file include/private/boost_ublas_row_iterator.hpp? eg. ~after increment and report here?


        void decrement()

        {

          assert(matrix);

          assert(index < matrix->size1() && index >= 0);

          index--;

        }

(disclaimer: I have not tested this at all, but you get the idea.)