MGCL V10
V10
MGCL V10
|
A virtual super class to solve non-linear equations by the bicection method. [詳解]
公開メンバ関数 | |
MGBisection (double ts, double te) | |
virtual | ~MGBisection () |
virtual void | set_initial_t (double t)=0 |
Prepare by setting the initial value. [詳解] | |
virtual double | compare_replace (double t, bool &replaced)=0 |
double | solve (double t, double span_initial, double tolerance, int &nrepition) |
Solve the equation with bisection method. [詳解] | |
A virtual super class to solve non-linear equations by the bicection method.
Let f(t) be a function of one double parameter, and a solution of f(t) is known to exist between [ts,te]. Then MGBisect::solve() gets the solution, given the initial candidate t, the initial span, and the tolerance to halt the iteration. To use MGBisection, define a subclass of MGBisection, and prepare member functions set_initial_t() and compare_replace(), and use solve() method to get the solution.
MGBisection::MGBisection | ( | double | ts, |
double | te | ||
) |
ts | parameter range from ts |
te | to te. |
|
inlinevirtual |
|
pure virtual |
compare with the previous function value(the initial value is set by set_initial_t) and replace t with the previous one if necessary. The function's return value is the new parameter value.
t | parameter value to compare at. |
replaced | true will be returned if the t is the new solution candidate value. |
|
pure virtual |
Prepare by setting the initial value.
double MGBisection::solve | ( | double | t, |
double | span_initial, | ||
double | tolerance, | ||
int & | nrepition | ||
) |
Solve the equation with bisection method.
t | The initial parameter value. |
span_initial | The initial parameter span length to increment or decrement, span*.5 will be the 1st try of the iteration. |
tolerance | The tolerance to halt the bisection iteration. |
nrepition | iterated number will be returned. |