MCPcopy Create free account
hub / github.com/coin-or/CppAD / file

Function file

example/cppad_code_gen/file.cpp:53–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53bool file(void)
54{ bool ok = true;
55 double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
56 //
57 // Store the compiled file in a dynamic link library
58 std::string file_name = "example_lib";
59 store(file_name);
60 //
61 // retrieve the compled function from the file
62 // (compiling take much longer than retrieving the file)
63 code_gen_fun f(file_name);
64
65 // evaluate the compiled function
66 size_t n = 2, m = 3;
67 CppAD::vector<double> x(n), y(m);
68 for(size_t j = 0; j < n; ++j)
69 x[j] = 1.0 / double(j + 2);
70 y = f(x);
71
72 // check function values
73 for(size_t i = 0; i < m; ++i)
74 { double check = double(i + 1) * std::sin( x[i % n] );
75 ok &= CppAD::NearEqual(y[i] , check, eps99, eps99);
76 }
77 return ok;
78}
79// END C++

Callers

nothing calls this directly

Calls 4

epsilonFunction · 0.85
storeFunction · 0.85
fFunction · 0.50
NearEqualFunction · 0.50

Tested by

no test coverage detected