Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcBisectSolver Class Reference

#include <BisectSolver.h>

Inheritance diagram for mcBisectSolver:

Inheritance graph
[legend]
Collaboration diagram for mcBisectSolver:

Collaboration graph
[legend]
List of all members.

Detailed Description

Implements the bisection algorithm to solve nonlinear equations.

Definition at line 55 of file BisectSolver.h.

Public Member Functions

 mcBisectSolver ()
virtual ~mcBisectSolver ()
bool math_SolveLine (mcMathLine &, const mcSymbolProperties *unk, mcSystemStepArray &)
 Solves the given mcMathLine for the given unknown with the bisection algorithm.
bool math_WorksOn (const mcMathOrSystem &m) const
 Returns TRUE if the given system does not contain more than one type of unknown and if it does not contain parameters.
bool math_isReady () const
 Returns TRUE if this solver is ready to work.
wxPanel * gui_GetOptionsPanel () const
 Returns the panel containing the options for this algorithm.
void math_SetDelta (const mcRealValue &d)
 Changes the delta which defines the approximation error which is accepted by the program.
bool math_SetStartRange (const mcRange &r, const mcMathLine &p, const mcSymbolProperties *)
 Sets the start range for the algorithm.

Protected Member Functions

mcRealValue math_Bisect (mcMathLine &tosolve, const mcSymbolProperties *unk, const mcRealValue &a, const mcRealValue &b, const mcRealValue &fa, const mcRealValue &fb)
 The recursive bisect function.
mcRealValue math_Bisect (mcMathLine &tosolve, const mcSymbolProperties *unk, const mcRealValue &a, const mcRealValue &b)
 Starts the bisection algorithm in the given range, calculating the values of the function in the two given points and then calls the #Bisect function.

Protected Attributes

mcRealValue m_fDelta
 The precision to which the algorithm searches the solution: is m_fDelta is 0.01 and the exact solution of #m_pCurrLine is 1.567, then mcBisectSolver will return a value comprised between 1.567-0.01 and 1.567+0.01.
mcExtRange m_rStart
 The range where the bisection algorithm is applied at the beginning.


Constructor & Destructor Documentation

mcBisectSolver::mcBisectSolver  )  [inline]
 

Definition at line 88 of file BisectSolver.h.

References m_fDelta, mcBISECTSOLVER_DEFAULT_DELTA, and mcST_BISECTION.

virtual mcBisectSolver::~mcBisectSolver  )  [inline, virtual]
 

Definition at line 96 of file BisectSolver.h.


Member Function Documentation

wxPanel* mcBisectSolver::gui_GetOptionsPanel  )  const [inline, virtual]
 

Returns the panel containing the options for this algorithm.

The returned pointer must be deleted by the caller, when it is not required anymore... If the returned value is NULL, no options are available for this solver.

Implements mcSolver.

Definition at line 112 of file BisectSolver.h.

mcRealValue mcBisectSolver::math_Bisect mcMathLine tosolve,
const mcSymbolProperties unk,
const mcRealValue a,
const mcRealValue b
[protected]
 

Starts the bisection algorithm in the given range, calculating the values of the function in the two given points and then calls the #Bisect function.

Definition at line 78 of file BisectSolver.cpp.

References math_Bisect().

mcRealValue mcBisectSolver::math_Bisect mcMathLine tosolve,
const mcSymbolProperties unk,
const mcRealValue a,
const mcRealValue b,
const mcRealValue fa,
const mcRealValue fb
[protected]
 

The recursive bisect function.

Parameters:
a,b The range where one solution of the current equation is surely located. Must be f(a)*f(b) < 0.
fa,fb The value of the function (equation) in the points a, b.

Definition at line 88 of file BisectSolver.cpp.

References mcRealValue::abs(), m_fDelta, mcASSERT, mcSOLVERLOG, and mcTXTV.

Referenced by math_Bisect(), and math_SolveLine().

bool mcBisectSolver::math_isReady  )  const [virtual]
 

Returns TRUE if this solver is ready to work.

This function can be used to check if all the options/settings for this solver have been correctly set and the #Solve() function will correctly work (on a system where #WorksOn returns TRUE).

Implements mcSolver.

Definition at line 150 of file BisectSolver.cpp.

References m_rStart, and mcExtRange::math_isFinite().

void mcBisectSolver::math_SetDelta const mcRealValue d  )  [inline]
 

Changes the delta which defines the approximation error which is accepted by the program.

Definition at line 117 of file BisectSolver.h.

References m_fDelta.

bool mcBisectSolver::math_SetStartRange const mcRange r,
const mcMathLine p,
const mcSymbolProperties
 

Sets the start range for the algorithm.

If the given range (for the given system) is wrong, then FALSE is returned and mcSolver::GetLastErr() can be used to retrieve the error description; returns TRUE on success.

Definition at line 157 of file BisectSolver.cpp.

References mcExtRange::data_DeepCopy(), mcSymbolArray::data_GetSymbol(), and m_rStart.

bool mcBisectSolver::math_SolveLine mcMathLine ,
const mcSymbolProperties unk,
mcSystemStepArray
[virtual]
 

Solves the given mcMathLine for the given unknown with the bisection algorithm.

You can find good docs about this algorithm on the web: it is based over the theorem of zero existence.

Implements mcSolver.

Definition at line 119 of file BisectSolver.cpp.

References mcExtRange::data_GetRange(), m_rStart, math_Bisect(), mcRange::math_GetLowerLimitValue(), mcRange::math_GetUpperLimitValue(), mcASSERT, mcMMT_EQUATION, mcSOLVERLOG, mcTXTP, and mcTXTV.

bool mcBisectSolver::math_WorksOn const mcMathOrSystem m  )  const [virtual]
 

Returns TRUE if the given system does not contain more than one type of unknown and if it does not contain parameters.

Implements mcSolver.

Definition at line 62 of file BisectSolver.cpp.

References mcMSTL1_EQUATIONS.


Member Data Documentation

mcRealValue mcBisectSolver::m_fDelta [protected]
 

The precision to which the algorithm searches the solution: is m_fDelta is 0.01 and the exact solution of #m_pCurrLine is 1.567, then mcBisectSolver will return a value comprised between 1.567-0.01 and 1.567+0.01.

Definition at line 64 of file BisectSolver.h.

Referenced by math_Bisect(), math_SetDelta(), and mcBisectSolver().

mcExtRange mcBisectSolver::m_rStart [protected]
 

The range where the bisection algorithm is applied at the beginning.

Definition at line 67 of file BisectSolver.h.

Referenced by math_isReady(), math_SetStartRange(), and math_SolveLine().


The documentation for this class was generated from the following files:

Documentation generated with Doxygen on Sun Feb 6 17:12:20 2005
Visit MathStudio home page for more info

[ Top ]