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 
ecl::SmoothLinearSpline::derivative
double derivative(const double &x) const
Spline derivative.
Definition: smooth_linear_spline.cpp:129
ecl::RightAlign
RightAlign
ecl::SmoothLinearSpline::dderivative
double dderivative(const double &x) const
Spline second derivative.
Definition: smooth_linear_spline.cpp:142
main
int main(int argc, char **argv)
Definition: smooth_linear_splines.cpp:44
floats.hpp
TEST
TEST(SmoothLinearSplinesTests, allEggsInOneBasket)
Definition: smooth_linear_splines.cpp:36
array.hpp
ecl::Array::back
reference back()
strings.hpp
ecl::Array::front
reference front()
ecl::Format
ecl::Array
ecl::SmoothLinearSpline
Storage container for a smoothed linear spline interpolation.
Definition: smooth_linear_spline.hpp:51


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:39