00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef DJC_COROPA_LIBALGEBRA_POLYLIEBASISH_SEEN
00015 #define DJC_COROPA_LIBALGEBRA_POLYLIEBASISH_SEEN
00016 #include "basis_traits.h"
00017
00019
00026 template<typename SCA, typename RAT, DEG n_letters, DEG max_degree>
00027 class poly_lie_basis : public basis_traits<With_Degree, n_letters, max_degree>
00028 {
00029 public:
00031 typedef poly_basis<SCA, RAT> POLYBASIS;
00033 typedef typename POLYBASIS::KEY POLYBASIS_KEY;
00035 typedef std::pair<LET, POLYBASIS_KEY> KEY;
00037 typedef poly<SCA, RAT> POLY;
00039 typedef RAT RATIONAL;
00041 struct KEY_LESS
00042 {
00043 bool inline operator()(const KEY& lhs, const KEY& rhs) const
00044 {
00045 return ((degree(lhs) < degree(rhs)) || ((degree(lhs) == degree(rhs)) && lhs < rhs));
00046 }
00047 };
00049 typedef std::map<KEY, SCA, KEY_LESS> MAP;
00051 typedef poly_lie<SCA, RAT, n_letters, max_degree> POLY_LIE;
00052
00053 public:
00055 poly_lie_basis(void) {}
00056 public:
00057
00059
00067 inline static POLY_LIE prod(const KEY& k1, const KEY& k2)
00068 {
00069 POLY poly1 = POLY::prediff(k2.second, k1.first);
00070 POLY poly2 = POLY::prediff(k1.second, k2.first);
00071 KEY mon1 (k2.first, k1.second);
00072 KEY mon2 (k1.first, k2.second);
00073 POLY_LIE result;
00074 result = prod2(poly1, mon1) - prod2(poly2, mon2);
00075 return result;
00076 }
00077
00079 inline static POLY_LIE prod2(const POLY& poly1, const KEY& liemon1)
00080 {
00081 POLY_LIE result;
00082 for (typename POLY::const_iterator it = poly1.begin(); it != poly1.end(); it++)
00083 {
00084 SCA temp = it->second;
00085 POLYBASIS_KEY temp2 = POLYBASIS::prod2(liemon1.second, it->first);
00086 result[make_pair(liemon1.first, temp2)] = temp;
00087 }
00088 return result;
00089 }
00090
00091
00093 inline static KEY keyofletter(LET letter)
00094 {
00095 POLYBASIS empty;
00096 KEY result (letter, empty.empty_key);
00097 return result;
00098 }
00100 inline static DEG degree(const KEY& k)
00101 {
00102 return POLYBASIS::degree(k.second);
00103 }
00105 inline friend
00106 std::ostream& operator<<(std::ostream& os, const std::pair<poly_lie_basis*, KEY>& t)
00107 {
00108 POLYBASIS poly1;
00109 std::pair<POLYBASIS*, POLYBASIS_KEY> polypair;
00110 polypair.first = &poly1;
00111 polypair.second = t.second.second;
00112 os << "{" << polypair << "}" << "d/dx" << t.second.first << "}";
00113 return os;
00114 }
00115
00116
00117 };
00118 #endif