rmuir commented on code in PR #14516: URL: https://github.com/apache/lucene/pull/14516#discussion_r2055723991
########## lucene/core/src/java/org/apache/lucene/util/SloppyMath.java: ########## @@ -178,6 +178,30 @@ public static double asin(double a) { } } + // some sloppyish stuff, do we really need this to be done in a sloppy way? + // unless it is performance sensitive, we should try to remove. + // This is performance sensitive, check SloppySinBenchmark and RectangleBenchmark + private static final double PIO2 = Math.PI / 2D; + + /** + * Returns the trigonometric sine of an angle converted as a cos operation. + * + * <p>Note that this is not quite right... e.g. sin(0) != 0 + * + * <p>Special cases: + * + * <ul> + * <li>If the argument is {@code NaN} or an infinity, then the result is {@code NaN}. + * </ul> + * + * @param a an angle, in radians. + * @return the sine of the argument. + * @see Math#sin(double) + */ + public static double sin(double a) { Review Comment: I agree it is better to have the benchmark. I'm not familiar with what the Rectangle code is doing here: I don't tend to think about sin() being associated with Rectanges... But the background is that the `cos()` and `asin()` are needed for this use-case: https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/document/LatLonPointDistanceComparator.java#L37-L43 We try hard to avoid calling these functions at all, but in some cases such as the sorting, many calls are needed. -- 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: issues-unsubscr...@lucene.apache.org 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