Boost C++ Libraries: Ticket #8292: [multiprecision] et_on with uBLAS become bad result https://svn.boost.org/trac10/ticket/8292 <p> <code>cpp_dec_float</code> with <code>et_on</code> with uBLAS become bad result. </p> <p> following example is basic vector processing with <code>et_on</code>: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/multiprecision/cpp_dec_float.hpp&gt; #include &lt;boost/numeric/ublas/vector.hpp&gt; #include &lt;boost/numeric/ublas/io.hpp&gt; namespace mp = boost::multiprecision; namespace ublas = boost::numeric::ublas; using float_type = mp::number&lt;mp::cpp_dec_float&lt;50&gt;&gt;; using vec = ublas::vector&lt;float_type&gt;; vec make_vector3(float_type x, float_type y, float_type z) { vec v(3); v[0] = x; v[1] = y; v[2] = z; return v; } vec normalize(vec v) { return v / ublas::norm_2(v); } int main() { vec p = make_vector3(0.0f, 0.0f, 0.0f); // now position vec q = make_vector3(3.0f, 0.0f, 6.0f); // target position vec v = normalize(q - p); std::cout &lt;&lt; "vector : " &lt;&lt; v &lt;&lt; std::endl; float_type speed = 0.1f; float_type accel = 0.1f; for (int i = 0; i &lt; 20; ++i) { p += v * speed; speed += accel; } std::cout &lt;&lt; "result pos : " &lt;&lt; p &lt;&lt; std::endl; } </pre><p> result: </p> <pre class="wiki">vector : [3](1,0,1) result pos : [3](1,0,1) </pre><p> this result is bad. should be: </p> <pre class="wiki">vector : [3](0.447214,0,0.894427) result pos : [3](9.39149,0,18.783) </pre><p> following code is using <code>et_off</code>: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/multiprecision/cpp_dec_float.hpp&gt; #include &lt;boost/numeric/ublas/vector.hpp&gt; #include &lt;boost/numeric/ublas/io.hpp&gt; namespace mp = boost::multiprecision; namespace ublas = boost::numeric::ublas; using float_type = mp::number&lt;mp::cpp_dec_float&lt;50&gt;, mp::et_off&gt;; using vec = ublas::vector&lt;float_type&gt;; vec make_vector3(float_type x, float_type y, float_type z) { vec v(3); v[0] = x; v[1] = y; v[2] = z; return v; } vec normalize(vec v) { return v / ublas::norm_2(v); } int main() { vec p = make_vector3(0.0f, 0.0f, 0.0f); // now position vec q = make_vector3(3.0f, 0.0f, 6.0f); // target position vec v = normalize(q - p); std::cout &lt;&lt; "vector : " &lt;&lt; v &lt;&lt; std::endl; float_type speed = 0.1f; float_type accel = 0.1f; for (int i = 0; i &lt; 20; ++i) { p += v * speed; speed += accel; } std::cout &lt;&lt; "result pos : " &lt;&lt; p &lt;&lt; std::endl; } </pre><p> result: </p> <pre class="wiki">vector : [3](0.447214,0,0.894427) result pos : [3](9.39149,0,18.783) </pre><p> this result is correct. </p> <p> And, associated issue is here: <a class="ext-link" href="http://stackoverflow.com/questions/14948102/boost-matrix-product-for-multiprecision-numbers"><span class="icon">​</span>http://stackoverflow.com/questions/14948102/boost-matrix-product-for-multiprecision-numbers</a> this is <code>et_on</code>'s issue too. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8292 Trac 1.4.3 Akira Takahashi <faithandbrave@…> Thu, 14 Mar 2013 09:23:25 GMT component changed; owner set https://svn.boost.org/trac10/ticket/8292#comment:1 https://svn.boost.org/trac10/ticket/8292#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">multiprecision</span> </li> </ul> Ticket anonymous Thu, 14 Mar 2013 10:09:08 GMT <link>https://svn.boost.org/trac10/ticket/8292#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8292#comment:2</guid> <description> <p> The compiler errors you reported on stack overflow are to be expected - uBlas knows nothing about expression template number types internally and can't currently be used with them. </p> <p> I'll investigate the runtime issues shortly. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 15 Mar 2013 17:29:23 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8292#comment:3 https://svn.boost.org/trac10/ticket/8292#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83439" title="Improve uBas integration to allow use of expression templates inside ...">[83439]</a>) Improve uBas integration to allow use of expression templates inside uBas templates. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8292" title="#8292: Bugs: [multiprecision] et_on with uBLAS become bad result (closed: fixed)">#8292</a>. </p> Ticket John Maddock Fri, 15 Mar 2013 18:47:45 GMT <link>https://svn.boost.org/trac10/ticket/8292#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8292#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83448" title="Add missing file, refs #8292">[83448]</a>) Add missing file, refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8292" title="#8292: Bugs: [multiprecision] et_on with uBLAS become bad result (closed: fixed)">#8292</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>