Kod do wpisu o nowościach o Javie 16 dostępny pod adresem: https://blog.mloza.pl/java-16-co-nowego/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.geometry; | |
public abstract sealed class Shape | |
permits Circle, Rectangle, Square { ... } | |
public final class Circle extends Shape { ... } | |
public sealed class Rectangle extends Shape | |
permits TransparentRectangle, FilledRectangle { ... } | |
public final class TransparentRectangle extends Rectangle { ... } | |
public final class FilledRectangle extends Rectangle { ... } | |
public non-sealed class Square extends Shape { ... } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_256; | |
void vectorComputation(float[] a, float[] b, float[] c) { | |
for (int i = 0; i < a.length; i += SPECIES.length()) { | |
var m = SPECIES.indexInRange(i, a.length); | |
// FloatVector va, vb, vc; | |
var va = FloatVector.fromArray(SPECIES, a, i, m); | |
var vb = FloatVector.fromArray(SPECIES, b, i, m); | |
var vc = va.mul(va). | |
add(vb.mul(vb)). | |
neg(); | |
vc.intoArray(c, i, m); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void scalarComputation(float[] a, float[] b, float[] c) { | |
for (int i = 0; i < a.length; i++) { | |
c[i] = (a[i] * a[i] + b[i] * b[i]) * -1.0f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment