]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Run-time GCD & LCM Determination</title> | |
5 | <link rel="stylesheet" href="../math.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.77.1"> | |
7 | <link rel="home" href="../index.html" title="Math Toolkit 2.5.1"> | |
8 | <link rel="up" href="../gcd_lcm.html" title="Chapter 11. Integer Utilities (Greatest Common Divisor and Least Common Multiple)"> | |
9 | <link rel="prev" href="lcm_function_object.html" title="LCM Function Object"> | |
10 | <link rel="next" href="compile_time.html" title="Compile-time GCD and LCM determination"> | |
11 | </head> | |
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
13 | <table cellpadding="2" width="100%"><tr> | |
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> | |
15 | <td align="center"><a href="../../../../../index.html">Home</a></td> | |
16 | <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> | |
17 | <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> | |
18 | <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> | |
19 | <td align="center"><a href="../../../../../more/index.htm">More</a></td> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="lcm_function_object.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../gcd_lcm.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compile_time.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> | |
27 | <a name="math_toolkit.run_time"></a><a class="link" href="run_time.html" title="Run-time GCD & LCM Determination">Run-time GCD & LCM Determination</a> | |
28 | </h2></div></div></div> | |
29 | <p> | |
30 | <span class="bold"><strong>Header: </strong></span> <a href="../../../../../boost/math/common_factor_rt.hpp" target="_top"><boost/math/common_factor_rt.hpp></a> | |
31 | </p> | |
32 | <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span> | |
33 | <span class="identifier">IntegerType</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span> | |
34 | ||
35 | <span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">ForwardIterator</span> <span class="special">></span> | |
36 | <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span><span class="identifier">I</span><span class="special">>::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="identifier">I</span><span class="special">></span> <span class="identifier">gcd_range</span><span class="special">(</span><span class="identifier">I</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">I</span> <span class="identifier">last</span><span class="special">);</span> | |
37 | ||
38 | <span class="keyword">template</span> <span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">IntegerType</span> <span class="special">></span> | |
39 | <span class="identifier">IntegerType</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">lcm</span><span class="special">(</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">IntegerType</span> <span class="keyword">const</span> <span class="special">&</span><span class="identifier">b</span> <span class="special">);</span> | |
40 | </pre> | |
41 | <p> | |
42 | The <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd</span></code> | |
43 | function template returns the greatest common (nonnegative) divisor of the | |
44 | two integers passed to it. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">gcd_range</span></code> is the iteration of the above gcd | |
45 | algorithm over a range, returning the greatest common divisor of all the elements. | |
46 | The algorithm terminates when the gcd reaches unity or the end of the range. | |
47 | Thus it also returns the iterator after the last element inspected because | |
48 | this may not be equal to the end of the range. The boost::math::lcm function | |
49 | template returns the least common (nonnegative) multiple of the two integers | |
50 | passed to it. The function templates are parameterized on the function arguments' | |
51 | IntegerType, which is also the return type. Internally, these function templates | |
52 | use an object of the corresponding version of the <code class="computeroutput"><span class="identifier">gcd_evaluator</span></code> | |
53 | and <code class="computeroutput"><span class="identifier">lcm_evaluator</span></code> class templates, | |
54 | respectively. | |
55 | </p> | |
56 | </div> | |
57 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
58 | <td align="left"></td> | |
59 | <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal, | |
60 | Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert | |
61 | Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani, | |
62 | Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p> | |
63 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
64 | file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) | |
65 | </p> | |
66 | </div></td> | |
67 | </tr></table> | |
68 | <hr> | |
69 | <div class="spirit-nav"> | |
70 | <a accesskey="p" href="lcm_function_object.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../gcd_lcm.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compile_time.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
71 | </div> | |
72 | </body> | |
73 | </html> |