]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // Copyright Nick Thompson 2017. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | // | |
6 | // Basic sanity check that header <boost/math/special_functions/gamma.hpp> | |
7 | // #includes all the files that it needs to. | |
8 | // | |
9 | #include <boost/math/differentiation/autodiff.hpp> | |
10 | // | |
11 | // Note this header includes no other headers, this is | |
12 | // important if this test is to be meaningful: | |
13 | // | |
14 | #include "test_compile_result.hpp" | |
15 | ||
16 | template <typename T> | |
17 | T fourth_power(T const& x) { | |
18 | T x4 = x * x; // retval in operator*() uses x4's memory via NRVO. | |
19 | x4 *= x4; // No copies of x4 are made within operator*=() even when squaring. | |
20 | return x4; // x4 uses y's memory in main() via NRVO. | |
21 | } | |
22 | ||
23 | void compile_and_link_test() | |
24 | { | |
25 | using namespace boost::math::differentiation; | |
26 | auto const x = make_fvar<double, 5>(2.0); // Find derivatives at x=2. | |
27 | auto const y = fourth_power(x); | |
28 | ||
29 | check_result<double>(y.derivative(1)); | |
30 | } |