15 #include <gtest/gtest.h> 19 #include "../../include/ecl/geometry/tension_spline.hpp" 25 using std::cout;
using std::endl;
36 TEST(TensionFunctionSplines,allEggsInOneBasket) {
44 int main(
int argc,
char **argv) {
46 Format<string> string_format; string_format.width(8); string_format.align(RightAlign);
47 Format<double> format; format.width(8); format.precision(2); format.align(RightAlign);
54 x_set << 0.0, 1.0, 2.0, 3.0, 4.0, 5.0;
55 y_set << 1.0, 2.0, 1.0, 3.0, 4.0, 4.0;
63 cout <<
"***********************************************************" << endl;
64 cout <<
" Tension Spline Blueprint" << endl;
65 cout <<
"***********************************************************" << endl;
71 TensionSpline spline_0_1 = TensionSpline::Natural(x_set, y_set, 0.1);
72 TensionSpline spline_1 = TensionSpline::Natural(x_set, y_set, 1.0);
73 TensionSpline spline_2 = TensionSpline::Natural(x_set, y_set, 2.0);
74 TensionSpline spline_3 = TensionSpline::Natural(x_set, y_set, 3.0);
75 TensionSpline spline_4 = TensionSpline::Natural(x_set, y_set, 4.0);
76 TensionSpline spline_10 = TensionSpline::Natural(x_set, y_set, 10.0);
77 cout << spline_1 << endl;
80 cout <<
"***********************************************************" << endl;
81 cout <<
" Output : Splines" << endl;
82 cout <<
"***********************************************************" << endl;
88 std::cout << string_format(
"t=0.1");
89 std::cout << string_format(
"t=1");
90 std::cout << string_format(
"t=2");
91 std::cout << string_format(
"t=3");
92 std::cout << string_format(
"t=4");
93 std::cout << string_format(
"t=10") << std::endl;
94 for (
int i = 0; i <= n; ++i ) {
95 double x = i*(x_set.
back()-x_set.
front())/n;
96 std::cout << format(spline_0_1(x));
97 std::cout << format(spline_1(x));
98 std::cout << format(spline_2(x));
99 std::cout << format(spline_3(x));
100 std::cout << format(spline_4(x));
101 std::cout << format(spline_10(x));
102 std::cout << std::endl;
106 cout <<
"***********************************************************" << endl;
107 cout <<
" Output : Derivatives" << endl;
108 cout <<
"***********************************************************" << endl;
114 std::cout << string_format(
"t=0.1");
115 std::cout << string_format(
"t=1");
116 std::cout << string_format(
"t=2");
117 std::cout << string_format(
"t=3");
118 std::cout << string_format(
"t=4");
119 std::cout << string_format(
"t=10") << std::endl;
120 for (
int i = 0; i <= n; ++i ) {
121 double x = i*(x_set.
back()-x_set.
front())/n;
122 std::cout << format(spline_0_1.
derivative(x));
128 std::cout << std::endl;
132 cout <<
"***********************************************************" << endl;
133 cout <<
" Output : 2nd Derivatives" << endl;
134 cout <<
"***********************************************************" << endl;
140 std::cout << string_format(
"t=0.1");
141 std::cout << string_format(
"t=1");
142 std::cout << string_format(
"t=2");
143 std::cout << string_format(
"t=3");
144 std::cout << string_format(
"t=4");
145 std::cout << string_format(
"t=10") << std::endl;
146 for (
int i = 0; i <= n; ++i ) {
147 double x = i*(x_set.
back()-x_set.
front())/n;
154 std::cout << std::endl;
158 cout <<
"***********************************************************" << endl;
159 cout <<
" Passed" << endl;
160 cout <<
"***********************************************************" << endl;
163 testing::InitGoogleTest(&argc,argv);
164 return RUN_ALL_TESTS();
int main(int argc, char **argv)
double derivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline derivative.
Storage container for a tension spline interpolation.
double dderivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline second derivative.
TEST(TensionFunctionSplines, allEggsInOneBasket)