smooth_linear_splines.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <iostream>
14 #include <string>
15 #include <gtest/gtest.h>
16 #include <ecl/containers/array.hpp>
19 #include "../../include/ecl/geometry/smooth_linear_spline.hpp"
20 
21 /*****************************************************************************
22 ** Using
23 *****************************************************************************/
24 
25 using std::cout; using std::endl;
26 using std::string;
27 using ecl::Array;
28 using ecl::RightAlign;
29 using ecl::Format;
31 
32 /*****************************************************************************
33 ** Tests
34 *****************************************************************************/
35 
36 TEST(SmoothLinearSplinesTests,allEggsInOneBasket) {
37  // Haven't got around to running this properly through gtests yet.
38  SUCCEED();
39 }
40 /*****************************************************************************
41 ** Main program
42 *****************************************************************************/
43 
44 int main(int argc, char **argv) {
45 
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);
48 
49  /*********************
50  ** Initialisation
51  **********************/
52  Array<double> x_set(6);
53  Array<double> y_set(6);
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;
56  const double a_max = 10.0;
57 
58  cout << endl;
59  cout << "***********************************************************" << endl;
60  cout << " Smooth Linear Spline Constructor" << endl;
61  cout << "***********************************************************" << endl;
62  cout << endl;
63 
64  SmoothLinearSpline spline = SmoothLinearSpline::Interpolation(x_set, y_set, a_max);
65 // cout << spline_1 << endl;
66 
67  cout << endl;
68  cout << "***********************************************************" << endl;
69  cout << " Output" << endl;
70  cout << "***********************************************************" << endl;
71  cout << endl;
72 
73  int n = 200;
74  cout << string_format("x ");
75  cout << string_format("y ");
76  cout << string_format("y' ");
77  cout << string_format("y''") << endl;
78  for ( int i = 0; i <= n; ++i ) {
79  double x = x_set[0] + i*(x_set.back()-x_set.front())/n;
80  cout << format(x);
81  cout << format(spline(x));
82  cout << format(spline.derivative(x));
83  cout << format(spline.dderivative(x)) << endl;
84  }
85 
86  cout << endl;
87  cout << "***********************************************************" << endl;
88  cout << " Passed" << endl;
89  cout << "***********************************************************" << endl;
90  cout << endl;
91 
92  testing::InitGoogleTest(&argc,argv);
93  return RUN_ALL_TESTS();
94 }
95 
Storage container for a smoothed linear spline interpolation.
double dderivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline second derivative.
int main(int argc, char **argv)
TEST(SmoothLinearSplinesTests, allEggsInOneBasket)
RightAlign
reference back()
reference front()
double derivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline derivative.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37