Next: , Previous: Error handling, Up: Basic concepts


4.4 The class hierarchy

GiNaC's class hierarchy consists of several classes representing mathematical objects, all of which (except for ex and some helpers) are internally derived from one abstract base class called basic. You do not have to deal with objects of class basic, instead you'll be dealing with symbols, numbers, containers of expressions and so on.

To get an idea about what kinds of symbolic composites may be built we have a look at the most important classes in the class hierarchy and some of the relations among the classes:

classhierarchy.png

The abstract classes shown here (the ones without drop-shadow) are of no interest for the user. They are used internally in order to avoid code duplication if two or more classes derived from them share certain features. An example is expairseq, a container for a sequence of pairs each consisting of one expression and a number (numeric). What is visible to the user are the derived classes add and mul, representing sums and products. See Internal structures, where these two classes are described in more detail. The following table shortly summarizes what kinds of mathematical objects are stored in the different classes:

symbol Algebraic symbols a, x, y...
constant Constants like Pi
numeric All kinds of numbers, 42, 7/3*I, 3.14159...
add Sums like x+y or a-(2*b)+3
mul Products like x*y or 2*a^2*(x+y+z)/b
ncmul Products of non-commutative objects
power Exponentials such as x^2, a^b, sqrt(2) ...


pseries Power Series, e.g. x-1/6*x^3+1/120*x^5+O(x^7)
function A symbolic function like sin(2*x)
lst Lists of expressions {x, 2*y, 3+z}
matrix mxn matrices of expressions
relational A relation like the identity x==y
indexed Indexed object like A_ij
tensor Special tensor like the delta and metric tensors
idx Index of an indexed object
varidx Index with variance
spinidx Index with variance and dot (used in Weyl-van-der-Waerden spinor formalism)
wildcard Wildcard for pattern matching
structure Template for user-defined classes