28 #ifndef _util_misc_compute_h
29 #define _util_misc_compute_h
33 #include <util/state/state.h>
34 #include <util/state/stateio.h>
42 typedef ResultInfo* ResultInfoP;
56 std::set<ResultInfoP> _results;
71 virtual bool throw_if_tolerance_exceeded()
const;
90 virtual void update();
94 virtual void save_data_state(
StateOut&);
95 virtual void restore_state(
StateIn&);
100 int& compute() {
return _compute; }
101 const int& compute()
const {
return _compute; }
102 int compute(
int c) {
int r = _compute; _compute = c;
return r; }
103 int& computed() {
return _computed; }
104 const int& computed()
const {
return _computed; }
105 virtual int needed()
const;
113 double _actual_accuracy;
114 double _desired_accuracy;
118 virtual void save_data_state(
StateOut&);
119 virtual void restore_state(
StateIn&);
125 double actual_accuracy()
const;
126 double desired_accuracy()
const;
127 void set_desired_accuracy(
double);
128 void set_actual_accuracy(
double);
129 int computed_to_desired_accuracy()
const
130 {
return computed() && _actual_accuracy <= _desired_accuracy; }
136 #include <util/misc/comptmpl.h>
140 typedef NCResult<int> Resultint;
141 typedef NCResult<double> Resultdouble;
142 typedef NCAccResult<double> AccResultdouble;