SCalc
|
An expression ! More...
#include <expression.hh>
Public Member Functions | |
Expression (Session *s) | |
virtual int | is_expression () |
Yes, this is an expression: | |
virtual double | evaluate (const double *values, const double *s=NULL)=0 |
Evaluate the expression. More... | |
virtual void | dump (::std::ostream &stream=::std::cerr) |
Dumps the contents of the expression to a stream. More... | |
virtual std::set< int > | used_variables () |
Variable used by an expression. More... | |
int | evaluable () |
Tells if this expression can be evaluated. | |
double | evaluate () |
If it can be evaluated, returns the given value. | |
virtual int | is_null () |
virtual int | is_id () |
If Id, then the value is always 1. | |
virtual int | is_const () |
If const, then the value is always 1. | |
virtual int | is_valid () |
virtual Expression * | derive (int id) |
Derive an expression with regards to one variable. More... | |
virtual Expression * | copy () |
Returns a freshly allocated copy of the expression. | |
virtual std::string | pretty_print ()=0 |
Pretty prints to a string. More... | |
virtual Expression * | simplify () |
Simplifies the expression. More... | |
virtual double * | mass_evaluate (int nb, double *target, const double **variables) |
Evaluates the Expression for different parameters. More... | |
![]() | |
ParserResult (Session *s) | |
Constructors/desctructors: | |
Session * | session () |
The SCalc::Session object used. More... | |
virtual int | can_delete () |
Expression * | to_expression () |
Converts to SCalc::Expression. More... | |
virtual int | is_syntax_error () |
Is it a SCalc::SyntaxError ? More... | |
SyntaxError * | to_syntax_error () |
Converts to SCalc::SyntaxError. More... | |
virtual int | is_func_def () |
Is it a SCalc::FuncDef ? More... | |
FuncDef * | to_func_def () |
Converts to SCalc::FuncDef. More... | |
Static Public Member Functions | |
Operations on expressions | |
A set of function to manipulate expressions algebraically. All these functions take ownership of the arguments you give them, and those will be freed when you free the result. | |
static Expression * | add (Expression *, Expression *) |
static Expression * | sub (Expression *, Expression *) |
static Expression * | mul (Expression *, Expression *) |
static Expression * | div (Expression *, Expression *) |
An expression !
This class represents a valid expression. It is a pure virtual class, but all its descendants are internals of SCalc.
|
virtual |
Derive an expression with regards to one variable.
id | the index of the variable by which we'll derive |
Returns a new Expression containing the derivative of the expression with regard to variable number id. You are responsible for taking care of freeing the result if necessary. You might want to simplify() the returned expression, as this is not done by default.
|
virtual |
Dumps the contents of the expression to a stream.
Used essentially for debugging.
|
pure virtual |
Evaluate the expression.
values | the values of the indeterminates. |
s | internal parameter. |
This function evaluates the expression using values for the values of the indeterminates. The second parameter is only used internally, you should never need it.
values is an array of variable values. You can get their name with the SCalc::Session::varnames() function. This way, you can setup the correspondance only once for a whole vector.
Referenced by SCalc::ExprFunc::evaluate().
|
inlinevirtual |
If Null, then the value is zero... Will be used for simplification, when I get to that point...
|
inlinevirtual |
True if no syntax errors. When looking for the result of an eval, always look for this !
|
virtual |
Evaluates the Expression for different parameters.
nb | the number of conditions |
target | where the results will be stored |
variables | array of pointers to arrays storing the conditions |
This function evaluates the expression nb times for the conditions given in variables. The results are stored in target.
|
pure virtual |
Pretty prints to a string.
Pretty-prints the expression to a string. Does not attempt to simplify anything.
Implements SCalc::ParserResult.
|
inlinevirtual |
Simplifies the expression.
Returns a copy of the expression with small simplifications performed. The simplification engine is very basic for now. It detects only some pretty obvious simplifications.
The returned value is a fresh copy that should be deleted when not used anymore.
|
inlinevirtual |
Variable used by an expression.
Returns a set containing the index of each variable used by the expression.