The result array must be aligned to the source array, with replicated alignment in dimension dim (see section 4.5).