@@ -530,8 +530,11 @@ if (printtree_flag == 1){
530530if (skipall_flag == 0 ) {
531531
532532
533- ex * theogfs_symb_fast ;
534- theogfs_symb_fast = new ex [leaves ];
533+ // ex *theogfs_symb_fast;
534+ // theogfs_symb_fast = new ex[leaves];
535+ float * theogfs_fast ;
536+ theogfs_fast = new float [leaves ];
537+
535538
536539 // only estimate if -t or -r or -c is not set to custom value
537540 if (estimate_flag == 1 ){
@@ -540,28 +543,53 @@ if (skipall_flag == 0) {
540543 estimate (& theta_hat ,& rho_hat ,para );
541544 }
542545 else {
543- //compute the symbolic formula in advance
544- // do this only once and give the functions to my_f_symbolic
546+ // // // // // // this part works well for smaller trees
547+ // //compute the symbolic formula in advance
548+ // // do this only once and give the functions to my_f_symbolic
549+ // cout << "Initializing the tree structure...\n";
550+ // rootTree(intree,NULL);
551+ // unprob_symb(intree);
552+ // initialize_tree(intree,leaves);
553+ // cout << "done.\nComputing probabilities along the tree...\n";
554+ // // cout << "We did get past the initialize tree\n";
555+ // // check_probs(tree,anzahl,para->rhoS);
556+ // comp_pkfhs(intree,leaves,x);
557+ // cout << "done.\nEstimation of theta and rho...\n";
558+ // // cout << "We computed the probabillties within the tree\n";
559+ // // check_probs(tree,anzahl,para->rhoS)
560+ // treegfs_symbolic_fast(intree,leaves,theogfs_symb_fast,x);
561+ // for(i=0; i<leaves; i++){
562+ // paraS->symbolicgfs[i] = theogfs_symb_fast[i];
563+ // // printf("\n\n\n\n");
564+ // // cout << theogfs_symb_fast[i];
565+ // // // // //
566+
567+
568+ // // // // // // this part works faster for larger trees
569+ // //compute the pkfhs and the gfs along the tree during estimation
570+ // this is faster than using the symbolic structure where many formulas appear many times
571+ // my_f_numeric will need the tree to compute the pkfhs along the tree
545572 cout << "Initializing the tree structure...\n" ;
546573 rootTree (intree ,NULL );
547- unprob_symb (intree );
548- initialize_tree (intree ,leaves );
549- cout << "done.\nComputing probabilities along the tree...\n" ;
574+ unprob (intree );
575+ initialize_tree_numeric (intree ,leaves );
576+ cout << "done.\nTesting to computing probabilities along the tree...\n" ;
550577// cout << "We did get past the initialize tree\n";
551578// check_probs(tree,anzahl,para->rhoS);
552- comp_pkfhs (intree ,leaves ,x );
579+ comp_pkfhs_numeric (intree ,leaves ,2.8 );
553580 cout << "done.\nEstimation of theta and rho...\n" ;
554581// cout << "We computed the probabillties within the tree\n";
555582// check_probs(tree,anzahl,para->rhoS)
556- treegfs_symbolic_fast (intree ,leaves ,theogfs_symb_fast ,x );
557- for (i = 0 ; i < leaves ; i ++ ){
558- paraS -> symbolicgfs [i ] = theogfs_symb_fast [i ];
559- // printf("\n\n\n\n");
560- // cout << theogfs_symb_fast[i];
561- }
583+ // treegfs_symbolic_fast(intree,leaves,theogfs_symb_fast,x);
584+ // for(i=0; i<leaves; i++){
585+ // paraS->symbolicgfs[i] = theogfs_symb_fast[i];
586+ // // printf("\n\n\n\n");
587+ // // cout << theogfs_symb_fast[i];
588+ // }
589+ // // // // //
562590
563591// cout << "We successfully called treegfs_symbolic_fast\n";
564- estimate_symbolic (& theta_hat ,& rho_hat ,paraS );
592+ estimate_numeric (& theta_hat ,& rho_hat ,para );
565593 }
566594 }
567595 //////////////////* END estimate theta and rho*//////////////////////////////////////////
@@ -588,11 +616,15 @@ if (skipall_flag == 0) {
588616// // compute the GFS given the tree
589617// treegfs(intree,leaves,est_gfs_giventree_theo,rho_hat); //this is not fast
590618 rootTree (intree ,NULL );
591- treegfs_symbolic_fast (intree ,leaves ,theogfs_symb_fast ,x );
592- int inc ;
593- for (inc = 0 ; inc < leaves ; inc ++ ){
594- est_gfs_giventree_theo [inc ] = to_double (ex_to < numeric > (theogfs_symb_fast [inc ].subs (x == rho_hat ).evalf ()));
595- }
619+ // treegfs_symbolic_fast(intree,leaves,theogfs_symb_fast,x); // this is fast but can only very slowly be evaluated
620+ unprob (intree );
621+ initialize_tree_numeric (intree ,leaves );
622+ comp_pkfhs_numeric (intree ,leaves ,rho_hat );
623+ treegfs_numeric_fast (intree ,leaves ,theogfs_fast ,rho_hat );
624+ // int inc;
625+ // for (inc = 0; inc < leaves; inc++){
626+ // est_gfs_giventree_theo[inc] = to_double(ex_to<numeric>(theogfs_symb_fast[inc].subs(x == rho_hat).evalf()));
627+ // }
596628
597629
598630
@@ -602,7 +634,8 @@ if (skipall_flag == 0) {
602634 printf ("Input GFS:\n" );
603635 printgfs (input_gfs ,leaves ,1. ,1. );
604636 printf ("Estimated GFS given the tree:\n" );
605- printgfs (est_gfs_giventree_theo ,leaves ,theta_hat ,rho_hat );
637+ // printgfs(est_gfs_giventree_theo,leaves,theta_hat,rho_hat);
638+ printgfs (theogfs_fast ,leaves ,theta_hat ,rho_hat );
606639 }
607640
608641
0 commit comments