The problem I think is that the vector class in the Ublas library does not have an overloaded operator== function.  My guess is that operator== is not defined in the library because its meaning could differ depending on how to user of the library interprets equality.  You could probably write your own operator== function so it would compile.


Simply comparing 2 ublas::vectors also fails to compile since there is no operator== defined as shown below.

// Does not compile
namespace ublas = boost::numeric::ublas;

int main()
{
    ublas::vector<int> c(2);
    ublas::vector<int> d(2);

    for (int i=0; i < c.size(); ++i)
    {
        c(i) = i;
        d(i) = i;
    }

    if (c == d)
    {
        std::cout << "SUCCESS!!!" << std::endl;
    }
   
    return 0;
}


Jesse

On Feb 6, 2008 3:20 PM, Nico Galoppo <ngaloppo@gmail.com> wrote:
On a related note, this fails with regular std::vector<> as well (not
only multi_array)

--nico

On Feb 6, 2008 12:22 PM, Nico Galoppo <ngaloppo@gmail.com> wrote:
> This test program fails to compile on my machine. Can anyone shed some
> light on why this is happening?
>
> #include <boost/numeric/ublas/vector.hpp>
> #include <boost/multi_array.hpp>
>
> int main()
> {
>   typedef boost::numeric::ublas::vector<double> T;
>   boost::multi_array<T, 2> a,b;
>
>   return (a == b);
> }
>
> $ g++ -I/opt/include test.cpp
> /usr/include/c++/4.0.0/bits/stl_algobase.h: In function 'bool
> std::equal(_InputIterator1, _InputIterator1, _InputIterator2) [with
> _InputIterator1 =
> boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<1ul>, const main()::T&>, _InputIterator2 =
> boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<1ul>, const main()::T&>]':
> /opt/include/boost/multi_array/subarray.hpp:117:   instantiated from
> 'bool boost::detail::multi_array::const_sub_array<T, NumDims,
> TPtr>::operator==(const boost::detail::multi_array::const_sub_array<T,
> NumDims, OPtr>&) const [with OPtr = const main()::T*, T = main()::T,
> long unsigned int NumDims = 1ul, TPtr = const main()::T*]'
> /usr/include/c++/4.0.0/bits/stl_algobase.h:760:   instantiated from
> 'bool std::equal(_InputIterator1, _InputIterator1, _InputIterator2)
> [with _InputIterator1 =
> boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<2ul>,
> boost::detail::multi_array::const_sub_array<main()::T, 1ul, const
> main()::T*> >, _InputIterator2 =
> boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<2ul>,
> boost::detail::multi_array::const_sub_array<main()::T, 1ul, const
> main()::T*> >]'
> /opt/include/boost/multi_array/multi_array_ref.hpp:273:   instantiated
> from 'bool boost::const_multi_array_ref<T, NumDims,
> TPtr>::operator==(const boost::const_multi_array_ref<T, NumDims,
> OPtr>&) const [with OPtr = main()::T*, T = main()::T, long unsigned
> int NumDims = 2ul, TPtr = main()::T*]'
> test.cpp:9:   instantiated from here
> /usr/include/c++/4.0.0/bits/stl_algobase.h:760: error: no match for
> 'operator==' in
> '((boost::iterator_facade<boost::detail::multi_array::array_iterator<main()::T,
> const main()::T*, mpl_::size_t<1ul>, const main()::T&>, main()::T,
> boost::random_access_traversal_tag, const main()::T&, ptrdiff_t>*)(&
> __first1))->boost::iterator_facade<I, V, TC, R, D>::operator* [with
> Derived = boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<1ul>, const main()::T&>, Value = main()::T,
> CategoryOrTraversal = boost::random_access_traversal_tag, Reference =
> const main()::T&, Difference = ptrdiff_t]() ==
> ((boost::iterator_facade<boost::detail::multi_array::array_iterator<main()::T,
> const main()::T*, mpl_::size_t<1ul>, const main()::T&>, main()::T,
> boost::random_access_traversal_tag, const main()::T&, ptrdiff_t>*)(&
> __first2))->boost::iterator_facade<I, V, TC, R, D>::operator* [with
> Derived = boost::detail::multi_array::array_iterator<main()::T, const
> main()::T*, mpl_::size_t<1ul>, const main()::T&>, Value = main()::T,
> CategoryOrTraversal = boost::random_access_traversal_tag, Reference =
> const main()::T&, Difference = ptrdiff_t]()'
>
>
> --
> Nico Galoppo :: http://www.ngaloppo.org
>



--
Nico Galoppo :: http://www.ngaloppo.org
_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas