proj home

Files   Classes   Functions   Hierarchy  

convexity< T > Class Template Reference

#include <mathlib.h>

Collaboration diagram for convexity< T >:

List of all members.

Public Member Functions

 convexity (T a_, T b_, T af_, T bf_)
 convexity ()
void operator() (bool &result, vector< T > const &x, vector< T > const &xf)
template<typename F >
void operator() (bool &result, F f, uint n, T const a_, T const b_)

Public Attributes

T a
T b
T af
T bf


Detailed Description

template<typename T>
class convexity< T >

Definition at line 208 of file mathlib.h.


Constructor & Destructor Documentation

template<typename T>
convexity< T >::convexity ( T  a_,
T  b_,
T  af_,
T  bf_ 
) [inline]

Definition at line 220 of file mathlib.h.

00221     : a(a_), b(b_), af(af_), bf(bf_) {}

template<class T >
convexity< T >::convexity (  )  [inline]

Definition at line 819 of file mathlib.h.

00820 {}


Member Function Documentation

template<class T >
template<typename F >
void convexity< T >::operator() ( bool result,
f,
uint  n,
T const   a_,
T const   b_ 
) [inline]

Definition at line 758 of file mathlib.h.

00765 {
00766   if (n==0)
00767   {
00768     result=false;
00769     return;
00770   }
00771 
00772   a = a_;
00773   b = b_;
00774 
00775   f(af,a);
00776   f(bf,b);
00777 
00778 //  cout << "af=" << af << ", bf=" << bf << endl;
00779 
00780   T one(1.0); //Unbelievabley  (j+1)/(n+1)*(b-a) was somewhere converting to int.
00781 
00782 /*
00783 // Building containers and forwarding.
00784   vector<T> x(n);
00785   vector<T> xf(n);
00786 
00787 
00788   for (uint j=0; j<n; ++j)
00789   {
00790     x[j] = a+(j+one)/(n+one)*(b-a);
00791     f(xf[j],x[j]);
00792     //cout << "x[" << j << "]=" << x[j] << ", xf[" << j << "]=" << xf[j] << endl;
00793   }
00794   operator()(result,x,xf);
00795 */
00796 
00797   T x;
00798   T xf;
00799   T lambda;
00800 
00801   for (uint j=0; j<n; ++j)
00802   {
00803     x = a+(j+one)/(n+one)*(b-a);
00804     f(xf,x);
00805 //    cout << "x[" << j << "]=" << x << ", xf[" << j << "]=" << xf << endl;
00806     lambda = (x-b)/(a-b);
00807     if ( lambda*af+bf*(one-lambda) < xf )
00808     {
00809       result = false;
00810       return;
00811     }
00812   }
00813  
00814 }

template<class T >
void convexity< T >::operator() ( bool result,
vector< T > const &  x,
vector< T > const &  xf 
) [inline]

Definition at line 824 of file mathlib.h.

00829 {
00830   result = true;
00831 
00832   T one(1.0);
00833 
00834   T lambda;
00835 
00836   for (uint i=0; i<x.size(); ++i)
00837   {
00838     lambda = (x[i]-b)/(a-b);
00839     if ( lambda*af+bf*(one-lambda) < xf[i] )
00840     {
00841       result = false;
00842       return;
00843     }
00844   }
00845 }


Member Data Documentation

template<typename T>
T convexity< T >::a

Definition at line 213 of file mathlib.h.

template<typename T>
T convexity< T >::af

Definition at line 216 of file mathlib.h.

template<typename T>
T convexity< T >::b

Definition at line 214 of file mathlib.h.

template<typename T>
T convexity< T >::bf

Definition at line 217 of file mathlib.h.


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

Generated on Fri Mar 4 00:49:52 2011 for Chelton Evans Source by  doxygen 1.5.8