@@ -359,34 +359,38 @@ namespace cadabra {
359359 return -(Adjform::value_type)data->begin ().number_of_children ();
360360 }
361361
362- AdjformEx::rational_type AdjformEx::zero = 0 ;
362+ AdjformEx::integer_type AdjformEx::zero = 0 ;
363363
364364 AdjformEx::AdjformEx ()
365365 {
366366
367367 }
368368
369- AdjformEx::AdjformEx (const Adjform& adjform, const AdjformEx::rational_type & value, const Ex& prefactor)
369+ AdjformEx::AdjformEx (const Adjform& adjform, const AdjformEx::integer_type & value, const Ex& prefactor)
370370 : prefactor(prefactor)
371371 {
372+ sizeof (mpq_class);
373+ sizeof (int64_t );
372374 set (adjform, value);
373375 }
374376
375- AdjformEx::AdjformEx (const Adjform& adjform, const rational_type & value, Ex::iterator prefactor)
377+ AdjformEx::AdjformEx (const Adjform& adjform, const integer_type & value, Ex::iterator prefactor)
376378 : prefactor(prefactor)
377379 {
378380 set (adjform, value);
379381 }
380382
381- AdjformEx::AdjformEx (Ex::iterator it, IndexMap& index_map, const Kernel& kernel)
383+ AdjformEx::AdjformEx (Ex& tr, Ex ::iterator it, IndexMap& index_map, const Kernel& kernel)
382384 : prefactor(str_node(" \\ prod" ))
383385 , tensor(str_node(" \\ prod" ))
384386 {
385387 set (Adjform (it, index_map, kernel));
386388
387389 if (*it->name == " \\ prod" ) {
390+ Ex_comparator comp (kernel.properties );
391+
388392 for (Ex::sibling_iterator beg = it.begin (), end = it.end (); beg != end; ++beg) {
389- if (has_indices (kernel, beg))
393+ if (has_indices (kernel, beg) || !comp. can_move_to_front (tr, it, beg) )
390394 tensor.append_child (tensor.begin (), (Ex::iterator)beg);
391395 else
392396 prefactor.append_child (prefactor.begin (), (Ex::iterator)beg);
@@ -410,7 +414,7 @@ namespace cadabra {
410414 one (tensor_begin->multiplier );
411415 }
412416
413- AdjformEx::rational_type AdjformEx::compare (const AdjformEx& other) const
417+ AdjformEx::integer_type AdjformEx::compare (const AdjformEx& other) const
414418 {
415419 // Early failure checks
416420 if (data.empty () || data.size () != other.data .size ())
@@ -419,7 +423,7 @@ namespace cadabra {
419423 // Find the numeric factor between the first two terms, then loop over all
420424 // other terms checking that the factor is the same. If not, return 0
421425 auto a_it = data.begin (), b_it = other.data .begin (), a_end = data.end ();
422- rational_type factor = a_it->second / b_it->second ;
426+ integer_type factor = a_it->second / b_it->second ;
423427 while (a_it != a_end) {
424428 if (a_it->first != b_it->first )
425429 return 0 ;
@@ -436,13 +440,13 @@ namespace cadabra {
436440 add (kv.first , kv.second );
437441 }
438442
439- void AdjformEx::combine (const AdjformEx& other, AdjformEx::rational_type factor)
443+ void AdjformEx::combine (const AdjformEx& other, AdjformEx::integer_type factor)
440444 {
441445 for (const auto & kv : other.data )
442446 add (kv.first , kv.second * factor);
443447 }
444448
445- void AdjformEx::multiply (const AdjformEx::rational_type & k)
449+ void AdjformEx::multiply (const AdjformEx::integer_type & k)
446450 {
447451 for (auto & kv : data)
448452 kv.second *= k;
@@ -517,33 +521,33 @@ namespace cadabra {
517521 return tensor;
518522 }
519523
520- const AdjformEx::rational_type & AdjformEx::get (const Adjform& adjform) const
524+ const AdjformEx::integer_type & AdjformEx::get (const Adjform& adjform) const
521525 {
522526 auto pos = data.find (adjform);
523527 return (pos == data.end ()) ? zero : pos->second ;
524528 }
525529
526- void AdjformEx::set (const Adjform& term, const AdjformEx::rational_type & value)
530+ void AdjformEx::set (const Adjform& term, const AdjformEx::integer_type & value)
527531 {
528532 if (!term.empty ())
529533 set_ (term, value);
530534 }
531535
532- void AdjformEx::set_ (const Adjform& term, const AdjformEx::rational_type & value)
536+ void AdjformEx::set_ (const Adjform& term, const AdjformEx::integer_type & value)
533537 {
534538 if (value != 0 )
535539 data[term] = value;
536540 else
537541 data.erase (term);
538542 }
539543
540- void AdjformEx::add (const Adjform& term, const AdjformEx::rational_type & value)
544+ void AdjformEx::add (const Adjform& term, const AdjformEx::integer_type & value)
541545 {
542546 if (!term.empty ())
543547 add_ (term, value);
544548 }
545549
546- void AdjformEx::add_ (const Adjform& term, const AdjformEx::rational_type & value)
550+ void AdjformEx::add_ (const Adjform& term, const AdjformEx::integer_type & value)
547551 {
548552 auto elem = data.find (term);
549553 if (elem == data.end () && value != 0 ) {
0 commit comments