Added support for generating a pivot matrix.

This satisfies issue #8 and supports issue #6.