|
|
The basic element. Map can be anything (by inheriting it), but it's nearly nothing by default.
A Map object just has a pointer to another Map object, and when you make it do anything, it passes the command to the next Map object.
bool m_forceEvaluation |
Sometimes, we want to evaluate some maps and some not, so we set the $$__noEvaluateFunctions flag, and set forceevaluation on maps we want to evaluate
QStringList split (const QChar &sep, const QString &str) |
Splits a string in several strings, separated by sep. The difference with QStringList::split, is that this method takes care of (basic) syntaxis, not to break things like : f(x,y,g(a,b)) in (x , y , g(a , b)) instead of (x, y, g(a,b) )
QString m_definition |
Textual definition . "2*x+3"
QString m_name |
Name of this function . "cos"
Map * m_tree |
The expression at the parameters . For example, if this function was defined as "f(x)=3+x" then "tree" contains : f | + / \ 3 x
But let's suppose f is being used on the definition of a g function like this : "g(x)=4*f(2*x)" . In this case, paramexpr contains * / \ 2 x
When evaluating f, paramexpr will be evaluated first, and their values will be assigned to the "params" variables.
g's tree will contain : * / \ paramexpr 4 f ------>x= | | + * / \ / \ 3 x 2 x
int checkParamTypes (const QDict <Map> &vars) |
Check each parameter to see if they have correct data types. Returns true if everything is ok, false if it's not.
void setParameters (const QString ¶ms) |
Parses the parameters and call setParameterExpression automatically The parameter should be in the form "14,x+2" for a call in the form f(14,x+2)
QDict <Map> * evalParams (const QDict <Map> &vars) |
Evaluates the parameters and stores them in a new QDict object. For example, if the function is f(x,z) and is used as this : 2*f(3*x,y+1), and vars contains { x=5, y=6 }, then the QDict object this function returns contains { x=15, y=6, z=7 }.
Note that you must delete the pointer that this function returns after using it !
Map * derive (const class Variable &var, const QDict <Map> &vars) |
Derivates (symbolically) the current map with respect to the variable var.
Map * functionFactory (const QString &name) |
Searches in the pool of maps for one with name "name", constructs a new map object of the same type and returns it
Map * parse (QString def) |
Parses a string and creates a map object.
bool isConstant (void) |
Returns true if this map doesn't depend on any variable. The difference with isA("Constant") is that this also check (when implemented) for constant matrices.
Map * simplify () |
Returns a simplified form of this Map if possible. If there's no simplified form, it returns 0L .
void simplifyFunction () |
Simplifies the tree calling simplify and substituting it with the simplified form. Note that it's "not desirable" to call this method on non-Map classes.
Map * add (Map * &m1, Map * &m2, bool managem1=false, bool managem2=false) |
Binary operations for maps. The nice thing about these methods is that they are quite optimized to do always the best thing with the pointers. For example, when you sum two temporary maps (and tell Map::add to "manage" them), they're not copied, but used directly.
With managem1 and managem2, you specify that you aren't going to need that pointer anymore, so instead of deleting it yourself in the next line, you tell Map::add to do whatever it wants with it, so if it isn't going to be used, it will be deleted. If you use true as value for managem1 or managem2, be sure to not reference that variable anymore, as it may be deleted ! (in this case, it will be set to 0L).
Map * add2 (Map * m1, Map * m2, bool managem1=false, bool managem2=false) |
These functions are provided for convience and should be used with extreme care
unsigned int nArgs (void) |
Returns the number of arguments
Map * argument (unsigned int i) |
Returns the map used as i-th argument.
inline Parameter * parameter (unsigned int i) |
Returns the parameter at the i-th position.
inline T * t (void) |
Returns a T object if this is a Constant Map. else, it returns 0L It's not neccesary to check if this->isA("Constant") since it's a virtual method.
inline TMatrix * tmatrix (void) |
Returns a TMatrix object if this is a Matrix Map. else, it returns 0L It's not neccesary to check if this->isA("Matrix") since it's a virtual method.