Welcome to Arithmetica, Version 3.0
This is not the final release of AAA.
The program revolves around the Node class, which is the fundamental building blocks of expression trees. Arithmetica cleans up the expression, and takes care of the function calls to other classes to parse, build, and evaluate the tree. The various subclasses of the worker class are responsible for printing, evaluating, or differentiating the expression represented by the tree of nodes. Ultimately though, the thing to remember about the basic structure is that everything revolves around the Node class, which simply holds data (and not mutator member functions, information about state, or type information).
Arithmetica: This class runs the program. In terms of work that it does, it presimplifies the user's expression before passing it to PretoPost. Nearly all the other work is passed to the other classes.
Opermap: This class is basically the interface between Arithmetica and PretoPost and the factory (Operation). This class is primarily contructs a map of operands to their respective constructors in Operation and also holds each operators precedence, all based upon the input from a *.ops file. In addition, it can return some other information about a string passed to it, such as isbinaryoperator(). Operators seen by client code are determined by the SearchAndDestroyOperatorsBiatch class.
Operation: Primarily a factory for constructing Nodes which in turn make up the tree. Operation itself is an abstract base class, and there are several levels of inheritance underneath it.
Nodes: Nodes are the fundamental building blocks for expression trees. They conists of only three pieces of data, a string myDescription, which is "variable" or "constant" for variables and constants and the string representing the operator otherwise, string myValue which is only non-empty for variables and constant, where they hold the value, and a vector of Node * that point to the children of the Nodes. There are some accessor functions, but know work is done on the Nodes from within the Node class.
PreToPost: This is the parser, and is only barely changed from the original arithmetica. It simply takes any infix expression and converts it to postfix. Obviously it is misnamed.
Worker: The class Worker itself is simply a parent class for the various classes that actually do work on the nodes. Those classes, Evaluate, Printer, Differator, and Function, are the actual guts of arithmetica. They evaluate, print, differentiate, and deal with images, respectively.
WorkerMap: This class is much like Opermap for operations, except that it is for Workers. It contains a map of all the operators and the workers (of all different types that go with them). When called by SearchAndDestroyOperatorsBiatch, it returns smaller maps that only contain the operators and corresponding workers that are desired in this running of arithemtica.
SearchandDestroyOperatorsBiatchThis particularly aptly named class perfoms a unique function. It is constructed with a file name, and then it parses that file, determining what functions should be perfomed on an expression and what operators are valid. It then makes maps of Operations and Workers that correspond to these operations, and thus determines how the expression is called and what happens when it is evaluted. See below of *.ops file construction.
VarMap: This map is simply a holder for the variable map. It performs some basic error checking, most importantly checking for circular dependencies.
All the Image Code: This is the code from class. It does all the image stuff
Evaluate,IEvalute: Exactly the same class, except that IEvalute is typedefed to work with Images while Evalute works with doubles. Obviously the class names are chagned too. They inhered from Worker
Differator: Inherits from Worker and performs differentiation
Lsys: This class perfroms Lsystem expansion and such. Logo here was very frustrating, as the screen size is so limited, it's hard to get output to look good. The spec was also not very clear at all. This class also inherits from Worker.
Arithmetica is currently designed so that all three of the various applications work within the same executable and the user can switch between them. This requires, among other things, being able to determine valid operators and vaild workers for each type of application. (You can't differentiate x%5 for example)
The method used for dealing with this is a .ops file for each type of application. There are four default *.ops files,
arith.ops
image.ops
diff.ops
lsys.ops
These files correspond to the arithmetica, imagemetica, diffmetica, and lsysmetica respectively. Their construction is simple. The first lines are the types of workers to create..the present options are "differentiate", "printer", and "evaluator". The next line is "***". On each successive line for the rest of the file there is one operator. Operators are made up of three argurments (B, U, or M, for binary operator, unary operator, or multivariable operator. Next is the string that makes up the operator. Finally is the int representing the operators precedence. Each part of this operator definition is separated by a space. Take a look at diff.ops for a clearer picture.
At this point, the most important thing to inlcude in this Programmer's Manual is how to add new nodes.
Step 1: Decide what types of workers (printer, evaluate, differentiate, or functions) will you operator work with.
Step 2: For each type of worker that you plan to support, go into that worker and add the code for your operator. Remember that these are inherited classes, so be sure to follow all the rules.
Step 3: Add your type of operation to the Operation class--in almost all cases this simply requires determining what parent class your operation belongs to (Unary, Binary, or Multi) and inheriting the code from that class. Then Modify the opermap class so that the function makeAllmap includes your operator (this will also probably require a change to the .h file to include your operators precedence.
Step 4: Add the workers you created to the master lists of workers in workermap.h. Finish off by adding your operator to the *.ops files for the workers you wish to add.
This may all seem a bit daunting...or at least complicated, but it's really not that bad at all. It only seems that way because all the code that does actual work has been taken out of nodes.h. It's the tradeoff with small classes. To prove how easy it actually is, the final version of this manual will show how to add the sum operator, step by step
The basic steps to add a new application are as follows:
Step 1: Add the code for your new application as a new class or modify an existing class that inherits from worker. Remember that it must implement the member function work as declared in worker.h.
Add functions in workermap.cpp to create the workers that you just wrote. Don't forget to #include your new class
Create a *.ops file for your new application (see above)
Create a new menu entry for your program in arithmetica.cpp
last modified: 10-09-02