summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/math/example/special_data.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/math/example/special_data.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/math/example/special_data.cpp')
-rw-r--r--src/boost/libs/math/example/special_data.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/boost/libs/math/example/special_data.cpp b/src/boost/libs/math/example/special_data.cpp
new file mode 100644
index 000000000..2e101b409
--- /dev/null
+++ b/src/boost/libs/math/example/special_data.cpp
@@ -0,0 +1,84 @@
+// 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)
+
+//[special_data_example
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+#include <boost/math/tools/test_data.hpp>
+#include <boost/test/included/prg_exec_monitor.hpp>
+#include <fstream>
+
+using namespace boost::math::tools;
+using namespace boost::math;
+using namespace std;
+using namespace boost::multiprecision;
+
+template <class T>
+T my_special(T a, T b)
+{
+ // Implementation of my_special here...
+ return a + b;
+}
+
+int cpp_main(int argc, char*argv [])
+{
+ //
+ // We'll use so many digits of precision that any
+ // calculation errors will still leave us with
+ // 40-50 good digits. We'll only run this program
+ // once so it doesn't matter too much how long this takes!
+ //
+ typedef number<cpp_dec_float<500> > bignum;
+
+ parameter_info<bignum> arg1, arg2;
+ test_data<bignum> data;
+
+ bool cont;
+ std::string line;
+
+ if(argc < 1)
+ return 1;
+
+ do{
+ //
+ // User interface which prompts for
+ // range of input parameters:
+ //
+ if(0 == get_user_parameter_info(arg1, "a"))
+ return 1;
+ if(0 == get_user_parameter_info(arg2, "b"))
+ return 1;
+
+ //
+ // Get a pointer to the function and call
+ // test_data::insert to actually generate
+ // the values.
+ //
+ bignum (*fp)(bignum, bignum) = &my_special;
+ data.insert(fp, arg2, arg1);
+
+ std::cout << "Any more data [y/n]?";
+ std::getline(std::cin, line);
+ boost::algorithm::trim(line);
+ cont = (line == "y");
+ }while(cont);
+ //
+ // Just need to write the results to a file:
+ //
+ std::cout << "Enter name of test data file [default=my_special.ipp]";
+ std::getline(std::cin, line);
+ boost::algorithm::trim(line);
+ if(line == "")
+ line = "my_special.ipp";
+ std::ofstream ofs(line.c_str());
+ line.erase(line.find('.'));
+ ofs << std::scientific << std::setprecision(50);
+ write_code(ofs, data, line.c_str());
+
+ return 0;
+}
+
+//]