MathParseKit is a C++ library for easy integration of a mathematical function interpreter in your code.

Differently from common thought, a mathematical interpreter is not a niche software component, but can become useful in a lot of applications allowing powerful user interactions.


Who is using MathParseKit:


A Few Examples:

1) Your application ask data to the user with a form. (how many applications do that?)

Required fields (Height, Width, Thickness, Weight).

Standard Situation:

Height: 1
Width: 2.5
Thickness: 0.7
Weight: 1.1375

With MathParseKit:

Height: 1
Width: 2.5
Thickness: 0.7
Weight: 0.65*Height*Width*Thickness

This allow the user to save a lot of time when there are fields that can be automatically computed from the values of the others.


2) Your application ask to the user an interaction with a graphical element that follow some shape rules.

The Height is 3 times the Width.
The hatch Thickness of borders is 1/15 of the Width.

Standard Situation:

You code the rules inside directly inside the program, probably copying and pasting this code all around because they are "fixed".

What if these rules change?

You need to recompile the application and redeploy to all customers.

What happens if you want to allow the user to configure these rules by hand?

You need a lot of hours of work to try to parametrize those rules in the simpler and linear way possible.

With MathParseKit:

Put in a configuration file or inside a program resource the rules as a string "2*4+Height-sqrt(Width)".
During program loading you load it and initialize the interpreter.

What if these rules change?

You simply change the rules in the configuration file or in the resource file and redeploy only it.

What happens if you want to allow the user to configure these rules by hand?

Load those rule from a file accessible from the user.


Here is a simple example application: 

  1. #include <iostream>
  2. #include <MParser.h>
  4. using namespace mpk;
  6. int wmain(int argc, wchar_t* argv[])
  7. {
  8. //Check if parameter is present
  9. if (argc < 2) return 0;
  11. //Initialize praser
  12. MParser parser;
  13. //Parse Parameter
  14. MFunction *f = parser.ParseFunction(argv[1]);
  15. if (f == NULL)
  16. {
  17. std::wcout << "Error " << parser.GetLastError() << " at Position " << parser.GetErrorPosition();
  18. return 0;
  19. }
  21. //Get Variables inside the function
  22. MVariablesList list;
  23. f->GetVariablesList(&list);
  25. //Ask for Variables values
  26. for (int i = 0; i<list.Count(); i++)
  27. {
  28. std::wcout << L"Variable " << list.GetItem(i)->GetName() << " = ";
  29. double value;
  30. std::wcin >> value;
  31. list.GetItem(i)->SetValue(value);
  32. }
  34. //Solve
  35. MFunction *ret = f->Solve(&list);
  37. //Check solution type
  38. if (ret->GetType() == MF_CONST)
  39. {
  40. std::cout << "Result = " << ((MFConst*)ret)->GetValue();
  41. }
  43. //Release objects
  44. f->Release();
  45. ret->Release();
  47. return 0;
  48. }

We use cookies to improve your experience. By closing this banner, scrolling this page or clicking on a link in this page you accept such use.