[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.4 Structures
If you are doing some very specialized things with GiNaC, or if you just
need some more organized way to store data in your expressions instead of
anonymous lists, you may want to implement your own algebraic classes.
('algebraic class' means any class directly or indirectly derived from
basic
that can be used in GiNaC expressions).
GiNaC offers two ways of accomplishing this: either by using the
structure<T>
template class, or by rolling your own class from
scratch. This section will discuss the structure<T>
template which
is easier to use but more limited, while the implementation of custom
GiNaC classes is the topic of the next section. However, you may want to
read both sections because many common concepts and member functions are
shared by both concepts, and it will also allow you to decide which approach
is most suited to your needs.
The structure<T>
template, defined in the GiNaC header file
‘structure.h’, wraps a type that you supply (usually a C++ struct
or class
) into a GiNaC object that can be used in expressions.