3.6 To unscramble the eggs 107
a matrix obtained from the identity by elementary column operations. Evidently, x = Ey,
which means that we must perform row operations on y to recover the answers in the right
order.
Now we can leave the example above, and state the rule in general. We are given p
systems of m simultaneous equations each, all having a commom m × n coefficient matrix
A,inn unknowns. At the end of the back solution we will have before us a matrix of the
form
I(r, r) B(r, n − r) P (r, p)
(3.6.6)
where I(r, r)isther×r identity matrix, r is the pseudorank of A,andB and P are matrices
of the sizes shown.
We adjoin under B the negative of the (n − r) × (n − r) identity matrix, and under P
we adjoin an (n − r) × p block of zeros. Next, we forget the identity matrix on the left,
and we consider the entire remaining n ×(n −r + p) matrix as a whole, call it T , say. Now
we exchange the rows of T according to the permuation array τ. Preciesly, row 1 of T will
be row τ
1
of the new T , row 2 will be row τ
2
, . . . . Conceptually, we should regard the
old T and the new T as occupying different areas of storage, so that the new T is just a
rearrangement of the rows of the old.
Now the first n −r columnsofthenewT are a basis for the kernel of A,andshouldbe
output as such, and the jth one of the last p columns of the new T is a particular solution
of the jth one of the input systems of equations, and should be output as such.
Although conceptually we should think of the old T and the new T as occupying distinct
arrays in memory, in fact it is perfectly possible to carry out the whole row interchange
procedure described above in just one array, the one that holds T , without ever “stepping
on our own toes,” so let’s consider that problem.
Suppose a linear array a =[a
1
,...,a
n
] is given, along with a permutation array τ =
[τ
1
,...,τ
n
]. We want to rearrange the entries of the array a according to the permuation τ
without using any additional array storage. Thus the present array a
1
willendupasthe
output a
τ
1
, the initial a
2
will end up as a
τ
2
, etc.
To do this with no extra array storage, let’s first pick up the element a
1
and move it to
a
τ
1
, being careful to store the original a
τ
1
in a temporary location t so it won’t be destroyed.
Next we move the contents of t to its destination, and so forth. After a certain number of
steps (maybe only 1), we will be back to a
1
.
Her’s an example to help clarify the situation. Suppose the arrays a and τ at input time
were:
a =[5, 7, 13, 9, 2, 8]
τ =[3, 4, 5, 2, 1, 6].
(3.6.7)
So we move the 5 in position a
1
to position a
3
(after putting the 13 into a safe place), and
then the 13 goes to position a
5
(after putting the 2 into a safe place) and the 2 is moved
into position a
1
, and we’re back where we started. The a array now has become
a =[2, 7, 5, 9, 13, 8]. (3.6.8)