SECTION 5.11 PROGRAMMING EXAMPLES AND EXERCISES 139
class in general and the meet() and join() functions in particular is much slower than
the specialized classes and the ordinary products.
To make it easier to produce degenerate cases—such as two parallel vectors—we round
the coordinates of multivectors
M1 and M2 to multiples of 0.2. This causes them to move
in a stepwise fashion.
5.11.2 EFFICIENCY
In Gaigen 2, the implementation of the meet and join is very slow compared to the other
products. This example performs a benchmark to demonstrate this. It creates 1,000,000
pairs of random vectors and bivectors. It then times how long it takes to compute the
outer product of these pairs, and how long it takes to compute the
join of these pairs. In
our benchmark the
join is about 100 times slower than outer product. There are several
reasons for this:
•
To compute the meet and join, a specialized (factorization) algorithm is used,
whereas computing the outer product is as simple as multiplying and summing
coordinates in the right way. See Section 21.7 for a description of the
meet and
join algorithm used in this example.
•
The algorithm uses the mv class instead of the specialized types such as vector and
bivector.Themv class uses coordinate compression, which is slow.
•
The ordinary subspace products are just very efficient in Gaigen 2.
It may be possible to optimize the
meet and join toalevelwheretheyareabout10
times slower than the regular products. But in general, you should try to avoid the
meet
and join in your programs if you care about efficiency. If you know the relative posi-
tion of elements involved, just use the formula B
∗
A in the appropriate subspace instead
of A ∩ B.
5.11.3 FLOATING POINT ISSUES
As stated above, the meet and join are computed by a factorization algorithm. Before the
factorization starts, the algorithm computes what the grade of the output should be. This
involves comparing a condition number (similar to that of a matrix) to a small threshold
value. Hence, the algorithm will flip-flop between grades in degenerate cases (e.g., near-
parallel vectors).
This example (see Figure 5.4) searches for the point where the join of two (near-)parallel
vectors changes from a vector to a 2-blade. It starts with a very small probe epsilon of
10
−10
, and tests if e
1
∪ ( e
1
+ 10
−10
e
2
) is a 2-blade. If not, it grows the probe epsilon, and
loops. In the example, the flip-flop occurs when b = e
1
+ 1.007748 −×10
−7
e
2
,whichis
to be expected, because the
meet-join algorithm uses an epsilon of 10
−7
.