unchecked_factorial.hpp

来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 403 行 · 第 1/2 页

HPP
403
字号
//  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_SP_UC_FACTORIALS_HPP#define BOOST_MATH_SP_UC_FACTORIALS_HPP#ifdef _MSC_VER#pragma once#endif#include <boost/array.hpp>#ifdef BOOST_MSVC#pragma warning(push) // Temporary until lexical cast fixed.#pragma warning(disable: 4127 4701)#endif#include <boost/lexical_cast.hpp>#ifdef BOOST_MSVC#pragma warning(pop)#endif#include <boost/config/no_tr1/cmath.hpp>#include <boost/math/special_functions/math_fwd.hpp>namespace boost { namespace math{// Forward declarations:template <class T>struct max_factorial;// efinitions:template <>inline float unchecked_factorial<float>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(float)){   static const boost::array<float, 35> factorials = {{      1.0F,      1.0F,      2.0F,      6.0F,      24.0F,      120.0F,      720.0F,      5040.0F,      40320.0F,      362880.0F,      3628800.0F,      39916800.0F,      479001600.0F,      6227020800.0F,      87178291200.0F,      1307674368000.0F,      20922789888000.0F,      355687428096000.0F,      6402373705728000.0F,      121645100408832000.0F,      0.243290200817664e19F,      0.5109094217170944e20F,      0.112400072777760768e22F,      0.2585201673888497664e23F,      0.62044840173323943936e24F,      0.15511210043330985984e26F,      0.403291461126605635584e27F,      0.10888869450418352160768e29F,      0.304888344611713860501504e30F,      0.8841761993739701954543616e31F,      0.26525285981219105863630848e33F,      0.822283865417792281772556288e34F,      0.26313083693369353016721801216e36F,      0.868331761881188649551819440128e37F,      0.29523279903960414084761860964352e39F,   }};   return factorials[i];}template <>struct max_factorial<float>{   BOOST_STATIC_CONSTANT(unsigned, value = 34);};template <>inline long double unchecked_factorial<long double>(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(long double)){   static const boost::array<long double, 171> factorials = {{      1L,      1L,      2L,      6L,      24L,      120L,      720L,      5040L,      40320L,      362880.0L,      3628800.0L,      39916800.0L,      479001600.0L,      6227020800.0L,      87178291200.0L,      1307674368000.0L,      20922789888000.0L,      355687428096000.0L,      6402373705728000.0L,      121645100408832000.0L,      0.243290200817664e19L,      0.5109094217170944e20L,      0.112400072777760768e22L,      0.2585201673888497664e23L,      0.62044840173323943936e24L,      0.15511210043330985984e26L,      0.403291461126605635584e27L,      0.10888869450418352160768e29L,      0.304888344611713860501504e30L,      0.8841761993739701954543616e31L,      0.26525285981219105863630848e33L,      0.822283865417792281772556288e34L,      0.26313083693369353016721801216e36L,      0.868331761881188649551819440128e37L,      0.29523279903960414084761860964352e39L,      0.103331479663861449296666513375232e41L,      0.3719933267899012174679994481508352e42L,      0.137637530912263450463159795815809024e44L,      0.5230226174666011117600072241000742912e45L,      0.203978820811974433586402817399028973568e47L,      0.815915283247897734345611269596115894272e48L,      0.3345252661316380710817006205344075166515e50L,      0.1405006117752879898543142606244511569936e52L,      0.6041526306337383563735513206851399750726e53L,      0.265827157478844876804362581101461589032e55L,      0.1196222208654801945619631614956577150644e57L,      0.5502622159812088949850305428800254892962e58L,      0.2586232415111681806429643551536119799692e60L,      0.1241391559253607267086228904737337503852e62L,      0.6082818640342675608722521633212953768876e63L,      0.3041409320171337804361260816606476884438e65L,      0.1551118753287382280224243016469303211063e67L,      0.8065817517094387857166063685640376697529e68L,      0.427488328406002556429801375338939964969e70L,      0.2308436973392413804720927426830275810833e72L,      0.1269640335365827592596510084756651695958e74L,      0.7109985878048634518540456474637249497365e75L,      0.4052691950487721675568060190543232213498e77L,      0.2350561331282878571829474910515074683829e79L,      0.1386831185456898357379390197203894063459e81L,      0.8320987112741390144276341183223364380754e82L,      0.507580213877224798800856812176625227226e84L,      0.3146997326038793752565312235495076408801e86L,      0.1982608315404440064116146708361898137545e88L,      0.1268869321858841641034333893351614808029e90L,      0.8247650592082470666723170306785496252186e91L,      0.5443449390774430640037292402478427526443e93L,      0.3647111091818868528824985909660546442717e95L,      0.2480035542436830599600990418569171581047e97L,      0.1711224524281413113724683388812728390923e99L,      0.1197857166996989179607278372168909873646e101L,      0.8504785885678623175211676442399260102886e102L,      0.6123445837688608686152407038527467274078e104L,      0.4470115461512684340891257138125051110077e106L,      0.3307885441519386412259530282212537821457e108L,      0.2480914081139539809194647711659403366093e110L,      0.188549470166605025498793226086114655823e112L,      0.1451830920282858696340707840863082849837e114L,      0.1132428117820629783145752115873204622873e116L,      0.8946182130782975286851441715398316520698e117L,      0.7156945704626380229481153372318653216558e119L,      0.5797126020747367985879734231578109105412e121L,      0.4753643337012841748421382069894049466438e123L,      0.3945523969720658651189747118012061057144e125L,      0.3314240134565353266999387579130131288001e127L,      0.2817104114380550276949479442260611594801e129L,      0.2422709538367273238176552320344125971528e131L,      0.210775729837952771721360051869938959523e133L,      0.1854826422573984391147968456455462843802e135L,      0.1650795516090846108121691926245361930984e137L,      0.1485715964481761497309522733620825737886e139L,      0.1352001527678402962551665687594951421476e141L,      0.1243841405464130725547532432587355307758e143L,      0.1156772507081641574759205162306240436215e145L,      0.1087366156656743080273652852567866010042e147L,      0.103299784882390592625997020993947270954e149L,      0.9916779348709496892095714015418938011582e150L,      0.9619275968248211985332842594956369871234e152L,      0.942689044888324774562618574305724247381e154L,      0.9332621544394415268169923885626670049072e156L,      0.9332621544394415268169923885626670049072e158L,      0.9425947759838359420851623124482936749562e160L,      0.9614466715035126609268655586972595484554e162L,      0.990290071648618040754671525458177334909e164L,      0.1029901674514562762384858386476504428305e167L,      0.1081396758240290900504101305800329649721e169L,      0.1146280563734708354534347384148349428704e171L,      0.1226520203196137939351751701038733888713e173L,      0.132464181945182897449989183712183259981e175L,      0.1443859583202493582204882102462797533793e177L,      0.1588245541522742940425370312709077287172e179L,      0.1762952551090244663872161047107075788761e181L,      0.1974506857221074023536820372759924883413e183L,      0.2231192748659813646596607021218715118256e185L,      0.2543559733472187557120132004189335234812e187L,      0.2925093693493015690688151804817735520034e189L,

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?