C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow 2020-01-01 00:00:00 +00:00
parent db2d357751
commit 281c2ccc65
24 changed files with 3061 additions and 1437 deletions

View File

@ -2,7 +2,7 @@
# **************************************************************
# * C++ Mathematical Expression Toolkit Library *
# * *
# * Author: Arash Partow (1999-2018) *
# * Author: Arash Partow (1999-2020) *
# * URL: http://www.partow.net/programming/exprtk/index.html *
# * *
# * Copyright notice: *
@ -16,7 +16,7 @@
COMPILER := -c++
#COMPILER := -clang
#COMPILER := -clang++
OPTIMIZATION_OPT := -O1
BASE_OPTIONS := -pedantic-errors -Wall -Wextra -Werror -Wno-long-long
OPTIONS := $(BASE_OPTIONS) $(OPTIMIZATION_OPT)

3282
exprtk.hpp

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* ExprTk vs Native Benchmarks *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 1 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,8 @@ void trig_function()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string = "clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)";
const std::string expression_string =
"clamp(-1.0,sin(2 * pi * x) + cos(x / 2 * pi),+1.0)";
T x;
@ -45,8 +46,8 @@ void trig_function()
for (x = T(-5); x <= T(+5); x += T(0.001))
{
T y = expression.value();
printf("%19.15f\t%19.15f\n",x,y);
const T y = expression.value();
printf("%19.15f\t%19.15f\n", x, y);
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 2 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,14 +29,15 @@ void square_wave()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expr_string = "a*(4/pi)*"
"((1 /1)*sin( 2*pi*f*t)+(1 /3)*sin( 6*pi*f*t)+"
" (1 /5)*sin(10*pi*f*t)+(1 /7)*sin(14*pi*f*t)+"
" (1 /9)*sin(18*pi*f*t)+(1/11)*sin(22*pi*f*t)+"
" (1/13)*sin(26*pi*f*t)+(1/15)*sin(30*pi*f*t)+"
" (1/17)*sin(34*pi*f*t)+(1/19)*sin(38*pi*f*t)+"
" (1/21)*sin(42*pi*f*t)+(1/23)*sin(46*pi*f*t)+"
" (1/25)*sin(50*pi*f*t)+(1/27)*sin(54*pi*f*t))";
const std::string expr_string =
"a*(4/pi)*"
"((1 /1)*sin( 2*pi*f*t)+(1 /3)*sin( 6*pi*f*t)+"
" (1 /5)*sin(10*pi*f*t)+(1 /7)*sin(14*pi*f*t)+"
" (1 /9)*sin(18*pi*f*t)+(1/11)*sin(22*pi*f*t)+"
" (1/13)*sin(26*pi*f*t)+(1/15)*sin(30*pi*f*t)+"
" (1/17)*sin(34*pi*f*t)+(1/19)*sin(38*pi*f*t)+"
" (1/21)*sin(42*pi*f*t)+(1/23)*sin(46*pi*f*t)+"
" (1/25)*sin(50*pi*f*t)+(1/27)*sin(54*pi*f*t))";
static const T pi = T(3.141592653589793238462643383279502);
@ -60,8 +61,8 @@ void square_wave()
for (t = (T(-2) * pi); t <= (T(+2) * pi); t += delta)
{
T result = expression.value();
printf("%19.15f\t%19.15f\n",t,result);
const T result = expression.value();
printf("%19.15f\t%19.15f\n", t, result);
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 3 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,8 @@ void polynomial()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string = "25x^5 - 35x^4 - 15x^3 + 40x^2 - 15x + 1";
const std::string expression_string =
"25x^5 - 35x^4 - 15x^3 + 40x^2 - 15x + 1";
const T r0 = T(0);
const T r1 = T(1);
@ -48,7 +49,7 @@ void polynomial()
for (x = r0; x <= r1; x += delta)
{
printf("%19.15f\t%19.15f\n",x,expression.value());
printf("%19.15f\t%19.15f\n", x, expression.value());
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 4 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -73,7 +73,7 @@ void fibonacci()
{
x = static_cast<T>(i);
T result = expression.value();
const T result = expression.value();
printf("fibonacci(%3d) = %10.0f\n",
static_cast<int>(i),

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 5 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -50,7 +50,7 @@ void custom_function()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string =
const std::string expression_string =
"myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))";
T x = T(1);
@ -70,7 +70,7 @@ void custom_function()
parser_t parser;
parser.compile(expression_string,expression);
T result = expression.value();
const T result = expression.value();
printf("Result: %10.5f\n",result);
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 6 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void vector_function()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string =
const std::string expression_string =
" for (var i := 0; i < min(x[],y[],z[]); i += 1) "
" { "
" z[i] := 3sin(x[i]) + 2log(y[i]); "

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 7 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void logic()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string = "not(A and B) or C";
const std::string expression_string = "not(A and B) or C";
symbol_table_t symbol_table;
symbol_table.create_variable("A");
@ -53,7 +53,7 @@ void logic()
symbol_table.get_variable("B")->ref() = T((i & 0x02) ? 1 : 0);
symbol_table.get_variable("C")->ref() = T((i & 0x04) ? 1 : 0);
int result = static_cast<int>(expression.value());
const int result = static_cast<int>(expression.value());
printf(" %d | %d | %d | %d | %d \n",
i,

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 8 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -28,7 +28,7 @@ void composite()
typedef exprtk::symbol_table<T> symbol_table_t;
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
typedef exprtk::parser_error::type error_t;
typedef exprtk::parser_error::type err_t;
typedef exprtk::function_compositor<T> compositor_t;
typedef typename compositor_t::function function_t;
@ -65,7 +65,7 @@ void composite()
for (std::size_t i = 0; i < parser.error_count(); ++i)
{
error_t error = parser.get_error(i);
const err_t error = parser.get_error(i);
printf("Error: %02d Position: %02d Type: [%14s] Msg: %s\tExpression: %s\n",
static_cast<unsigned int>(i),
@ -78,7 +78,7 @@ void composite()
return;
}
T result = expression.value();
const T result = expression.value();
printf("%s = %e\n", expression_string.c_str(), result);
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 9 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -133,9 +133,9 @@ void primes()
{
x = static_cast<T>(i);
T result1 = expression1.value();
T result2 = expression2.value();
T result3 = expression3.value();
const T result1 = expression1.value();
const T result2 = expression2.value();
const T result3 = expression3.value();
printf("%03d Result1: %c Result2: %c Result3: %c\n",
static_cast<unsigned int>(i),

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 10 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -64,7 +64,7 @@ void newton_sqrt()
" } ",
"x"));
std::string expression_str = "newton_sqrt(x)";
const std::string expression_str = "newton_sqrt(x)";
expression_t expression;
expression.register_symbol_table(symbol_table);
@ -76,7 +76,7 @@ void newton_sqrt()
{
x = static_cast<T>(i);
T result = expression.value();
const T result = expression.value();
printf("sqrt(%03d) - Result: %15.13f\tReal: %15.13f\n",
static_cast<unsigned int>(i),

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 11 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void square_wave2()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string wave_program =
const std::string wave_program =
" var r := 0; "
" for (var i := 0; i < 1000; i += 1) "
" { "
@ -59,8 +59,8 @@ void square_wave2()
for (t = (T(-2) * pi); t <= (T(+2) * pi); t += delta)
{
T result = expression.value();
printf("%19.15f\t%19.15f\n",t,result);
const T result = expression.value();
printf("%19.15f\t%19.15f\n", t, result);
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 12 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void bubble_sort()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string bubblesort_program =
const std::string bubblesort_program =
" var upper_bound := v[]; "
" var swapped := false; "
" repeat "

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 13 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -31,7 +31,7 @@ void savitzky_golay_filter()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string sgfilter_program =
const std::string sgfilter_program =
" var weight[9] := "
" { "
" -21, 14, 39, "
@ -89,7 +89,7 @@ void savitzky_golay_filter()
for (std::size_t i = 0; i < v_out.size(); ++i)
{
printf("%10.6f\t%10.6f\n",v_in[i],v_out[i]);
printf("%10.6f\t%10.6f\n", v_in[i], v_out[i]);
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 14 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -28,7 +28,7 @@ void stddev_example()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string stddev_program =
const std::string stddev_program =
" var x[25] := { "
" 1, 2, 3, 4, 5, "
" 6, 7, 8, 9, 10, "
@ -44,7 +44,7 @@ void stddev_example()
parser_t parser;
parser.compile(stddev_program,expression);
T stddev = expression.value();
const T stddev = expression.value();
printf("stddev(1..25) = %10.6f\n",stddev);
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 15 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void black_scholes_merton_model()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string bsm_model_program =
const std::string bsm_model_program =
" var d1 := (log(s / x) + (r + v^2 / 2) * t) / (v * sqrt(t)); "
" var d2 := d1 - v * sqrt(t); "
" "
@ -71,7 +71,7 @@ void black_scholes_merton_model()
printf("BSM(%s,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f) = %10.6f\n",
callput_flag.c_str(),
s,x,t,r,v,
s, x, t, r, v,
bsm);
}
@ -82,7 +82,7 @@ void black_scholes_merton_model()
printf("BSM(%s,%5.3f,%5.3f,%5.3f,%5.3f,%5.3f) = %10.6f\n",
callput_flag.c_str(),
s,x,t,r,v,
s, x, t, r, v,
bsm);
}
}

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 16 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -30,7 +30,7 @@ void linear_least_squares()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string linear_least_squares_program =
const std::string linear_least_squares_program =
" if (x[] == y[]) "
" { "
" beta := (sum(x * y) - sum(x) * sum(y) / x[]) / "

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 17 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -47,7 +47,7 @@ void monte_carlo_pi()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string monte_carlo_pi_program =
const std::string monte_carlo_pi_program =
" var experiments[5 * 10^7] := [(rnd_01^2 + rnd_01^2) <= 1]; "
" 4 * sum(experiments) / experiments[]; ";

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 18 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -29,7 +29,7 @@ void file_io()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string fileio_program =
const std::string fileio_program =
" var file_name := 'file.txt'; "
" var stream := null; "
" "

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library *
* *
* Simple Example 19 *
* Author: Arash Partow (1999-2018) *
* Author: Arash Partow (1999-2020) *
* URL: http://www.partow.net/programming/exprtk/index.html *
* *
* Copyright notice: *
@ -55,7 +55,7 @@ public:
if (
(1 == ps_index) &&
!exprtk::rtl::vecops::helper::
load_vector_range<T>::process(parameters,r0,r1,1,2,0)
load_vector_range<T>::process(parameters, r0, r1, 1, 2, 0)
)
return T(0);
@ -84,7 +84,7 @@ void vector_randu()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string vecrandu_program =
const std::string vecrandu_program =
" var noise[6] := [0]; "
" "
" if (randu(noise,0,5) == false) "

File diff suppressed because it is too large Load Diff

View File

@ -428,8 +428,8 @@ of C++ compilers:
| [r0:r1] | The closed interval [r0,r1] of the specified string. |
| | eg: Given a string x with a value of 'abcdefgh' then: |
| | 1. x[1:4] == 'bcde' |
| | 2. x[ :5] == x[:5] == 'abcdef' |
| | 3. x[3: ] == x[3:] =='cdefgh' |
| | 2. x[ :5] == x[:10 / 2] == 'abcdef' |
| | 3. x[2 + 1: ] == x[3:] =='defgh' |
| | 4. x[ : ] == x[:] == 'abcdefgh' |
| | 5. x[4/2:3+2] == x[2:5] == 'cdef' |
| | |
@ -706,6 +706,61 @@ This allows for the original element to be modified independently of
the expression instance and to also allow the expression to be
evaluated using the current value of the element.
Note: Any variable reference provided to a given symbol_table
instance, must have a life time at least as long as the life-time of
the symbol_table instance. In the event the variable reference is
invalidated before the symbol_table or any dependent expression
instances have been destructed, then any associated expression
evaluations or variable referencing via the symbol_table instance will
result in undefined behaviour.
The following bit of code instantiates a symbol_table and expression
instance, then proceeds to demonstrate various ways in which
references to variables can be added to the symbol_table, and how
those references are subsequently invalidated resulting in various
forms of undefined behaviour.
typedef exprtk::symbol_table<double> symbol_table_t;
symbol_table_t symbol_table;
expression_t expression;
{
double x = 123.4567;
symbol_table.add_variable("x", x);
} // Reference to variable x has been invalidated
std::deque<double> y {1.1, 2.2, 3.3};
symbol_table.add_variable("y", y.back());
y.pop_back(); // Reference to variable y has been invalidated
std::vector<double> z {4.4, 5.5, 6.6};
symbol_table.add_variable("z", z.front());
z.erase(z.begin());
// Reference to variable z has been invalidated
double* w = new double(123.456);
symbol_table.add_variable("w", *w);
delete w; // Reference to variable w has been invalidated
const std::string expression_str = "x + y / z * w";
// Compilation of expression will succeed
parser.compile(expression_str,expression);
expression.value();
// Evaluation will result in undefined behaviour
symbol_table.get_variable("x")->ref() = 135.791;
// Assignment will result in undefined behaviour
The example below demonstrates the relationship between variables,
symbol_table and expression. Note the variables are modified as they
normally would in a program, and when the expression is evaluated the
@ -865,7 +920,7 @@ The above denoted AST will be evaluated in the following order:
Generally an expression in ExprTk can be thought of as a free function
similar to those found in imperative languages. This form of pseudo
function will have a name, it may have a set of one or more inputs and
will return at least one value as its result. Futhermore the function
will return at least one value as its result. Furthermore the function
when invoked, may cause a side-effect that changes the state of the
host program.
@ -968,7 +1023,7 @@ copied, it will then result in two or more identical expressions
utilizing the exact same references for variables. This obviously is
not the default assumed scenario and will give rise to non-obvious
behaviours when using the expressions in various contexts such as
muli-threading et al.
multi-threading et al.
The prescribed method for cloning an expression is to compile it from
its string form. Doing so will allow the 'user' to properly consider
@ -1260,7 +1315,7 @@ in a statement will cause it to have a side-effect:
(b) Invoking a user-defined function that has side-effects
The following are examples of expressions where the side-effect status
of the statements (or sub-exressions) within the expressions have been
of the statements (sub-expressions) within the expressions have been
noted:
+-+----------------------+------------------------------+
@ -1814,15 +1869,16 @@ embedded into the expression.
There are five types of function interface:
+---+----------------------+-------------+----------------------+
| # | Name | Return Type | Input Types |
+---+----------------------+-------------+----------------------+
| 1 | ifunction | Scalar | Scalar |
| 2 | ivararg_function | Scalar | Scalar |
| 3 | igeneric_function | Scalar | Scalar,Vector,String |
| 4 | igeneric_function II | String | Scalar,Vector,String |
| 5 | function_compositor | Scalar | Scalar |
+---+----------------------+-------------+----------------------+
+---+----------------------+--------------+----------------------+
| # | Name | Return Type | Input Types |
+---+----------------------+--------------+----------------------+
| 1 | ifunction | Scalar | Scalar |
| 2 | ivararg_function | Scalar | Scalar |
| 3 | igeneric_function | Scalar | Scalar,Vector,String |
| 4 | igeneric_function II | String | Scalar,Vector,String |
| 5 | igeneric_function III| String/Scalar| Scalar,Vector,String |
| 6 | function_compositor | Scalar | Scalar |
+---+----------------------+--------------+----------------------+
(1) ifunction
This interface supports zero to 20 input parameters of only the scalar
@ -2198,7 +2254,60 @@ as follows:
(4) Scalar (4) String
(5) function_compositor
(5) igeneric_function III
In this section we will discuss an extension of the igeneric_function
interface that will allow for the overloading of a user defined custom
function, where by it can return either a scalar or string value type
depending on the input parameter sequence with which the function is
invoked.
template <typename T>
struct foo : public exprtk::igeneric_function<T>
{
typedef typename exprtk::igeneric_function<T>::parameter_list_t
parameter_list_t;
foo()
: exprtk::igeneric_function<T>
(
"T:T|S:TS",
igfun_t::e_rtrn_overload
)
{}
// Scalar value returning invocations
inline T operator()(const std::size_t& ps_index,
parameter_list_t parameters)
{
...
}
// String value returning invocations
inline T operator()(const std::size_t& ps_index,
std::string& result,
parameter_list_t& parameters)
{
...
}
};
In the example above the custom user defined function "foo" can be
invoked by using either one of two input parameter sequences, which
are defined as follows:
Sequence-0 Sequence-1
'T' -> T 'TS' -> S
(1) Scalar (1) Scalar
(2) String
The parameter sequence definitions are identical to the previously
define igeneric_function, with the exception of the inclusion of the
return type - which can only be either a scalar T or a string S.
(6) function_compositor
The function compositor is a factory that allows one to define and
construct a function using ExprTk syntax. The functions are limited to
returning a single scalar value and consuming up to six parameters as
@ -2715,7 +2824,7 @@ expression being compiled.
This can become problematic, as in the default scenario it is assumed
the symbol_table that is registered with the expression instance will
already posses the externally available variables, functions and
already possess the externally available variables, functions and
constants needed during the compilation of the expression.
In the event there are symbols in the expression that can't be mapped
@ -2838,7 +2947,7 @@ after which the expression itself can be evaluated.
for (auto& var_name : variable_list)
{
T& v = symbol_table.variable_ref(var_name);
T& v = unknown_var_symbol_table.variable_ref(var_name);
v = ...;
}
@ -2999,6 +3108,24 @@ constructor of the user defined USR.
Note: The primary symbol table for an expression is the first symbol
table to be registered with that instance of the expression.
Note: For a successful symbol resolution using the normal USR all of
the following are required:
(1) Only if successful shall the process method return TRUE
(2) The default_value parameter will have been set
(3) The error_message parameter will be empty
(4) usr_symbol_type input parameter field will be set to either:
(*) e_usr_variable_type
(*) e_usr_constant_type
Note: For a successful symbol resolution using the extended USR all of
the following are required:
(1) Only if successful shall the process method return TRUE
(2) symbol_table parameter will have had the newly resolved
variable or string added to it
(3) error_message parameter will be empty
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[SECTION 19 - ENABLING & DISABLING FEATURES]
@ -3716,7 +3843,7 @@ follows:
}
}
else
printf("An error occured.");
printf("An error occurred.");
(b) collect_functions
@ -3740,7 +3867,7 @@ follows:
}
}
else
printf("An error occured.");
printf("An error occurred.");
Note: When either the 'collect_variables' or 'collect_functions' free
@ -3752,10 +3879,10 @@ true.
Note: The default interface provided for both the collect_variables
and collect_functions free_functions, assumes that expressions will
only be utilising the ExprTk reserved funnctions (eg: abs, cos, min
only be utilising the ExprTk reserved functions (eg: abs, cos, min
etc). When user defined functions are to be used in an expression, a
symbol_table instance containing said functions can be passed to
either routine, and will be incorparated during the compilation and
either routine, and will be incorporated during the compilation and
Dependent Entity Collection processes. In the following example, a
user defined free function named 'foo' is registered with a
symbol_table. Finally the symbol_table instance and associated
@ -3785,7 +3912,7 @@ expression string are passed to the exprtk::collect_functions routine.
}
}
else
printf("An error occured.");
printf("An error occurred.");
(c) compute