/** Test of vectorizing operations with Java's jdk.incubator.vector classes. You need to use this with a later version of Java and add the following to your java invocation line: --add-modules jdk.incubator.vector --add-opens=jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED Vector API: https://docs.oracle.com/en/java/javase/23/docs/api/jdk.incubator.vector/jdk/incubator/vector/package-summary.html */ // Note that if len is not a multiple of species.length[] then the last items don't // get done. You have to write your code twice. All of this is lame. len = 10001 a = toArray[1 to len] startb = 2 b = toArray[startb to startb+len-1] species = staticJava["jdk.incubator.vector.FloatVector", "SPECIES_PREFERRED"] println[species.toString[]] i = 0 la = length[a] ila = newJava["java.lang.Long", la] // This lets the next line disambiguate between // loopBound[int] and loopBound[long] upperBound = species.loopBound[ila] println["upperBound is $upperBound"] c = newJavaArray["float", [la]] il = species.length[] println["il is $il"] while i < upperBound { fa = callJava["jdk.incubator.vector.FloatVector", "fromArray", [species, a, i]] fb = callJava["jdk.incubator.vector.FloatVector", "fromArray", [species, b, i]] fc = fa.add[fb] fc.intoArray[c, i] i = i + il } println[first[c, 10]] println[last[c,8]]