Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65539 - in sandbox/chrono/libs/ratio/doc: . html
From: vicente.botet_at_[hidden]
Date: 2010-09-23 01:40:14


Author: viboes
Date: 2010-09-23 01:40:12 EDT (Thu, 23 Sep 2010)
New Revision: 65539
URL: http://svn.boost.org/trac/boost/changeset/65539

Log:
Ratio update doc
Binary files modified:
   sandbox/chrono/libs/ratio/doc/ratio.pdf
Text files modified:
   sandbox/chrono/libs/ratio/doc/html/index.html | 26 ++++--------------------
   sandbox/chrono/libs/ratio/doc/ratio.qbk | 41 ---------------------------------------
   2 files changed, 6 insertions(+), 61 deletions(-)

Modified: sandbox/chrono/libs/ratio/doc/html/index.html
==============================================================================
--- sandbox/chrono/libs/ratio/doc/html/index.html (original)
+++ sandbox/chrono/libs/ratio/doc/html/index.html 2010-09-23 01:40:12 EDT (Thu, 23 Sep 2010)
@@ -1499,25 +1499,9 @@
         result in overflow.
       </p>
 <p>
- Boost.Ratio has implemented some simplifications in order to reduce the possibility
- of overflow, but these don't take care of all possible cases. For example
- the preceding example doesn't works now.
- </p>
-<p>
- In order to take care of this case we could apply this kind of simplification:
- </p>
-<pre class="programlisting"><span class="identifier">simplify</span><span class="special">&lt;</span> <span class="identifier">fraction</span><span class="special">&lt;</span><span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">&gt;,</span> <span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">,</span><span class="identifier">D</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="special">::=</span>
- <span class="keyword">case</span> <span class="identifier">gcd</span><span class="special">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">C</span><span class="special">)</span> <span class="special">&gt;</span> <span class="number">1</span> <span class="identifier">simplify</span><span class="special">&lt;</span> <span class="identifier">fraction</span><span class="special">&lt;</span><span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">C</span><span class="special">),</span><span class="identifier">B</span><span class="special">&gt;,</span> <span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">/</span><span class="identifier">gcd</span><span class="special
">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">C</span><span class="special">),</span><span class="identifier">D</span><span class="special">&gt;&gt;&gt;</span>
- <span class="keyword">case</span> <span class="identifier">gcd</span><span class="special">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">D</span><span class="special">)</span> <span class="special">&gt;</span> <span class="number">1</span> <span class="identifier">simplify</span><span class="special">&lt;</span> <span class="identifier">fraction</span><span class="special">&lt;</span><span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">D</span><span class="special">),</span><span class="identifier">B</span><span class="special">&gt;,</span> <span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">,</span><span class="identifier">D</span><span class="special">
/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">D</span><span class="special">)&gt;&gt;&gt;</span>
- <span class="keyword">case</span> <span class="identifier">gcd</span><span class="special">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">)</span> <span class="special">&gt;</span> <span class="number">1</span> <span class="identifier">simplify</span><span class="special">&lt;</span> <span class="identifier">fraction</span><span class="special">&lt;</span><span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">)&gt;,</span> <span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">/</span><span class="identifier">gcd</span><span class="special
">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">),</span><span class="identifier">D</span><span class="special">&gt;&gt;&gt;</span>
- <span class="keyword">case</span> <span class="identifier">gcd</span><span class="special">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">D</span><span class="special">)</span> <span class="special">&gt;</span> <span class="number">1</span> <span class="identifier">simplify</span><span class="special">&lt;</span> <span class="identifier">fraction</span><span class="special">&lt;</span><span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">D</span><span class="special">)&gt;,</span> <span class="identifier">times</span><span class="special">&lt;</span><span class="identifier">C</span><span class="special">,</span><span class="identifier">D</span><span class="special">
/</span><span class="identifier">gcd</span><span class="special">(</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">D</span><span class="special">)&gt;&gt;&gt;</span>
- <span class="identifier">otherwise</span> <span class="identifier">ratio</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">*</span><span class="identifier">B</span><span class="special">,</span> <span class="identifier">C</span><span class="special">*</span><span class="identifier">D</span><span class="special">&gt;</span>
-</pre>
-<p>
- While this works in some cases, a more general factorization algorithm will
- be needed to manage with all the cases. Whether we should manage with them
- is an open question, as the compile times will be increassed strongly to
- cover some causual cases.
+ Boost.Ratio implementes some simplifications in order to reduce the possibility
+ of overflow. The general idea is to use the gcd of some of the possible products
+ that can overflow, and simplify before doing the product.
       </p>
 </div>
 <div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title">
@@ -2347,7 +2331,7 @@
 <a name="boost_ratio.appendices.todo"></a> Appendix H: Future plans
 </h3></div></div></div>
 <a name="boost_ratio.appendices.todo.for_later_releases"></a><h4>
-<a name="id5014547"></a>
+<a name="id5013689"></a>
         <a href="index.html#boost_ratio.appendices.todo.for_later_releases">For later
         releases</a>
       </h4>
@@ -2359,7 +2343,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: September 22, 2010 at 16:05:04 GMT</small></p></td>
+<td align="left"><p><small>Last revised: September 23, 2010 at 05:36:54 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/chrono/libs/ratio/doc/ratio.pdf
==============================================================================
Binary files. No diff available.

Modified: sandbox/chrono/libs/ratio/doc/ratio.qbk
==============================================================================
--- sandbox/chrono/libs/ratio/doc/ratio.qbk (original)
+++ sandbox/chrono/libs/ratio/doc/ratio.qbk 2010-09-23 01:40:12 EDT (Thu, 23 Sep 2010)
@@ -1054,48 +1054,9 @@
 
 When the result is representable, but a simple application of arithmetic rules would result in overflow, e.g. `ratio_multiply<ratio<INTMAX_MAX,2>,ratio<2,INTMAX_MAX>>` can be reduced to `ratio<1,1>`, but the direct result of `ratio<INTMAX_MAX*2,INTMAX_MAX*2>` would result in overflow.
 
-Boost.Ratio has implemented some simplifications in order to reduce the possibility of overflow, but these don't take care of all possible cases. For example the preceding example doesn't works now.
+Boost.Ratio implementes some simplifications in order to reduce the possibility of overflow. The general idea is to use the gcd of some of the possible products that can overflow, and simplify before doing the product.
 
-In order to take care of this case we could apply this kind of simplification:
 
- simplify< fraction<times<A,B>, times<C,D> > > ::=
- case gcd(A,C) > 1 simplify< fraction<times<A/gcd(A,C),B>, times<C/gcd(A,C),D>>>
- case gcd(A,D) > 1 simplify< fraction<times<A/gcd(A,D),B>, times<C,D/gcd(A,D)>>>
- case gcd(B,C) > 1 simplify< fraction<times<A,B/gcd(B,C)>, times<C/gcd(B,C),D>>>
- case gcd(B,D) > 1 simplify< fraction<times<A,B/gcd(B,D)>, times<C,D/gcd(B,D)>>>
- otherwise ratio<A*B, C*D>
-
-While this works in some cases, a more general factorization algorithm will be needed to manage with all the cases. Whether we should manage with them is an open question, as the compile times will be increassed strongly to cover some causual cases.
-
-[/
-simplify< fraction<times<A,B>, times<C,D> > > ::=
-simplify< fraction<times<factorize<A>,factorize<B>>,
- times<factorize<C>,factorize<D>> > > ::=
-simplify< fraction<factors<AxB>,
- factors<CxD> > > ::=
-simplify< factors<AxB>, factors<CxD> >
-
-simplify< void, B > > ::= ratio< 1, B >
-simplify< A, void > > ::= ratio< A, 1 >
-simplify< factors<N, A>, factors<N, B> > > ::= simplify< A, B >
-
-simplify< factors<N, A>, factors<N+M, B> > > ::=
-let xx = simplify< A, factors<N+M, B> > >
- ratio<N*xx.num, xx.den>
-
-simplify< factors<N+M, A>, factors<M, B> > > ::=
-let xx = simplify< N+M, factors<M, B> > >
- ratio<xx.num, M*xx.den>
-
-factorize<0> = 0
-factorize<1> = 2
-
-factorize<N> = factorize_n<N, 2>
-
-factorize_n<N, A, R=N%2> = factorize_n<N, A+1>
-factorize_n<N, N, 1> N
-factorize_n<N, A, 0> = times<A, factorize_n<N/A>, A>
-]
 [endsect]
 
 [/======================================================]


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk