00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #ifndef polybori_routines_pbori_routines_dd_h_ 00017 #define polybori_routines_pbori_routines_dd_h_ 00018 00019 // include basic definitions 00020 #include <polybori/pbori_defs.h> 00021 00022 // get addition definitions 00023 #include <polybori/iterators/CTermIter.h> 00024 #include <polybori/iterators/PBoRiOutIter.h> 00025 #include <set> 00026 #include <vector> 00027 00028 BEGIN_NAMESPACE_PBORI 00029 00031 template<class DDType, class OutputType> 00032 OutputType 00033 dd_last_lexicographical_term(const DDType& dd, type_tag<OutputType>) { 00034 00035 typedef typename DDType::idx_type idx_type; 00036 typedef typename DDType::size_type size_type; 00037 typedef OutputType term_type; 00038 00039 term_type result(dd.ring()); 00040 00041 PBORI_ASSERT(!dd.isZero()); 00042 00043 size_type nlen = std::distance(dd.lastBegin(), dd.lastEnd()); 00044 00045 // store indices in list 00046 std::vector<idx_type> indices(nlen); 00047 00048 // iterator, which uses changeAssign to insert variable 00049 // wrt. given indices to a monomial 00050 PBoRiOutIter<term_type, idx_type, change_assign<term_type> > 00051 outiter(result); 00052 00053 // insert backward (for efficiency reasons) 00054 reversed_inter_copy(dd.lastBegin(), dd.lastEnd(), indices, outiter); 00055 00056 return result; 00057 } 00058 00059 00060 END_NAMESPACE_PBORI 00061 00062 #endif