Let's try.
Here is a simple diagram:
When user inputs some data for evaluation SMath Studio stores this data within a simple array of primitives (operands, operators, brackets, functions - that's all). There is a type of data to store this primitives - Class
Term. Before transferring input data to the Numeric Library (
NuLib.dll) or to the Symbolic Library (
SyLib.dll) SMath Studio needs to substitute all available variables (commonly - operands) and functions (all the built-in, user-defined or defined in plugins). There is a place for the low-level expression evaluation. Plugins of this level can extend it in the most non-abstracted way. Array of Term elements represented in
Reverse Polish notation (RPN - please be sure, that you understand how it works before creating such kind of plugins). Note, that here you can create the most powerful functions with the smallest CPU & RAM usage, but it is rather hard.
Note, that all the functions that are placed inside plugins delivered in standard Setup (talk is about
plugins\SpecialFunctions.dll) created using low-level expression evaluation. Even
:= operator is also part of this level (but it is built-in to the canvas.dll - not a plugin).
The most abstracted levels of evaluation are: Symbolic expression evaluation and Numeric expression evaluation. They are used depending on the user request to calculate with symbols or not.
Full symbolic expression can be stored in
MItem Class. You can operate with instances of this class using standard operators + - * / and it has several methods to make it easy to operate with expressions. Actually,
MItem is very interesting Class
It was fully designed by me and it is not used anywhere before. Fer example: it doesn't support - and / operators at all (I mean it cannot store and work with them), instead of it every part of
MItem Class expression has boolean fields:
Negative (means -a) and
Inverse (means 1/a). So, you should respect this fact in order to avoid some errors.
Numeric expression evaluation has no any strange facts. You must know, that it is represented by
TNumber class with several constructors for any kind of type you want to work with: Double (
TDouble), Fraction (
TFraction), Complex number (
TComplex), Matrix (
TMatrix), Algebraic system (
TSystem) or number with infinities (
TInfinity - obsolete one - will be merged with
TFraction later).
Plugins has a higher priority then any built-in behavior, but smaller then any user-defined one (behavior = defined function, operator or operand).
We have some articles for developers in the wiki. In Russian, but, there is just a little text, but the biggest part is the code - so, I hope, you will have no problems there:
IPluginMathNumericEvaluationThere are some implemented methods for conversions between arrays of Term, MItem and TNumber classes:
SMath.Manager.Converter.ToTerms(string) - Converts String to Term[]
SMath.Manager.Converter.ToString(Term[]) - Converts Term[] to String
SMath.Math.Symbolic.Converter.ToMItem(string) - Converts String to MItem
SMath.Math.Symbolic.Converter.ToMItem(Term[]) - Converts Term[] to MItem
SMath.Math.Symbolic.Converter.ToString(MItem) - Converts MItem to String
SMath.Math.Numeric.Expression.Calculate(Term[]) - Numeric expression calculation
SMath.Math.Symbolic.Expression.SimplifyEx(MItem) - Symbolic expression simplification
SMath.Math.Symbolic.Expression.DifferentiateEx(MItem, MItem) - Symbolic differentiation of expression
Seems, that's it for now. For further info, please, ask me to describe things you're interested in.
Contact me via ICQ and/or Skype if you need some just-in-time help
I understand, that creating plugins is a hard work and I'm ready to provide maximum help with it! Or, maybe, it is better to publish all questions and answers here... it's up to you (depends on the questions maybe).
Best regards, Andrey Ivashov.
Edited by user 06 May 2010 07:29:20(UTC)
| Reason: Not specified