The Expression Parser

If you need to calculate a matrix as result of a complex expression or formula (several functions combined together), you have several choices: The last option is usually the one that requires the last of your time. The idea is to write the expression as a text, to parse it and produce the intermediate and final functions and result matrices from it.

There is only one constraint: the expression parser can only parse formulas with functions that return one and only one matrix (most of the functions are like that).

Here is it how it works. We say that it is possible to write a function as a text in the following way: template_name(input_matrix1, input_matrix2 .. input_matrixN, “parameter1”, “parameter2”, .. “parameterN”) where: For example: plus(matrix1, matrix2) or interval(“1”, “100”, “1”)

The matrices in the expression are assigned to the input matrices of the template following their order: the 1st matrix to the 1st template's matrix, the 2nd to the 2nd and so on.
The expression is valid if there are enough matrices to cover the number of the template's mandatory input matrices.

The parameters in the expression are assigned to the parameters of the template following their order: the 1st parameter to the 1st template's p the 2nd to the 2nd and so on.
If in the template there are a set of parameters that are optional, they are not needed in the expression if they are at the end of the template's parameter set.
For example, if the template has 5 parameters and parameter 2, 4 and 5 are optional, the expression needs values for the parameters 1, 2, 3 (in the same order) but not for parameters 4 and 5, since they are the last 2.

Since the input matrix of a function can be the result of another one, we can combine the functions in an expression, for example: plus(log(matrix1), exp(matrix2))

Parsing this expression, the parser produces the following items: Here is an example of the output matrices of the expression parser for the plus(log(matrix1), exp(matrix2)) expression:

Intermediate Matrices

The fact that the intermediate functions and matrices are stored in separate sub-packages keeps the project structure simple and efficient: To start the expression parser right click with the mouse on the functions tree and select the Expression Parser menu, which shows the expression parser wizard.
The parser is organized as a wizard, therefore is divided in steps.
In each step the parser shows you the current status of the parsing and/or tells you to enter or choose some parameter.
Click on the Next button to go to the next step, Back to go to the previous. Sometimes it is not possible to go to the next step because some of the data entered in the current step or in a previous step is wrong. In this case you can fix the wrong data, then go again to the next steps.

When you open the wizard, you are on the first step. The wizard has also step 2 (raw tree), step 3 (refined tree), step 4 (files), step 5 (summary).