summaryrefslogtreecommitdiff
path: root/libs/math/doc/sf_and_dist/html/math_toolkit/special/factorials/sf_falling_factorial.html
blob: 3dcb4d48af325fa85759b7361d0bb3e7a042be00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Falling Factorial</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../../../index.html" title="Math Toolkit">
<link rel="up" href="../factorials.html" title="Factorials and Binomial Coefficients">
<link rel="prev" href="sf_rising_factorial.html" title="Rising Factorial">
<link rel="next" href="sf_binomial.html" title="Binomial Coefficients">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sf_rising_factorial.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../factorials.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="sf_binomial.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section math_toolkit_special_factorials_sf_falling_factorial">
<div class="titlepage"><div><div><h4 class="title">
<a name="math_toolkit.special.factorials.sf_falling_factorial"></a><a class="link" href="sf_falling_factorial.html" title="Falling Factorial">Falling
        Factorial</a>
</h4></div></div></div>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">factorials</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
        </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<a class="link" href="../../main_overview/result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">falling_factorial</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">i</span><span class="special">);</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../policy.html" title="Policies">Policy</a><span class="special">&gt;</span>
<a class="link" href="../../main_overview/result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">falling_factorial</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../../policy.html" title="Policies">Policy</a><span class="special">&amp;);</span>

<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
          Returns the falling factorial of <span class="emphasis"><em>x</em></span> and <span class="emphasis"><em>i</em></span>:
        </p>
<p>
          falling_factorial(x, i) = x(x-1)(x-2)(x-3)...(x-i+1)
        </p>
<p>
          Note that this function is only defined for positive <span class="emphasis"><em>i</em></span>,
          hence the <code class="computeroutput"><span class="keyword">unsigned</span></code> second
          argument. Argument <span class="emphasis"><em>x</em></span> can be either positive or negative
          however.
        </p>
<p>
          The final <a class="link" href="../../policy.html" title="Policies">Policy</a> argument is
          optional and can be used to control the behaviour of the function: how
          it handles errors, what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Policies">policy documentation for more details</a>.
        </p>
<p>
          May return the result of <a class="link" href="../../main_overview/error_handling.html#overflow_error">overflow_error</a>
          if the result is too large to represent in type T.
        </p>
<p>
          The return type of these functions is computed using the <a class="link" href="../../main_overview/result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
          type calculation rules</em></span></a>: the type of the result is <code class="computeroutput"><span class="keyword">double</span></code> if T is an integer type, otherwise
          the type of the result is T.
        </p>
<h5>
<a name="math_toolkit.special.factorials.sf_falling_factorial.h0"></a>
          <span><a name="math_toolkit.special.factorials.sf_falling_factorial.accuracy"></a></span><a class="link" href="sf_falling_factorial.html#math_toolkit.special.factorials.sf_falling_factorial.accuracy">Accuracy</a>
        </h5>
<p>
          The accuracy will be the same as the <a class="link" href="../sf_gamma/gamma_ratios.html" title="Ratios of Gamma Functions">tgamma_delta_ratio</a>
          function.
        </p>
<h5>
<a name="math_toolkit.special.factorials.sf_falling_factorial.h1"></a>
          <span><a name="math_toolkit.special.factorials.sf_falling_factorial.testing"></a></span><a class="link" href="sf_falling_factorial.html#math_toolkit.special.factorials.sf_falling_factorial.testing">Testing</a>
        </h5>
<p>
          The spot tests for the falling factorials use data generated by functions.wolfram.com.
        </p>
<h5>
<a name="math_toolkit.special.factorials.sf_falling_factorial.h2"></a>
          <span><a name="math_toolkit.special.factorials.sf_falling_factorial.implementation"></a></span><a class="link" href="sf_falling_factorial.html#math_toolkit.special.factorials.sf_falling_factorial.implementation">Implementation</a>
        </h5>
<p>
          Rising and falling factorials are implemented as ratios of gamma functions
          using <a class="link" href="../sf_gamma/gamma_ratios.html" title="Ratios of Gamma Functions">tgamma_delta_ratio</a>.
          Optimisations for small integer arguments are handled internally by that
          function.
        </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010 John Maddock, Paul A. Bristow, Hubert Holin, Xiaogang Zhang, Bruno
      Lalande, Johan R&#229;de, Gautam Sewani, Thijs van den Berg and Benjamin Sobotta<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        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>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="sf_rising_factorial.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../factorials.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="sf_binomial.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>