00001
00006
00007
00008
00009 #include "node.h"
00010
00011 #ifndef TOOLBOX
00012
00013 node * mknode_mass(int n, real m)
00014 {
00015 node *root = mknode(n);
00016
00017 root->set_mass(m);
00018 for_all_daughters(node, root, b) b->set_mass(m/n);
00019
00020 return root;
00021 }
00022
00023 #else
00024
00025 void main(int argc, char ** argv)
00026 {
00027 int n = 1;
00028 real m = 1.0;
00029
00030 check_help();
00031
00032 extern char *poptarg;
00033 int c;
00034 char* param_string = "m:n:";
00035
00036 while ((c = pgetopt(argc, argv, param_string)) != -1)
00037 switch(c) {
00038
00039 case 'm': m = atof(poptarg);
00040 break;
00041 case 'n': n = atoi(poptarg);
00042 break;
00043 case '?': params_to_usage(cerr, argv[0], param_string);
00044 get_help();
00045 exit(1);
00046 }
00047
00048 if (m <= 0) err_exit("mknodes: M > 0 required!");
00049 if (n <= 0) err_exit("mknodes: N > 0 required!");
00050
00051 node * root = mknode_mass(n, m);
00052
00053 root->log_history(argc, argv);
00054
00055 put_node(cout, *root);
00056 rmtree(root);
00057 }
00058
00059 #endif
00060
00061