Opened 14 years ago

Last modified 14 years ago

#1915 assigned Support Requests

Nested matrix products with transposes causes compiler to complain error: invalid application of ‘sizeof’

Reported by: Leo Singer <aronnax@…> Owned by: Gunter
Milestone: To Be Determined Component: uBLAS
Version: Boost 1.34.1 Severity: Cosmetic
Keywords: ublas trans nested product Cc:

Description

When using ublas, a pair of nested products will cause the compiler to complain if there is a trans on any of the operands. For example:

using namespace boost::numeric::ublas;
matrix<float> A(3,3),   B(3,3), C(3,3);

prod(prod(A,B),trans(C));  // fails
prod(prod(trans(A),B),C);  // fails
prod(prod(A,trans(B)),C);  // fails
prod(prod(A,B),C);  // OK

The compiler produces the following error message:

/opt/local/include/boost/numeric/ublas/matrix_expression.hpp: In function ‘typename boost::numeric::ublas::matrix_matrix_binary_traits<typename E1::value_type, E1, typename E2::value_type, E2>::result_type boost::numeric::ublas::prod(const boost::numeric::ublas::matrix_expression<E>&, const boost::numeric::ublas::matrix_expression<E2>&) [with E1 = boost::numeric::ublas::matrix_matrix_binary<boost::numeric::ublas::matrix<float, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<float, std::allocator<float> > >, boost::numeric::ublas::matrix<float, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<float, std::allocator<float> > >, boost::numeric::ublas::matrix_matrix_prod<float, float, float> >, E2 = boost::numeric::ublas::matrix_unary2<boost::numeric::ublas::matrix<float, boost::numeric::ublas::basic_row_major<size_t, ptrdiff_t>, boost::numeric::ublas::unbounded_array<float, std::allocator<float> > >, boost::numeric::ublas::scalar_identity<float> >]’:
bad_multiply.cpp:9:   instantiated from here
/opt/local/include/boost/numeric/ublas/matrix_expression.hpp:4815: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’ 

Change History (1)

comment:1 by Gunter, 14 years ago

Keywords: nested product added
Milestone: Boost 1.36.0To Be Determined
Severity: ProblemCosmetic
Status: newassigned
Type: BugsSupport Requests

the compilation failure is by design. You see this from the STATIC_ASSERTION_FAILURE which causes a compiler error. However, I agree that the error message itself is not very helpful.

Actually any nested product should cause a static assertion since the numerical complexity of the expression prod(prod(A,B),C) is far bigger that for the approach using a temporary: temp = prod(A,B); prod(temp,C);

(see http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS section "Controlling the complexity of nested products")

Actually any nested product without temporaries should cause a static assertion. I'll check this in a few days.

Note: See TracTickets for help on using tickets.