C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html
This commit is contained in:
parent
7715a906f3
commit
73b1e4c9f3
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
|||
# **************************************************************
|
||||
# * C++ Mathematical Expression Toolkit Library *
|
||||
# * *
|
||||
# * Author: Arash Partow (1999-2014) *
|
||||
# * Author: Arash Partow (1999-2015) *
|
||||
# * URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
# * *
|
||||
# * Copyright notice: *
|
||||
|
|
67
exprtk.hpp
67
exprtk.hpp
|
@ -2,7 +2,7 @@
|
|||
******************************************************************
|
||||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
@ -6540,7 +6540,8 @@ namespace exprtk
|
|||
typedef typename range_t::cached_range_t cached_range_t;
|
||||
|
||||
generic_string_range_node(expression_ptr str_branch, range_t brange)
|
||||
: branch_(str_branch),
|
||||
: initialised_(false),
|
||||
branch_(str_branch),
|
||||
branch_deletable_(branch_deletable(branch_)),
|
||||
str_base_ptr_ (0),
|
||||
str_range_ptr_(0),
|
||||
|
@ -6563,6 +6564,8 @@ namespace exprtk
|
|||
if (0 == str_range_ptr_)
|
||||
return;
|
||||
}
|
||||
|
||||
initialised_ = (str_base_ptr_ && str_range_ptr_);
|
||||
}
|
||||
|
||||
~generic_string_range_node()
|
||||
|
@ -6578,7 +6581,7 @@ namespace exprtk
|
|||
|
||||
inline T value() const
|
||||
{
|
||||
if (str_base_ptr_ && str_range_ptr_)
|
||||
if (initialised_)
|
||||
{
|
||||
branch_->value();
|
||||
|
||||
|
@ -6641,6 +6644,7 @@ namespace exprtk
|
|||
|
||||
private:
|
||||
|
||||
bool initialised_;
|
||||
expression_ptr branch_;
|
||||
bool branch_deletable_;
|
||||
str_base_ptr str_base_ptr_;
|
||||
|
@ -6670,6 +6674,7 @@ namespace exprtk
|
|||
expression_ptr branch0,
|
||||
expression_ptr branch1)
|
||||
: binary_node<T>(opr,branch0,branch1),
|
||||
initialised_(false),
|
||||
str0_base_ptr_ (0),
|
||||
str1_base_ptr_ (0),
|
||||
str0_range_ptr_(0),
|
||||
|
@ -6705,16 +6710,16 @@ namespace exprtk
|
|||
if (0 == str1_range_ptr_)
|
||||
return;
|
||||
}
|
||||
|
||||
initialised_ = str0_base_ptr_ &&
|
||||
str1_base_ptr_ &&
|
||||
str0_range_ptr_ &&
|
||||
str1_range_ptr_ ;
|
||||
}
|
||||
|
||||
inline T value() const
|
||||
{
|
||||
if (
|
||||
str0_base_ptr_ &&
|
||||
str1_base_ptr_ &&
|
||||
str0_range_ptr_ &&
|
||||
str1_range_ptr_
|
||||
)
|
||||
if (initialised_)
|
||||
{
|
||||
binary_node<T>::branch_[0].first->value();
|
||||
binary_node<T>::branch_[1].first->value();
|
||||
|
@ -6779,6 +6784,7 @@ namespace exprtk
|
|||
|
||||
private:
|
||||
|
||||
bool initialised_;
|
||||
str_base_ptr str0_base_ptr_;
|
||||
str_base_ptr str1_base_ptr_;
|
||||
irange_ptr str0_range_ptr_;
|
||||
|
@ -6805,6 +6811,7 @@ namespace exprtk
|
|||
|
||||
swap_string_node(expression_ptr branch0, expression_ptr branch1)
|
||||
: binary_node<T>(details::e_swap,branch0,branch1),
|
||||
initialised_(false),
|
||||
str0_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);
|
||||
}
|
||||
|
||||
initialised_ = (str0_node_ptr_ && str1_node_ptr_);
|
||||
}
|
||||
|
||||
inline T value() const
|
||||
{
|
||||
if (
|
||||
str0_node_ptr_ &&
|
||||
str1_node_ptr_
|
||||
)
|
||||
if (initialised_)
|
||||
{
|
||||
binary_node<T>::branch_[0].first->value();
|
||||
binary_node<T>::branch_[1].first->value();
|
||||
|
@ -6867,6 +6873,7 @@ namespace exprtk
|
|||
|
||||
private:
|
||||
|
||||
bool initialised_;
|
||||
strvar_node_ptr str0_node_ptr_;
|
||||
strvar_node_ptr str1_node_ptr_;
|
||||
};
|
||||
|
@ -6992,6 +6999,7 @@ namespace exprtk
|
|||
expression_ptr branch0,
|
||||
expression_ptr branch1)
|
||||
: binary_node<T>(opr,branch0,branch1),
|
||||
initialised_(false),
|
||||
str0_base_ptr_ (0),
|
||||
str1_base_ptr_ (0),
|
||||
str0_node_ptr_ (0),
|
||||
|
@ -7018,16 +7026,16 @@ namespace exprtk
|
|||
|
||||
str1_range_ptr_ = &(range_ptr->range_ref());
|
||||
}
|
||||
|
||||
initialised_ = str0_base_ptr_ &&
|
||||
str1_base_ptr_ &&
|
||||
str0_node_ptr_ &&
|
||||
str1_range_ptr_ ;
|
||||
}
|
||||
|
||||
inline T value() const
|
||||
{
|
||||
if (
|
||||
str0_base_ptr_ &&
|
||||
str1_base_ptr_ &&
|
||||
str0_node_ptr_ &&
|
||||
str1_range_ptr_
|
||||
)
|
||||
if (initialised_)
|
||||
{
|
||||
binary_node<T>::branch_[1].first->value();
|
||||
|
||||
|
@ -7081,6 +7089,7 @@ namespace exprtk
|
|||
|
||||
private:
|
||||
|
||||
bool initialised_;
|
||||
str_base_ptr str0_base_ptr_;
|
||||
str_base_ptr str1_base_ptr_;
|
||||
strvar_node_ptr str0_node_ptr_;
|
||||
|
@ -7107,6 +7116,7 @@ namespace exprtk
|
|||
expression_ptr branch0,
|
||||
expression_ptr branch1)
|
||||
: binary_node<T>(opr,branch0,branch1),
|
||||
initialised_(false),
|
||||
str0_base_ptr_ (0),
|
||||
str1_base_ptr_ (0),
|
||||
str0_node_ptr_ (0),
|
||||
|
@ -7141,17 +7151,17 @@ namespace exprtk
|
|||
|
||||
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
|
||||
{
|
||||
if (
|
||||
str0_base_ptr_ &&
|
||||
str1_base_ptr_ &&
|
||||
str0_node_ptr_ &&
|
||||
str0_range_ptr_ &&
|
||||
str1_range_ptr_
|
||||
)
|
||||
if (initialised_)
|
||||
{
|
||||
binary_node<T>::branch_[0].first->value();
|
||||
binary_node<T>::branch_[1].first->value();
|
||||
|
@ -7213,6 +7223,7 @@ namespace exprtk
|
|||
|
||||
private:
|
||||
|
||||
bool initialised_;
|
||||
str_base_ptr str0_base_ptr_;
|
||||
str_base_ptr str1_base_ptr_;
|
||||
strvar_node_ptr str0_node_ptr_;
|
||||
|
@ -30138,8 +30149,8 @@ namespace exprtk
|
|||
namespace information
|
||||
{
|
||||
static const char* library = "Mathematical Expression Toolkit";
|
||||
static const char* version = "2.7182818284590452353602874713526624977572470936999";
|
||||
static const char* date = "20141101";
|
||||
static const char* version = "2.7182818284590452353602874713526624977572470936999595";
|
||||
static const char* date = "20150111";
|
||||
|
||||
static inline std::string data()
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* ExprTk vs Native Benchmarks *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 1 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 2 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 3 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 4 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 5 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 6 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 7 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 8 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 9 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 10 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 11 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 12 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 13 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 14 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 15 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 16 *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Examples and Unit-Tests *
|
||||
* Author: Arash Partow (1999-2014) *
|
||||
* Author: Arash Partow (1999-2015) *
|
||||
* URL: http://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
|
|
13
readme.txt
13
readme.txt
|
@ -1171,6 +1171,7 @@ parameters and their views are as follows:
|
|||
(2) Vector - vector_view
|
||||
(3) String - string_view
|
||||
|
||||
|
||||
The above denoted type views provide non-const reference-like access
|
||||
to each parameter, as such modifications made to the input parameters
|
||||
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
|
||||
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,
|
||||
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,
|
||||
std::string& result,
|
||||
parameter_list_t parameters)
|
||||
|
@ -1589,6 +1590,7 @@ zero input parameters the calling styles are as follows:
|
|||
(2) x + sin(foo - 2) / y
|
||||
|
||||
|
||||
|
||||
[16 - EXPRESSION DEPENDENTS]
|
||||
Any expression that is not a literal (aka constant) will have
|
||||
dependencies. The types of 'dependencies' an expression can have are
|
||||
|
@ -1816,6 +1818,7 @@ more of the following checkers:
|
|||
(2) Numeric Checker
|
||||
(3) Sequence Checker
|
||||
|
||||
|
||||
(c) Numeric Errors
|
||||
This class of error is related to conversion of numeric values from
|
||||
their string form to the underlying numerical type (float, double
|
||||
|
@ -1994,10 +1997,12 @@ into account when using Exprtk:
|
|||
default : y > 2 ? 3 : 4;
|
||||
};
|
||||
x != while (y > 0) { y -= 1; };
|
||||
x -= {if(min(x,y) < 2 * max(x,y))
|
||||
x -= {
|
||||
if(min(x,y) < 2 * max(x,y))
|
||||
x + 2;
|
||||
else
|
||||
x + y - 3;}
|
||||
x + y - 3;
|
||||
}
|
||||
)
|
||||
{
|
||||
(x + y) / (x - y);
|
||||
|
|
Loading…
Reference in New Issue