Adding maxSelDim to matrix implementation
Added maxSelDim at matrix