Einen FloatVector umkehren (1/jedes Element)Java

Java-Forum
Guest
 Einen FloatVector umkehren (1/jedes Element)

Post by Guest »

In Java gibt es eine API namens VectorApi. Es ermöglicht die Durchführung arithmetischer Operationen für ein ganzes float[]-Array in einem einzigen CPU-Zyklus.
Zum Beispiel:

Code: Select all

FloatVector fv = FloatVector.fromArray(SPECIES, new float[]{1, 2, 3, 4, 5, 6, 7}, 0);
//multiplies the wohle array in a single cycle by 2 (if the CPU supports this)
fv.mul(2f);
Jetzt möchte ich das Ergebnis von 1f / FloatVector berechnen. Im Moment mache ich das per

Code: Select all

fv.pow(-1f);
Ich gehe davon aus, dass dies ein langsamer Vorgang sein könnte. Gibt es einen besseren Weg, dies zu tun?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post