diff options
| author | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-05-11 22:17:58 +0200 |
| commit | 32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (patch) | |
| tree | c6e107c1ee4d70610e43a7912e57c720334a08c7 /boost/libs/math/example/bessel_zeros_interator_example.cpp | |
| parent | 08299e8b2bf50ba90daf570f57def529dd29d6e7 (diff) | |
New upstream version 2.2.0~rc1+repackupstream/2.2.0_rc1+repack
Diffstat (limited to 'boost/libs/math/example/bessel_zeros_interator_example.cpp')
| -rw-r--r-- | boost/libs/math/example/bessel_zeros_interator_example.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/boost/libs/math/example/bessel_zeros_interator_example.cpp b/boost/libs/math/example/bessel_zeros_interator_example.cpp deleted file mode 100644 index 989c2489..00000000 --- a/boost/libs/math/example/bessel_zeros_interator_example.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright Christopher Kormanyos 2013. -// Copyright Paul A. Bristow 2013. -// Copyright John Maddock 2013. - -// Distributed under 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). - -#ifdef _MSC_VER -# pragma warning (disable : 4512) // assignment operator could not be generated. -# pragma warning (disable : 4996) // assignment operator could not be generated. -#endif - -#include <iostream> -#include <limits> -#include <vector> -#include <algorithm> -#include <iomanip> -#include <iterator> - -//[bessel_zeros_iterator_example_1 - -/*`[h5 Using Output Iterator to sum zeros of Bessel Functions] - -This example demonstrates summing zeros of the Bessel functions. -To use the functions for finding zeros of the functions we need - */ - -#include <boost/math/special_functions/bessel.hpp> - -/*`We use the `cyl_bessel_j_zero` output iterator parameter `out_it` -to create a sum of ['1/zeros[super 2]] by defining a custom output iterator: -*/ - -template <class T> -struct output_summation_iterator -{ - output_summation_iterator(T* p) : p_sum(p) - {} - output_summation_iterator& operator*() - { return *this; } - output_summation_iterator& operator++() - { return *this; } - output_summation_iterator& operator++(int) - { return *this; } - output_summation_iterator& operator = (T const& val) - { - *p_sum += 1./ (val * val); // Summing 1/zero^2. - return *this; - } -private: - T* p_sum; -}; - -//] [/bessel_zeros_iterator_example_1] - -int main() -{ - try - { -//[bessel_zeros_iterator_example_2 - -/*`The sum is calculated for many values, converging on the analytical exact value of `1/8`. -*/ - using boost::math::cyl_bessel_j_zero; - double nu = 1.; - double sum = 0; - output_summation_iterator<double> it(&sum); // sum of 1/zeros^2 - cyl_bessel_j_zero(nu, 1, 10000, it); - - double s = 1/(4 * (nu + 1)); // 0.125 = 1/8 is exact analytical solution. - std::cout << std::setprecision(6) << "nu = " << nu << ", sum = " << sum - << ", exact = " << s << std::endl; - // nu = 1.00000, sum = 0.124990, exact = 0.125000 -//] [/bessel_zeros_iterator_example_2] - } - catch (std::exception ex) - { - std::cout << "Thrown exception " << ex.what() << std::endl; - } - return 0; - } // int_main() - -/* - Output: - - nu = 1, sum = 0.12499, exact = 0.125 -*/ |
