mirror of
https://github.com/ArashPartow/exprtk.git
synced 2025-07-08 03:09:03 +00:00
C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html
This commit is contained in:
committed by
Arash Partow
parent
f46bffcd69
commit
cc1b800c2b
@ -2,8 +2,8 @@
|
||||
**************************************************************
|
||||
* C++ Mathematical Expression Toolkit Library *
|
||||
* *
|
||||
* Simple Example 5 *
|
||||
* Author: Arash Partow (1999-2023) *
|
||||
* Simple Example 05 *
|
||||
* Author: Arash Partow (1999-2024) *
|
||||
* URL: https://www.partow.net/programming/exprtk/index.html *
|
||||
* *
|
||||
* Copyright notice: *
|
||||
@ -11,6 +11,7 @@
|
||||
* permitted under the guidelines and in accordance with the *
|
||||
* most current version of the MIT License. *
|
||||
* https://www.opensource.org/licenses/MIT *
|
||||
* SPDX-License-Identifier: MIT *
|
||||
* *
|
||||
**************************************************************
|
||||
*/
|
||||
@ -31,14 +32,14 @@ struct myfunc : public exprtk::ifunction<T>
|
||||
: exprtk::ifunction<T>(2)
|
||||
{ exprtk::disable_has_side_effects(*this); }
|
||||
|
||||
inline T operator()(const T& v1, const T& v2)
|
||||
T operator()(const T& v1, const T& v2)
|
||||
{
|
||||
return T(1) + (v1 * v2) / T(3);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline T myotherfunc(T v0, T v1, T v2)
|
||||
T myotherfunc(T v0, T v1, T v2)
|
||||
{
|
||||
return std::abs(v0 - v1) * v2;
|
||||
}
|
||||
@ -51,7 +52,7 @@ void custom_function()
|
||||
typedef exprtk::parser<T> parser_t;
|
||||
|
||||
const std::string expression_string =
|
||||
"myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))";
|
||||
"myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))";
|
||||
|
||||
T x = T(1);
|
||||
T y = T(2);
|
||||
|
Reference in New Issue
Block a user