Adding functionality for NxM matrices