Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77607 - in sandbox/big_number/libs/multiprecision: doc/html doc/html/boost_multiprecision/tut example
From: john_at_[hidden]
Date: 2012-03-28 13:47:42


Author: johnmaddock
Date: 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
New Revision: 77607
URL: http://svn.boost.org/trac/boost/changeset/77607

Log:
Update floating point examples to show Boost.Math usage.
Text files modified:
   sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html | 2 +-
   sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html | 15 +++++++++++++++
   sandbox/big_number/libs/multiprecision/doc/html/index.html | 2 +-
   sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp | 6 ++++++
   sandbox/big_number/libs/multiprecision/example/gmp_snips.cpp | 6 ++++++
   sandbox/big_number/libs/multiprecision/example/mpfr_snips.cpp | 6 ++++++
   6 files changed, 35 insertions(+), 2 deletions(-)

Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -295,7 +295,7 @@
 
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">v</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 20!</span>
 
-<span class="comment">// Try again at arbitrary precision:</span>
+<span class="comment">// Repeat at arbitrary precision:</span>
 <span class="identifier">cpp_int</span> <span class="identifier">u</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
 <span class="keyword">for</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;=</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
    <span class="identifier">u</span> <span class="special">*=</span> <span class="identifier">i</span><span class="special">;</span>

Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -286,7 +286,12 @@
 <span class="comment">// Operations at fixed precision and full standard library support:</span>
 <span class="identifier">mpf_float_100</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">mpf_float_100</span><span class="special">&gt;::</span><span class="identifier">digits</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// We can use any C++ std lib function:</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// print log(2)</span>
+<span class="comment">// We can also use any function from Boost.Math:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// These even work when the argument is an expression template:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span> <span class="special">*</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
 
 <span class="comment">// Access the underlying representation:</span>
 <span class="identifier">mpf_t</span> <span class="identifier">f</span><span class="special">;</span>
@@ -407,7 +412,12 @@
 <span class="comment">// Operations at fixed precision and full numeric_limits support:</span>
 <span class="identifier">mpfr_float_100</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">mpfr_float_100</span><span class="special">&gt;::</span><span class="identifier">digits</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// We can use any C++ std lib function:</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// print log(2)</span>
+<span class="comment">// We can also use any function from Boost.Math:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// These even work when the argument is an expression template:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span> <span class="special">*</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
 
 <span class="comment">// Access the underlying data:</span>
 <span class="identifier">mpfr_t</span> <span class="identifier">r</span><span class="special">;</span>
@@ -485,7 +495,12 @@
 <span class="comment">// Operations at fixed precision and full numeric_limits support:</span>
 <span class="identifier">cpp_dec_float_100</span> <span class="identifier">b</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">cpp_dec_float_100</span><span class="special">&gt;::</span><span class="identifier">digits</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// We can use any C++ std lib function:</span>
 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// print log(2)</span>
+<span class="comment">// We can also use any function from Boost.Math:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="comment">// These even work when the argument is an expression template:</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">tgamma</span><span class="special">(</span><span class="identifier">b</span> <span class="special">*</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">&lt;&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
 </pre>
 <p>
       </p>

Modified: sandbox/big_number/libs/multiprecision/doc/html/index.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/index.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/index.html 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -66,7 +66,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: March 28, 2012 at 17:05:42 GMT</small></p></td>
+<td align="left"><p><small>Last revised: March 28, 2012 at 17:43:15 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp (original)
+++ sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -4,6 +4,7 @@
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
 
 #include <boost/multiprecision/cpp_dec_float.hpp>
+#include <boost/math/special_functions/gamma.hpp>
 #include <iostream>
 
 void t1()
@@ -16,7 +17,12 @@
    // Operations at fixed precision and full numeric_limits support:
    cpp_dec_float_100 b = 2;
    std::cout << std::numeric_limits<cpp_dec_float_100>::digits << std::endl;
+ // We can use any C++ std lib function:
    std::cout << log(b) << std::endl; // print log(2)
+ // We can also use any function from Boost.Math:
+ std::cout << boost::math::tgamma(b) << std::endl;
+ // These even work when the argument is an expression template:
+ std::cout << boost::math::tgamma(b * b) << std::endl;
    //]
 }
 

Modified: sandbox/big_number/libs/multiprecision/example/gmp_snips.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/example/gmp_snips.cpp (original)
+++ sandbox/big_number/libs/multiprecision/example/gmp_snips.cpp 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -4,6 +4,7 @@
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
 
 #include <boost/multiprecision/gmp.hpp>
+#include <boost/math/special_functions/gamma.hpp>
 #include <iostream>
 
 void t1()
@@ -44,7 +45,12 @@
    // Operations at fixed precision and full standard library support:
    mpf_float_100 b = 2;
    std::cout << std::numeric_limits<mpf_float_100>::digits << std::endl;
+ // We can use any C++ std lib function:
    std::cout << log(b) << std::endl; // print log(2)
+ // We can also use any function from Boost.Math:
+ std::cout << boost::math::tgamma(b) << std::endl;
+ // These even work when the argument is an expression template:
+ std::cout << boost::math::tgamma(b * b) << std::endl;
 
    // Access the underlying representation:
    mpf_t f;

Modified: sandbox/big_number/libs/multiprecision/example/mpfr_snips.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/example/mpfr_snips.cpp (original)
+++ sandbox/big_number/libs/multiprecision/example/mpfr_snips.cpp 2012-03-28 13:47:41 EDT (Wed, 28 Mar 2012)
@@ -4,6 +4,7 @@
 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
 
 #include <boost/multiprecision/mpfr.hpp>
+#include <boost/math/special_functions/gamma.hpp>
 #include <iostream>
 
 void t1()
@@ -22,7 +23,12 @@
    // Operations at fixed precision and full numeric_limits support:
    mpfr_float_100 b = 2;
    std::cout << std::numeric_limits<mpfr_float_100>::digits << std::endl;
+ // We can use any C++ std lib function:
    std::cout << log(b) << std::endl; // print log(2)
+ // We can also use any function from Boost.Math:
+ std::cout << boost::math::tgamma(b) << std::endl;
+ // These even work when the argument is an expression template:
+ std::cout << boost::math::tgamma(b * b) << std::endl;
 
    // Access the underlying data:
    mpfr_t r;


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