<div dir="ltr"><div>Hi,</div><div><br></div><div>I've been experimenting with the Vector API in an attempt to port the XXH3 hashing algorithm to Java. One of the steps requires rearranging the elements of a vector by swapping adjacent values. I.e., (v0, v1, v2, v3, ...) -> (v1, v0, v3, v2, ...).</div><div><br></div><div>One usability issue I'm running into is creating the VectorShuffle in a species-agnostic manner. The VectorShuffle.fromArray() expects a number of indices that matches *exactly* the length of the vector for the given species, so it's harder to create a shuffle that uses SPECIES_PREFERRED without additional logic to construct that array of indices dynamically.</div><div><br></div><div>To illustrate, I need to do the following for each species:<br></div><div><br></div><div>    VectorShuffle.fromArray(LongVector.SPECIES_128, new int[] { 1, 0 }, 0)</div><div>    VectorShuffle.fromArray(LongVector.SPECIES_256, new int[] { 1, 0, 3, 2 }, 0)</div><div>    VectorShuffle.fromArray(LongVector.SPECIES_512, new int[] { 1, 0, 3, 2, 5, 4, 7, 6 }, 0)</div><div><br></div><div>Of course, I could make something like this<br></div><br><div>    VectorShuffle.fromArray(LongVector.SPECIES_PREFERRED, makeIndexesFromTemplate(new int[] { 1, 0 }), 0)</div><div><br></div><div>with my own custom "makeIndexesFromTemplate" function to create the array of indices of the appropriate length.</div><div><br></div><div>Is there anything like that in the Vector APIs that I haven't been able to find? If not, would it make sense to add something like it, or allow VectorShuffle.fromXXX to derive such mapping?</div><div><br></div><div>- Martin<br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br></div></div></div></div></div>