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
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
00110
00111
00112 virtual int extrapolate(const Ref<SCExtrapData>& data,
00113 const Ref<SCExtrapError>& error) = 0;
00114
00115
00116
00117
00118
00119 virtual void start_extrapolation();
00120
00121 virtual void reinitialize() =0;
00122 };
00123
00124
00125 #endif
00126
00127
00128
00129
00130