Boost C++ Libraries: Ticket #5498: Issues with the Interval Library https://svn.boost.org/trac10/ticket/5498 <p> I am trying to compile some examples; in particular, the trigonometric, hyperbolic trig and transendental (exp, log!!)functions don't compile with default roudning policy (see file I included). It's a kind of show-stopper. </p> <p> Some user requests as well are: </p> <ol><li>Instead of bool when comparing interval, use <a class="missing wiki">TriBool</a> (a result can be _indeterminate_) </li></ol><ol start="2"><li>Interval is missing midpoint() (same as median()). </li></ol><ol start="3"><li>Interval analysis is highly specialised; more user examples would be very welcome. </li></ol><p> I have the books by R.E. Moore but it takes some time to map his results to Interval. </p> <p> best regards </p> <p> Daniel </p> <p> <em> Code </em></p> <p> <em> TestInterval101.cpp </em> <em> Tests for Interval arithmetic. </em> <em> (C) Datasim Education BV 2009-2011 </em></p> <p> #include &lt;boost/numeric/interval.hpp&gt; </p> <p> template&lt;class T, class Policies&gt; std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, </p> <blockquote> <p> const boost::numeric::interval&lt;T, Policies&gt; &amp;x) { </p> </blockquote> <blockquote> <p> os &lt;&lt; "[" &lt;&lt; x.lower() &lt;&lt; ", " &lt;&lt; x.upper() &lt;&lt; "]"; return os; </p> </blockquote> <p> } </p> <p> typedef boost::numeric::interval&lt;double&gt; Range; </p> <p> int main() { </p> <blockquote> <p> using namespace boost::numeric; </p> </blockquote> <p> </p> <blockquote> <p> <em> Create and manipulate some numbers. Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>(0.0, 1,0); </em></p> </blockquote> <blockquote> <p> Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>(-10.0, 20.0); Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a>(20.8, 44.9); </p> </blockquote> <blockquote> <p> double t = 2.0; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> += t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> -= t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> *= t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> /= t; </p> </blockquote> <blockquote> <p> Range rTmp(2.0, 3.0); <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> += rTmp; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> -= rTmp; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> *= rTmp; <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> /= rTmp; </p> </blockquote> <blockquote> <p> <em> Numeric operations. Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> + <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>; Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> - <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>; Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> * <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>; Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> / <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>; </em></p> </blockquote> <blockquote> <p> <em> More numeric operations. t = 3.0; <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> + t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> - t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> * t; <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> / t; </em></p> </blockquote> <blockquote> <p> <em> Algebraic functions. <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = abs(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = sqrt(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = square(<a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">r3</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = pow(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>, 2); </em> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a><sup>2 Range <a class="changeset" href="https://svn.boost.org/trac10/changeset/8" title="Initial content for next-gen Boost website. ">r8</a> = nth_root(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>, 4); </sup></p> </blockquote> <blockquote> <p> <em> NONE COMPILES </em> Transcendental functions </p> </blockquote> <p> <em> <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = exp(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); </em> boost::numeric::interval&lt;double, boost::numeric::interval_lib::default_policies&lt;double&gt; &gt; myI; <em> myI = boost::numeric::exp(myI); </em></p> <blockquote> <p> <em><a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = log(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); </em></p> </blockquote> <blockquote> <p> <em> Trigonometric functions </em></p> </blockquote> <p> /* <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = sin(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = cos(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = tan(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = asin(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = acos(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = atan(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); </p> </blockquote> <blockquote> <p> <em> Hyperbolic trigonometric functions <a class="changeset" href="https://svn.boost.org/trac10/changeset/4" title="Tweak disclaimer formatting, again">r4</a> = sinh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/5" title="Boost customization">r5</a> = cosh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = tanh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/7" title="Initial content for next-gen Boost website. ">r7</a> = asinh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/8" title="Initial content for next-gen Boost website. ">r8</a> = acosh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>); <a class="changeset" href="https://svn.boost.org/trac10/changeset/6" title="New repository initialized by cvs2svn.">r6</a> = atanh(<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">r2</a>);*/ </em></p> </blockquote> <p> </p> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5498 Trac 1.4.3 anonymous Sat, 23 Apr 2011 09:11:56 GMT attachment set https://svn.boost.org/trac10/ticket/5498 https://svn.boost.org/trac10/ticket/5498 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">TestBug.cc</span> </li> </ul> Ticket anonymous Wed, 28 Sep 2011 04:59:03 GMT <link>https://svn.boost.org/trac10/ticket/5498#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:1</guid> <description> <p> I (Daniel Duffy) discovered the cause: Interval does not provide default implementation of up and down rounding policies. As a POC, I created a simple policy that I tested with interval Newton Raphson </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 28 Sep 2011 05:00:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5498#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:2</guid> <description> <p> class DDPolicy : public rounded_math&lt;double&gt; { public: </p> <blockquote> <p> double exp_up(double x) { return ::exp(x);} double exp_down(double x) { return ::exp(x);} </p> </blockquote> <blockquote> <p> <em> etc. </em></p> </blockquote> <p> }; </p> <blockquote> <p> <em> Transcendental functions boost::numeric::interval&lt;double, policies&lt;DDPolicy, checking_strict&lt;double&gt; &gt; &gt; rA; boost::numeric::interval&lt;double, policies&lt;DDPolicy, checking_strict&lt;double&gt; &gt; &gt; rB; </em></p> </blockquote> <blockquote> <p> rB = exp(rA); </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 12 Jun 2013 21:35:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5498#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:3</guid> <description> <p> How is this a showstopper? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 07 Jul 2013 16:40:40 GMT</pubDate> <title>severity changed https://svn.boost.org/trac10/ticket/5498#comment:4 https://svn.boost.org/trac10/ticket/5498#comment:4 <ul> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket anonymous Sat, 05 Oct 2013 18:38:58 GMT <link>https://svn.boost.org/trac10/ticket/5498#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:5</guid> <description> <p> Well. IMO is still a show stopper and it has not been solved. </p> <p> Daniel Duffy </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 05 Oct 2013 18:47:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5498#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:6</guid> <description> <p> It's a show stopper because you can't &lt;cmath&gt; functionality on Interval. But +, -, * and / do work. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 21 Dec 2014 21:17:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5498#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:7</guid> <description> <p> We are now 4 years on. You conventiently changed status to PROBLEM... </p> <p> Has this show stopper been resolved? IMO it's easy to fix. </p> <p> thanks </p> <p> Daniel J. Duffy </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 03 Nov 2015 21:50:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5498#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5498#comment:8</guid> <description> <p> Anybody with a solution?? </p> </description> <category>Ticket</category> </item> </channel> </rss>