uBLAS compile fail on sparse matrix debug code
Hi all, I just write a simple program to test the efficiency of sparse matrix operation in uBLAS and get the following error message on a FreeBSD with gcc 2.95 : !gmake 2>&1| tee /tmp/v446688/2g++ -c test.cpp -I. -I/usr/local/include -Wall -g -O2 -march=i686 -pipe -ftemplate-depth-30 -g3 -O0 -o test.o g++ test.o -o a.out test.o: In function `pair<unsigned int, unsigned int> * __copy_backward<pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, int>(pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, random_access_iterator_tag, int *)': /usr/include/g++/stl_algobase.h(.gnu.linkonce.t.norm_inf__Q45boost7numeric5ublast11type_traits1ZUiRCUi+0x15): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::imag(unsigned int const &)' /usr/include/g++/stl_algobase.h(.gnu.linkonce.t.norm_inf__Q45boost7numeric5ublast11type_traits1ZUiRCUi+0x24): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::abs(unsigned int const &)' /usr/include/g++/stl_algobase.h(.gnu.linkonce.t.norm_inf__Q45boost7numeric5ublast11type_traits1ZUiRCUi+0x3a): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::real(unsigned int const &)' /usr/include/g++/stl_algobase.h(.gnu.linkonce.t.norm_inf__Q45boost7numeric5ublast11type_traits1ZUiRCUi+0x49): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::abs(unsigned int const &)' /usr/include/g++/stl_algobase.h(.gnu.linkonce.t.equals__H2ZQ45boost7numeric5ublast6vector2ZUiZQ45boost7numeric5ublast15unbounded_array1ZUiZQ45boost7numeric5ublast6vector2ZUiZQ45boost7numeric5ublast15unbounded_array1ZUi_Q35boost7numeric5ublasRCQ45boost7numeric5ublast17vector_expression1ZX01RCQ45boost7numeric5ublast17vector_expression1ZX11_b+0x2e): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::sqrt(unsigned int const &)' If I comment out the second prod() or use -DNDEBUG everything is ok. So I suspect the error is caused by debug code in sparse matrix prod operation. here is the main code block: int main(int argc,char* argv[]) { try { namespace ublas = boost::numeric::ublas; using namespace ublas; size_t d = 7000; ublas::vector<unsigned> v(d); ublas::matrix<unsigned> m (d,d); ublas::sparse_matrix<unsigned> ms (d,d); for (size_t i = 0;i < 10000;++i) { size_t r = (size_t)(drand48() * d); size_t c = (size_t)(drand48() * d); ++m(r,c); ++ms(r,c); ++v(r); ++v(c); } { progress_timer t; std::cout << "matrix * vector" << endl; ublas::prod(m,v); } { progress_timer t; std::cout << "sparse matrix * vector" << endl; ublas::prod(ms,v); } }
Hi Zhang, you wrote:
I just write a simple program to test the efficiency of sparse matrix operation in uBLAS and get the following error message on a FreeBSD with gcc 2.95 :
!gmake 2>&1| tee /tmp/v446688/2g++ -c test.cpp -I. -I/usr/local/include -Wall -g -O2 -march=i686 -pipe -ftemplate-depth-30 -g3 -O0 -o test.o g++ test.o -o a.out test.o: In function `pair<unsigned int, unsigned int> * __copy_backward<pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, int>(pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, pair<unsigned int, unsigned int> *, random_access_iterator_tag, int *)': /usr/include/g++/stl_algobase.h (.gnu.linkonce.t.norm_inf__Q45boost7numeric5ublast11type_traits1ZUiRCUi+0x1 5): undefined reference to `boost::numeric::ublas::type_traits<unsigned int>::imag(unsigned int const &)' /usr/include/g++/stl_algobase.h
[snip more linker messages]
If I comment out the second prod() or use -DNDEBUG everything is ok. So I suspect the error is caused by debug code in sparse matrix prod operation.
here is the main code block:
I've stumbled across a similar problem some time ago and silently fixed it in my code base. The following (slightly edited ;-) test compiles fine for me: ---------- #include <iostream> #include <boost/progress.hpp> #include <boost/numeric/ublas/matrix_sparse.hpp> int main(int argc,char* argv[]) { namespace ublas = boost::numeric::ublas; using namespace ublas; size_t d = 7000; ublas::vector<unsigned> v(d); ublas::matrix<unsigned> m (d,d); ublas::sparse_matrix<unsigned> ms (d,d); for (size_t i = 0;i < 10000;++i) { size_t r = (size_t)(drand48() * d); size_t c = (size_t)(drand48() * d); ++m(r,c); ++ms(r,c); ++v(r); ++v(c); } { boost::progress_timer t; std::cout << "matrix * vector" << std::endl; ublas::prod(m,v); } { boost::progress_timer t; std::cout << "sparse matrix * vector" << std::endl; ublas::prod(ms,v); } } ---------- The reason for the problem is that you're using integral types instead of floating point types as far as I see. The class template ublas::type_traits<> in traits.hpp currently contains some functions, which are only declared, but not defined. So you've probably at least three options to proceed: - switch to floating point types - fix the type_traits<> class yourself - look into the latest development version at http://groups.yahoo.com/group/ublas-dev/files HTH, Joerg
participants (2)
-
jhr.walter@t-online.de
-
Zhang Le