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

mcSolver Class Reference

#include <Solver.h>

Inheritance diagram for mcSolver:

Inheritance graph
[legend]
Collaboration diagram for mcSolver:

Collaboration graph
[legend]
List of all members.

Detailed Description

An algorithm designed to solve a specific type of problem.

This is an abstract class which must be used as base class for all the solvers handled by mcMathCore.

Definition at line 64 of file Solver.h.

Public Member Functions

 mcSolver ()
virtual ~mcSolver ()
Getters.
Some inlined getters.

wxString math_GetDesc () const
 Returns the description of this solver.
wxString math_GetName () const
 Returns the name of this solver.
wxString math_GetLastErr () const
 Returns the description of the last error after a call to #Solve().
mcSolverType math_GetType () const
 Returns the type of this solver.
Miscellaneous functions.
Some various functions.

virtual void data_Check () const
 Checks this solver; an assert should fail if this function finds something wrong.
virtual bool math_PreSolve (const mcMathOrSystem &, mcSystemStepArray &)
virtual bool math_PostSolve (const mcMathOrSystem &, mcSystemStepArray &)
Abstract functions.
These are the core of mcSolver-derived classes.

virtual bool math_WorksOn (const mcMathOrSystem &) const =0
 Returns TRUE if this algorithm can be applied on the given math system solving it for one of the mcSymbol contained registered as unknowns.
virtual bool math_WorksOn (const mcMathOrSystem &, const mcSymbolProperties *unk) const
 Works like math_WorksOn but this overloaded function also takes the symbol which will be used as unknown to solve for.
virtual bool math_Solve (const mcMathOrSystem &, mcSystemStepArray &)
 The most important function: it must apply the algorithm encapsulated in this class to the given math system.
virtual bool math_SolveLine (mcMathLine &, const mcSymbolProperties *unk, mcSystemStepArray &)=0
 Solves the given mcMathMng object for the given symbol, filling the given mcSystemStepArray with the intermediate resolution steps.
virtual bool math_isReady () const =0
 Returns TRUE if this solver is ready to work.
virtual wxPanel * gui_GetOptionsPanel () const =0
 Returns the panel containing the options for this algorithm.

Protected Member Functions

void math_ResetUnkArray ()
 Sets to NULL the array containing the unknowns.
mcSymbolPropertiesmath_GetUnknown (const mcMathOrSystem &sys, int n) const
 Returns the n-th unknown symbol found in the given system.
void math_DoSimplifyStep (long lflags, long rflags, mcMathLine &tosimplify, mcSystemStepArray &steps, mcExpSimRes *p=NULL)
 Performs a simplification step on the given system and puts the new step in the given mcSystemStepArray.
void math_DoCompleteSimplification (long lflags, long rflags, mcMathLine &tosimplify, mcSystemStepArray &steps)
 Performs repeated simplification steps until the given system is not completely simplified.
void math_DoExpandStep (long lflags, long rflags, mcMathLine &tosimplify, mcSystemStepArray &steps, mcExpSimRes *p=NULL)
 Like math_DoSimplifyStep but calls mcElementHelpers::math_Expand.
void math_DoCompleteExpansion (long lflags, long rflags, mcMathLine &tosimplify, mcSystemStepArray &steps)
 Like math_DoCompleteSimplification but calls mcElementHelpers::math_Expand.
void math_SplitInTwoEquations (const mcPolynomial &lfirsteq, const mcPolynomial &lseceq, const mcPolynomial &rfirsteq, const mcPolynomial &rseceq, mcSystemStepArray &steps, mcLogicOperator conn=mcLO_OR)
 Creates the solution.
void math_SplitInTwoEquations (mcMathLine *firsteq, mcMathLine *seceq, mcSystemStepArray &steps, mcLogicOperator conn=mcLO_OR)
void math_SplitInTwoEquations (const mcMathLine &firsteq, const mcMathLine &seceq, mcSystemStepArray &steps, mcLogicOperator conn=mcLO_OR)

Protected Attributes

mcSolverType m_nType
 The unique identifier of this solver.
wxString m_strName
 The name of this solver.
wxString m_strDesc
 A short description of this solver.
wxString m_strLastErr
 The description of the last error (if any).
mcRealValue m_fLastLenght
 The lenght value for the last step.
const mcSymbolPropertiesm_pUnkArr [mcSOLVER_MAXLINES]
 The unknown respect to the system is being solved.


Constructor & Destructor Documentation

mcSolver::mcSolver  )  [inline]
 

Definition at line 146 of file Solver.h.

References math_ResetUnkArray().

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

Definition at line 147 of file Solver.h.


Member Function Documentation

math_Expand math_DoExpandStep void mcSolver::data_Check  )  const [virtual]
 

Checks this solver; an assert should fail if this function finds something wrong.

Definition at line 203 of file Solver.cpp.

References mcASSERT.

Referenced by mcSolverArray::data_Check().

virtual wxPanel* mcSolver::gui_GetOptionsPanel  )  const [pure 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.

Implemented in mcBisectSolver, mcSimplifySolver, mcExpandSolver, and mcPolySolver.

void mcSolver::math_DoCompleteExpansion long  lflags,
long  rflags,
mcMathLine tosimplify,
mcSystemStepArray steps
[protected]
 

Like math_DoCompleteSimplification but calls mcElementHelpers::math_Expand.

Referenced by mcExpandSolver::math_SolveLine().

void mcSolver::math_DoCompleteSimplification long  lflags,
long  rflags,
mcMathLine tosimplify,
mcSystemStepArray steps
[protected]
 

Performs repeated simplification steps until the given system is not completely simplified.

Returns the last step added to the given mcLineStepArray.

Referenced by mcPolySolver::math_GetPolyCoeff(), mcSimplifySolver::math_SolveLine(), mcPolySolver::math_SolveLineFirstDegree(), and mcPolySolver::math_SolveLineSecondDegree().

void mcSolver::math_DoExpandStep long  lflags,
long  rflags,
mcMathLine tosimplify,
mcSystemStepArray steps,
mcExpSimRes p = NULL
[protected]
 

Like math_DoSimplifyStep but calls mcElementHelpers::math_Expand.

void mcSolver::math_DoSimplifyStep long  lflags,
long  rflags,
mcMathLine tosimplify,
mcSystemStepArray steps,
mcExpSimRes p = NULL
[protected]
 

Performs a simplification step on the given system and puts the new step in the given mcSystemStepArray.

If p is not NULL, then it is set to the result of the operation. Returns the new step added to the array.

wxString mcSolver::math_GetDesc  )  const [inline]
 

Returns the description of this solver.

Definition at line 156 of file Solver.h.

References m_strDesc.

wxString mcSolver::math_GetLastErr  )  const [inline]
 

Returns the description of the last error after a call to #Solve().

Definition at line 163 of file Solver.h.

References m_strLastErr.

wxString mcSolver::math_GetName  )  const [inline]
 

Returns the name of this solver.

Definition at line 159 of file Solver.h.

References m_strName.

Referenced by mcSolverArray::math_Contains().

mcSolverType mcSolver::math_GetType  )  const [inline]
 

Returns the type of this solver.

Definition at line 166 of file Solver.h.

References m_nType.

mcSymbolProperties* mcSolver::math_GetUnknown const mcMathOrSystem sys,
int  n
const [protected]
 

Returns the n-th unknown symbol found in the given system.

virtual bool mcSolver::math_isReady  )  const [pure 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).

Implemented in mcBisectSolver, mcSimplifySolver, mcExpandSolver, and mcPolySolver.

Referenced by math_Solve().

bool mcSolver::math_PostSolve const mcMathOrSystem ,
mcSystemStepArray
[virtual]
 

Definition at line 251 of file Solver.cpp.

References mcMATHLOG, mcTXT, and mcUNUSED.

Referenced by math_Solve().

bool mcSolver::math_PreSolve const mcMathOrSystem ,
mcSystemStepArray
[virtual]
 

Definition at line 209 of file Solver.cpp.

References mcMathOrSystem::data_AddSys(), mcMathAndSystem::data_GetLine(), mcSymbolArray::data_GetSymbol(), mcMathOrSystem::data_GetSys(), m_pUnkArr, m_strLastErr, mcElement::math_ContainsSymbol(), math_WorksOn(), mcMATHLOG, mcTXT, and mcTXTP.

Referenced by math_Solve().

void mcSolver::math_ResetUnkArray  )  [protected]
 

Sets to NULL the array containing the unknowns.

Definition at line 59 of file Solver.cpp.

References m_pUnkArr, and mcSOLVER_MAXLINES.

Referenced by mcSolver().

bool mcSolver::math_Solve const mcMathOrSystem ,
mcSystemStepArray
[virtual]
 

The most important function: it must apply the algorithm encapsulated in this class to the given math system.

Todo:
define solver behaviour for multiple unknowns or equations.

Definition at line 267 of file Solver.cpp.

References mcSymbolProperties::data_Check(), m_pUnkArr, m_strLastErr, math_isReady(), math_PostSolve(), math_PreSolve(), math_SolveLine(), math_WorksOn(), mcASSERT, mcMATHLOG, and mcTXT.

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

Solves the given mcMathMng object for the given symbol, filling the given mcSystemStepArray with the intermediate resolution steps.

Implemented in mcBisectSolver, mcSimplifySolver, mcExpandSolver, and mcPolySolver.

Referenced by math_Solve().

void mcSolver::math_SplitInTwoEquations const mcMathLine firsteq,
const mcMathLine seceq,
mcSystemStepArray steps,
mcLogicOperator  conn = mcLO_OR
[protected]
 

Definition at line 77 of file Solver.cpp.

References math_SplitInTwoEquations().

void mcSolver::math_SplitInTwoEquations mcMathLine firsteq,
mcMathLine seceq,
mcSystemStepArray steps,
mcLogicOperator  conn = mcLO_OR
[protected]
 

Definition at line 84 of file Solver.cpp.

References mcMathOrSystem::data_AddLineToLastAndSystem(), mcMathOrSystem::data_AddLineToNewAndSystem(), and mcLO_OR.

void mcSolver::math_SplitInTwoEquations const mcPolynomial lfirsteq,
const mcPolynomial lseceq,
const mcPolynomial rfirsteq,
const mcPolynomial rseceq,
mcSystemStepArray steps,
mcLogicOperator  conn = mcLO_OR
[protected]
 

Creates the solution.

Definition at line 65 of file Solver.cpp.

Referenced by mcPolySolver::math_SolveLineSecondDegree(), and math_SplitInTwoEquations().

virtual bool mcSolver::math_WorksOn const mcMathOrSystem ,
const mcSymbolProperties unk
const [inline, virtual]
 

Works like math_WorksOn but this overloaded function also takes the symbol which will be used as unknown to solve for.

This function is called after the more generic math_WorksOn function, when the unknown to be used to solve each specific line has been decided by math_PreSolve.

Definition at line 205 of file Solver.h.

virtual bool mcSolver::math_WorksOn const mcMathOrSystem  )  const [pure virtual]
 

Returns TRUE if this algorithm can be applied on the given math system solving it for one of the mcSymbol contained registered as unknowns.

Note:
This function does not take a mcSymbolProperties which indicates the unknown to solve for.because the unknown to solve for will be decided by math_PreSolve, _after_ this function has been called.

Implemented in mcBisectSolver, mcSimplifySolver, mcExpandSolver, and mcPolySolver.

Referenced by math_PreSolve(), and math_Solve().


Member Data Documentation

mcRealValue mcSolver::m_fLastLenght [protected]
 

The lenght value for the last step.

Definition at line 84 of file Solver.h.

mcSolverType mcSolver::m_nType [protected]
 

The unique identifier of this solver.

This should be set on the derived-class constructor.

Definition at line 70 of file Solver.h.

Referenced by math_GetType().

const mcSymbolProperties* mcSolver::m_pUnkArr[mcSOLVER_MAXLINES] [protected]
 

The unknown respect to the system is being solved.

Definition at line 90 of file Solver.h.

Referenced by math_PreSolve(), math_ResetUnkArray(), and math_Solve().

wxString mcSolver::m_strDesc [protected]
 

A short description of this solver.

This should be set on the derived-class constructor.

Definition at line 78 of file Solver.h.

Referenced by math_GetDesc().

wxString mcSolver::m_strLastErr [protected]
 

The description of the last error (if any).

Definition at line 81 of file Solver.h.

Referenced by math_GetLastErr(), math_PreSolve(), and math_Solve().

wxString mcSolver::m_strName [protected]
 

The name of this solver.

This should be set on the derived-class constructor.

Definition at line 74 of file Solver.h.

Referenced by math_GetName().


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

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

[ Top ]