Files Classes Functions Hierarchy
#include <mathlib.h>
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 |
Definition at line 208 of file mathlib.h.
| void convexity< T >::operator() | ( | bool & | result, | |
| F | 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 }
| 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 }
1.5.8