21 Config::set_current_dir(
"x002");
23 std::string fname = Config::get_current_file(__func__,
"dat");
26 std::ofstream fout{ fname };
29 throw std::ios_base::failure{ fname };
32 fout << std::scientific << std::setprecision(2);
34 for (
double x = -2; x <= 2; x += 1) {
35 fout << std::setw(9) << x <<
"," << std::pow(x, 2)
36 <<
"," << std::setw(9) << std::pow(x, 3)
37 <<
"," << std::setw(9) << std::pow(x, 4)
38 <<
"," << std::setw(9) << std::pow(x, 5) << std::endl;
41 }
catch (std::ios_base::failure ferror) {
42 std::cout <<
"could not open file:" 43 << ferror.what() << std::endl;
52 std::ofstream fout{ fname };
55 throw std::ios_base::failure{ fname };
63 using RealFN = std::function<double(double)>;
72 std::initializer_list<RealFN> fnlst,
73 std::array<double, 3> params) {
76 auto [xmin, xmax, dx] = params;
77 for (
double x = xmin; x <= xmax; x += dx) {
80 for (
auto &fn : fnlst) {
92 Config::set_current_dir(
"x002");
93 std::string fname = Config::get_current_file(std::string(__func__) +
".dat");
95 auto fn2 = [](
double x) {
return std::pow(x, 2); };
96 auto fn3 = [](
double x) {
return std::pow(x, 3); };
97 auto fn4 = [](
double x) {
return std::pow(x, 4); };
98 auto fn5 = [](
double x) {
return std::pow(x, 5); };
103 fout << std::scientific << std::setprecision(2);
107 fn_data(fout, { fn2, fn3, fn4, fn5 }, { -2, 2, 0.5 });
109 }
catch (std::ios_base::failure ferror) {
110 std::cout <<
"could not open file:" 111 << ferror.what() << std::endl;
std::function< double(double)> RealFN
void fn_data(std::ofstream &fout, std::initializer_list< RealFN > fnlst, std::array< double, 3 > params)
fn_data Ausgabe von Funktionswerten in eine Datei
auto open_file(const std::string &fname)
open_file öffne Ausgabestrom für eine Datei
void ex2()
ex2 schreibe Funktionsdaten für x^2,x^3,x^4,x^5
void ex1()
ex1 Ausgabe von Funktionswerten in eine Datei