root/library/tests/mpdf_harness.cpp @ 471

Revision 471, 1.3 kB (checked in by mido, 15 years ago)

1) ad UserInfo?: UI::get a UI::build predelany tak, ze vraci fals / NULL v pripade neexistence pozadovaneho Settingu, pridana enumericky typ UI::SettingPresence?, predelany stavajici UI implementace, dodelana UI dokumentace
2) dokoncena konfigurace ASTYLERU, brzy bude aplikovan
3) doxygen nastaven tak, ze vytvari soubor doxy_warnings.txt

Line 
1#include "mpdf_harness.h"
2#include "base/bdmbase.h"
3#include "base/user_info.h"
4#include "stat/exp_family.h"
5#include "mat_checks.h"
6#include "test_util.h"
7#include "UnitTest++.h"
8
9namespace bdm {
10
11template<>
12const ParticularUI<mpdf_harness> &ParticularUI<mpdf_harness>::factory(
13    ParticularUI<mpdf_harness>("mpdf_harness"));
14
15void mpdf_harness::test_config(const char *config_file_name) {
16    RV::clear_all();
17
18    UIFile in(config_file_name);
19    Array<mpdf_harness *> input;
20        UI::get(input, in, "data");
21    int sz = input.size();
22    CHECK(sz > 0);
23    for (int i = 0; i < sz; ++i) {
24        input(i)->test(config_file_name, i);
25    }
26}
27
28void mpdf_harness::from_setting(const Setting &set) {                   
29        hmpdf = UI::build<mpdf>(set, "mpdf", UI::compulsory);
30    UI::get(cond, set, "cond", UI::compulsory);
31    UI::get(mean, set, "mean", UI::compulsory);
32
33
34        UI::get(nsamples, set, "nsamples");
35    UI::get(R, set, "R");
36        UI::get(tolerance, set, "tolerance");
37}
38
39void mpdf_harness::test(const char *config_name, int idx)
40{
41    CurrentContext cc(config_name, idx);
42
43    mat smp = hmpdf->samplecond_m(cond, nsamples);
44    int n = smp.cols();
45    vec emu = smp * ones(n) / n;
46    mat er = (smp * smp.T()) / n - outer_product(emu, emu);
47    CHECK_CLOSE_EX(mean, emu, tolerance);
48    CHECK_CLOSE_EX(R, er, tolerance);
49}
50
51}
Note: See TracBrowser for help on using the browser.