Convert X.transform to use the new X.matrix class.

The unit test is not modified yet.