Ticket #212: unvalid_colorflows_AME.patch
File unvalid_colorflows_AME.patch, 2.9 KB (added by , 12 years ago) |
---|
-
AMEGIC++/Amplitude/CFColor.C
447 447 Complex value; 448 448 449 449 if (string_list.size()>0) { 450 newaddend = BuildTChain(string_list); 450 bool valid = true; 451 newaddend = BuildTChain(string_list,valid); 451 452 string_list.clear(); 452 453 factor_list.clear(); 453 454 454 //lookup string key in map 455 TF_Iterator tit = t_table.find(newaddend); 456 if (tit!=t_table.end()) value = total*t_table[newaddend]; 455 if (valid) { 456 //lookup string key in map 457 TF_Iterator tit = t_table.find(newaddend); 458 if (tit!=t_table.end()) value = total*t_table[newaddend]; 459 else { 460 st.Sort(*it); 461 ReplaceT(*it); 462 st.Expand(*it); 463 st.Linear(*it); 464 ReplaceD(*it,*it); 465 value = st.evalcolor(*it); 466 t_table.insert(std::make_pair(newaddend,value/total)); 467 } 468 Kabbala* newone = new Kabbala(newaddend,value); 469 (*it)->value = newone; 470 (*it)->op = 0; 471 } 457 472 else { 458 st.Sort(*it); 459 ReplaceT(*it); 460 st.Expand(*it); 461 st.Linear(*it); 462 ReplaceD(*it,*it); 463 value = st.evalcolor(*it); 464 t_table.insert(std::make_pair(newaddend,value/total)); 473 //unvalid color structure, return zero 474 Kabbala* zero = new Kabbala(string("0"),Complex(0.,0.)); 475 (*it)->value = zero; 476 (*it)->op = 0; 465 477 } 466 Kabbala* newone = new Kabbala(newaddend,value);467 (*it)->value = newone;468 (*it)->op = 0;469 478 } 470 479 else { 471 480 st.Sort(*it); … … 547 556 if (map) delete [] map; 548 557 } 549 558 550 string CFColor::BuildTChain(vector<string> string_list )559 string CFColor::BuildTChain(vector<string> string_list, bool & valid) 551 560 { 552 561 string key; 553 562 Char_Map translator; 554 563 char tmp,ca = 'A'; 555 564 vector<string> tmp_list; 556 565 566 size_t length = string_list.size(); 567 //approximate length faculty 568 size_t nperm = pow(length,length-1); 569 557 570 //generate the traces 558 571 for(;;) { 572 nperm--; 559 573 if (tmp_list.size()==0) { 560 574 tmp = string_list[0][2]; 561 575 tmp_list.push_back(string_list[0]); … … 583 597 } 584 598 } 585 599 if (string_list.size()==0) break; 600 if (nperm==0) { 601 valid = false; 602 break; 603 } 586 604 } 587 605 return key; 588 606 } -
AMEGIC++/Amplitude/CFColor.H
40 40 41 41 void ExtractIndices(sknot*,CharNum_Map&); 42 42 char DeliverIndex(CharNum_Map&,char&); 43 std::string BuildTChain(std::vector<std::string> );43 std::string BuildTChain(std::vector<std::string>,bool&); 44 44 std::string MapFChain(std::vector<std::string>); 45 45 TFprod_Table t_table; 46 46 TFprod_Table f_table;