Specialize generic_scale! when input and output are the same array

Ref #8145