00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00039 namespace sc {
00040
00043 class SCExtrapData: public SavableState {
00044 public:
00046 SCExtrapData();
00048 SCExtrapData(StateIn&);
00049 virtual ~SCExtrapData();
00050
00051 void save_data_state(StateOut&);
00052
00054 virtual SCExtrapData* copy() = 0;
00056 virtual void zero() = 0;
00059 virtual void accumulate_scaled(double scale, const Ref<SCExtrapData>&) = 0;
00060 };
00061
00062
00065 class SCExtrapError: public SavableState {
00066 public:
00068 SCExtrapError();
00070 SCExtrapError(StateIn&);
00071 virtual ~SCExtrapError();
00072
00073 void save_data_state(StateOut&);
00074
00076 virtual double error() = 0;
00078 virtual double scalar_product(const Ref<SCExtrapError>&) = 0;
00079 };
00080
00081
00087 class SelfConsistentExtrapolation: public SavableState {
00088 private:
00089 double error_;
00090 int errorset_;
00091 double tolerance_;
00092 protected:
00093 void set_error(double e) { error_ = e; errorset_ = 1; }
00094 public:
00095 SelfConsistentExtrapolation();
00096 SelfConsistentExtrapolation(StateIn&);
00100 SelfConsistentExtrapolation(const Ref<KeyVal>&);
00101 ~SelfConsistentExtrapolation();
00102
00103 void save_data_state(StateOut&);
00104
00105 void set_tolerance(double t) { tolerance_ = t; }
00106 double tolerance() { return tolerance_; }
00107 double error() { return error_; }
00108
00109 int converged() { return errorset_? error_ <= tolerance_ : 0; }
00110
00111
00112
00113
00114 virtual int extrapolate(const Ref<SCExtrapData>& data,
00115 const Ref<SCExtrapError>& error) = 0;
00116
00117
00118
00119
00120
00121 virtual void start_extrapolation();
00122
00123 virtual void reinitialize() =0;
00124 };
00125
00126 }
00127
00128 #endif
00129
00130
00131
00132
00133