Skip to content

Commit

Permalink
Scale delta to the vector size
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoop committed Mar 5, 2025
1 parent 82ba0fc commit d6c2a6a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.function.ToLongBiFunction;

import static org.elasticsearch.simdvec.internal.vectorization.ESVectorUtilSupport.B_QUERY;
import static org.hamcrest.Matchers.closeTo;

public class ESVectorUtilTests extends BaseVectorizationTests {

Expand Down Expand Up @@ -49,6 +50,8 @@ public void testIpFloatByte() {

private void testIpFloatByteImpl(ToDoubleBiFunction<float[], byte[]> impl) {
int vectorSize = randomIntBetween(1, 1024);
// scale the delta according to the vector size
double delta = 1e-5 * vectorSize;

float[] q = new float[vectorSize];
byte[] d = new byte[vectorSize];
Expand All @@ -61,7 +64,7 @@ private void testIpFloatByteImpl(ToDoubleBiFunction<float[], byte[]> impl) {
for (int i = 0; i < q.length; i++) {
expected += q[i] * d[i];
}
assertEquals(expected, impl.applyAsDouble(q, d), 1e-2);
assertThat(impl.applyAsDouble(q, d), closeTo(expected, delta));
}

public void testBitAndCount() {
Expand Down

0 comments on commit d6c2a6a

Please sign in to comment.