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

scextrap.h

00001 //
00002 // scextrap.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifndef _math_optimize_scextrap_h
00029 #define _math_optimize_scextrap_h
00030 
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034 
00035 #include <util/class/class.h>
00036 #include <util/state/state.h>
00037 #include <util/keyval/keyval.h>
00038 
00041 class SCExtrapData: public SavableState {
00042   public:
00044     SCExtrapData();
00046     SCExtrapData(StateIn&);
00047     virtual ~SCExtrapData();
00048 
00049     void save_data_state(StateOut&);
00050     
00052     virtual SCExtrapData* copy() = 0;
00054     virtual void zero() = 0;
00057     virtual void accumulate_scaled(double scale, const Ref<SCExtrapData>&) = 0;
00058 };
00059 
00060 
00063 class SCExtrapError: public SavableState {
00064   public:
00066     SCExtrapError();
00068     SCExtrapError(StateIn&);
00069     virtual ~SCExtrapError();
00070 
00071     void save_data_state(StateOut&);
00072     
00074     virtual double error() = 0;
00076     virtual double scalar_product(const Ref<SCExtrapError>&) = 0;
00077 };
00078 
00079 
00085 class SelfConsistentExtrapolation: public SavableState {
00086   private:
00087     double error_;
00088     int errorset_;
00089     double tolerance_;
00090   protected:
00091     void set_error(double e) { error_ = e; errorset_ = 1; }
00092   public:
00093     SelfConsistentExtrapolation();
00094     SelfConsistentExtrapolation(StateIn&);
00098     SelfConsistentExtrapolation(const Ref<KeyVal>&);
00099     ~SelfConsistentExtrapolation();
00100 
00101     void save_data_state(StateOut&);
00102     
00103     void set_tolerance(double t) { tolerance_ = t; }
00104     double tolerance() { return tolerance_; }
00105     double error() { return error_; }
00106 
00107     int converged() { return errorset_? error_ <= tolerance_ : 0; }
00108 
00109     // Makes a copy of data and returns the extrapolation in
00110     // data.  A reference to error is saved so a copy must
00111     // be given to extrapolate if error could be changed.
00112     virtual int extrapolate(const Ref<SCExtrapData>& data,
00113                             const Ref<SCExtrapError>& error) = 0;
00114 
00115     // Extrapolation should be started when this is called,
00116     // if it hasn't already started.  The default starting
00117     // point is implemenation dependent.  This member might
00118     // do nothing in some implementations.
00119     virtual void start_extrapolation();
00120 
00121     virtual void reinitialize() =0;
00122 };
00123 
00124 
00125 #endif
00126 
00127 // Local Variables:
00128 // mode: c++
00129 // c-file-style: "CLJ"
00130 // End:

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.