// RootFinder.h #ifndef RootFinder_H #define RootFinder_H // Abstract interface for class which finds a root of an // equation. I.e. x for which f(x) = 0. // // Different root-finding algorithms inherit from this base and // implement methods solve(double,double) and status(). // // Equations are solved by inheriting from those methods and // implementing method evaluate(double). It may also optionally // implement method no_solution() which should return a value that // the function cannot reach. // #include "StatusValue.h" class RootFinder { public: // methods // constructor RootFinder(); // destructor virtual ~RootFinder(); // Find solution starting with two guesses. // Return no_solution() for failure. virtual StatusDouble solve(double x1, double x2) const =0; // Evaluate the function. virtual StatusDouble evaluate(double x) const =0; }; #endif