smooth_linear_splines.cpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Includes
00011 *****************************************************************************/
00012 
00013 #include <iostream>
00014 #include <string>
00015 #include <gtest/gtest.h>
00016 #include <ecl/containers/array.hpp>
00017 #include <ecl/formatters/floats.hpp>
00018 #include <ecl/formatters/strings.hpp>
00019 #include "../../include/ecl/geometry/smooth_linear_spline.hpp"
00020 
00021 /*****************************************************************************
00022 ** Using
00023 *****************************************************************************/
00024 
00025 using std::cout; using std::endl;
00026 using std::string;
00027 using ecl::Array;
00028 using ecl::RightAlign;
00029 using ecl::Format;
00030 using ecl::SmoothLinearSpline;
00031 
00032 /*****************************************************************************
00033 ** Tests
00034 *****************************************************************************/
00035 
00036 TEST(SmoothLinearSplinesTests,allEggsInOneBasket) {
00037         // Haven't got around to running this properly through gtests yet.
00038         SUCCEED();
00039 }
00040 /*****************************************************************************
00041 ** Main program
00042 *****************************************************************************/
00043 
00044 int main(int argc, char **argv) {
00045 
00046     Format<string> string_format; string_format.width(8); string_format.align(RightAlign);
00047     Format<double> format; format.width(8); format.precision(2); format.align(RightAlign);
00048 
00049     /*********************
00050     ** Initialisation
00051     **********************/
00052     Array<double> x_set(6);
00053     Array<double> y_set(6);
00054     x_set << 0.0, 1.0, 2.0, 3.0, 4.0, 5.0;
00055     y_set << 1.0, 2.0, 1.0, 3.0, 4.0, 4.0;
00056     const double a_max = 10.0;
00057 
00058     cout << endl;
00059     cout << "***********************************************************" << endl;
00060     cout << "           Smooth Linear Spline Constructor" << endl;
00061     cout << "***********************************************************" << endl;
00062     cout << endl;
00063 
00064     SmoothLinearSpline spline = SmoothLinearSpline::Interpolation(x_set, y_set, a_max);
00065 //    cout << spline_1 << endl;
00066 
00067     cout << endl;
00068     cout << "***********************************************************" << endl;
00069     cout << "                      Output" << endl;
00070     cout << "***********************************************************" << endl;
00071     cout << endl;
00072 
00073     int n = 200;
00074     cout << string_format("x  ");
00075     cout << string_format("y  ");
00076     cout << string_format("y' ");
00077     cout << string_format("y''") << endl;
00078     for ( int i = 0; i <= n; ++i ) {
00079         double x = x_set[0] + i*(x_set.back()-x_set.front())/n;
00080         cout << format(x);
00081         cout << format(spline(x));
00082         cout << format(spline.derivative(x));
00083         cout << format(spline.dderivative(x)) << endl;
00084     }
00085 
00086     cout << endl;
00087     cout << "***********************************************************" << endl;
00088     cout << "                      Passed" << endl;
00089     cout << "***********************************************************" << endl;
00090     cout << endl;
00091 
00092     testing::InitGoogleTest(&argc,argv);
00093     return RUN_ALL_TESTS();
00094 }
00095 


ecl_geometry
Author(s): Daniel Stonier (d.stonier@gmail.com)
autogenerated on Thu Jan 2 2014 11:13:11