Source file src/simd/internal/spec/shuffles.go
1 // Copyright 2026 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //simdgen:category Shuffles 6 7 package spec 8 9 // Permute permutes x. 10 // 11 // z[i] = x[indices[i] % len(x)] 12 // 13 //specgen:require indices=Uint{xN}x{xL} 14 func Permute[E Elt, W Width, E2 Uints](x Vec[E, W], indices Vec[E2, W]) (z Vec[E, W]) { 15 z = makeVec[E, W]() 16 for i := range z { 17 z[i] = x[uint(indices[i])%uint(x.len())] 18 } 19 return z 20 } 21