All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
KernelFunctions.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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_KernelFunctions_h
23 #define __PLUMED_tools_KernelFunctions_h
24 
25 #include "Tools.h"
26 #include "Matrix.h"
27 #include "core/Value.h"
28 #include <vector>
29 
30 namespace PLMD {
31 
33 private:
34 /// Is the metric matrix diagonal
35  bool diagonal;
36 /// What type of kernel are we using
38 /// The center of the kernel function
39  std::vector<double> center;
40 /// The width of the kernel
41  std::vector<double> width;
42 /// The height of the kernel
43  double height;
44 /// Convert the width into matrix form
45  Matrix<double> getMatrix() const;
46 /// Get the cutoff for a kernel
47  double getCutoff( const double& width ) const ;
48 public:
49  KernelFunctions( const std::vector<double>& at, const std::vector<double>& sig, const std::string& type, const bool multivariate ,const double& w, const bool norm );
50 /// Get the dimensionality of the kernel
51  unsigned ndim() const;
52 /// Get the position of the center
53  std::vector<double> getCenter() const;
54 /// Get the support
55  std::vector<unsigned> getSupport( const std::vector<double>& dx ) const;
56 /// get it in continuous form
57  std::vector<double> getContinuousSupport( ) const;
58 /// Evaluate the kernel function
59  double evaluate( const std::vector<Value*>& pos, std::vector<double>& derivatives, bool usederiv=true ) const;
60 /// Read a kernel function from a file
61  static KernelFunctions* read( IFile* ifile, const std::vector<std::string>& valnames );
62 };
63 
64 inline
66  unsigned k=0, ncv=ndim(); Matrix<double> mymatrix(ncv,ncv);
67  for(unsigned i=0;i<ncv;i++){
68  for(unsigned j=i;j<ncv;j++){
69  mymatrix(i,j)=mymatrix(j,i)=width[k]; // recompose the full inverse matrix
70  k++;
71  }
72  }
73  return mymatrix;
74 }
75 
76 inline
77 unsigned KernelFunctions::ndim() const {
78  return center.size();
79 }
80 
81 inline
82 std::vector<double> KernelFunctions::getCenter() const {
83  return center;
84 }
85 
86 }
87 #endif
std::vector< unsigned > getSupport(const std::vector< double > &dx) const
Get the support.
std::vector< double > getCenter() const
Get the position of the center.
static KernelFunctions * read(IFile *ifile, const std::vector< std::string > &valnames)
Read a kernel function from a file.
double evaluate(const std::vector< Value * > &pos, std::vector< double > &derivatives, bool usederiv=true) const
Evaluate the kernel function.
double height
The height of the kernel.
Matrix< double > getMatrix() const
Convert the width into matrix form.
double getCutoff(const double &width) const
Get the cutoff for a kernel.
std::vector< double > getContinuousSupport() const
get it in continuous form
unsigned ndim() const
Get the dimensionality of the kernel.
std::vector< double > center
The center of the kernel function.
enum PLMD::KernelFunctions::@4 ktype
What type of kernel are we using.
std::vector< double > width
The width of the kernel.
Class for input files.
Definition: IFile.h:40
void const char const char int double int double double int int double int double * w
Definition: Matrix.h:42
bool diagonal
Is the metric matrix diagonal.
KernelFunctions(const std::vector< double > &at, const std::vector< double > &sig, const std::string &type, const bool multivariate, const double &w, const bool norm)
T norm(const std::vector< T > &A)
Calculate the dot product between a vector and itself.
Definition: Matrix.h:61