x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
binomial.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\math\special_functions\binomial.hpp
旋转
特效
属性
历史版本
// Copyright John Maddock 2006. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_MATH_SF_BINOMIAL_HPP #define BOOST_MATH_SF_BINOMIAL_HPP #include
#include
#include
namespace boost{ namespace math{ template
T binomial_coefficient(unsigned n, unsigned k, const Policy& pol) { BOOST_MATH_STD_USING static const char* function = "boost::math::binomial_coefficient<%1%>(unsigned, unsigned)"; if(k > n) return policies::raise_domain_error
( function, "The binomial coefficient is undefined for k > n, but got k = %1%.", k, pol); T result; if((k == 0) || (k == n)) return 1; if((k == 1) || (k == n-1)) return n; if(n <= max_factorial
::value) { // Use fast table lookup: result = unchecked_factorial
(n); result /= unchecked_factorial
(n-k); result /= unchecked_factorial
(k); } else { // Use the beta function: if(k < n - k) result = k * beta(static_cast
(k), static_cast
(n-k+1), pol); else result = (n - k) * beta(static_cast
(k+1), static_cast
(n-k), pol); if(result == 0) return policies::raise_overflow_error
(function, 0, pol); result = 1 / result; } // convert to nearest integer: return ceil(result - 0.5f); } // // Type float can only store the first 35 factorials, in order to // increase the chance that we can use a table driven implementation // we'll promote to double: // template <> inline float binomial_coefficient
>(unsigned n, unsigned k, const policies::policy<>& pol) { return policies::checked_narrowing_cast
>(binomial_coefficient
(n, k, pol), "boost::math::binomial_coefficient<%1%>(unsigned,unsigned)"); } template
inline T binomial_coefficient(unsigned n, unsigned k) { return binomial_coefficient
(n, k, policies::policy<>()); } } // namespace math } // namespace boost #endif // BOOST_MATH_SF_BINOMIAL_HPP
binomial.hpp
网页地址
文件地址
上一页
6/35
下一页
下载
( 2 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.