
Ublas : 
Subject: Re: [ublas] Floating point exceptions and unexpected call to sqrt with sparse integer vectors
From: Paul C. Leopardi (paul.leopardi_at_[hidden])
Date: 20090811 06:03:33
On Tue, 11 Aug 2009, Mark Johnson wrote:
> Gdb shows that the exception is generated in a call to sqrt(2147483648)
>
> [mj_at_lugha tmp]$ gdb ublasint
> ...(gdb) run
> Starting program: /home/mj/tmp/ublasint
>
> Program received signal SIGFPE, Arithmetic exception.
> 0x0000000000405468 in std::sqrt<int> (__x=2147483648) at
>
[...]
> #3 0x0000000000403fbe in
>
> boost::numeric::ublas::detail::expression_type_check<boost::numeric::ublas:
>:mapped_vector<int, boost::numeric::ublas::map_std<unsigned long, int,
> std::allocator<std::pair<unsigned long const, int> > > >,
> boost::numeric::ublas::vector<int,
> boost::numeric::ublas::unbounded_array<int, std::allocator<int> > >
>
> > (e1=@0x7fffffffdee0, e2=@0x7fffffffde00) at
>
> /usr/include/boost/numeric/ublas/detail/vector_assign.hpp:42
> #4 0x0000000000403466 in
>
> boost::numeric::ublas::vector_assign<boost::numeric::ublas::scalar_assign,
> boost::numeric::ublas::mapped_vector<int,
> boost::numeric::ublas::map_std<unsigned long, int,
> std::allocator<std::pair<unsigned long const, int> > > >,
> boost::numeric::ublas::unit_vector<int, std::allocator<int> > >
> (v=@0x7fffffffdee0, e=@0x7fffffffdf20) at
> /usr/include/boost/numeric/ublas/detail/vector_assign.hpp:369
[...]
> Any ideas as to what's happening? I must admit I don't understand why
> the program is calling sqrt()!
Hi Mark,
Seems to have something to do with BOOST_UBLAS_TYPE_CHECK being defined
because NDEBUG is not defined. Try compiling again with DNDEBUG to check
this. You could also try mapping your integer vectors to double vectors for
the purposes of uBLAS operations.
Sorry I can't explain why sqrt is being called. AFAICT the check should use
norm_inf which shouldn't use sqrt. You'll have to call on a uBLAS author to
dig deeper.
Best, Paul