00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #pragma once
00014
00015 #ifndef __lie2vectorfield__
00016 #define __lie2vectorfield__
00017
00018
00019 #include <math.h>
00020 #include "alg_types2.h"
00021
00022
00024
00028 template <typename my_alg_type, typename VF>
00029 class lietovectorfield
00030 {
00031 typedef typename my_alg_type::LIE LIE;
00032 typedef typename my_alg_type::S S;
00033 typedef typename my_alg_type::Q Q;
00034
00035 static const unsigned DEPTH = my_alg_type::DEPTH;
00036 static const unsigned myDIM = my_alg_type::myDIM;
00037
00038 typedef typename alg::lie_basis<S,Q,myDIM,DEPTH> LBASIS;
00039 typedef typename LBASIS::KEY LKEY;
00040
00041
00042 private:
00044 std::vector<VF> vecargument;
00047 std::map<unsigned int, VF> table;
00048
00049 public:
00051 lietovectorfield(const std::vector<VF> & vecarg)
00052 : vecargument(vecarg)
00053 {
00054 }
00055
00057 ~lietovectorfield(void)
00058 {
00059 }
00060
00063 VF lie2vectorfield(const LIE & liearg)
00064 {
00065 VF result;
00066 for (LIE::const_iterator i = liearg.begin(); i != liearg.end(); ++i)
00067 {
00068 VF::scaled_add(expand(i->first),(double) i->second, result);
00069 }
00070 return result;
00071 }
00072
00074 VF expand(const LKEY & k)
00075 {
00076 std::map<unsigned int, VF>::iterator it;
00077 it = table.find(k);
00078 if (it == table.end())
00079 {
00080 return table[k] = rec_expand(k);
00081 }
00082 else
00083 {
00084 return it->second;
00085 }
00086 }
00087
00088 private:
00090 VF rec_expand(const LKEY & k)
00091 {
00092 if (LIE::basis.letter(k))
00093 {
00094 return (VF) vecargument[k-1];
00095 }
00096 else
00097 {
00098 return VF::Lie(expand( LIE::basis.lparent(k)), expand( LIE::basis.rparent(k)));
00099 }
00100 }
00101
00102 };
00103
00104
00105
00106 #endif // __lie2vectorfield__