Boost logo

Boost :

Subject: Re: [boost] compilation errors with ublas / cppad
From: Oleg Labutin (ol.labutin_at_[hidden])
Date: 2015-11-30 16:12:31


Hi Caspers,
  in gennerally we can get information about operators or convertible for
distanation classes. Or implement traits for operators < like std::less
e.g. for using inside ublas.

Best regards

2015-11-30 22:34 GMT+02:00 Peter Caspers <pcaspers1973_at_[hidden]>:

> Hi Oleg,
>
> thank you. I am aware of this workaround. I was looking for a clean
> fix and some background, since for example the multiprecision classes
> from boost seem to work in the same context. It would be great if
> someone could give some insight into this.
>
> Best regards
> Peter
>
> On 30 November 2015 at 16:28, Oleg Labutin <ol.labutin_at_[hidden]> wrote:
> > #include <cppad/cppad.hpp>
> > #include <boost/numeric/ublas/lu.hpp>
> >
> > typedef CppAD::AD<double> my_dbl;
> >
> > namespace boost {
> > namespace numeric {
> > namespace ublas
> > {
> > template<class M>
> > class sparse_matrix_element;
> >
> > template<class T, class L, std::size_t IB, class IA, class
> TA>
> > class compressed_matrix;
> >
> > template<class T, class ALLOC>
> > class unbounded_array;
> >
> > namespace detail {
> >
> > template <typename Left, typename Base>
> > inline bool operator < (Left const& left, CppAD::AD<Base>
> > const& right)
> > {
> > return left. operator my_dbl() < right;
> > }
> > }
> > }
> > }
> > }
> >
> > int main() {
> >
> > boost::numeric::ublas::matrix<my_dbl> a(3, 3);
> > boost::numeric::ublas::permutation_matrix<int> pert(3);
> >
> > const int singular = lu_factorize(a, pert);
> >
> > return 0;
> > }
> >
> >
> > 2015-11-24 20:22 GMT+02:00 Peter Caspers <pcaspers1973_at_[hidden]>:
> >
> >> Hi,
> >>
> >> I think this has been asked before, but since I am not aware of any
> >> answer, I would like to bring up the topic again:
> >>
> >> When using CppAD::AD<double> with boost ublas, certain compilation
> >> errors show up. I attach a small example (ublas_cppad.cpp) and the
> >> (start of the) error messages I get (compilation_errors.txt, produced
> >> with boost 1.59.0, g++ 4.9.3, CppAD-20151124).
> >>
> >> The problem is in matrix_assign.hpp; when changing
> >>
> >> template<class E1, class E2, class S>
> >> BOOST_UBLAS_INLINE
> >> bool equals (const matrix_expression<E1> &e1, const
> >> matrix_expression<E2> &e2, S epsilon, S min_norm) {
> >> return norm_inf (e1 - e2) < epsilon *
> >> std::max<S> (std::max<S> (norm_inf (e1), norm_inf
> >> (e2)), min_norm);
> >> }
> >>
> >> to
> >>
> >> template<class E1, class E2, class S>
> >> BOOST_UBLAS_INLINE
> >> bool equals (const matrix_expression<E1> &e1, const
> >> matrix_expression<E2> &e2, S epsilon, S min_norm) {
> >> S tmp = norm_inf (e1 - e2);
> >> return tmp < epsilon *
> >> std::max<S> (std::max<S> (norm_inf (e1), norm_inf
> >> (e2)), min_norm);
> >> }
> >>
> >> the example code compiles without errors. Can someone point out, how
> >> this should be fixed (either on boost or CppAD side)? In general, are
> >> there requirements for a type T to cooperate with ublas matrices one
> >> should be aware of?
> >>
> >> Thank you
> >> Peter
> >>
> >>
> >> _______________________________________________
> >> Unsubscribe & other changes:
> >> http://lists.boost.org/mailman/listinfo.cgi/boost
> >>
> >
> > _______________________________________________
> > Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk