LCOV - code coverage report
Current view: top level - tools - CubicInterpolation.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 0 10 0.0 %
Date: 2018-12-19 07:49:13 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2018 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : #ifndef __PLUMED_tools_CubicInterpolation_h
      23             : #define __PLUMED_tools_CubicInterpolation_h
      24             : 
      25             : #include <vector>
      26             : #include "Matrix.h"
      27             : #include "core/Value.h"
      28             : 
      29             : namespace PLMD {
      30             : 
      31             : // Abstract base class for cubic interpolation
      32             : class CInterpolation {
      33             : private:
      34             :   unsigned bold;
      35             :   Matrix<double> splinepoints;
      36             :   unsigned search1( const unsigned& kk, const double& x, const unsigned& jold ) const ;
      37             : protected:
      38             :   std::vector<double> lb, ub;
      39             :   std::vector<unsigned> np, stride;
      40             :   unsigned findBox( const std::vector<double>& pos );
      41             :   double getPointSpacing( const unsigned dir, const unsigned k ) const ;
      42             :   double getCrossTermDenominator( const unsigned i, const unsigned j ) const ;
      43             : public:
      44             :   CInterpolation( const std::vector<unsigned>& dd, const std::vector<double>& fmin, const std::vector<double>& fmax );
      45             :   virtual ~CInterpolation();
      46             :   unsigned getNumberOfSplinePoints() const ;
      47             :   void getNumbersOfPoints( std::vector<unsigned>& nspline ) const ;
      48             :   void getSplinePoint( const unsigned nn, std::vector<double>& pp ) const ;
      49             :   void getGridBoundaries( std::vector<double>& gmin, std::vector<double>& gmax ) const ;
      50             :   virtual void set_table( const std::vector<Value>& ff )=0;
      51             :   virtual double get_fdf( const std::vector<double>& pos )=0;
      52             : };
      53             : 
      54             : inline
      55           0 : unsigned CInterpolation::getNumberOfSplinePoints() const {
      56           0 :   return splinepoints.nrows();
      57             : }
      58             : 
      59             : inline
      60             : void CInterpolation::getSplinePoint( const unsigned nn, std::vector<double>& pp ) const {
      61             :   plumed_dbg_assert( nn<splinepoints.nrows() && pp.size()==np.size() );
      62             :   for(unsigned i=0; i<np.size(); ++i) pp[i]=splinepoints(nn,i);
      63             : }
      64             : 
      65             : inline
      66           0 : double CInterpolation::getPointSpacing( const unsigned dir, const unsigned k ) const {
      67           0 :   unsigned i=k*stride[dir];
      68           0 :   return splinepoints(i+stride[dir], dir) - splinepoints(i, dir);
      69             : }
      70             : 
      71             : inline
      72           0 : double CInterpolation::getCrossTermDenominator( const unsigned i, const unsigned j ) const {
      73             :   plumed_dbg_assert( splinepoints.ncols()==2 );
      74           0 :   unsigned iplus, iminus; iplus=(i+1)*stride[0]; iminus=(i-1)*stride[0];
      75           0 :   return ( splinepoints(iplus,0) - splinepoints(iminus,0) ) * ( splinepoints(iplus+j+1,1) - splinepoints(iplus+j-1,1) );
      76             : }
      77             : 
      78             : inline
      79             : void CInterpolation::getGridBoundaries( std::vector<double>& gmin, std::vector<double>& gmax ) const {
      80             :   getSplinePoint( 0, gmin ); getSplinePoint( splinepoints.nrows()-1, gmax );
      81             : }
      82             : 
      83           0 : class InterpolateCubic : public CInterpolation {
      84             : private:
      85             :   std::vector<double> clist;
      86             : public:
      87             :   InterpolateCubic( const std::vector<unsigned>& dd, const std::vector<double>& fmin, const std::vector<double>& fmax );
      88             :   void set_table( const std::vector<Value>& ff );
      89             :   double get_fdf( const std::vector<double>& pos );
      90             : };
      91             : 
      92           0 : class InterpolateBicubic : public CInterpolation {
      93             : private:
      94             :   Matrix<int> wt;
      95             :   std::vector<double> t1, t2;
      96             :   Matrix<double> dcross;
      97             :   std::vector<double> clist;
      98             :   void IBicCoeff( const std::vector<double>& y, const std::vector<double>& dy1, const std::vector<double>& dy2,
      99             :                   const std::vector<double>& d2y12, const double& d1, const double& d2, Matrix<double>& c );
     100             : public:
     101             :   InterpolateBicubic( const std::vector<unsigned>& dd, const std::vector<double>& fmin, const std::vector<double>& fmax );
     102             :   void set_table( const std::vector<Value>& ff );
     103             :   double get_fdf( const std::vector<double>& pos );
     104             : };
     105             : 
     106             : }
     107             : 
     108             : 
     109             : #endif

Generated by: LCOV version 1.13