Boost logo

Ublas :

From: Ashima Atul (ashima_at_[hidden])
Date: 2007-11-27 00:57:21


Hi,

I am a new user of boost and am trying to do a product of two matrices.
The elements inside the matrices are not int/double but are objects of a
structure 'myType'. I have added definitions for the required operator
overloading functions.

But, when I try to compile the code, I get a huge error with all the
template information and in the end the error says
*/usr/local/include/boost-1_34_1/boost/numeric/ublas/functional.hpp:1197:
error: no matching function for call to 'myType::myType(int)'
matDouble.cpp:4: note: candidates are: myType::myType()
matDouble.cpp:4: note: myType::myType(const myType&)

*I have attached the whole error at the end.

Here's the code :

#include <string>
#include <iostream>

struct myType{
                char a[4];
                int y;
        };

myType operator+(const myType& lhs, const myType& rhs)
 {
        //to add addition logic
        return lhs;
 }

myType operator*(const myType& lhs, const myType& rhs)
 {
        //to add multiplication logic
        return lhs;
 }

myType operator+=(const myType& lhs, const myType& rhs)
 {
        //to add logic
        return lhs;
 }

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
typedef matrix< myType > myTypeMatrix;

int main () {
    myTypeMatrix m1(3,3);
    myTypeMatrix m2(3,3);
    myTypeMatrix m3(3,3);

    for (unsigned i = 0; i < 3; ++ i)
        for (unsigned j = 0; j < 3; ++ j){
            strcpy( ((m1)(i,j)).a, "abc");
            strcpy( ((m2)(i,j)).a, "abc");
            ((myType) (m1) (i, j)).y = ((myType) (m2) (i, j)).y = 7;
        }
     (m3) = prod ((m1), (m2));

}

Any help regarding this would be highly appreciated.

Thanks,
Ashima

Error
*****

/usr/local/include/boost-1_34_1/boost/numeric/ublas/functional.hpp: In
static member function 'static typename
boost::numeric::ublas::matrix_matrix_binary_functor<T1, T2,
TR>::result_type boost::numeric::ublas::matrix_matrix_prod<T1, T2,
TR>::apply(const boost::numeric::ublas::matrix_expression<E1>&, const
boost::numeric::ublas::matrix_expression<E2>&, typename
boost::numeric::ublas::matrix_matrix_binary_functor<T1, T2,
TR>::size_type, typename
boost::numeric::ublas::matrix_matrix_binary_functor<T1, T2,
TR>::size_type) [with E1 = boost::numeric::ublas::matrix_reference<const
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
> >, E2 = boost::numeric::ublas::matrix_reference<const
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
> >, T1 = myType, T2 = myType, TR = myType]':
/usr/local/include/boost-1_34_1/boost/numeric/ublas/matrix_expression.hpp:4239:
instantiated from 'typename F::result_type
boost::numeric::ublas::matrix_matrix_binary<E1, E2,
F>::operator()(typename boost::numeric::ublas::promote_traits<typename
E1::size_type, typename E2::size_type>::promote_type, typename
boost::numeric::ublas::promote_traits<typename E1::size_type, typename
E2::size_type>::promote_type) const [with E1 =
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, E2 = boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, F = boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType>]'
/usr/local/include/boost-1_34_1/boost/numeric/ublas/detail/matrix_assign.hpp:592:
instantiated from 'void
boost::numeric::ublas::indexing_matrix_assign(M&, const
boost::numeric::ublas::matrix_expression<E2>&,
boost::numeric::ublas::row_major_tag) [with F =
boost::numeric::ublas::scalar_assign, M =
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, E =
boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType> >]'
/usr/local/include/boost-1_34_1/boost/numeric/ublas/detail/matrix_assign.hpp:625:
instantiated from 'void boost::numeric::ublas::matrix_assign(M&, const
boost::numeric::ublas::matrix_expression<E>&,
boost::numeric::ublas::dense_proxy_tag, C) [with F =
boost::numeric::ublas::scalar_assign, R =
boost::numeric::ublas::basic_full<size_t>, M =
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, E =
boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType> >,
C = boost::numeric::ublas::row_major_tag]'
/usr/local/include/boost-1_34_1/boost/numeric/ublas/detail/matrix_assign.hpp:1215:
instantiated from 'void boost::numeric::ublas::matrix_assign(M&, const
boost::numeric::ublas::matrix_expression<E2>&) [with F =
boost::numeric::ublas::scalar_assign, M =
boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, E =
boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType> >]'
/usr/local/include/boost-1_34_1/boost/numeric/ublas/matrix.hpp:111:
instantiated from 'boost::numeric::ublas::matrix<T, L, A>::matrix(const
boost::numeric::ublas::matrix_expression<E1>&) [with AE =
boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType> >,
T = myType, L = boost::numeric::ublas::basic_row_major<size_t,
ptrdiff_t>, A = boost::numeric::ublas::unbounded_array<myType,
std::allocator<myType> >]'
/usr/local/include/boost-1_34_1/boost/numeric/ublas/matrix.hpp:200:
instantiated from 'boost::numeric::ublas::matrix<T, L, A>&
boost::numeric::ublas::matrix<T, L, A>::operator=(const
boost::numeric::ublas::matrix_expression<E1>&) [with AE =
boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix<myType,
boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>,
boost::numeric::ublas::unbounded_array<myType, std::allocator<myType> >
>, boost::numeric::ublas::matrix_matrix_prod<myType, myType, myType> >,
T = myType, L = boost::numeric::ublas::basic_row_major<size_t,
ptrdiff_t>, A = boost::numeric::ublas::unbounded_array<myType,
std::allocator<myType> >]'
*matDouble.cpp:43: instantiated from here
/usr/local/include/boost-1_34_1/boost/numeric/ublas/functional.hpp:1197:
error: no matching function for call to 'myType::myType(int)'
matDouble.cpp:4: note: candidates are: myType::myType()
matDouble.cpp:4: note: myType::myType(const myType&)*