rank and transform arrays in place