Introduced explicit template parameter for output dimension.