1#ifndef ALGORITHM_BASE_HH
2#define ALGORITHM_BASE_HH
39 default : assert(!
"strange error in doAction");
44 void reset(std::string
const& name_)
59 if(valid && !logged) logger.push_back(currentValue);
60 if(!valid) logger.resize(logger.size()+1);
65 void logValue(
int i) {
if(valid) logger[i]=currentValue; logged=
true; }
71 int size() {
int sz= logger.size();
if(valid && !logged) sz++;
return sz;}
85 if(i < logger.size() && i >= 0)
return logger[i];
86 if(i==logger.size() && valid && !logged)
return currentValue;
87 namedAssertion(
false,
"Index failure!");
92 operator T&() { namedAssertion(valid,
"TypeCast: operator T&()");
return currentValue;}
97 T&
value_nonconst() { valid =
true; namedAssertion(valid,
"TypeCast: value_nonconst()");
return currentValue;}
99 T
const&
value()
const { namedAssertion(valid,
"TypeCast: value()");
return currentValue;}
104 s.setf(std::ios::scientific,std::ios::floatfield);
106 for(
int i=0; i!=
size(); i++)
107 s << (*
this)[i] << std::endl;
111 std::vector<T> logger;
116 void namedAssertion(
bool val,std::string caller)
const
120 std::cout << name <<
" from " << caller <<
":" << std::endl;
196 virtual int runAlgorithm()=0;
Abstract Vector for function space algorithms.
Base class for algorithms. Provides a unified interface and some simple wrapper routines,...
void reportOnIteration(int level)
virtual void finalize(int)
virtual void terminationMessage(int)
int algorithmWrapper()
Run algorithm, completely with initialization and finalization.
int oneStepWrapper()
Run one step of algorithm.
virtual void initialize()
void performTiming(bool doit)
Base class for algorithmic parameters.
void logStep()
Log all quantities in this class.
virtual void reset()
Reset all quantities in this class.
virtual ~IterationParameters()
virtual void doForAll(LQAction::ToDo td)
To be overloaded by derived class.
IterationParameters(double desiredAccuracy_, int maxSteps_)
Class that represents a quantity that can be logged during the course of an algortihm.
bool isLogged()
returns true, iff current value is already logged
void reset(std::string const &name_)
Delete any information contained in this class, on exit: state like freshly constructed.
T const & operator[](int i)
Return value from log buffer (used seldomly)
LoggedQuantity< T > & operator=(T const &rvalue)
Set current value.
int size()
Get size of log buffer.
void doAction(LQAction::ToDo td, std::string const &name_="noName")
void print(std::ostream &s)
print log-buffer into a stream, to be used for analysis of an algorithm
bool isValid()
Returns true, iff there is a valid current value.
void logValue()
Insert current value into log buffer.
void devalidate()
devalidate current value
LoggedQuantity(std::string const &name_)
void logValue(int i)
Insert current value into log buffer at a certain number i (used seldomly)
Base class for Newton's method. Defines the main algorithm, potentially using damping.