1
0

Add test data helpers

This commit is contained in:
2026-07-26 11:45:28 +00:00
parent 5c9ddcc029
commit deb4aedec0

View File

@@ -0,0 +1,22 @@
package com.ankurm.vectorapi;
import java.util.Random;
public final class Data {
static float[] randomFloats(int n, long seed) {
Random r = new Random(seed);
float[] a = new float[n];
for (int i = 0; i < n; i++) a[i] = r.nextFloat();
return a;
}
static void assertSame(String what, float[] x, float[] y) {
for (int i = 0; i < x.length; i++) {
if (Math.abs(x[i] - y[i]) > 1e-4f) {
throw new AssertionError(what + ": mismatch at " + i + ": " + x[i] + " != " + y[i]);
}
}
}
private Data() {}
}