rbf::radial_basis_function Class Reference

Base abstract class. More...

#include <rbf.hpp>

Inheritance diagram for rbf::radial_basis_function:

Inheritance graph
[legend]
Collaboration diagram for rbf::radial_basis_function:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 radial_basis_function ()
 Default constructor, centred at zero by default.
virtual ~radial_basis_function ()
 radial_basis_function (const point &c)
 Specify the point where this rbf is centred.
void set_centre (const point &c)
 Specify the point where this rbf is centred.
double at (const point &x) const
 Evaluate rbf at x.
double operator() (const point &x) const
 Evaluate rbf at x.
double d (const point &x, size_t k) const
 First partial derivative at x in direction k;.
double d2 (const point &x, size_t k1, size_t k2) const
 Second derivative at x in directions k1 and k2.
bool operator< (const radial_basis_function &phi) const

Static Public Member Functions

static void set_dimension (size_t dim)
 Specify the dimension of all rbf's.

Protected Member Functions

virtual double operator() (double r) const =0
 The scalar functions defining each RBF.
virtual double d (double r) const =0
 The scalar first derivative defining each RBF.
virtual double d2 (double r) const =0
 The scalar second derivative defining each RBF.

Private Member Functions

void bad_dimension (string file, int line, size_t dim) const

Private Attributes

point centre
 Point on which this rbf is centred.

Static Private Attributes

static size_t dimension = 0
 Dimensionality of all rbfs.

Friends

size_t hash_value (const radial_basis_function &)
 An rbf hash function.


Detailed Description

Base abstract class.

Constructor & Destructor Documentation

rbf::radial_basis_function::radial_basis_function (  ) 

Default constructor, centred at zero by default.

00022                                               {
00023     if(dimension != 0){
00024       point zero(dimension); //Centred by default at the origin.
00025       centre = zero;
00026     }
00027   }

rbf::radial_basis_function::~radial_basis_function (  )  [virtual]

00036                                                {
00037     //Nothing to destroy!
00038   }

rbf::radial_basis_function::radial_basis_function ( const point c  ) 

Specify the point where this rbf is centred.

00029                                                             {
00030     if(c.size() != dimension)
00031       bad_dimension(__FILE__, __LINE__, c.size());
00032     else
00033       centre = c;
00034   }

Here is the call graph for this function:


Member Function Documentation

void rbf::radial_basis_function::set_dimension ( size_t  dim  )  [static]

Specify the dimension of all rbf's.

00047                                                      {
00048     dimension = dim;
00049   }

void rbf::radial_basis_function::set_centre ( const point c  ) 

Specify the point where this rbf is centred.

00040                                                       {
00041     if(c.size () != dimension)
00042       bad_dimension(__FILE__, __LINE__, c.size());
00043     else
00044       centre = c;
00045   }

Here is the call graph for this function:

double rbf::radial_basis_function::at ( const point x  )  const

Evaluate rbf at x.

00071                                                       {
00072     return operator()(x);
00073   }

Here is the call graph for this function:

double rbf::radial_basis_function::operator() ( const point x  )  const

Evaluate rbf at x.

00075                                                               {
00076     if(x.size() != dimension)
00077       bad_dimension(__FILE__, __LINE__, x.size());
00078     return operator()( norm(x - centre) );
00079   }

Here is the call graph for this function:

double rbf::radial_basis_function::d ( const point x,
size_t  k 
) const

First partial derivative at x in direction k;.

00081                                                                {
00082     if(x.size() != dimension)
00083       bad_dimension(__FILE__, __LINE__, x.size());
00084     else if(k < 1 or k > dimension){
00085       error_handling::badArgument exc;
00086       exc.reason = "Cannot differentiate wrt given index: out of bounds.";
00087       exc.line = __LINE__;
00088       exc.file = __FILE__;
00089        throw exc;
00090     }
00091     else if(x == centre)
00092       return d(0);
00093 
00094     double r = norm(x - centre);
00095     //Call virtualised derived class function.
00096     double result = d(r)*(x(k) - centre(k))/r; 
00097     return result;
00098   }

Here is the call graph for this function:

double rbf::radial_basis_function::d2 ( const point x,
size_t  k1,
size_t  k2 
) const

Second derivative at x in directions k1 and k2.

00101                                                               {
00102     if(x.size() != dimension)
00103       bad_dimension(__FILE__, __LINE__, x.size());
00104     else if(k1 < 1 or k1 > dimension or k2 < 1 or k2 > dimension){
00105       error_handling::badArgument exc;
00106       exc.reason = "Cannot differentiate wrt given indices: out of bounds.";
00107       exc.line = __LINE__;
00108       exc.file = __FILE__;
00109       throw exc;
00110     }
00111     else if(x == centre and k1 == k2)
00112       return d2(0);
00113     else if(x == centre and k1 != k2)
00114       return 0;
00115     else if(k1 != k2){
00116       double r = norm(x-centre);
00117       double r2 = r*r;
00118       double top = (x(k1) - centre(k1)) * (x(k2)-centre(k2));
00119       return   
00120         top * d2(r) / r2 -
00121         top * d(r) / (r2*r);
00122     }
00123     double r = norm(x-centre);
00124     double r2 = r*r;
00125     double top = x(k1) - centre(k1); top = top*top;
00126     double result =  top*d2(r)/r2  +  d(r)/r  -  top*d(r)/(r2*r);
00127     return result;
00128     
00129   }

Here is the call graph for this function:

bool rbf::radial_basis_function::operator< ( const radial_basis_function phi  )  const

00142   {
00143     return (this->centre) < phi.centre;
00144   }

virtual double rbf::radial_basis_function::operator() ( double  r  )  const [protected, pure virtual]

virtual double rbf::radial_basis_function::d ( double  r  )  const [protected, pure virtual]

virtual double rbf::radial_basis_function::d2 ( double  r  )  const [protected, pure virtual]

void rbf::radial_basis_function::bad_dimension ( string  file,
int  line,
size_t  dim 
) const [private]

In case we attempt to give this rbf an argument of the wrong dimension.

00052                                                                        {
00053     error_handling::badDimension exc;
00054     if(dimension == 0)
00055       exc.reason = 
00056         "Vector of wrong dimensionality passed to "
00057         "radial basis function. \n" 
00058         "(Did you forget to set the dimension?)";
00059     else
00060       exc.reason = 
00061         "Vector of wrong dimensionality passed to "
00062         "radial basis function.";      
00063 
00064     exc.line = line;
00065     exc.file = file;
00066     exc.given_dimension = dim;
00067     exc.actual_dimension = dimension;
00068     throw exc;
00069   }


Friends And Related Function Documentation

size_t hash_value ( const radial_basis_function phi  )  [friend]

An rbf hash function.

00132   {
00133     size_t seed = 0;
00134     using namespace boost;
00135     for(size_t i = 1; i <= phi.centre.size(); i++)
00136       hash_combine(seed,phi.centre(i));
00137     hash_combine(seed,typeid(phi).name());
00138     return seed;
00139   }


Member Data Documentation

Point on which this rbf is centred.

size_t rbf::radial_basis_function::dimension = 0 [static, private]

Dimensionality of all rbfs.


The documentation for this class was generated from the following files:

Generated on Fri Jun 6 17:28:30 2008 by  doxygen 1.5.6