The Theory of Canonical Matrices