Errata: In equation (6.17), elements of the output matrix should be in the opposite order