cubic_spline.cpp
Go to the documentation of this file.
00001 
00012 /*****************************************************************************
00013 ** Includes
00014 *****************************************************************************/
00015 
00016 #include <ecl/exceptions/standard_exception.hpp>
00017 #include "../../include/ecl/geometry/cubic_spline.hpp"
00018 
00019 /*****************************************************************************
00020 ** Namespaces
00021 *****************************************************************************/
00022 
00023 namespace ecl {
00024 
00025 /*****************************************************************************
00026 ** Implementation
00027 *****************************************************************************/
00028 
00029 double CubicSpline::operator()(const double &x) const ecl_assert_throw_decl(StandardException) {
00030     ecl_assert_throw( ( ( x >= discretised_domain.front() ) && ( x <= discretised_domain.back() ) ), StandardException(LOC,OutOfRangeError) );
00031     int index = 0;
00032     while ( x > discretised_domain[index+1] ) {
00033         ++index;
00034     }
00035     return cubic_polynomials[index](x);
00036 }
00037 
00038 double CubicSpline::derivative(double x) const ecl_assert_throw_decl(StandardException) {
00039     ecl_assert_throw( ( ( x >= discretised_domain.front() ) && ( x <= discretised_domain.back() ) ), StandardException(LOC,OutOfRangeError) );
00040     int index = 0;
00041     while ( x > discretised_domain[index+1] ) {
00042         ++index;
00043     }
00044     return cubic_polynomials[index].derivative()(x);
00045 }
00046 
00047 double CubicSpline::dderivative(double x) const ecl_assert_throw_decl(StandardException) {
00048     ecl_assert_throw( ( ( x >= discretised_domain.front() ) && ( x <= discretised_domain.back() ) ), StandardException(LOC,OutOfRangeError) );
00049     int index = 0;
00050     while ( x > discretised_domain[index+1] ) {
00051         ++index;
00052     }
00053     return cubic_polynomials[index].derivative().derivative()(x);
00054 }
00055 
00056 } // namespace ecl


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