Files Classes Functions Hierarchy
#include <functest.h>
Static Public Member Functions | |
| static void | test01 () |
| Explicitly defining a class within a function scope and using it. | |
| static void | test02 () |
| Defining a 2D function. | |
| static void | test03 () |
| Defining a function with one argument and instantiating it with template types on the input and output. | |
| static void | test04 () |
| Defining a function with two arguments and instantiating it with template types on the input and output. | |
| static void | test05 () |
| Defining a 1D function and using it in the same scope. | |
| static void | test06 () |
| Defining a 2D function and using it in the same scope. | |
| static void | test07 () |
| funcstate function test. | |
| static void | test08 () |
Definition at line 7 of file functest.h.
| void functest::test01 | ( | ) | [static] |
Explicitly defining a class within a function scope and using it.
Definition at line 10 of file functest.cpp.
References SHOW.
Referenced by main().
00011 { 00012 cout << "Creating a class within a function is legal" << endl; 00013 cout << "This may be used to eliminate the global name." << endl; 00014 cout << "Testing with points" << endl; 00015 00016 pt2 p0(1.0,2.0); 00017 pt2 p1(3.5,6.0); 00018 00019 class fred 00020 { 00021 public: 00022 00023 pt2 p0; 00024 pt2 p1; 00025 00026 pt2 operator()(double t) 00027 { return p0 + (p1-p0)*t; } 00028 }; 00029 00030 fred f; 00031 f.p0 = pt2(1.0,2.0); 00032 f.p1 = pt2(3.5,6.0); 00033 00034 cout << SHOW( f(1.0) ) << endl; 00035 00036 }
| void functest::test02 | ( | ) | [static] |
Defining a 2D function.
Definition at line 38 of file functest.cpp.
References funcA1V2, and SHOW.
Referenced by main().
00039 { 00040 funcA1V2(finterp,v0+(v1-v0)*x,x,pt2,double) f(pt2(1.0,2.0),pt2(3.5,6.0)); 00041 00042 cout << SHOW( f(1.0) ) << endl; 00043 pt2 y; 00044 f(y,1.0); 00045 cout << SHOW(y) << endl; 00046 }
| void functest::test03 | ( | ) | [static] |
Defining a function with one argument and instantiating it with template types on the input and output.
Definition at line 50 of file functest.cpp.
References SHOW.
Referenced by main().
00051 { 00052 cout << "Test templated function with one argument." << endl; 00053 cubic2<double,double> f; 00054 cout << SHOW( f(5.0) ) << endl; 00055 double y; 00056 cubic2<double,double>()(y,1.0); 00057 cout << SHOW(y) << endl; 00058 }
| void functest::test04 | ( | ) | [static] |
Defining a function with two arguments and instantiating it with template types on the input and output.
Definition at line 61 of file functest.cpp.
References SHOW.
Referenced by main().
00062 { 00063 cout << "Test templated function with two arguments." << endl; 00064 00065 tri1<double,double> f; 00066 cout << SHOW( f(0.2,0.3) ) << endl; 00067 }
| void functest::test05 | ( | ) | [static] |
| void functest::test06 | ( | ) | [static] |
| void functest::test07 | ( | ) | [static] |
funcstate function test.
Definition at line 82 of file functest.cpp.
References SHOW.
Referenced by main().
00083 { 00084 class f1 : public funcstate< double > 00085 { 00086 public: 00087 00088 f1() : funcstate<double>(2,true) {} 00089 00090 doublec operator()() 00091 { 00092 double v0 = (xi[0]*xi[0]+xi[1]-11.0); 00093 double v1 = (xi[1]*xi[1]+xi[0]-7.0); 00094 xi[2] = v0*v0 + v1*v1; 00095 return xi[2]; 00096 } 00097 }; 00098 00099 f1 f; 00100 f.xi[0]=1.0; 00101 f.xi[1]=0.0; 00102 f(); 00103 double y=f.xi[2]; 00104 cout << SHOW(y) << endl; 00105 }
| void functest::test08 | ( | ) | [static] |
Definition at line 107 of file functest.cpp.
References funcstate< X >::dim, funchistory< X >::pop(), printvecfunc(), funchistory< X >::push(), and funcstate< X >::xi.
Referenced by main().
00108 { 00109 prob_f002 f; 00110 00111 funchistory<double> fh(f); 00112 00113 f.xi[0]=1.0; 00114 f.xi[1]=0.0; 00115 f(); 00116 cout << printvecfunc(f.xi,f.dim+1) << endl; 00117 fh.push(); 00118 f.xi[1]=1.0; 00119 f(); 00120 cout << printvecfunc(f.xi,f.dim+1) << endl; 00121 fh.push(); 00122 f.xi[0]=3.0; 00123 f.xi[1]=3.0; 00124 f(); 00125 00126 //cout << SHOW(f.dim) << endl; 00127 00128 cout << printvecfunc(f.xi,f.dim+1) << endl; 00129 00130 cout << "Restoring the previous value" << endl; 00131 fh.pop(); 00132 cout << printvecfunc(f.xi,f.dim+1) << endl; 00133 00134 /* 00135 double* t = new double[2]; 00136 t[0]=.2; 00137 t[1]=.3; 00138 fh.fs.set_position(t); 00139 */ 00140 00141 }
1.5.8