redimensionalized matrices appropriately