#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@gmail.com>:
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