File: hyp_1f1_neg_int_data.cpp

package info (click to toggle)
scipy 1.16.0-1exp7
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 234,820 kB
  • sloc: cpp: 503,145; python: 344,611; ansic: 195,638; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 848; makefile: 785; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (83 lines) | stat: -rw-r--r-- 2,391 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//  (C) Copyright John Maddock 2023.
//  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)

#define BOOST_MATH_MAX_SERIES_ITERATION_POLICY 10000000
#define BOOST_MATH_USE_MPFR

#include "mp_t.hpp"
#include <boost/math/special_functions/hypergeometric_1F1.hpp>
#include <boost/math/special_functions/hypergeometric_pFq.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/lexical_cast.hpp>
#include <fstream>
#include <map>
#include <boost/math/tools/test_data.hpp>
#include <boost/random.hpp>

using namespace boost::math::tools;
using namespace boost::math;
using namespace std;

struct hypergeometric_1f1_gen
{
   mp_t operator()(mp_t arg1, mp_t arg2, mp_t z)
   {
      boost::multiprecision::mpfr_float a1(arg1), a2(arg2), a3(z), r;
      r = boost::math::hypergeometric_pFq_precision({ a1 }, { a2 }, a3, 50);
      return mp_t(r);
   }
};


int main(int, char* [])
{
   parameter_info<mp_t> arg1, arg2, arg3;
   test_data<mp_t> data;

   std::cout << "Welcome.\n"
      "This program will generate spot tests for 1F1 with negative integer arguments:\n";

   std::string line;
   bool cont;

   random_ns::mt19937 rnd;
   random_ns::uniform_real_distribution<float> ur_a(0, 20);


   for (int i = -4; i > -100000; i *= 7)
   {
      arg1 = make_single_param(mp_t(i));
      arg2 = make_single_param(mp_t(-100004));
      arg3 = make_single_param(mp_t(ur_a(rnd)));

      data.insert(hypergeometric_1f1_gen(), arg1, arg2, arg3);
      arg3.z1 = -arg3.z1;
      data.insert(hypergeometric_1f1_gen(), arg1, arg2, arg3);
   }

   for (int i = -4; i > -100000; i *= 7)
   {
      arg1 = make_single_param(mp_t(i));
      arg2 = make_single_param(mp_t(mp_t(i) - 3));
      arg3 = make_single_param(mp_t(ur_a(rnd)));

      data.insert(hypergeometric_1f1_gen(), arg1, arg2, arg3);
      arg3.z1 = -arg3.z1;
      data.insert(hypergeometric_1f1_gen(), arg1, arg2, arg3);
   }

   std::cout << "Enter name of test data file [default=hypergeometric_1f1_neg_int.ipp]";
   std::getline(std::cin, line);
   boost::algorithm::trim(line);
   if (line == "")
      line = "hypergeometric_1f1_neg_int.ipp";
   std::ofstream ofs(line.c_str());
   ofs << std::scientific << std::setprecision(40);
   write_code(ofs, data, line.c_str());

   return 0;
}