#include <Variable.h>
Public Member Functions | |
KnownVariable (string cat_, string name_, const MathStructure &o, string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true) | |
KnownVariable (string cat_, string name_, string expression_, string title_="", bool is_local=true, bool is_builtin=false, bool is_active=true) | |
KnownVariable () | |
KnownVariable (const KnownVariable *variable) | |
virtual ExpressionItem * | copy () const |
virtual void | set (const ExpressionItem *item) |
bool | isKnown () const |
virtual bool | isExpression () const |
virtual string | expression () const |
int | subtype () const |
virtual void | set (const MathStructure &o) |
virtual void | set (string expression_) |
virtual const MathStructure & | get () |
virtual bool | representsPositive (bool=false) |
virtual bool | representsNegative (bool=false) |
virtual bool | representsNonNegative (bool=false) |
virtual bool | representsNonPositive (bool=false) |
virtual bool | representsInteger (bool=false) |
virtual bool | representsNumber (bool=false) |
virtual bool | representsRational (bool=false) |
virtual bool | representsReal (bool=false) |
virtual bool | representsComplex (bool=false) |
virtual bool | representsNonZero (bool=false) |
virtual bool | representsEven (bool=false) |
virtual bool | representsOdd (bool=false) |
virtual bool | representsUndefined (bool=false, bool=false, bool=false) |
virtual bool | representsBoolean () |
virtual bool | representsNonMatrix () |
Protected Attributes | |
MathStructure * | mstruct |
bool | b_expression |
int | calculated_precision |
string | sexpression |
Known variables have an associated value. The value can be a simple number or a full mathematical expression. The known variable class is used both for variable values and constants.
The value can be provided as an expression in the form of a text string or as a mathematical value in the form of an object of the MathStructure class. The text string is parsed when needed, which saves time when loading many variable definitions which might not be used, at least not immediately.
KnownVariable::KnownVariable | ( | string | cat_, | |
string | name_, | |||
const MathStructure & | o, | |||
string | title_ = "" , |
|||
bool | is_local = true , |
|||
bool | is_builtin = false , |
|||
bool | is_active = true | |||
) |
Create a known variable with a value.
cat_ | Category that the variable belongs to. | |
name_ | Initial name of the variable. | |
o | Value. | |
title_ | Descriptive name. | |
is_local | If the variable is local/user-defined or global. | |
is_builtin | If the variable is builtin and not modifiable. | |
is_active | If the variable is active and can be used in expressions. |
KnownVariable::KnownVariable | ( | string | cat_, | |
string | name_, | |||
string | expression_, | |||
string | title_ = "" , |
|||
bool | is_local = true , |
|||
bool | is_builtin = false , |
|||
bool | is_active = true | |||
) |
Create a known variable with an text string expression.
cat_ | Category that the variable belongs to. | |
name_ | Initial name of the variable. | |
expression_ | Expression. | |
title_ | Descriptive name. | |
is_local | If the variable is local/user-defined or global. | |
is_builtin | If the variable is builtin and not modifiable. | |
is_active | If the variable is active and can be used in expressions. |
KnownVariable::KnownVariable | ( | ) |
Create an empty known variable. Primarily for internal use.
KnownVariable::KnownVariable | ( | const KnownVariable * | variable | ) |
Create a copy of a known variable.
variable | Known variable to copy. |
bool KnownVariable::isKnown | ( | ) | const [inline, virtual] |
Returns if the variable has a known value (as oppossed to assumptions).
Implements Variable.
virtual bool KnownVariable::isExpression | ( | ) | const [virtual] |
Returns if the variable has an text string expression instead of a value.
virtual string KnownVariable::expression | ( | ) | const [virtual] |
Returns the variable's string expression or an empty string if it has not got an expression.
int KnownVariable::subtype | ( | ) | const [inline, virtual] |
Returns the subtype of the variable, corresponding to which subsubclass the object belongs to.
Reimplemented from Variable.
References SUBTYPE_KNOWN_VARIABLE.
virtual void KnownVariable::set | ( | const MathStructure & | o | ) | [virtual] |
Sets the value of the variable. If expression is set, it is cleared.
o | Value. |
Reimplemented in DynamicVariable.
virtual void KnownVariable::set | ( | string | expression_ | ) | [virtual] |
Sets the text string expression of the variable. The value is cleared.
expression_ | Expression. |
Reimplemented in DynamicVariable.
virtual const MathStructure& KnownVariable::get | ( | ) | [virtual] |
Returns the value of the variable. If no value is set or parsed and an expression is set, the expression is parsed and resulting value returned.
Reimplemented in DynamicVariable.
virtual bool KnownVariable::representsPositive | ( | bool | = false |
) | [virtual] |
Returns if the variable represents a positive value.
Reimplemented from Variable.
Reimplemented in DynamicVariable.