Return-Path:
As of version 2.0 this no longer implements Serializable.
* - * @version $Id: FastCosineTransformer.java 1213585 2011-12-13 07:44:52Z - * celestin $ + * @version $Id$ * @since 1.2 */ public class FastCosineTransformer implements RealTransformer { @@ -154,8 +155,13 @@ public class FastCosineTransformer imple return new FastCosineTransformer(true); } - /** {@inheritDoc} */ - public double[] transform(double[] f) throws IllegalArgumentException { + /** + * {@inheritDoc} + * + * @throws MathIllegalArgumentException if the length of the data array is + * not a power of two plus one + */ + public double[] transform(double[] f) throws MathIllegalArgumentException { if (orthogonal) { final double s = FastMath.sqrt(2.0 / (f.length - 1)); @@ -164,26 +170,55 @@ public class FastCosineTransformer imple return fct(f); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws NonMonotonicSequenceException if the lower bound is greater + * than, or equal to the upper bound + * @throws NotStrictlyPositiveException if the number of sample points is + * negative + * @throws MathIllegalArgumentException if the number of sample points is + * not a power of two plus one + */ public double[] transform(UnivariateFunction f, - double min, double max, int n) throws IllegalArgumentException { + double min, double max, int n) throws + NonMonotonicSequenceException, + NotStrictlyPositiveException, + MathIllegalArgumentException { final double[] data = FastFourierTransformer.sample(f, min, max, n); return transform(data); } - /** {@inheritDoc} */ - public double[] inverseTransform(double[] f) - throws IllegalArgumentException { + /** + * {@inheritDoc} + * + * @throws MathIllegalArgumentException if the length of the data array is + * not a power of two plus one + */ + public double[] inverseTransform(double[] f) throws + MathIllegalArgumentException { final double s2 = 2.0 / (f.length - 1); final double s1 = orthogonal ? FastMath.sqrt(s2) : s2; return FastFourierTransformer.scaleArray(fct(f), s1); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * + * @throws NonMonotonicSequenceException if the lower bound is greater + * than, or equal to the upper bound + * @throws NotStrictlyPositiveException if the number of sample points is + * negative + * @throws MathIllegalArgumentException if the number of sample points is + * not a power of two plus one + */ public double[] inverseTransform(UnivariateFunction f, - double min, double max, int n) throws IllegalArgumentException { + double min, double max, int n) throws + NonMonotonicSequenceException, + NotStrictlyPositiveException, + MathIllegalArgumentException { final double[] data = FastFourierTransformer.sample(f, min, max, n); return inverseTransform(data); @@ -194,18 +229,19 @@ public class FastCosineTransformer imple * * @param f the real data array to be transformed * @return the real transformed array - * @throws IllegalArgumentException if any parameters are invalid + * @throws MathIllegalArgumentException if the length of the data array is + * not a power of two plus one */ protected double[] fct(double[] f) - throws IllegalArgumentException { + throws MathIllegalArgumentException { final double[] transformed = new double[f.length]; final int n = f.length - 1; if (!FastFourierTransformer.isPowerOf2(n)) { - throw MathRuntimeException.createIllegalArgumentException( - LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE, - f.length); + throw new MathIllegalArgumentException( + LocalizedFormats.NOT_POWER_OF_TWO_PLUS_ONE, + Integer.valueOf(f.length)); } if (n == 1) { // trivial case transformed[0] = 0.5 * (f[0] + f[1]); Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java?rev=1226359&r1=1226358&r2=1226359&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java Mon Jan 2 07:19:58 2012 @@ -38,10 +38,8 @@ public interface RealTransformer { * * @param f the real data array to be transformed (signal) * @return the real transformed array (spectrum) - * @throws IllegalArgumentException if any parameters are invalid */ - double[] transform(double[] f) - throws IllegalArgumentException; + double[] transform(double[] f); /** * Returns the forward transform of the specified real function, sampled on @@ -52,20 +50,16 @@ public interface RealTransformer { * @param max the (exclusive) upper bound for the interval * @param n the number of sample points * @return the real transformed array - * @throws IllegalArgumentException if any parameters are invalid */ - double[] transform(UnivariateFunction f, double min, double max, int n) - throws IllegalArgumentException; + double[] transform(UnivariateFunction f, double min, double max, int n); /** * Returns the inverse transform of the specified real data set. * * @param f the real data array to be inversely transformed * @return the real inversely transformed array - * @throws IllegalArgumentException if any parameters are invalid */ - double[] inverseTransform(double[] f) - throws IllegalArgumentException; + double[] inverseTransform(double[] f); /** * Returns the inverse transform of the specified real function, sampled @@ -76,9 +70,6 @@ public interface RealTransformer { * @param max the (exclusive) upper bound for the interval * @param n the number of sample points * @return the real inversely transformed array - * @throws IllegalArgumentException if any parameters are invalid */ - double[] inverseTransform(UnivariateFunction f, double min, double max, int n) - throws IllegalArgumentException; - + double[] inverseTransform(UnivariateFunction f, double min, double max, int n); }