msokolov commented on a change in pull request #2047: URL: https://github.com/apache/lucene-solr/pull/2047#discussion_r523001646
########## File path: lucene/core/src/java/org/apache/lucene/util/VectorUtil.java ########## @@ -25,47 +25,22 @@ private VectorUtil() { } - public static float dotProduct(float[] a, float[] b) { - float res = 0f; - /* - * If length of vector is larger than 8, we use unrolled dot product to accelerate the - * calculation. - */ - int i; - for (i = 0; i < a.length % 8; i++) { - res += b[i] * a[i]; - } - if (a.length < 8) { - return res; - } - float s0 = 0f; - float s1 = 0f; - float s2 = 0f; - float s3 = 0f; - float s4 = 0f; - float s5 = 0f; - float s6 = 0f; - float s7 = 0f; - for (; i + 7 < a.length; i += 8) { - s0 += b[i] * a[i]; - s1 += b[i + 1] * a[i + 1]; - s2 += b[i + 2] * a[i + 2]; - s3 += b[i + 3] * a[i + 3]; - s4 += b[i + 4] * a[i + 4]; - s5 += b[i + 5] * a[i + 5]; - s6 += b[i + 6] * a[i + 6]; - s7 += b[i + 7] * a[i + 7]; + public static double dotProduct(float[] a, float[] b) { Review comment: As an alternative, we could also consider changing the test to have a larger epsilon. I found that with the current 1e-5, I got one failure in 100 runs. Changing to 1e-4, I ran 1000 iterations with no failures. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org