@@ -26,10 +26,10 @@ void collect_factors::fill_hash_map(iterator it)
2626 factor_hash.clear ();
2727 sibling_iterator sib=tr.begin (it);
2828 unsigned int factors=0 ;
29- while (sib!=tr.end (it)) {
29+ while (sib!=tr.end (it)) { // iterate over all factors in the product
3030 sibling_iterator chsib=tr.begin (sib);
3131 bool dontcollect=false ;
32- while (chsib!=tr.end (sib)) {
32+ while (chsib!=tr.end (sib)) { // iterate over all child nodes of a factor
3333 const Symbol *smb=kernel.properties .get <Symbol>(chsib, true );
3434 // std::cerr << chsib << ": " << smb << std::endl;
3535 if ((chsib->fl .parent_rel ==str_node::p_sub || chsib->fl .parent_rel ==str_node::p_super) &&
@@ -40,8 +40,10 @@ void collect_factors::fill_hash_map(iterator it)
4040 ++chsib;
4141 }
4242 if (!dontcollect) {
43- if (*sib->name ==" \\ pow" )
44- factor_hash.insert (std::pair<hashval_t , sibling_iterator>(tr.calc_hash (tr.begin (sib)), tr.begin (sib)));
43+ if (*sib->name ==" \\ pow" ) {
44+ if (tr.begin (sib)->is_rational ()==false ) // do not collect exponents of numbers
45+ factor_hash.insert (std::pair<hashval_t , sibling_iterator>(tr.calc_hash (tr.begin (sib)), tr.begin (sib)));
46+ }
4547 else
4648 factor_hash.insert (std::pair<hashval_t , sibling_iterator>(tr.calc_hash (sib), sib));
4749 ++factors;
@@ -78,6 +80,11 @@ Algorithm::result_t collect_factors::apply(iterator& st)
7880 else {
7981 expsum.append_child (expsumit, str_node (" 1" , str_node::b_round));
8082 }
83+ // FIXME: If the multiplier of this factor is non-zero, we
84+ // have (pure number)**(exp). We need to catch this
85+ // separately. std::cerr << (*thisbin1).second << std::endl;
86+ // For now, we have disabled collecting such factors; sympy
87+ // can do it anyway.
8188 assert (*((*thisbin1).second ->multiplier )==1 );
8289 // find the other, identical factors
8390 while (thisbin2!=factor_hash.end () && thisbin2->first ==curr) {
0 commit comments