• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright Christopher Kormanyos 2013.
3 // Copyright Paul A. Bristow 2013.
4 // Copyright John Maddock 2013.
5 
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or
8 // copy at http://www.boost.org/LICENSE_1_0.txt).
9 
10 #ifdef _MSC_VER
11 #  pragma warning (disable : 4512) // assignment operator could not be generated.
12 #  pragma warning (disable : 4996) // assignment operator could not be generated.
13 #endif
14 
15 #include <iostream>
16 #include <limits>
17 #include <vector>
18 #include <algorithm>
19 #include <iomanip>
20 #include <iterator>
21 
22 //[neumann_zeros_example_1
23 
24 /*`[h5 Calculating zeros of the Neumann function.]
25 This example also shows how Boost.Math and Boost.Multiprecision can be combined to provide
26 a many decimal digit precision. For 50 decimal digit precision we need to include
27 */
28 
29   #include <boost/multiprecision/cpp_dec_float.hpp>
30 
31 /*`and a `typedef` for `float_type` may be convenient
32 (allowing a quick switch to re-compute at built-in `double` or other precision)
33 */
34   typedef boost::multiprecision::cpp_dec_float_50 float_type;
35 
36 //`To use the functions for finding zeros of the `cyl_neumann` function we need:
37 
38   #include <boost/math/special_functions/bessel.hpp>
39 //] [/neumann_zerso_example_1]
40 
main()41 int main()
42 {
43   try
44   {
45     {
46 //[neumann_zeros_example_2
47 /*`The Neumann (Bessel Y) function zeros are evaluated very similarly:
48 */
49     using boost::math::cyl_neumann_zero;
50     double zn = cyl_neumann_zero(2., 1);
51     std::cout << "cyl_neumann_zero(2., 1) = " << zn << std::endl;
52 
53     std::vector<float> nzeros(3); // Space for 3 zeros.
54     cyl_neumann_zero<float>(2.F, 1, nzeros.size(), nzeros.begin());
55 
56     std::cout << "cyl_neumann_zero<float>(2.F, 1, ";
57     // Print the zeros to the output stream.
58     std::copy(nzeros.begin(), nzeros.end(),
59               std::ostream_iterator<float>(std::cout, ", "));
60 
61     std::cout << "\n""cyl_neumann_zero(static_cast<float_type>(220)/100, 1) = "
62       << cyl_neumann_zero(static_cast<float_type>(220)/100, 1) << std::endl;
63     // 3.6154383428745996706772556069431792744372398748422
64 
65 //] //[/neumann_zeros_example_2]
66     }
67   }
68   catch (std::exception const& ex)
69   {
70     std::cout << "Thrown exception " << ex.what() << std::endl;
71   }
72 } // int main()
73 
74 /*
75  Output:
76 
77 cyl_neumann_zero(2., 1) = 3.38424
78 cyl_neumann_zero<float>(2.F, 1,
79 3.38424
80 6.79381
81 10.0235
82 3.61544
83 */
84 
85 
86