Files Classes Functions Hierarchy
#include <randomtest.h>
Static Public Member Functions | |
| static int | test01 () |
| Test random11<>. | |
| static int | test02 () |
| Test random00<>. | |
| static int | test03 () |
| Test random10<>. | |
| static int | test04 () |
| Test random01<>. | |
| static int | test05 () |
| static void | test06 () |
| static void | test07 () |
| template<typename R > | |
| static boolc | testprintrandom (R &r, uintc n, boolc zero, boolc one) |
| Test interval 0 to 1 optionally with end points. | |
| template<typename R > | |
| static boolc | domaintest (list< typename R::Ttype > &lst, R const &r, boolc zero, boolc one) |
| Test for out of bounds cases. | |
| template<typename R > | |
| static boolc | randomcontainer (list< typename R::Ttype > &lst, R &r, uintc n, boolc zero, boolc one) |
| Returns true if elements enpoints are correct. | |
Definition at line 12 of file randomtest.h.
| boolc randomtest::domaintest | ( | list< typename R::Ttype > & | lst, | |
| R const & | r, | |||
| boolc | zero, | |||
| boolc | one | |||
| ) | [inline, static] |
Test for out of bounds cases.
The opposite testing for is harder as their is no garantee that [0,1] would produce a 0 element.
Definition at line 28 of file randomtest.cpp.
References randomgenerator::domain().
00034 { 00035 for 00036 ( 00037 typename list< typename R::Ttype >::iterator i = lst.begin(); 00038 i!=lst.end(); i++ 00039 ) 00040 { 00041 if (randomgenerator::domain(*i,zero,one)==false) 00042 return false; 00043 } 00044 00045 return true; 00046 }
| boolc randomtest::randomcontainer | ( | list< typename R::Ttype > & | lst, | |
| R & | r, | |||
| uintc | n, | |||
| boolc | zero, | |||
| boolc | one | |||
| ) | [inline, static] |
Returns true if elements enpoints are correct.
Definition at line 12 of file randomtest.cpp.
Referenced by testprintrandom().
00019 { 00020 for (uint i=0; i<n; ++i) 00021 lst.push_back(r()); 00022 00023 return domaintest(lst,r,zero,one); 00024 }
| int randomtest::test01 | ( | ) | [static] |
Test random11<>.
Definition at line 83 of file randomtest.cpp.
References r, and testprintrandom().
Referenced by main().
00084 { 00085 cout << endl << "[0,1] interval, n=8" << endl; 00086 random11<> r(8); 00087 return ! testprintrandom(r,30,true,true); 00088 }
| int randomtest::test02 | ( | ) | [static] |
Test random00<>.
Definition at line 90 of file randomtest.cpp.
References r, and testprintrandom().
Referenced by main().
00091 { 00092 cout << endl << "(0,1) interval, n=8" << endl; 00093 random00<> r(8); 00094 return ! testprintrandom(r,30,false,false); 00095 }
| int randomtest::test03 | ( | ) | [static] |
Test random10<>.
Definition at line 97 of file randomtest.cpp.
References r, and testprintrandom().
Referenced by main().
00098 { 00099 cout << endl << "[0,1) interval, n=8" << endl; 00100 random10<> r(8); 00101 return ! testprintrandom(r,30,true,false); 00102 }
| int randomtest::test04 | ( | ) | [static] |
Test random01<>.
Definition at line 104 of file randomtest.cpp.
References r, and testprintrandom().
Referenced by main().
00105 { 00106 cout << endl << "(0,1] interval, n=8" << endl; 00107 random01<> r(8); 00108 return ! testprintrandom(r,30,false,true); 00109 }
| int randomtest::test05 | ( | ) | [static] |
Definition at line 111 of file randomtest.cpp.
References randomgenerator::domain().
Referenced by main().
00112 { 00113 typedef point2<double> pt2; 00114 typedef point3<double> pt3; 00115 00116 uint N=100; 00117 bool res=true; 00118 00119 for (uint i=0; i<N; ++i) 00120 { 00121 pt2 p1 = randompoint<>().makepoint2(); 00122 // cout << SHOW(p1) << endl; 00123 res &= randomgenerator::domain(p1); 00124 } 00125 00126 for (uint i=0; i<N; ++i) 00127 { 00128 pt2 p1 = randompoint< random01<> >(random01<>(8)).makepoint2(); 00129 res &= randomgenerator::domain(p1); 00130 } 00131 00132 for (uint i=0; i<N; ++i) 00133 { 00134 pt2 p1 = randompoint< random10<> >(random10<>(8)).makepoint2(); 00135 res &= randomgenerator::domain(p1); 00136 } 00137 00138 for (uint i=0; i<N; ++i) 00139 { 00140 pt2 p1 = randompoint< random00<> >(random00<>(16)).makepoint2(); 00141 res &= randomgenerator::domain(p1); 00142 } 00143 00144 for (uint i=0; i<N; ++i) 00145 { 00146 pt3 p1 = randompoint<>().makepoint3(); 00147 // cout << SHOW(p1) << endl; 00148 res &= randomgenerator::domain(p1); 00149 } 00150 00151 return !res; 00152 }
| void randomtest::test06 | ( | ) | [static] |
Definition at line 154 of file randomtest.cpp.
Referenced by main().
00155 { 00156 uint count=10; 00157 cout << "Repeated list of random numbers each time this program called." << endl; 00158 cout << "Ouput " << count << " rand() numbers" << endl; 00159 for (uint i=0; i<count; ++i) 00160 cout << i << ": " << rand() << endl; 00161 }
| void randomtest::test07 | ( | ) | [static] |
Definition at line 163 of file randomtest.cpp.
Referenced by main().
00164 { 00165 randomgenerator().randomize_start(); 00166 00167 uint count=10; 00168 cout << "Different list of random numbers each time this program called." << endl; 00169 cout << "Ouput " << count << " rand() numbers" << endl; 00170 for (uint i=0; i<count; ++i) 00171 cout << i << ": " << rand() << endl; 00172 }
| boolc randomtest::testprintrandom | ( | R & | r, | |
| uintc | n, | |||
| boolc | zero, | |||
| boolc | one | |||
| ) | [inline, static] |
Test interval 0 to 1 optionally with end points.
Returns true if elements enpoints are correct.
Definition at line 50 of file randomtest.cpp.
References randomcontainer().
Referenced by test01(), test02(), test03(), and test04().
00056 { 00057 list< typename R::Ttype > lst; 00058 00059 bool res = randomtest::randomcontainer(lst,r,n,zero,one); 00060 00061 for ( 00062 typename list< typename R::Ttype >::iterator i = lst.begin(); 00063 i!=lst.end(); i++ ) 00064 { cout << *i << " "; } 00065 cout << endl << endl; 00066 00067 cout << "Removing duplicates to look at sample space." << endl; 00068 00069 lst.sort(); 00070 lst.unique(); 00071 00072 for ( 00073 typename list< typename R::Ttype >::iterator i = lst.begin(); 00074 i!=lst.end(); i++ ) 00075 { cout << *i << " "; } 00076 cout << endl << endl; 00077 00078 assert(res); 00079 00080 return res; 00081 }
1.5.8