Skip to content

Runtime Library Packages

Back to index

Previous | Index | Next

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();
  1. Basic I/O functions:

  2. print

  3. println

  4. File I/O functions:

  5. open (b) close

  6. write (d) read
  7. getline (f) eof

  8. Vector Operations functions:

  9. all_true (01) all_false

  10. any_true (03) any_false
  11. assign (05) count
  12. copy (07) reverse
  13. rotate-left (09) rotate-right
  14. shift-left (11) shift-right
  15. sort (13) nth_element
  16. iota (15) sumk
  17. axpy (17) axpby
  18. axpyz (19) axpbyz
  19. axpbsy (21) axpbsyz
  20. axpbz (23) dot
  21. dotk (25) diff
  22. threshold_above (27) threshold_below
  23. select (29) min/max_elementwise

Previous | Index | Next