Computing rank-convolutions with a mask