Added matrix multiplication to generate matrix.