• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

RDE_lib2/POLYLIE.h

00001 /* *************************************************************
00002 
00003 Copyright 2010 Terry Lyons, Stephen Buckley, Djalil Chafai, 
00004 Greg Gyurkó and Arend Janssen. 
00005 
00006 Distributed under the terms of the GNU General Public License, 
00007 Version 3. (See accompanying file License.txt)
00008 
00009 ************************************************************* */
00010 
00011 
00012 
00013 #pragma once
00014 
00015 #ifndef __POLYLIE__
00016 #define __POLYLIE__
00017 
00018 
00019 #include "libalgebra.h"
00020 #include "LieMatrix.h"
00021 #include "AbstractSolutionPoint.h"
00022 
00023 
00024 template <typename my_alg_type>
00025 class POLYLIE :
00026         public alg::poly_lie<typename my_alg_type::SCA, typename my_alg_type::RAT, my_alg_type::ALPHABET_SIZE, my_alg_type::DEPTH> 
00027 {
00028         typedef typename my_alg_type::SCA SCA;
00029         typedef typename my_alg_type::RAT RAT;
00030         typedef typename my_alg_type::DEG DEG;
00031         typedef typename my_alg_type::LET LET;
00032 
00033         static const unsigned DEPTH = my_alg_type::DEPTH;
00034         static const unsigned myDIM = my_alg_type::myDIM;
00035         static const unsigned ALPHABET_SIZE = my_alg_type::ALPHABET_SIZE;
00036 
00037         typedef alg::poly_lie<SCA,RAT,ALPHABET_SIZE,DEPTH> ALG;
00038 
00039 public:
00040         POLYLIE (ALG in) : ALG(in)
00041         {
00042         }
00043 
00044         POLYLIE(LET x, LET y , DEG z) : ALG(x,y,z) //constructs y^z d/dx
00045         {
00046         }
00047 
00048         POLYLIE(void) 
00049         {
00050         }
00051 
00052         ~POLYLIE(void)
00053         {
00054         }
00055 
00056         explicit POLYLIE(LieMatrix<my_alg_type> & m) : ALG(LET(1), LET(1), DEG(1))
00057         {
00058                 (*this) *= m[0][0];
00059 
00060                 for(unsigned int j=1; j < myDIM; j++)
00061                 {
00062                         (*this) += (ALG(LET(1), LET(j+1), DEG(1)) * m[0][j]);
00063                 }
00064 
00065                 for(unsigned int i=1; i < myDIM; i++)
00066                 {
00067                         for(unsigned int j=0; j < myDIM; j++)
00068                         {
00069                                 (*this) += (ALG(LET(i+1), LET(j+1), DEG(1)) * m[i][j]);
00070                         }
00071                 }
00072         }
00073 
00074         static POLYLIE<my_alg_type>& scaled_add( POLYLIE<my_alg_type> & B, SCA l, POLYLIE<my_alg_type> & result)
00075         {
00076                 result += B*l;
00077                 return result;
00078         }
00079 
00080         // the Lie bracket
00081         static POLYLIE<my_alg_type> Lie(const POLYLIE<my_alg_type> & A, const POLYLIE<my_alg_type> & B)
00082         {
00083                 return A.ALG::operator *(B);
00084         }
00085 
00086         AbstractSolutionPoint<my_alg_type> evaluate(AbstractSolutionPoint<my_alg_type> & p)
00087         {
00088                 AbstractSolutionPoint<my_alg_type> result;
00089 
00090                 std::map<alg::poly_lie_basis<SCA,RAT,ALPHABET_SIZE,DEPTH>::KEY,SCA,alg::poly_lie_basis<SCA,RAT,ALPHABET_SIZE,DEPTH>::KEY_LESS>::iterator j=(*this).begin();
00091 
00092                 while(j != (*this).end())
00093                 {                       
00094                         if (result.find(((*j).first).first) != result.end() )
00095                         {
00096                                 result[((*j).first).first] += (*j).second * eval_key(((*j).first).second, p);
00097                         }
00098                         else
00099                         {
00100                                 result[((*j).first).first] = (*j).second * eval_key(((*j).first).second, p);
00101                         }
00102 
00103                         j++;
00104                         
00105                 }
00106 
00107                 return result;
00108         }
00109 
00110         SCA eval_key(std::map<LET, DEG> k, AbstractSolutionPoint<my_alg_type> & values)
00111         {
00112                 SCA result(1);
00113 
00114                 std::map<LET, DEG>::iterator it;
00115                 AbstractSolutionPoint<my_alg_type>::iterator j;
00116 
00117                 for(it = k.begin(); it != k.end(); ++it)
00118                 {
00119                         if (it->second > 0)
00120                         {
00121                                 j = values.find(it->first);
00122 
00123                                 if (j != values.end())
00124                                 {
00125                                         for (DEG d = 1; d <= it->second; ++d)
00126                                         {
00127                                                 result *= j->second;
00128                                         }
00129                                 } 
00130                                 else
00131                                 {   
00132                                         result = SCA(0);
00133                                 }
00134                         }
00135                 }
00136 
00137                 return result;
00138         }
00139 
00140 };
00141 
00142 #endif // __POLYLIE__

Generated on Fri Jan 14 2011 17:50:33 for Rough Differential Equation Solver by  doxygen 1.7.1