generalized ndim