slow-J commented on code in PR #16790:
URL: https://github.com/apache/lucene/pull/16790#discussion_r4525008951


##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -598,6 +598,62 @@ public static float recalculateOffset(
         vector, oldAlpha, oldMinQuantile, scale, alpha, minQuantile, 
maxQuantile);
   }
 
+  /**
+   * Subtracts {@code centroid} from {@code vector} in place, for the 
optimized scalar quantizer,
+   * and writes into {@code stats} the dot product of the original vector with 
{@code centroid},
+   * then the min, max, sum of squares and sum of the result, and the sum of 
its squared differences
+   * from its mean.
+   *
+   * @lucene.experimental
+   */
+  public static void osqCenter(float[] vector, float[] centroid, float[] 
stats) {
+    if (vector.length != centroid.length) {
+      throw new IllegalArgumentException(
+          "vector dimensions differ: " + vector.length + "!=" + 
centroid.length);
+    }
+    if (stats.length != 6) {
+      throw new IllegalArgumentException("stats must have 6 entries: " + 
stats.length);
+    }
+    IMPL.osqCenter(vector, centroid, stats);
+  }
+
+  /**
+   * Computes the sums that the optimized scalar quantizer's interval search 
needs for one interval.
+   * Each value {@code x} of {@code vector}, limited to {@code [lower, 
upper]}, is rounded half up
+   * to one of {@code points} levels {@code k}, which dequantizes to {@code 
x'}. Writes the sums of
+   * k, k * k, x * k, x * (x - x') and (x - x') * (x - x') into {@code stats}.
+   *
+   * @lucene.experimental
+   */
+  public static void osqGridStats(
+      float[] vector, float lower, float upper, int points, double[] stats) {
+    if (points < 2 || points > 256) {
+      throw new IllegalArgumentException("points must be in [2, 256]: " + 
points);
+    }
+    if (stats.length != 5) {
+      throw new IllegalArgumentException("stats must have 5 entries: " + 
stats.length);
+    }
+    assert lower <= upper : lower + " > " + upper;

Review Comment:
   Good catch, I'll remove it!



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to