Boost C++ Libraries: Ticket #1915: Nested matrix products with transposes causes compiler to complain error: invalid application of ‘sizeof’ https://svn.boost.org/trac10/ticket/1915 <p> When using ublas, a pair of nested products will cause the compiler to complain if there is a <code>trans</code> on any of the operands. For example: </p> <div class="wiki-code"><div class="code"><pre><span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">numeric</span><span class="o">::</span><span class="n">ublas</span><span class="p">;</span> <span class="n">matrix</span><span class="o">&lt;</span><span class="kt">float</span><span class="o">&gt;</span> <span class="n">A</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">),</span> <span class="n">B</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">),</span> <span class="n">C</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">);</span> <span class="n">prod</span><span class="p">(</span><span class="n">prod</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">B</span><span class="p">),</span><span class="n">trans</span><span class="p">(</span><span class="n">C</span><span class="p">));</span> <span class="c1">// fails</span> <span class="n">prod</span><span class="p">(</span><span class="n">prod</span><span class="p">(</span><span class="n">trans</span><span class="p">(</span><span class="n">A</span><span class="p">),</span><span class="n">B</span><span class="p">),</span><span class="n">C</span><span class="p">);</span> <span class="c1">// fails</span> <span class="n">prod</span><span class="p">(</span><span class="n">prod</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">trans</span><span class="p">(</span><span class="n">B</span><span class="p">)),</span><span class="n">C</span><span class="p">);</span> <span class="c1">// fails</span> <span class="n">prod</span><span class="p">(</span><span class="n">prod</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">B</span><span class="p">),</span><span class="n">C</span><span class="p">);</span> <span class="c1">// OK</span> </pre></div></div><p> The compiler produces the following error message: </p> <pre class="wiki">/opt/local/include/boost/numeric/ublas/matrix_expression.hpp: In function ‘typename boost::numeric::ublas::matrix_matrix_binary_traits&lt;typename E1::value_type, E1, typename E2::value_type, E2&gt;::result_type boost::numeric::ublas::prod(const boost::numeric::ublas::matrix_expression&lt;E&gt;&amp;, const boost::numeric::ublas::matrix_expression&lt;E2&gt;&amp;) [with E1 = boost::numeric::ublas::matrix_matrix_binary&lt;boost::numeric::ublas::matrix&lt;float, boost::numeric::ublas::basic_row_major&lt;size_t, ptrdiff_t&gt;, boost::numeric::ublas::unbounded_array&lt;float, std::allocator&lt;float&gt; &gt; &gt;, boost::numeric::ublas::matrix&lt;float, boost::numeric::ublas::basic_row_major&lt;size_t, ptrdiff_t&gt;, boost::numeric::ublas::unbounded_array&lt;float, std::allocator&lt;float&gt; &gt; &gt;, boost::numeric::ublas::matrix_matrix_prod&lt;float, float, float&gt; &gt;, E2 = boost::numeric::ublas::matrix_unary2&lt;boost::numeric::ublas::matrix&lt;float, boost::numeric::ublas::basic_row_major&lt;size_t, ptrdiff_t&gt;, boost::numeric::ublas::unbounded_array&lt;float, std::allocator&lt;float&gt; &gt; &gt;, boost::numeric::ublas::scalar_identity&lt;float&gt; &gt;]’: 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&lt;false&gt;’ </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1915 Trac 1.4.3 Gunter Wed, 14 May 2008 21:56:28 GMT keywords, status, type, severity, milestone changed https://svn.boost.org/trac10/ticket/1915#comment:1 https://svn.boost.org/trac10/ticket/1915#comment:1 <ul> <li><strong>keywords</strong> nested product added </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.36.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> <p> 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. </p> <p> 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); </p> <p> (see <a class="ext-link" href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS"><span class="icon">​</span>http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Effective_UBLAS</a> section "Controlling the complexity of nested products") </p> <p> Actually any nested product without temporaries should cause a static assertion. I'll check this in a few days. </p> Ticket