Changeset 477 for library/tests/egiw_test.cpp
- Timestamp:
- 08/05/09 14:40:03 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/egiw_test.cpp
r456 r477 14 14 15 15 template<> 16 const ParticularUI<egiw> &ParticularUI<egiw>::factory (17 ParticularUI<egiw> ("egiw"));16 const ParticularUI<egiw> &ParticularUI<egiw>::factory ( 17 ParticularUI<egiw> ( "egiw" ) ); 18 18 19 19 template<> 20 const ParticularUI<egiw_harness> &ParticularUI<egiw_harness>::factory (21 ParticularUI<egiw_harness> ("egiw_harness"));20 const ParticularUI<egiw_harness> &ParticularUI<egiw_harness>::factory ( 21 ParticularUI<egiw_harness> ( "egiw_harness" ) ); 22 22 23 TEST (test_egiw) {24 epdf_harness::test_config("egiw.cfg");23 TEST ( test_egiw ) { 24 epdf_harness::test_config ( "egiw.cfg" ); 25 25 } 26 26 27 TEST (test_egiw_1_2) {28 29 30 31 27 TEST ( test_egiw_1_2 ) { 28 // Setup model 29 double mu = 1.1; //unit step parametr 30 double b = 3.0; // sequence of <1 -1 1 -1...> 31 double s = 0.1; 32 32 33 33 34 35 mat V(3, 3);36 V(0, 0) = pow(mu, 2) + pow(b, 2) + s;37 V(1, 0) = mu;38 V(2, 0) = b;34 // TEST 1x1 EGIW 35 mat V ( 3, 3 ); 36 V ( 0, 0 ) = pow ( mu, 2 ) + pow ( b, 2 ) + s; 37 V ( 1, 0 ) = mu; 38 V ( 2, 0 ) = b; 39 39 40 V(0, 1) = V(1, 0);41 V(1, 1) = 1.0;42 V(2, 1) = 0.0;40 V ( 0, 1 ) = V ( 1, 0 ); 41 V ( 1, 1 ) = 1.0; 42 V ( 2, 1 ) = 0.0; 43 43 44 V(0, 2) = V(2, 0);45 V(1, 2) = V(2, 1);46 V(2, 2) = 1.0;44 V ( 0, 2 ) = V ( 2, 0 ); 45 V ( 1, 2 ) = V ( 2, 1 ); 46 V ( 2, 2 ) = 1.0; 47 47 48 48 double nu = 20; 49 49 50 egiw E(1, nu * V, nu); 51 CHECK_CLOSE(vec("1.1 3.0 0.142857"), E.mean(), epsilon);52 CHECK_CLOSE(7.36731, E.lognc(), epsilon);50 egiw E ( 1, nu * V, nu ); 51 CHECK_CLOSE ( vec ( "1.1 3.0 0.142857" ), E.mean(), epsilon ); 52 CHECK_CLOSE ( 7.36731, E.lognc(), epsilon ); 53 53 54 55 vec rgr(3);54 int n = 100; 55 vec rgr ( 3 ); 56 56 57 mat Tmp(2 * n, n);57 mat Tmp ( 2 * n, n ); 58 58 59 60 for (int k = 0; k < n; k++) { // ALL b61 rgr(1) = 1 + k * (1.0 / n) * 4.0;62 for (int i = 0; i < 2*n; i++) { //ALL mu63 rgr(0) = -2 + i * (1.0 / n) * 3.0;64 for (int j = 0; j < n; j++) { // All sigma65 rgr(2) = (j + 1) * (1.0 / n) * 2.0;59 double summ = 0.0; 60 for ( int k = 0; k < n; k++ ) { // ALL b 61 rgr ( 1 ) = 1 + k * ( 1.0 / n ) * 4.0; 62 for ( int i = 0; i < 2*n; i++ ) { //ALL mu 63 rgr ( 0 ) = -2 + i * ( 1.0 / n ) * 3.0; 64 for ( int j = 0; j < n; j++ ) { // All sigma 65 rgr ( 2 ) = ( j + 1 ) * ( 1.0 / n ) * 2.0; 66 66 67 Tmp(i, j) = E.evallog(rgr); 68 } 67 Tmp ( i, j ) = E.evallog ( rgr ); 68 } 69 } 70 summ += sumsum ( exp ( Tmp ) ) / n / n / n * 3.0 * 2.0 * 4.0; 69 71 } 70 summ += sumsum(exp(Tmp)) / n / n / n * 3.0 * 2.0 * 4.0;71 }72 72 73 CHECK_CLOSE(1.0, summ, 0.1);73 CHECK_CLOSE ( 1.0, summ, 0.1 ); 74 74 } 75 75