Changeset 722 for library/tests/pdf_harness.cpp
- Timestamp:
- 11/13/09 16:11:31 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/pdf_harness.cpp
r713 r722 48 48 49 49 int tc = 0; 50 Array<vec> actual (CurrentContext::max_trial_count);50 Array<vec> actual ( CurrentContext::max_trial_count ); 51 51 do { 52 52 mat smp = hpdf->samplecond_mat ( cond, nsamples ); 53 53 vec emu = smp * ones ( nsamples ) / nsamples; 54 actual ( tc ) = emu;54 actual ( tc ) = emu; 55 55 ++tc; 56 56 } while ( ( tc < CurrentContext::max_trial_count ) && 57 !UnitTest::AreClose ( mean, actual( tc - 1 ), delta ) );57 !UnitTest::AreClose ( mean, actual ( tc - 1 ), delta ) ); 58 58 if ( ( tc == CurrentContext::max_trial_count ) && 59 ( !UnitTest::AreClose ( mean, actual( CurrentContext::max_trial_count - 1 ), delta ) ) ) {59 ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), delta ) ) ) { 60 60 UnitTest::MemoryOutStream stream; 61 stream << CurrentContext::format_context (__LINE__) << "expected " << mean << " +/- " << delta << " but was " << actual;61 stream << CurrentContext::format_context ( __LINE__ ) << "expected " << mean << " +/- " << delta << " but was " << actual; 62 62 63 UnitTest::TestDetails details (*UnitTest::CurrentTest::Details(), 0, false);63 UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), 0, false ); 64 64 65 65 UnitTest::CurrentTest::Results()->OnTestFailure ( details, stream.GetText() ); 66 66 } 67 67 } 68 68 69 69 void pdf_harness::check_covariance() { 70 70 int tc = 0; 71 Array<mat> actual (CurrentContext::max_trial_count);71 Array<mat> actual ( CurrentContext::max_trial_count ); 72 72 do { 73 73 mat smp = hpdf->samplecond_mat ( cond, nsamples ); 74 74 vec emu = smp * ones ( nsamples ) / nsamples; 75 75 mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); 76 actual ( tc ) = er;76 actual ( tc ) = er; 77 77 ++tc; 78 78 } while ( ( tc < CurrentContext::max_trial_count ) && 79 !UnitTest::AreClose ( R, actual( tc - 1 ), tolerance ) );79 !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); 80 80 if ( ( tc == CurrentContext::max_trial_count ) && 81 ( !UnitTest::AreClose ( R, actual( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) {81 ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 82 82 UnitTest::MemoryOutStream stream; 83 stream << CurrentContext::format_context (__LINE__) << "expected " << R << " +/- " << tolerance << " but was " << actual;83 stream << CurrentContext::format_context ( __LINE__ ) << "expected " << R << " +/- " << tolerance << " but was " << actual; 84 84 85 UnitTest::TestDetails details (*UnitTest::CurrentTest::Details(), 0, false);85 UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), 0, false ); 86 86 87 87 UnitTest::CurrentTest::Results()->OnTestFailure ( details, stream.GetText() ); 88 88 } 89 89 } 90 90