Added matrix manipulation routine.