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

RDE_lib2/AbstractSolutionPoint.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 __ABSTRACTSOLUTIONPOINT__
00016 #define __ABSTRACTSOLUTIONPOINT__
00017 
00018 
00019 #include "lietovectorfield.h"
00020 
00021 
00023 
00027 template <typename my_alg_type>
00028 class AbstractSolutionPoint : public std::map<typename my_alg_type::LET, typename my_alg_type::SCA>
00029 {
00030         typedef typename my_alg_type::SCA SCA;
00031         typedef typename my_alg_type::LET LET;
00032         typedef typename my_alg_type::mtlVector mtlVector;
00033 
00034         static const unsigned myDIM = my_alg_type::myDIM;
00035 
00036 public:
00038         AbstractSolutionPoint(void){};
00040         ~AbstractSolutionPoint(void){};
00041 
00043         explicit AbstractSolutionPoint(mtlVector& v)
00044         {
00045                 for(unsigned int i=0; i < myDIM; i++)
00046                 {
00047                         if ( v[i] != 0 )
00048                         {
00049                                 (*this)[LET(i+1)] = v[i];
00050                         }
00051                 }
00052         };
00053 
00054         AbstractSolutionPoint<my_alg_type> operator + (AbstractSolutionPoint<my_alg_type> & p2)
00055         {
00056                 AbstractSolutionPoint<my_alg_type> result;
00057 
00058                 std::map<LET, SCA>::iterator i=(*this).begin();
00059 
00060                 while(i != (*this).end())
00061                 {
00062                         if (p2.find((*i).first) != p2.end() )
00063                         {
00064                                 result[(*i).first] = (*this)[(*i).first] + p2[(*i).first];
00065                         }
00066                         else
00067                         {
00068                                 result[(*i).first] = (*this)[(*i).first]; 
00069                         }
00070 
00071                         i++;
00072                 }
00073 
00074                 i=p2.begin();
00075 
00076                 while(i != p2.end())
00077                 {
00078                         if (result.find((*i).first) == result.end())
00079                         {
00080                                 result[(*i).first] = p2[(*i).first];
00081                         }
00082 
00083                         i++;
00084                 }
00085 
00086                 return result;
00087         };
00088 
00089         AbstractSolutionPoint<my_alg_type> operator - (AbstractSolutionPoint<my_alg_type> & p2)
00090         {
00091                 return (-1)*p2 + (*this);
00092         };
00093 
00094         friend AbstractSolutionPoint<my_alg_type> operator * (SCA s, AbstractSolutionPoint<my_alg_type> & p)
00095         {
00096                 AbstractSolutionPoint<my_alg_type> result;
00097 
00098                 std::map<LET, SCA>::iterator i=p.begin();
00099 
00100                 while(i != p.end())
00101                 {
00102                         result[(*i).first] = (*i).second * s;
00103                         i++;
00104                 }
00105 
00106                 return result;
00107         };
00108 
00109 
00110 }; //END CLASS DEFINITION AbstractSolutionPoint
00111 
00112 
00113 #endif // __ABSTRACTSOLUTIONPOINT__

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