[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/losttem/exprtk/master/exprtk_simple_example_03.cpp [Back]  [Original]

/*
 **************************************************************
 *         C++ Mathematical Expression Toolkit Library        *
 *                                                            *
 * Simple Example 3                                           *
 * Author: Arash Partow (1999-2022)                           *
 * URL: http://www.partow.net/programming/exprtk/index.html   *
 *                                                            *
 * Copyright notice:                                          *
 * Free use of the Mathematical Expression Toolkit Library is *
 * permitted under the guidelines and in accordance with the  *
 * most current version of the MIT License.                   *
 * http://www.opensource.org/licenses/MIT                     *
 *                                                            *
 **************************************************************
*/


#include 
#include 

#include "exprtk.hpp"


template 
void polynomial()
{
   typedef exprtk::symbol_table symbol_table_t;
   typedef exprtk::expression   expression_t;
   typedef exprtk::parser       parser_t;

   const std::string expression_string =
                  "25x^5 - 35x^4 - 15x^3 + 40x^2 - 15x + 1";

   const T r0 = T(0);
   const T r1 = T(1);
         T  x = T(0);

   symbol_table_t symbol_table;
   symbol_table.add_variable("x",x);

   expression_t expression;
   expression.register_symbol_table(symbol_table);

   parser_t parser;
   parser.compile(expression_string,expression);

   const T delta = T(1.0 / 100.0);

   for (x = r0; x 

Web Proxy Viewer  |  New URL  |  Original Page