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