st: Mata: editing values in a matrix when a condition is met

I need to edit the values of a large matrix in Mata. More precisely, I
need to replace all values smaller than a number X by X, and all numbers
greater than Y by Y. The functions editvalue and _editvalue allow you to
replace a scalar by other in a matrix, but not to specify a condition
like x < X to trigger the replacement. Is there a way of doing this
economically, that is, without looping over all elements of the matrix?