Last revised: June 16, 2021 at 10:35:24 GMT
Last revised: June 27, 2021 at 18:26:02 GMT
1 2 4 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
addition
+ +add_fn
at
- +atanh
@@ -1320,6 +1327,10 @@fibonacci
+ +find_alpha
means
- -means_and_covariance
Graphing, Profiling, and Generating Test Data for Special Functions
set
+ +set_zero
unchecked_fibonacci
+ +unreal
A B C D E F G H I K L M N O P Q R S T U V W
bilinear_uniform
+ +fibonacci_generator
+ +fisher_f_distribution
A B C D E F G H I K L N P R S T U V W
BOOST_MATH_STANDALONE
diff --git a/doc/html/indexes/s05.html b/doc/html/indexes/s05.html index 6e8b4bbce..33bc41746 100644 --- a/doc/html/indexes/s05.html +++ b/doc/html/indexes/s05.html @@ -23,7 +23,7 @@1 2 4 5 7 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
addition
+ +add_fn
at
- +atanh
@@ -818,6 +825,22 @@Bilinear Uniform Interpolation
+bilinear_uniform
+ +binomial
BOOST_MATH_STANDALONE
@@ -2404,6 +2428,7 @@Finding Zeros of Bessel Functions of the First and Second Kinds
F Distribution Examples
- -Facets for Floating-Point Infinities and NaNs
fibonacci
+ +Fibonacci Numbers
+ +fibonacci_generator
+ +file
Algorithm TOMS 748: Alefeld, Potra and Shi: Enclosing zeros of continuous functions
means
- -means_and_covariance
Finding Zeros of Bessel Functions of the First and Second Kinds
Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values
Graphing, Profiling, and Generating Test Data for Special Functions
set
+ +Setting Polices at Namespace Scope
unchecked_fibonacci
+ +uniform
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
#include <boost/math/interpolators/bilinear_uniform.hpp> + +namespace boost::math::interpolators { + +template <class RandomAccessContainer> +class bilinear_uniform +{ +public: + using Real = typename RandomAccessContainer::value_type; + + bilinear_uniform(RandomAccessContainer && fieldData, decltype(fieldData.size()) rows, decltype(fieldData.size()) cols, Real dx = 1, Real dy = 1, Real x0 = 0, Real y0 = 0) + + Real operator()(Real x, Real y) const; +}; ++
+ The bilinear uniform interpolator takes a grid of data points specified by + a linear index and interpolates between each segment using a bilinear function. + Note that "bilinear" does not mean linear-it is the product of two + linear functions. The interpolant is continuous and its evaluation is constant + time. An example usage is as follows: +
+std::vector<double> v{0.1, 0.2, 0.3, + 0.4, 0.5, 0.5}; +using boost::math::interpolators::bilinear_uniform; +int rows = 2; +int cols = 3; +double dx = 1; +double dy = 1; +auto bu = bilinear_uniform(std::move(v), rows, cols, dx, dy); +// evaluate at a point: +double z = bu(0.0, 0.0); ++
+ Periodically, it is helpful to see what data the interpolator has. This can + be achieved via +
+std::cout << ub << "\n"; ++
+ Note that the interpolator is pimpl'd, so that copying the class is cheap, + and hence it can be shared between threads. (The call operator is threadsafe.) +
++ Note that the layout of the field data follows the convention found in laying + out images: The first value is associated with (x0, y0), and the last value + is associate with (x0 + (cols - 1)dx, y0 + (rows - 1)dy). This matches with + how we think about laying out matrices in C order, but of course there is no + canonical choice and conventions must be made. For example, it is traditional + in image processing the associate the first field value with the center of + the pixel (which would be called a cell-centered field in VTK). This interpolator + is point-centered, in the sense that (x0,y0) is associated with value v[0], + and (x0+dx, y0) associated with v[1]. If you have cell-centered data at (0,0), + then just pass (x0,y0) = (0.5, 0.5) to this interpolator. +
++ Note that this interpolator does not provide the option for a rotation. We + regarded that as too expensive to handle in this class. Rotating the arguments + must be performed by the user. +
+
+ The google/benchmark in reporting/performance/bilinear_uniform_performance.cpp demonstrates
+ the cost of the call operator for this interpolator:
+
Run on (16 X 4300 MHz CPU s) +CPU Caches: + L1 Data 32K (x8) + L1 Instruction 32K (x8) + L2 Unified 1024K (x8) + L3 Unified 11264K (x1) +Load Average: 0.92, 0.64, 0.35 +-------------------------------------- +Benchmark Time +-------------------------------------- +Bilinear<double>/64 13.6 ns +Bilinear<double>/128 13.3 ns +Bilinear<double>/256 13.9 ns +Bilinear<double>/512 13.7 ns +Bilinear<double>/1024 13.2 ns +Bilinear<double>/2048 13.1 ns +Bilinear<double>/4096 13.2 ns +Bilinear<double>/8192 13.2 ns ++
| + | + |
This documentation aims to use of the following naming and formatting conventions.
diff --git a/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html b/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html
index 7b11aa984..f204bcf3b 100644
--- a/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html
+++ b/doc/html/math_toolkit/dist_ref/dists/hypergeometric_dist.html
@@ -342,22 +342,6 @@
![]() |
-Note | -
|---|---|
- The kurtosis formula above is not quite correct and kurtosis excess is - now calculated from Wolfram - Alpha hypergeometric distribution kurtosis. (The hypergeometric - distribution kurtosis excess is mentioned in Wolfram - Hypergeometric distribution but coyly only described as "the - kurtosis excess is given by a complicated expression."). - This has been found numerically equivalent to the Wikipedia - hypergeometric kurtosis excess formula. - |
| diff --git a/doc/html/math_toolkit/history1.html b/doc/html/math_toolkit/history1.html index 3d50c46e6..3ff59e77c 100644 --- a/doc/html/math_toolkit/history1.html +++ b/doc/html/math_toolkit/history1.html @@ -38,6 +38,42 @@ |
![]() |
+Home | +Libraries | +People | +FAQ | +More | +
+ Fibonacci numbers + (Fn) follows the linear recurrence Fn=Fn-1+Fn-2 starting with F0=0, F1=1. +
+#include <boost/math/special_functions/fibonacci.hpp> ++
namespace boost { namespace math { + +template <class T, class Policy> +constexpr T fibonacci(unsigned long long n) // Checked version (default policy) + +template <class T, class Policy> +constexpr T fibonacci(unsigned long long n, const Policy &pol) // Checked version (policy for errors etc.) + +template <typename T> +constexpr T unchecked_fibonacci(unsigned long long n) noexcept(std::is_fundamental<T>::value); { // Unchecked version (no policy). + +}} // namespaces ++
+ The functions return Fn for a given input n having type
+ T.
+
+ The checked versions checks for the overflow before starting the computation.
+ If n is so large that the result can not be represented
+ in type T, it then calls overflow_error.
+ The overflow check is susceptible to off-by-one errors around the overflow
+ limit. See Binet's Formula below for more details on the check.
+
+ These functions are all constexpr
+ from C++14 onwards, and in addition unchecked_fibonacci
+ is noexcept when T is a fundamental
+ type.
+
+ The final Policy 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 policy + documentation for more details. +
++ If in the checked version, the overflow check succeeds then the unchecked + version is called which computes the desired Fn. Checked version is slower + because of the overhead involved in overflow check. +
+#include <boost/math/special_functions/fibonacci.hpp> ++
template <typename T> +class fibonacci_generator { + // returns consecutive fibonacci number starting from 0, 1, 1, 2, ... + T operator()(); + // reset the generator to start from nth fibonacci number + void set(unsigned long long n); +} ++
+ The generator returns consecutive fibonacci numbers starting with 0, 1, 1, + 2... +
+
+ The state of the generator can be modified using set()
+ which makes generator return consecutive fibonacci numbers starting from
+ n[sup th] fibonacci number.
+
boost::math::fibonacci_generator<int> gen; +int x = gen(); // x is 0 +int y = gen(); // y is 1 +for(int i = 0; i < 5; ++i) // this loop is same as gen.set(7); + gen(); +int z = gen(); // z is 13 ++
+ Generator is non-throwing for all fundamental types and will not check for + overflows. +
++ The type must be an arithmetic type supporting +, -, * and can be initialized + from trivial integral types. +
+
+ The file reciprocal_fibonacci_constant.cpp
+ uses fibonacci_generator
+ to calculate the reciprocal fibonacci constant to 1000 digit precision like
+ so:
+
#include <boost/math/special_functions/fibonacci.hpp> +#include <boost/multiprecision/mpfr.hpp> +#include <iomanip> +#include <iostream> + +int main() { + using Real = boost::multiprecision::mpfr_float_1000; + boost::math::fibonacci_generator<Real> gen; + gen.set(1); // start producing values from 1st fibonacci number + Real ans = 0; + const int ITR = 1000; + for (int i = 0; i < ITR; ++i) { + ans += 1.0 / gen(); + } + std::cout << std::setprecision(1000) << "Reciprocal fibonacci constant after " + << ITR << " iterations is: " << ans << std::endl; +} ++
+ The time complexity for computing fibonacci number is O(log n), without considering
+ the time complexities of multiplication and addition (where n
+ is the input parameter). The implementation is iterative version of Dijkstra's identities
+ and which simply walks down the bits of n.
+
+ There is a closed form expression for computing fibonacci numbers but since + it suffers from imprecision issues (using floating point computation), it + is not implemented. +
++ However an approximate formula is used for the overflow checking in the checked + version. +
+| + | + |