Runtime Library Packages¶
MathExpr includes a range of extensions, that provide functionalities beyond simple numerical calculations. Currently the available packages are:
+---+--------------------+-----------------------------------+
| # | Package Name | Namespace/Type |
+---+--------------------+-----------------------------------+
| 1 | Basic I/O | math_expr::rtl::io::package<T> |
| 2 | File I/O | math_expr::rtl::io::file::package<T> |
| 3 | Vector Operations | math_expr::rtl::vecops::package<T> |
+---+--------------------+-----------------------------------+
In order to make the features of a specific package available within an expression, an instance of the package must be added to the expression's associated symbol table. In the following example, the file I/O package is made available for the given expression:
typedef math_expr::symbol_table<T> symbol_table_t;
typedef math_expr::expression<T> expression_t;
typedef math_expr::parser<T> parser_t;
math_expr::rtl::io::file::package<T> fileio_package;
const std::string expression_string =
" var file_name := 'file.txt'; "
" var stream := null; "
" "
" stream := open(file_name,'w'); "
" "
" write(stream,'Hello world....\n'); "
" "
" close(stream); "
" ";
symbol_table_t symbol_table;
symbol_table.add_package(fileio_package);
expression_t expression;
expression.register_symbol_table(symbol_table);
parser_t parser;
parser.compile(expression_string,expression);
expression.value();
-
Basic I/O functions:
-
print -
println -
File I/O functions:
-
open (b) close
- write (d) read
-
getline (f) eof
-
Vector Operations functions:
-
all_true (01) all_false
- any_true (03) any_false
- assign (05) count
- copy (07) reverse
- rotate-left (09) rotate-right
- shift-left (11) shift-right
- sort (13) nth_element
- iota (15) sumk
- axpy (17) axpby
- axpyz (19) axpbyz
- axpbsy (21) axpbsyz
- axpbz (23) dot
- dotk (25) diff
- threshold_above (27) threshold_below
- select (29) min/max_elementwise