Mathematical computations


Files

file  CMathExpression.cpp
 This file contains the implementations of the different functions that will be used in mathematical calculation.
file  CMathExpression.h
 This file contains the definition of the class that will represent a mathematical expression.
file  compute.cpp
 This file contains the implementation of the classes that will be used to compute a mathematical expression.
file  compute.h
 This file contains the definitions of the classes that will be used to compute a mathematical expression.

Classes

class  CMathExpression
 This class represents a mathematical expression. More...
class  CValue
 This class is the base class from which other classes are derived. More...
class  COperation
 This class is the base class for mathematical operations. More...
class  CAddition
 This class represents addition. More...
class  CSubstraction
 This class represents substraction. More...
class  CProduct
 This class represents product. More...
class  CDivision
 This class represents division. More...
class  COpposite
 This class represents the unary minus. More...
class  CSqrt
 This class represents square root. More...
class  CSin
 This class represents sine. More...
class  CCos
 This class represents cosine. More...
class  CTan
 This class represents tangent. More...
class  CExp
 this class respresents exponential. More...
class  CLn
 this class respresents natural logarithm. More...
class  CPow
 This class represents exposants. More...
class  CVariable
 This class represents a variable. More...
class  CNumber
 This class represents a constant floating point number. More...

Functions

bool In (const char *Formula, int min, int max)
 This function checks is an operator (+, -, *, /, ^) is in parenthesis.
void BEFORE_PUSH (std::vector< char > &v, int &i)
void AFTER_POP (std::vector< char > &v, int &i)
static CValueCMathExpression::BuildFormula (const char *Formula, int min, int max)
 This recursive function is used to build the tree associated with a mathematical expression.
 CMathExpression::CMathExpression (const char *Equation=0)
 This is the CMathExpression constructor.
static bool CMathExpression::Validate (const std::string &Formula, int *value=NULL, int min=-1, int max=-1)
 This recursive function validates an equation.
void CMathExpression::Compile (std::vector< char > &v) const
 This function fills the vector with code to compute the given formula.
static CValueCValue::GetNewAddition (CValue *pLeftOperand, CValue *pRightOperand)
static CValueCValue::GetNewSubstraction (CValue *pLeftOperand, CValue *pRightOperand)
static CValueCValue::GetNewProduct (CValue *pLeftOperand, CValue *pRightOperand)
static CValueCValue::GetNewDivision (CValue *pLeftOperand, CValue *pRightOperand)
static CValueCValue::GetNewOpposite (CValue *pLeftOperand)
static CValueCValue::GetNewSqrt (CValue *pLeftOperand)
static CValueCValue::GetNewSin (CValue *pLeftOperand)
static CValueCValue::GetNewCos (CValue *pLeftOperand)
static CValueCValue::GetNewTan (CValue *pLeftOperand)
static CValueCValue::GetNewExp (CValue *pLeftOperand)
static CValueCValue::GetNewLn (CValue *pLeftOperand)
static CValueCValue::GetNewPow (CValue *pLeftOperand, CValue *pRightOperand)
 CAddition::CAddition (CValue *pLeftOperand, CValue *pRightOperand)
 CSubstraction::CSubstraction (CValue *pLeftOperand, CValue *pRightOperand)
 CProduct::CProduct (CValue *pLeftOperand, CValue *pRightOperand)
 CDivision::CDivision (CValue *pLeftOperand, CValue *pRightOperand)
 COpposite::COpposite (CValue *pLeftOperand)
 CSqrt::CSqrt (CValue *pLeftOperand)
 CSin::CSin (CValue *pLeftOperand)
 CCos::CCos (CValue *pLeftOperand)
 CTan::CTan (CValue *pLeftOperand)
 CExp::CExp (CValue *pLeftOperand)
 CLn::CLn (CValue *pLeftOperand)
 CPow::CPow (CValue *pLeftOperand, CValue *pRightOperand)
 CVariable::CVariable (TYPE_VARIABLE Type)
 CNumber::CNumber (float Number)
virtual CValueCAddition::GetCopy () const
virtual CValueCSubstraction::GetCopy () const
virtual CValueCProduct::GetCopy () const
virtual CValueCDivision::GetCopy () const
virtual CValueCOpposite::GetCopy () const
virtual CValueCSqrt::GetCopy () const
virtual CValueCSin::GetCopy () const
virtual CValueCCos::GetCopy () const
virtual CValueCTan::GetCopy () const
virtual CValueCExp::GetCopy () const
virtual CValueCLn::GetCopy () const
virtual CValueCPow::GetCopy () const
virtual CValueCVariable::GetCopy () const
virtual CValueCNumber::GetCopy () const
virtual float CAddition::Compute (const CVector3f &Point) const
virtual float CSubstraction::Compute (const CVector3f &Point) const
virtual float CProduct::Compute (const CVector3f &Point) const
virtual float CDivision::Compute (const CVector3f &Point) const
virtual float COpposite::Compute (const CVector3f &Point) const
virtual float CSqrt::Compute (const CVector3f &Point) const
virtual float CSin::Compute (const CVector3f &Point) const
virtual float CCos::Compute (const CVector3f &Point) const
virtual float CTan::Compute (const CVector3f &Point) const
virtual float CExp::Compute (const CVector3f &Point) const
virtual float CLn::Compute (const CVector3f &Point) const
virtual float CPow::Compute (const CVector3f &Point) const
virtual float CVariable::Compute (const CVector3f &Point) const
virtual float CNumber::Compute (const CVector3f &Point) const
virtual CValueCAddition::Derive (TYPE_VARIABLE Type) const
virtual CValueCSubstraction::Derive (TYPE_VARIABLE Type) const
virtual CValueCProduct::Derive (TYPE_VARIABLE Type) const
virtual CValueCDivision::Derive (TYPE_VARIABLE Type) const
virtual CValueCOpposite::Derive (TYPE_VARIABLE Type) const
virtual CValueCSqrt::Derive (TYPE_VARIABLE Type) const
virtual CValueCSin::Derive (TYPE_VARIABLE Type) const
virtual CValueCCos::Derive (TYPE_VARIABLE Type) const
virtual CValueCTan::Derive (TYPE_VARIABLE Type) const
virtual CValueCExp::Derive (TYPE_VARIABLE Type) const
virtual CValueCPow::Derive (TYPE_VARIABLE Type) const
virtual CValueCLn::Derive (TYPE_VARIABLE Type) const
virtual CValueCVariable::Derive (TYPE_VARIABLE Type) const
virtual CValueCNumber::Derive (TYPE_VARIABLE Type) const
virtual void CAddition::Print (std::ostream &o) const
virtual void CSubstraction::Print (std::ostream &o) const
virtual void CProduct::Print (std::ostream &o) const
virtual void CDivision::Print (std::ostream &o) const
virtual void COpposite::Print (std::ostream &o) const
virtual void CSqrt::Print (std::ostream &o) const
virtual void CSin::Print (std::ostream &o) const
virtual void CCos::Print (std::ostream &o) const
virtual void CTan::Print (std::ostream &o) const
virtual void CExp::Print (std::ostream &o) const
virtual void CLn::Print (std::ostream &o) const
virtual void CPow::Print (std::ostream &o) const
virtual void CVariable::Print (std::ostream &o) const
virtual void CNumber::Print (std::ostream &o) const
virtual void CAddition::Compile (std::vector< char > &v, int &i) const
virtual void CSubstraction::Compile (std::vector< char > &v, int &i) const
virtual void CProduct::Compile (std::vector< char > &v, int &i) const
virtual void CDivision::Compile (std::vector< char > &v, int &i) const
virtual void COpposite::Compile (std::vector< char > &v, int &i) const
virtual void CSqrt::Compile (std::vector< char > &v, int &i) const
virtual void CSin::Compile (std::vector< char > &v, int &i) const
virtual void CCos::Compile (std::vector< char > &v, int &i) const
virtual void CTan::Compile (std::vector< char > &v, int &i) const
virtual void CExp::Compile (std::vector< char > &v, int &i) const
virtual void CLn::Compile (std::vector< char > &v, int &i) const
virtual void CPow::Compile (std::vector< char > &v, int &i) const
virtual void CVariable::Compile (std::vector< char > &v, int &i) const
virtual void CNumber::Compile (std::vector< char > &v, int &i) const

Detailed Description


Function Documentation

void AFTER_POP ( std::vector< char > &  v,
int &  i 
) [inline]

Definition at line 1437 of file compute.cpp.

Referenced by CPow::Compile(), CLn::Compile(), CExp::Compile(), CTan::Compile(), CDivision::Compile(), CProduct::Compile(), CSubstraction::Compile(), and CAddition::Compile().

void BEFORE_PUSH ( std::vector< char > &  v,
int &  i 
) [inline]

Definition at line 1412 of file compute.cpp.

Referenced by CNumber::Compile(), CVariable::Compile(), CPow::Compile(), CLn::Compile(), CExp::Compile(), and CTan::Compile().

CValue * CMathExpression::BuildFormula ( const char *  Formula,
int  min,
int  max 
) [static, private, inherited]

This recursive function is used to build the tree associated with a mathematical expression.

It expects a valid expression (formula).

Definition at line 81 of file CMathExpression.cpp.

References CValue::GetNewAddition(), CValue::GetNewCos(), CValue::GetNewDivision(), CValue::GetNewExp(), CValue::GetNewLn(), CValue::GetNewOpposite(), CValue::GetNewPow(), CValue::GetNewProduct(), CValue::GetNewSin(), CValue::GetNewSqrt(), CValue::GetNewSubstraction(), CValue::GetNewTan(), In(), CValue::TYPE_X, CValue::TYPE_Y, and CValue::TYPE_Z.

Referenced by CMathExpression::CMathExpression().

CAddition::CAddition ( CValue pLeftOperand,
CValue pRightOperand 
) [inherited]

CAddition simple contructor.

Definition at line 526 of file compute.cpp.

Referenced by CAddition::GetCopy().

CCos::CCos ( CValue pLeftOperand  )  [inherited]

CCos simple constructor.

Definition at line 582 of file compute.cpp.

Referenced by CCos::GetCopy().

CDivision::CDivision ( CValue pLeftOperand,
CValue pRightOperand 
) [inherited]

CDivision simple constructor.

Definition at line 550 of file compute.cpp.

Referenced by CDivision::GetCopy().

CExp::CExp ( CValue pLeftOperand  )  [inherited]

CExp simple constructor.

Definition at line 598 of file compute.cpp.

Referenced by CExp::GetCopy().

CLn::CLn ( CValue pLeftOperand  )  [inherited]

CLn simple constructor.

Definition at line 606 of file compute.cpp.

Referenced by CLn::GetCopy().

CMathExpression::CMathExpression ( const char *  Formula = 0  )  [inherited]

This is the CMathExpression constructor.

It uses BuildFormula.

Definition at line 226 of file CMathExpression.cpp.

References CMathExpression::BuildFormula(), CMathExpression::Compile(), CValue::GetNewSubstraction(), CMathExpression::m_pFormula, and CMathExpression::m_pFunction.

CNumber::CNumber ( float  Number  )  [inherited]

CNumber simple constructor.

Definition at line 630 of file compute.cpp.

References CNumber::m_Number.

Referenced by CNumber::Derive(), and CNumber::GetCopy().

void CNumber::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements CValue.

Definition at line 1843 of file compute.cpp.

References BEFORE_PUSH(), and CNumber::m_Number.

void CVariable::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements CValue.

Definition at line 1834 of file compute.cpp.

References BEFORE_PUSH(), and CVariable::m_Type.

void CPow::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1689 of file compute.cpp.

References AFTER_POP(), BEFORE_PUSH(), CValue::Compile(), CValue::IsConstant(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

void CLn::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1651 of file compute.cpp.

References AFTER_POP(), BEFORE_PUSH(), CValue::Compile(), and COperation::m_pLeftOperand.

void CExp::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1579 of file compute.cpp.

References AFTER_POP(), BEFORE_PUSH(), CValue::Compile(), and COperation::m_pLeftOperand.

void CTan::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1559 of file compute.cpp.

References AFTER_POP(), BEFORE_PUSH(), CValue::Compile(), and COperation::m_pLeftOperand.

void CCos::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1549 of file compute.cpp.

References CValue::Compile(), and COperation::m_pLeftOperand.

void CSin::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1539 of file compute.cpp.

References CValue::Compile(), and COperation::m_pLeftOperand.

void CSqrt::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1529 of file compute.cpp.

References CValue::Compile(), and COperation::m_pLeftOperand.

void COpposite::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1519 of file compute.cpp.

References CValue::Compile(), and COperation::m_pLeftOperand.

void CDivision::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1505 of file compute.cpp.

References AFTER_POP(), CValue::Compile(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

void CProduct::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1491 of file compute.cpp.

References AFTER_POP(), CValue::Compile(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

void CSubstraction::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1477 of file compute.cpp.

References AFTER_POP(), CValue::Compile(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

void CAddition::Compile ( std::vector< char > &  v,
int &  i 
) const [virtual, inherited]

This pure virtual function fills the vector with code to compute the formula.

Implements COperation.

Definition at line 1462 of file compute.cpp.

References AFTER_POP(), CValue::Compile(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

void CMathExpression::Compile ( std::vector< char > &  v  )  const [private, inherited]

This function fills the vector with code to compute the given formula.

It "compiles" the mathematical expression by filling the buffer with the appropriate Intel instruction byte codes.

Definition at line 415 of file CMathExpression.cpp.

References CValue::Compile(), and CMathExpression::m_pFormula.

Referenced by CMathExpression::GetDerivative().

float CNumber::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the sum of the left and right values.

Implements CValue.

Definition at line 950 of file compute.cpp.

References CNumber::m_Number.

float CVariable::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the value of the corresponding coordinate in the point.

Implements CValue.

Definition at line 936 of file compute.cpp.

References CVariable::m_Type, CValue::TYPE_X, CValue::TYPE_Y, CValue::TYPE_Z, CVector3f::x, CVector3f::y, and CVector3f::z.

float CPow::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the left value to the power of the right value.

Implements COperation.

Definition at line 924 of file compute.cpp.

References CValue::Compute(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

float CLn::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the natural logarithm of the left value.

Implements COperation.

Definition at line 914 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CExp::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the exponential of the left value.

Implements COperation.

Definition at line 904 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CTan::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the tangent of the left value.

Implements COperation.

Definition at line 894 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CCos::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the cosine of the left value.

Implements COperation.

Definition at line 884 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CSin::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the sine of the left value.

Implements COperation.

Definition at line 874 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CSqrt::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the square root of the left value.

Implements COperation.

Definition at line 864 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float COpposite::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the opposite of the left value.

Implements COperation.

Definition at line 854 of file compute.cpp.

References CValue::Compute(), and COperation::m_pLeftOperand.

float CDivision::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the quotient of the left and right values.

Implements COperation.

Definition at line 843 of file compute.cpp.

References CValue::Compute(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

float CProduct::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the product of the left and right values.

Implements COperation.

Definition at line 832 of file compute.cpp.

References CValue::Compute(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

float CSubstraction::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the difference between the left and right values.

Implements COperation.

Definition at line 821 of file compute.cpp.

References CValue::Compute(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

float CAddition::Compute ( const CVector3f Point  )  const [virtual, inherited]

This function returns the sum of the left and right values.

Implements COperation.

Definition at line 810 of file compute.cpp.

References CValue::Compute(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

COpposite::COpposite ( CValue pLeftOperand  )  [inherited]

COpposite simple constructor.

Definition at line 558 of file compute.cpp.

Referenced by COpposite::GetCopy().

CPow::CPow ( CValue pLeftOperand,
CValue pRightOperand 
) [inherited]

CPow simple constructor.

Definition at line 614 of file compute.cpp.

Referenced by CPow::GetCopy().

CProduct::CProduct ( CValue pLeftOperand,
CValue pRightOperand 
) [inherited]

CProduct simple constructor.

Definition at line 542 of file compute.cpp.

Referenced by CProduct::GetCopy().

CSin::CSin ( CValue pLeftOperand  )  [inherited]

CSin simple constructor.

Definition at line 574 of file compute.cpp.

Referenced by CSin::GetCopy().

CSqrt::CSqrt ( CValue pLeftOperand  )  [inherited]

CSqrt simple constructor.

Definition at line 566 of file compute.cpp.

Referenced by CSqrt::GetCopy().

CSubstraction::CSubstraction ( CValue pLeftOperand,
CValue pRightOperand 
) [inherited]

CSubstraction simple constructor.

Definition at line 534 of file compute.cpp.

Referenced by CSubstraction::GetCopy().

CTan::CTan ( CValue pLeftOperand  )  [inherited]

CTan simple constructor.

Definition at line 590 of file compute.cpp.

Referenced by CTan::GetCopy().

CVariable::CVariable ( TYPE_VARIABLE  Type  )  [inherited]

CVariable simple constructor.

Definition at line 622 of file compute.cpp.

References CVariable::m_Type.

Referenced by CVariable::GetCopy().

CValue * CNumber::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of a number.

$ \frac{dC}{dx} = 0 $, where $ C $ is constant.

Implements CValue.

Definition at line 1200 of file compute.cpp.

References CNumber::CNumber().

CValue * CVariable::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of a variable.

$ \frac{dx}{dx} = 1 $ , $ \frac{dy}{dx} = 0 $

Implements CValue.

Definition at line 1186 of file compute.cpp.

References CVariable::m_Type.

CValue * CLn::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the natural logarithm.

$ \left ( \ln \left ( f(x) \right ) \right ) ' = \frac{f'(x)}{f(x)} $

Implements COperation.

Definition at line 1173 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewDivision(), and COperation::m_pLeftOperand.

CValue * CPow::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of a function to the power of another.

$ \left ( f(x)^{g(x)} \right ) ' = f(x)^{g(x)} \left ( g'(x) \ln \left ( f(x) \right ) + \frac{g(x)f'(x)}{f(x)} \right ) $

Implements COperation.

Definition at line 1135 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewAddition(), CValue::GetNewDivision(), CValue::GetNewLn(), CValue::GetNewPow(), CValue::GetNewProduct(), CValue::IsConstant(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CExp::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the exponential.

$ \left ( e^{f(x)} \right ) ' = e^{f(x)} f'(x) $

Implements COperation.

Definition at line 1118 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewExp(), CValue::GetNewProduct(), and COperation::m_pLeftOperand.

CValue * CTan::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the tangent.

$ \left ( \tan{f(x)} \right ) ' = \left ( \sec {\left ( f(x) \right )} \right ) ^ 2 f'(x) = \frac{f'(x)}{\left ( \cos{ \left ( f(x) \right )} \right ) ^ 2}$

Implements COperation.

Definition at line 1103 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewCos(), CValue::GetNewDivision(), CValue::GetNewPow(), and COperation::m_pLeftOperand.

CValue * CCos::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the cosine.

$ \left ( \cos{f(x)} \right ) ' = - \sin{\left ( f(x) \right )} f'(x) $

Implements COperation.

Definition at line 1087 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewOpposite(), CValue::GetNewProduct(), CValue::GetNewSin(), and COperation::m_pLeftOperand.

CValue * CSin::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the sine.

$ \left ( \sin{f(x)} \right ) ' = \cos{\left ( f(x) \right )} f'(x) $

Implements COperation.

Definition at line 1073 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewCos(), CValue::GetNewProduct(), and COperation::m_pLeftOperand.

CValue * CSqrt::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the square root.

$ \left ( \sqrt{f(x)} \right ) ' = \frac{f'(x)}{2 \sqrt{f(x)}} $

Implements COperation.

Definition at line 1058 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewDivision(), CValue::GetNewProduct(), CValue::GetNewSqrt(), and COperation::m_pLeftOperand.

CValue * COpposite::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the opposite.

$ \left ( -f(x) \right ) ' = -f'(x) $

Implements COperation.

Definition at line 1044 of file compute.cpp.

References CValue::Derive(), CValue::GetNewOpposite(), and COperation::m_pLeftOperand.

CValue * CDivision::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the division.

$ \left ( \frac{f(x)}{g(x)} \right ) ' = \frac{f'(x) g(x) - f(x) g'(x)}{g(x)^2} $

Implements COperation.

Definition at line 1019 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewDivision(), CValue::GetNewPow(), CValue::GetNewProduct(), CValue::GetNewSubstraction(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CProduct::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the product.

$ \left ( f(x)g(x) \right ) ' = f'(x) g(x) + f(x) g'(x) $

Implements COperation.

Definition at line 1001 of file compute.cpp.

References CValue::Derive(), CValue::GetCopy(), CValue::GetNewAddition(), CValue::GetNewProduct(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CSubstraction::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the substraction.

$ \left ( f(x)-g(x) \right ) ' = f'(x) - g'(x) $

Implements COperation.

Definition at line 986 of file compute.cpp.

References CValue::Derive(), CValue::GetNewSubstraction(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CAddition::Derive ( TYPE_VARIABLE  Type  )  const [virtual, inherited]

This function returns a newly allocated pointer to the CValue object representing the derivative of the addition.

$ \left ( f(x)+g(x) \right ) ' = f'(x) + g'(x) $

Implements COperation.

Definition at line 971 of file compute.cpp.

References CValue::Derive(), CValue::GetNewAddition(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CNumber::GetCopy (  )  const [virtual, inherited]

This function returns a copy of this object.

Implements CValue.

Definition at line 793 of file compute.cpp.

References CNumber::CNumber(), and CNumber::m_Number.

CValue * CVariable::GetCopy (  )  const [virtual, inherited]

This function returns a copy of this object.

Implements CValue.

Definition at line 785 of file compute.cpp.

References CVariable::CVariable(), and CVariable::m_Type.

CValue * CPow::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 774 of file compute.cpp.

References CPow::CPow(), CValue::GetCopy(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CLn::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 763 of file compute.cpp.

References CLn::CLn(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CExp::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 752 of file compute.cpp.

References CExp::CExp(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CTan::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 741 of file compute.cpp.

References CTan::CTan(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CCos::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 730 of file compute.cpp.

References CCos::CCos(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CSin::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 719 of file compute.cpp.

References CSin::CSin(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CSqrt::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 708 of file compute.cpp.

References CSqrt::CSqrt(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * COpposite::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 697 of file compute.cpp.

References COpposite::COpposite(), CValue::GetCopy(), and COperation::m_pLeftOperand.

CValue * CDivision::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 685 of file compute.cpp.

References CDivision::CDivision(), CValue::GetCopy(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CProduct::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 673 of file compute.cpp.

References CProduct::CProduct(), CValue::GetCopy(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CSubstraction::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 660 of file compute.cpp.

References CSubstraction::CSubstraction(), CValue::GetCopy(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CAddition::GetCopy (  )  const [virtual, inherited]

This function returns a copy of the tree represented by this object.

Implements COperation.

Definition at line 648 of file compute.cpp.

References CAddition::CAddition(), CValue::GetCopy(), COperation::m_pLeftOperand, and COperation::m_pRightOperand.

CValue * CValue::GetNewAddition ( CValue pLeftOperand,
CValue pRightOperand 
) [static, inherited]

This function returns a newly allocated pointer to an object representing the addition of the two value passed as parameters.

It simplifies constants and additions to 0.

Definition at line 48 of file compute.cpp.

References CValue::IsAddNeutralElem(), and CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), CPow::Derive(), CProduct::Derive(), and CAddition::Derive().

CValue * CValue::GetNewCos ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the cosine of the left value.

It simplifies constants.

Definition at line 346 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), CTan::Derive(), and CSin::Derive().

CValue * CValue::GetNewDivision ( CValue pLeftOperand,
CValue pRightOperand 
) [static, inherited]

This function returns a newly allocated pointer to an object representing the division of the two value passed as parameters.

It simplifies constants numerator equals 0 and denominator equals 1.

Definition at line 209 of file compute.cpp.

References CValue::IsConstant(), CValue::IsMultAbsorbElem(), and CValue::IsMultNeutralElem().

Referenced by CMathExpression::BuildFormula(), CLn::Derive(), CPow::Derive(), CTan::Derive(), CSqrt::Derive(), and CDivision::Derive().

CValue * CValue::GetNewExp ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the exponential of the left value.

It simplifies constants.

Definition at line 390 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), and CExp::Derive().

CValue * CValue::GetNewLn ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the natural logarithm of the left value.

It simplifies constants.

Definition at line 412 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), and CPow::Derive().

CValue * CValue::GetNewOpposite ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the opposite of the left value.

It simplifies constants.

Definition at line 276 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), CCos::Derive(), and COpposite::Derive().

CValue * CValue::GetNewPow ( CValue pLeftOperand,
CValue pRightOperand 
) [static, inherited]

This function returns a newly allocated pointer to an object representing the left value to the power of the right value

It simplifies constants and 0 or 1 as operands.

Definition at line 434 of file compute.cpp.

References CValue::IsConstant(), CValue::IsMultAbsorbElem(), and CValue::IsMultNeutralElem().

Referenced by CMathExpression::BuildFormula(), CPow::Derive(), CTan::Derive(), and CDivision::Derive().

CValue * CValue::GetNewProduct ( CValue pLeftOperand,
CValue pRightOperand 
) [static, inherited]

This function returns a newly allocated pointer to an object representing the product of the two value passed as parameters.

It simplifies multiplication by 0 and by 1.

Definition at line 138 of file compute.cpp.

References CValue::IsConstant(), CValue::IsMultAbsorbElem(), and CValue::IsMultNeutralElem().

Referenced by CMathExpression::BuildFormula(), CPow::Derive(), CExp::Derive(), CCos::Derive(), CSin::Derive(), CSqrt::Derive(), CDivision::Derive(), and CProduct::Derive().

CValue * CValue::GetNewSin ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the sine of the left value.

It simplifies constants.

Definition at line 324 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), and CCos::Derive().

CValue * CValue::GetNewSqrt ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the square root of the left value.

It simplifies constants.

Definition at line 298 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), and CSqrt::Derive().

CValue * CValue::GetNewSubstraction ( CValue pLeftOperand,
CValue pRightOperand 
) [static, inherited]

This function returns a newly allocated pointer to an object representing the substraction of the two value passed as parameters.

it simplifies constants and 0 substractions.

Definition at line 93 of file compute.cpp.

References CValue::IsAddNeutralElem(), and CValue::IsConstant().

Referenced by CMathExpression::BuildFormula(), CMathExpression::CMathExpression(), CDivision::Derive(), and CSubstraction::Derive().

CValue * CValue::GetNewTan ( CValue pLeftOperand  )  [static, inherited]

This function returns a newly allocated pointer to an object representing the tangent of the left value.

It simplifies constants.

Definition at line 368 of file compute.cpp.

References CValue::IsConstant().

Referenced by CMathExpression::BuildFormula().

bool In ( const char *  Formula,
int  min,
int  max 
) [inline]

This function checks is an operator (+, -, *, /, ^) is in parenthesis.

It counts the number of opening parenthesis '(' before the operator and the number of closing parenthesis ')'. If the two are the same, the operator is not between parenthesis.

Definition at line 62 of file CMathExpression.cpp.

Referenced by CMathExpression::BuildFormula(), and CMathExpression::Validate().

void CNumber::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the number it represents.

Implements CValue.

Definition at line 1403 of file compute.cpp.

References CNumber::m_Number.

void CVariable::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the variable it represents.

Implements CValue.

Definition at line 1388 of file compute.cpp.

References CVariable::m_Type, CValue::TYPE_X, CValue::TYPE_Y, and CValue::TYPE_Z.

void CPow::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the of the left value to the power of the right value.

Implements COperation.

Definition at line 1374 of file compute.cpp.

References COperation::m_pLeftOperand, COperation::m_pRightOperand, and CValue::Print().

void CLn::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the natural logarithm of the left value.

Implements COperation.

Definition at line 1361 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CExp::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the exponential of the left value.

Implements COperation.

Definition at line 1348 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CTan::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the tangent of the left value.

Implements COperation.

Definition at line 1335 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CCos::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the cosine of the left value.

Implements COperation.

Definition at line 1322 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CSin::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the sine of the left value.

Implements COperation.

Definition at line 1309 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CSqrt::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the square root of the left value.

Implements COperation.

Definition at line 1296 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void COpposite::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the opposite of the left value.

Implements COperation.

Definition at line 1283 of file compute.cpp.

References COperation::m_pLeftOperand, and CValue::Print().

void CDivision::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the left value on the right value, in parenthesis.

Implements COperation.

Definition at line 1267 of file compute.cpp.

References COperation::m_pLeftOperand, COperation::m_pRightOperand, and CValue::Print().

void CProduct::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the left value times the right value, in parenthesis.

Implements COperation.

Definition at line 1251 of file compute.cpp.

References COperation::m_pLeftOperand, COperation::m_pRightOperand, and CValue::Print().

void CSubstraction::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the left value minus the right value, in parenthesis.

Implements COperation.

Definition at line 1235 of file compute.cpp.

References COperation::m_pLeftOperand, COperation::m_pRightOperand, and CValue::Print().

void CAddition::Print ( std::ostream &  o  )  const [virtual, inherited]

This function fills the stream with the expression of the left value plus the right value, in parenthesis.

Implements COperation.

Definition at line 1219 of file compute.cpp.

References COperation::m_pLeftOperand, COperation::m_pRightOperand, and CValue::Print().

bool CMathExpression::Validate ( const std::string &  strFormula,
int *  value = NULL,
int  min = -1,
int  max = -1 
) [static, inherited]

This recursive function validates an equation.

It accepts two references to ints where are stored the values that caused the error, in case there is one.

Definition at line 263 of file CMathExpression.cpp.

References In().

Referenced by CRenderObj::Update(), and CRenderObj::Validate().


Generated on Fri Dec 5 03:20:33 2008 for Mathematical Ray-tracer by  doxygen 1.5.4