542 SPECIALIZING THE STRUCTURE FOR EFFICIENCY CHAPTER 22
However, when geometric algebra is first presented to a computer scientist or
programmer, the question arises how an implementation of geometric algebra can ever
be as efficient as the current way of implementing geometry (based in linear algebra with
various extensions). Many features of geometric algebra seem to work against efficiency:
2
n
coordinates are required to represent a multivector for an n-dimensional space, the
conformal model of 3-D space requires a 5-D algebra (with its 32-D basis), there appear
to be many products and operations, and so on.
All initial geomet ric algebra implementations (like [43, 47]) seemed to confirm this, for
they were st ructurally pretty but unacceptably slow for practical applications on high vol-
ume data. They were not designed with efficiency in mind. This is a pity, for the structure
of geometric algebr a actually offers many opportunities to home in on the essential com-
putations that need to be done in an application. Effectively, these permit its practical use
as a high-level programming language that computes efficiently.
Three issues will recur in the attempt to make an efficient implementation: multivectors,
metrics, and operations.
•
Multivectors are the fundamental elements of computation in geometric algebra,
but they are big (2
n
coordinates for n-D). So although it is mathematically attractive
that all elements can be considered as multivectors, you would rather not base an
implementation on it.
Fortunately, most geometrically sensible elements of computation use only limited
grades, and in a particular manner. This suggests defining a fixed, specialized multi-
vector type for a variable whenever possible, to reduce storage and processing. Such
a multivector type is an indication of its geometrical meaning, immediately imply-
ing a more limited use of grades or basis blades. Examples of specialized multivector
types in the programming examples of Part I and II abound:
vector, translator,
and
circle,tonameafew.
In a large group of geometric algorithms and applications, we can naturally im-
pose such fixed multivector types on variables without compromising our solutions.
(And if in some application we cannot, we can always revert to the multivectors.)
•
The metric is a very fundamental feature of a geometric algebra, affecting the most
basic products. Many different metrics are useful and need to be allowed, yet looking
up the metric at run-time (e.g., from a table) is too costly. We should therefore not
just implement a general geometric algebra and use it in a particular situation; for
efficiency, we need a special implementation for every metrically different geometric
algebra.
•
The number of basic operations on multivectors is quite large, and e very opera-
tion can be applied on every element. Written out in coordinates, the operations
are not complicated, but precisely because the execution of each individual prod-
uct or operation requires relatively few computations, any overhead imposed by
the implementation (such as a conditional branch due to looping) will result in a
significant degradation of performance.