Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vfamputation.h

00001 /***************************************************************************
00002                         vfamputation.h
00003                         -----------
00004                              
00005     begin                : Thu Apr 26 08:33:27 CEST 2001
00006     author               : (C) 2001 by Michael Peeters
00007     email                : Michael.Peeters@vub.ac.be
00008 ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #ifndef VFAMPUTATION_H
00020 #define VFAMPUTATION_H
00021 
00022 #include "vectorfunction.h"
00023 #include "newtonroot.h"
00024 #include "utility.h"
00025 #include <vector>
00026 
00027 namespace MODEL 
00028 {
00029 
00033   template<integer dims, typename nelem=number, class NT = NumericTraits<nelem,dims> >
00034   class VFAmputation : public VectorFunction<dims,nelem,NT>
00035   {
00036   public:
00037         typedef typename NumericTraits<nelem,dims+1>::vf greatervf;
00038         typedef typename NumericTraits<nelem,dims+1>::vect greatervect;
00039 
00040   public:
00042         VFAmputation(greatervf& func, const integer& var, bool own=false)
00043           : f((own)?func.clone():&func), owned(own), dynpar(var) 
00044         {
00045           define_parameter("amputated",paramvar);
00046           // add subvariables
00047           map<string,number*>& subparlist=func.get_parlist();
00048           map<string,number*>::iterator run=subparlist.begin();
00049           map<string,number*>::iterator endrun=subparlist.end();
00050           
00051           while(run!=endrun){
00052                 // cerr << "ADDING PARAMETER : " << run->first << endl;
00053                 define_parameter(run->first,*(run->second));
00054                 ++run;
00055           }
00056           
00057         }
00058         
00060         ~VFAmputation() {if(owned)delete f;}
00061         
00064         VFAmputation(const VFAmputation& vfb) : f(vfb.f), owned(false),
00065                                                                                         dynpar(vfb.dynpar)  
00066         {
00067           const map<string,number*>& subparlist=vfb.get_parlist();
00068           map<string,number*>::const_iterator run=subparlist.begin();
00069           map<string,number*>::const_iterator endrun=subparlist.end();
00070           
00071           while(run!=endrun){
00072                 define_parameter(run->first,*(run->second));
00073                 ++run;
00074           }
00075         }
00076                 
00078         virtual VFAmputation* clone () const {return new VFAmputation(*this);}
00079         
00084         virtual const vect& function(vect& fu,const vect& u)
00085         {                       
00086           greatervect v=convert(u);
00087           greatervect fv=convert(fu);
00088           
00089           fu=convert(f->function(fv,v));          
00090           return fu;      
00091         }
00092 
00094         greatervect convert(const vect& v)
00095         {
00096           greatervect w;
00097           for (integer i=0; i<dims+1; i++)
00098                 if(i<dynpar) w[i]=v[i] ;
00099                 else if (i==dynpar) w[i]=paramvar;
00100                 else if (i>dynpar) w[i]=v[i-1] ;
00101           
00102           return w;
00103         }
00104         
00106         vect        convert(const greatervect& v)
00107         {
00108           vect w;
00109           for (integer i=0; i<dims+1; i++)
00110                 if(i<dynpar) w[i]=v[i] ;
00111                 else if (i==dynpar) paramvar=v[i];
00112                 else if (i>dynpar) w[i]=v[i+1] ;
00113           
00114           return w;
00115         }
00116 
00117   private:
00118         greatervf*              f;
00119         bool    owned;
00120 
00121         integer dynpar;
00122         number paramvar;
00123 
00124         PRIVATE_ASSIGN(VFAmputation);
00125         
00126   };
00127 
00128 
00129 }// end namespace
00130 
00131 
00132 #endif
00133 /*********************************************************************
00134 $Id: vfamputation.h,v 1.1 2001/05/22 10:54:55 mpeeters Exp $
00135 **********************************************************************
00136 
00137 
00138 #include "vectorfunction.h"
00139 #include "newtonroot.h"
00140 #include <vector>
00141 
00142 $Log: vfamputation.h,v $
00143 Revision 1.1  2001/05/22 10:54:55  mpeeters
00144 Moved sources and headers for libModel to model/ subdirectory, in an attempt to rationalize the source tree. This should make things "netter".
00145 
00146 Revision 1.1  2001/05/21 12:00:27  mpeeters
00147 Reservoirfunction is a special kind of vectorfunction (at the moment, implemented like a heap of dung), vfamputation if a way to remove dependencies from certain vectorfuncions (to remove their dimensionality).
00148 
00149 *********************************************************************/

To get the sources or tarballs, please go to SourceForge or you can use the CVS repository.

More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be

Last update: June 2002.


Looking for Open Source? Check out SourceForge Logo !