Changeset 1648 for trunk


Ignore:
Timestamp:
Dec 13, 2008, 10:28:39 AM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #466. Added more GSL functionality, added constructor tests.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/interpolation_test.cc

    r1645 r1648  
    22
    33/*
    4   Copyright (C) 2007 Jari Häkkinen
     4  Copyright (C) 2008 Jari Häkkinen
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    2222#include "Suite.h"
    2323
     24#include "yat/regression/AkimaInterpolation.h"
     25#include "yat/regression/AkimaPeriodicInterpolation.h"
    2426#include "yat/regression/CSplineInterpolation.h"
     27#include "yat/regression/CSplinePeriodicInterpolation.h"
     28#include "yat/regression/LinearInterpolation.h"
     29#include "yat/regression/PolynomialInterpolation.h"
    2530#include "yat/utility/Vector.h"
    2631#include "yat/utility/VectorConstView.h"
     
    3136{
    3237  using namespace theplu::yat;
     38  using namespace theplu::yat::regression;
    3339
    3440  test::Suite suite(argc, argv);
     
    5359  y(0)=100; y(1)= 97; y(2)=111; y(3)=120; y(4)=117; y(5)=103;
    5460
    55   regression::CSplineInterpolation cspline(x,y);
     61  CSplineInterpolation cspline(x,y);
    5662
    5763  utility::Vector w(11);
     
    7581    }
    7682
     83  // lazy testing, at least try to create the objects
     84  AkimaInterpolation(x,y);
     85  AkimaPeriodicInterpolation(x,y);
     86  CSplinePeriodicInterpolation(x,y);
     87  LinearInterpolation(x,y);
     88  PolynomialInterpolation(x,y);
     89
    7790  return suite.return_value();
    7891}
  • trunk/yat/regression/GSLInterpolation.cc

    r1644 r1648  
    5858
    5959
    60   double GSLInterpolation::evaluate(const double x) const
     60  size_t GSLInterpolation::bsearch(const double x_array[], double x,
     61                                   size_t index_lo, size_t index_hi) const
     62  {
     63    return gsl_interp_bsearch(x_array, x, index_lo, index_hi);
     64  }
     65
     66
     67  double GSLInterpolation::evaluate(double x)
    6168  {
    62     return gsl_interp_eval(interpolator_,x_,y_,x,accelerator_);
     69    return gsl_interp_eval(interpolator_, x_, y_, x, accelerator_);
     70  }
     71
     72
     73  double GSLInterpolation::evaluate_derivative(double x)
     74  {
     75    return gsl_interp_eval_deriv(interpolator_, x_, y_, x, accelerator_);
     76  }
     77
     78
     79  double GSLInterpolation::evaluate_derivative2(double x)
     80  {
     81    return gsl_interp_eval_deriv2(interpolator_, x_, y_, x, accelerator_);
     82  }
     83
     84
     85  double GSLInterpolation::evaluate_integral(double a, double b)
     86  {
     87    return gsl_interp_eval_integ(interpolator_, x_, y_, a, b, accelerator_);
     88  }
     89
     90
     91  unsigned int GSLInterpolation::min_size(void) const
     92  {
     93    return gsl_interp_min_size(interpolator_);
    6394  }
    6495
  • trunk/yat/regression/GSLInterpolation.h

    r1644 r1648  
    5353
    5454  public:
     55    /**
     56       \brief Search index.
     57
     58       This function returns the index \f$ i \f$ of the array \a
     59       x_array such that \f$ x_array[i] <= x < x_array[i+1] \f$. The
     60       index is searched for in the range
     61       \f$ [index_lo, index_hi] \f$.
     62    */
     63    size_t bsearch(const double x_array[], double x, size_t index_lo,
     64                   size_t index_hi) const;
    5565
    5666    /**
     
    6070       \a x.
    6171    */
    62     double evaluate(const double x) const;
     72    double evaluate(double x);
     73
     74    /**
     75       \brief Calculate the derivative of the interpolated function at
     76       \a x.
     77
     78       \return The derivative.
     79    */
     80    double evaluate_derivative(double x);
     81
     82    /**
     83       \brief Calculate the 2nd derivative of the interpolated
     84       function at \a x.
     85
     86       \return The 2nd derivative.
     87    */
     88    double evaluate_derivative2(double x);
     89
     90    /**
     91       \brief Calculate the numerical integral of the interpolated
     92       function over the range \f$ [a,b] \f$.
     93
     94       \return The integral.
     95    */
     96    double evaluate_integral(double a, double b);
     97
     98    /**
     99       \brief This function returns the minimum number of points
     100       required by the interpolation type.
     101
     102       For example, Akima spline interpolation requires a minimum of 5
     103       points.
     104
     105       \return The minimum number of points required.
     106    */
     107    unsigned int min_size(void) const;
    63108
    64109  protected:
  • trunk/yat/regression/Makefile.am

    r1647 r1648  
    2929  Local.cc MultiDimensional.cc MultiDimensionalWeighted.cc Naive.cc   \
    3030  NaiveWeighted.cc OneDimensional.cc OneDimensionalWeighted.cc        \
    31   Polynomial.cc LinearInterpolation.cc PolynomialWeighted.cc
     31  Polynomial.cc PolynomialInterpolation.cc PolynomialWeighted.cc
    3232
    3333include_regressiondir = $(includedir)/yat/regression
     
    3939  LinearWeighted.h Local.h MultiDimensional.h                         \
    4040  MultiDimensionalWeighted.h Naive.h NaiveWeighted.h OneDimensional.h \
    41   OneDimensionalWeighted.h Polynomial.h LinearInterpolation.cc        \
     41  OneDimensionalWeighted.h Polynomial.h PolynomialInterpolation.cc    \
    4242  PolynomialWeighted.h
Note: See TracChangeset for help on using the changeset viewer.