[467] | 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" |
---|
[468] | 6 | #include "square_mat_point.h" |
---|
[467] | 7 | #include <iostream> |
---|
| 8 | #include <iomanip> |
---|
| 9 | #include <stdlib.h> |
---|
| 10 | |
---|
| 11 | using namespace std; |
---|
| 12 | using namespace bdm; |
---|
| 13 | using namespace itpp; |
---|
| 14 | |
---|
[477] | 15 | UIREGISTER ( size_generator ); |
---|
| 16 | UIREGISTER ( additive_generator ); |
---|
[537] | 17 | //UIREGISTER ( square_mat_point ); |
---|
[467] | 18 | |
---|
| 19 | const char *generator_file_name = "generator.cfg"; |
---|
| 20 | const char *agenda_file_name = "agenda.cfg"; |
---|
| 21 | int agenda_length = 10; |
---|
| 22 | |
---|
[477] | 23 | int main ( int argc, char const *argv[] ) { |
---|
| 24 | RNG_randomize(); |
---|
[467] | 25 | |
---|
[477] | 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; |
---|
[467] | 45 | } else { |
---|
[477] | 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 | } |
---|
[467] | 55 | } |
---|
| 56 | |
---|
[477] | 57 | ++param; |
---|
[467] | 58 | } |
---|
| 59 | |
---|
[477] | 60 | if ( unknown || update_next ) { |
---|
| 61 | cerr << "usage: " << argv[0] << " [ -g generator.cfg ] [ -a agenda_output.cfg ] [ -l agenda_length ]" << endl; |
---|
| 62 | } else { |
---|
[527] | 63 | Array<shared_ptr<square_mat_point> > mag ( agenda_length ); |
---|
[467] | 64 | |
---|
[477] | 65 | UIFile gspec ( generator_file_name ); |
---|
[527] | 66 | shared_ptr<generator> gen ( UI::build<generator> ( gspec, "generator", UI::compulsory ) ); |
---|
[477] | 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 | } |
---|
[467] | 73 | |
---|
[477] | 74 | UIFile fag; |
---|
| 75 | UI::save ( mag, fag, "agenda" ); |
---|
| 76 | fag.save ( agenda_file_name ); |
---|
[468] | 77 | } |
---|
[467] | 78 | } |
---|