On Wed, Apr 27, 2011 at 02:04:43PM +0200, Luc Maisonobe wrote: > Le 27/04/2011 13:54, er...@apache.org a écrit : > > Author: erans > > Hi Gilles, > > > Date: Wed Apr 27 11:54:16 2011 > > New Revision: 1097088 > > > > URL: http://svn.apache.org/viewvc?rev=1097088&view=rev > > Log: > > MATH-561 > > Map a value to the interval [O, period). > > > > Modified: > > > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java > > > > commons/proper/math/trunk/src/test/java/org/apache/commons/math/util/MathUtilsTest.java > > > > Modified: > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java > > URL: > > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java?rev=1097088&r1=1097087&r2=1097088&view=diff > > ============================================================================== > > --- > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java > > (original) > > +++ > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/MathUtils.java > > Wed Apr 27 11:54:16 2011 > > @@ -1281,6 +1281,22 @@ public final class MathUtils { > > return a - TWO_PI * FastMath.floor((a + FastMath.PI - center) / > > TWO_PI); > > } > > > > + /** > > + * Reduce to the primary interval {@code [0 period)}. > > + * > > + * @param a Value to reduce. > > + * @param period Period. > > + * @param offset Value that will be mapped to {@code 0}. > > + * @return the value, within the interval {@code [0 period)}, > > + * that corresponds to {@code a}. > > + */ > > + public static double reduce(double a, > > + double period, > > + double offset) { > > + final double p = Math.abs(period); > > + return a - p * Math.floor((a - offset) / p) - offset; > > Shouldn't this be replaced by FastMath ?
Done in revision 1097094. Best, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org