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  package spec
     6  
     7  // Permute permutes x.
     8  //
     9  //	z[i] = x[indices[i] % len(x)]
    10  //
    11  //specgen:require indices=Uint{xN}x{xL}
    12  func Permute[E Elt, W Width, E2 Uints](x Vec[E, W], indices Vec[E2, W]) (z Vec[E, W]) {
    13  	z = makeVec[E, W]()
    14  	for i := range z {
    15  		z[i] = x[uint(indices[i])%uint(x.len())]
    16  	}
    17  	return z
    18  }
    19  

View as plain text