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

This commit is contained in:
Arash Partow 2015-01-08 21:35:36 +11:00
parent 7715a906f3
commit 73b1e4c9f3
21 changed files with 71 additions and 55 deletions

View File

@ -2,7 +2,7 @@
# ************************************************************** # **************************************************************
# * C++ Mathematical Expression Toolkit Library * # * C++ Mathematical Expression Toolkit Library *
# * * # * *
# * Author: Arash Partow (1999-2014) * # * Author: Arash Partow (1999-2015) *
# * URL: http://www.partow.net/programming/exprtk/index.html * # * URL: http://www.partow.net/programming/exprtk/index.html *
# * * # * *
# * Copyright notice: * # * Copyright notice: *

View File

@ -2,7 +2,7 @@
****************************************************************** ******************************************************************
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *
@ -6540,7 +6540,8 @@ namespace exprtk
typedef typename range_t::cached_range_t cached_range_t; typedef typename range_t::cached_range_t cached_range_t;
generic_string_range_node(expression_ptr str_branch, range_t brange) generic_string_range_node(expression_ptr str_branch, range_t brange)
: branch_(str_branch), : initialised_(false),
branch_(str_branch),
branch_deletable_(branch_deletable(branch_)), branch_deletable_(branch_deletable(branch_)),
str_base_ptr_ (0), str_base_ptr_ (0),
str_range_ptr_(0), str_range_ptr_(0),
@ -6563,6 +6564,8 @@ namespace exprtk
if (0 == str_range_ptr_) if (0 == str_range_ptr_)
return; return;
} }
initialised_ = (str_base_ptr_ && str_range_ptr_);
} }
~generic_string_range_node() ~generic_string_range_node()
@ -6578,7 +6581,7 @@ namespace exprtk
inline T value() const inline T value() const
{ {
if (str_base_ptr_ && str_range_ptr_) if (initialised_)
{ {
branch_->value(); branch_->value();
@ -6641,8 +6644,9 @@ namespace exprtk
private: private:
expression_ptr branch_; bool initialised_;
bool branch_deletable_; expression_ptr branch_;
bool branch_deletable_;
str_base_ptr str_base_ptr_; str_base_ptr str_base_ptr_;
irange_ptr str_range_ptr_; irange_ptr str_range_ptr_;
mutable range_t base_range_; mutable range_t base_range_;
@ -6670,6 +6674,7 @@ namespace exprtk
expression_ptr branch0, expression_ptr branch0,
expression_ptr branch1) expression_ptr branch1)
: binary_node<T>(opr,branch0,branch1), : binary_node<T>(opr,branch0,branch1),
initialised_(false),
str0_base_ptr_ (0), str0_base_ptr_ (0),
str1_base_ptr_ (0), str1_base_ptr_ (0),
str0_range_ptr_(0), str0_range_ptr_(0),
@ -6705,16 +6710,16 @@ namespace exprtk
if (0 == str1_range_ptr_) if (0 == str1_range_ptr_)
return; return;
} }
initialised_ = str0_base_ptr_ &&
str1_base_ptr_ &&
str0_range_ptr_ &&
str1_range_ptr_ ;
} }
inline T value() const inline T value() const
{ {
if ( if (initialised_)
str0_base_ptr_ &&
str1_base_ptr_ &&
str0_range_ptr_ &&
str1_range_ptr_
)
{ {
binary_node<T>::branch_[0].first->value(); binary_node<T>::branch_[0].first->value();
binary_node<T>::branch_[1].first->value(); binary_node<T>::branch_[1].first->value();
@ -6779,6 +6784,7 @@ namespace exprtk
private: private:
bool initialised_;
str_base_ptr str0_base_ptr_; str_base_ptr str0_base_ptr_;
str_base_ptr str1_base_ptr_; str_base_ptr str1_base_ptr_;
irange_ptr str0_range_ptr_; irange_ptr str0_range_ptr_;
@ -6805,6 +6811,7 @@ namespace exprtk
swap_string_node(expression_ptr branch0, expression_ptr branch1) swap_string_node(expression_ptr branch0, expression_ptr branch1)
: binary_node<T>(details::e_swap,branch0,branch1), : binary_node<T>(details::e_swap,branch0,branch1),
initialised_(false),
str0_node_ptr_(0), str0_node_ptr_(0),
str1_node_ptr_(0) str1_node_ptr_(0)
{ {
@ -6817,14 +6824,13 @@ namespace exprtk
{ {
str1_node_ptr_ = static_cast<strvar_node_ptr>(binary_node<T>::branch_[1].first); str1_node_ptr_ = static_cast<strvar_node_ptr>(binary_node<T>::branch_[1].first);
} }
initialised_ = (str0_node_ptr_ && str1_node_ptr_);
} }
inline T value() const inline T value() const
{ {
if ( if (initialised_)
str0_node_ptr_ &&
str1_node_ptr_
)
{ {
binary_node<T>::branch_[0].first->value(); binary_node<T>::branch_[0].first->value();
binary_node<T>::branch_[1].first->value(); binary_node<T>::branch_[1].first->value();
@ -6867,6 +6873,7 @@ namespace exprtk
private: private:
bool initialised_;
strvar_node_ptr str0_node_ptr_; strvar_node_ptr str0_node_ptr_;
strvar_node_ptr str1_node_ptr_; strvar_node_ptr str1_node_ptr_;
}; };
@ -6992,6 +6999,7 @@ namespace exprtk
expression_ptr branch0, expression_ptr branch0,
expression_ptr branch1) expression_ptr branch1)
: binary_node<T>(opr,branch0,branch1), : binary_node<T>(opr,branch0,branch1),
initialised_(false),
str0_base_ptr_ (0), str0_base_ptr_ (0),
str1_base_ptr_ (0), str1_base_ptr_ (0),
str0_node_ptr_ (0), str0_node_ptr_ (0),
@ -7018,16 +7026,16 @@ namespace exprtk
str1_range_ptr_ = &(range_ptr->range_ref()); str1_range_ptr_ = &(range_ptr->range_ref());
} }
initialised_ = str0_base_ptr_ &&
str1_base_ptr_ &&
str0_node_ptr_ &&
str1_range_ptr_ ;
} }
inline T value() const inline T value() const
{ {
if ( if (initialised_)
str0_base_ptr_ &&
str1_base_ptr_ &&
str0_node_ptr_ &&
str1_range_ptr_
)
{ {
binary_node<T>::branch_[1].first->value(); binary_node<T>::branch_[1].first->value();
@ -7081,6 +7089,7 @@ namespace exprtk
private: private:
bool initialised_;
str_base_ptr str0_base_ptr_; str_base_ptr str0_base_ptr_;
str_base_ptr str1_base_ptr_; str_base_ptr str1_base_ptr_;
strvar_node_ptr str0_node_ptr_; strvar_node_ptr str0_node_ptr_;
@ -7107,6 +7116,7 @@ namespace exprtk
expression_ptr branch0, expression_ptr branch0,
expression_ptr branch1) expression_ptr branch1)
: binary_node<T>(opr,branch0,branch1), : binary_node<T>(opr,branch0,branch1),
initialised_(false),
str0_base_ptr_ (0), str0_base_ptr_ (0),
str1_base_ptr_ (0), str1_base_ptr_ (0),
str0_node_ptr_ (0), str0_node_ptr_ (0),
@ -7141,17 +7151,17 @@ namespace exprtk
str1_range_ptr_ = &(range_ptr->range_ref()); str1_range_ptr_ = &(range_ptr->range_ref());
} }
initialised_ = str0_base_ptr_ &&
str1_base_ptr_ &&
str0_node_ptr_ &&
str0_range_ptr_ &&
str1_range_ptr_ ;
} }
inline T value() const inline T value() const
{ {
if ( if (initialised_)
str0_base_ptr_ &&
str1_base_ptr_ &&
str0_node_ptr_ &&
str0_range_ptr_ &&
str1_range_ptr_
)
{ {
binary_node<T>::branch_[0].first->value(); binary_node<T>::branch_[0].first->value();
binary_node<T>::branch_[1].first->value(); binary_node<T>::branch_[1].first->value();
@ -7213,6 +7223,7 @@ namespace exprtk
private: private:
bool initialised_;
str_base_ptr str0_base_ptr_; str_base_ptr str0_base_ptr_;
str_base_ptr str1_base_ptr_; str_base_ptr str1_base_ptr_;
strvar_node_ptr str0_node_ptr_; strvar_node_ptr str0_node_ptr_;
@ -30138,8 +30149,8 @@ namespace exprtk
namespace information namespace information
{ {
static const char* library = "Mathematical Expression Toolkit"; static const char* library = "Mathematical Expression Toolkit";
static const char* version = "2.7182818284590452353602874713526624977572470936999"; static const char* version = "2.7182818284590452353602874713526624977572470936999595";
static const char* date = "20141101"; static const char* date = "20150111";
static inline std::string data() static inline std::string data()
{ {

View File

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

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 1 * * Simple Example 1 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 2 * * Simple Example 2 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 3 * * Simple Example 3 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 4 * * Simple Example 4 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 5 * * Simple Example 5 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 6 * * Simple Example 6 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 7 * * Simple Example 7 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 8 * * Simple Example 8 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 9 * * Simple Example 9 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 10 * * Simple Example 10 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 11 * * Simple Example 11 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 12 * * Simple Example 12 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 13 * * Simple Example 13 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 14 * * Simple Example 14 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 15 * * Simple Example 15 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Simple Example 16 * * Simple Example 16 *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -3,7 +3,7 @@
* C++ Mathematical Expression Toolkit Library * * C++ Mathematical Expression Toolkit Library *
* * * *
* Examples and Unit-Tests * * Examples and Unit-Tests *
* Author: Arash Partow (1999-2014) * * Author: Arash Partow (1999-2015) *
* URL: http://www.partow.net/programming/exprtk/index.html * * URL: http://www.partow.net/programming/exprtk/index.html *
* * * *
* Copyright notice: * * Copyright notice: *

View File

@ -1171,6 +1171,7 @@ parameters and their views are as follows:
(2) Vector - vector_view (2) Vector - vector_view
(3) String - string_view (3) String - string_view
The above denoted type views provide non-const reference-like access The above denoted type views provide non-const reference-like access
to each parameter, as such modifications made to the input parameters to each parameter, as such modifications made to the input parameters
will persist after the function call has completed. The following will persist after the function call has completed. The following
@ -1418,14 +1419,14 @@ Two specific overrides of the function operator are provided one for
standard generic functions and one for string returning functions. The standard generic functions and one for string returning functions. The
overrides are as follows: overrides are as follows:
// f(psi,i_0,i_1,....,i_N) --> Scalar // Scalar <-- function(psi,i_0,i_1,....,i_N)
inline T operator()(const std::size_t& ps_index, inline T operator()(const std::size_t& ps_index,
parameter_list_t parameters) parameter_list_t parameters)
{ {
... ...
} }
// f(psi,i_0,i_1,....,i_N) --> String // String <-- function(psi,i_0,i_1,....,i_N)
inline T operator()(const std::size_t& ps_index, inline T operator()(const std::size_t& ps_index,
std::string& result, std::string& result,
parameter_list_t parameters) parameter_list_t parameters)
@ -1589,6 +1590,7 @@ zero input parameters the calling styles are as follows:
(2) x + sin(foo - 2) / y (2) x + sin(foo - 2) / y
[16 - EXPRESSION DEPENDENTS] [16 - EXPRESSION DEPENDENTS]
Any expression that is not a literal (aka constant) will have Any expression that is not a literal (aka constant) will have
dependencies. The types of 'dependencies' an expression can have are dependencies. The types of 'dependencies' an expression can have are
@ -1816,6 +1818,7 @@ more of the following checkers:
(2) Numeric Checker (2) Numeric Checker
(3) Sequence Checker (3) Sequence Checker
(c) Numeric Errors (c) Numeric Errors
This class of error is related to conversion of numeric values from This class of error is related to conversion of numeric values from
their string form to the underlying numerical type (float, double their string form to the underlying numerical type (float, double
@ -1994,10 +1997,12 @@ into account when using Exprtk:
default : y > 2 ? 3 : 4; default : y > 2 ? 3 : 4;
}; };
x != while (y > 0) { y -= 1; }; x != while (y > 0) { y -= 1; };
x -= {if(min(x,y) < 2 * max(x,y)) x -= {
x + 2; if(min(x,y) < 2 * max(x,y))
else x + 2;
x + y - 3;} else
x + y - 3;
}
) )
{ {
(x + y) / (x - y); (x + y) / (x - y);