root/library/tests/stresssuite/square_mat_prep.cpp

Revision 1064, 2.4 kB (checked in by mido, 14 years ago)

astyle applied all over the library

Line 
1#include "base/bdmbase.h"
2#include "base/user_info.h"
3#include "generator.h"
4#include "additive_generator.h"
5#include "size_generator.h"
6#include "../square_mat_point.h"
7#include <iostream>
8#include <iomanip>
9#include <stdlib.h>
10
11using namespace std;
12using namespace bdm;
13using namespace itpp;
14
15UIREGISTER ( size_generator );
16UIREGISTER ( additive_generator );
17//UIREGISTER ( square_mat_point );
18
19const char *generator_file_name = "generator.cfg";
20const char *agenda_file_name = "agenda.cfg";
21int agenda_length = 10;
22
23int main ( int argc, char const *argv[] ) {
24    RNG_randomize();
25
26    bool unknown = false;
27    int update_next = 0; // 1 generator file, 2 agenda file, 3 agenda length
28    const char **param = argv + 1;
29    while ( *param && !unknown ) {
30        if ( update_next ) {
31            if ( update_next == 1 ) {
32                generator_file_name = *param;
33            } else if ( update_next == 2 ) {
34                agenda_file_name = *param;
35            } else {
36                int length = atoi ( *param );
37                if ( length > 0 ) {
38                    agenda_length = length;
39                } else {
40                    cerr << "invalid agenda length value ignored" << endl;
41                }
42            }
43
44            update_next = 0;
45        } else {
46            if ( !strcmp ( *param, "-a" ) ) {
47                update_next = 2;
48            } else if ( !strcmp ( *param, "-g" ) ) {
49                update_next = 1;
50            } else if ( !strcmp ( *param, "-l" ) ) {
51                update_next = 3;
52            } else {
53                unknown = true;
54            }
55        }
56
57        ++param;
58    }
59
60    if ( unknown || update_next ) {
61        cerr << "usage: " << argv[0] << " [ -g generator.cfg ] [ -a agenda_output.cfg ] [ -l agenda_length ]" << endl;
62    } else {
63        Array<shared_ptr<square_mat_point> > mag ( agenda_length );
64
65        UIFile gspec ( generator_file_name );
66        shared_ptr<generator> gen ( UI::build<generator> ( gspec, "generator", UI::compulsory ) );
67        for ( int i = 0; i < agenda_length; ++i ) {
68            mat m = gen->next();
69            square_mat_point *p = new square_mat_point();
70            p->set_parameters ( m, randu ( m.rows() ), randu() );
71            mag ( i ) = p;
72        }
73
74        UIFile fag;
75        UI::save ( mag, fag, "agenda" );
76        fag.save ( agenda_file_name );
77    }
78}
Note: See TracBrowser for help on using the browser.