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
    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     // Makes a copy of data and returns the extrapolation in
    00112     // data.  A reference to error is saved so a copy must
    00113     // be given to extrapolate if error could be changed.
    00114     virtual int extrapolate(const Ref<SCExtrapData>& data,
    00115                             const Ref<SCExtrapError>& error) = 0;
    00116
    00117     // Extrapolation should be started when this is called,
    00118     // if it hasn't already started.  The default starting
    00119     // point is implemenation dependent.  This member might
    00120     // do nothing in some implementations.
    00121     virtual void start_extrapolation();
    00122
    00123     virtual void reinitialize() =0;
    00124 };
    00125
    00126 }
    00127
    00128 #endif
    00129
    00130 // Local Variables:
    00131 // mode: c++
    00132 // c-file-style: "CLJ"
    00133 // End: