From 22bcab04fe9c6494306c98c683f470a4960aa781 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Mon, 10 Sep 2012 14:48:03 +0000 Subject: [PATCH] Updated throws declarations for transform package. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1382906 13f79535-47bb-0310-9956-ffa450edef68 --- .../transform/FastCosineTransformer.java | 5 ++-- .../math3/transform/RealTransformer.java | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/transform/FastCosineTransformer.java b/src/main/java/org/apache/commons/math3/transform/FastCosineTransformer.java index 0748825fa..6d407300b 100644 --- a/src/main/java/org/apache/commons/math3/transform/FastCosineTransformer.java +++ b/src/main/java/org/apache/commons/math3/transform/FastCosineTransformer.java @@ -94,7 +94,8 @@ public class FastCosineTransformer implements RealTransformer, Serializable { * @throws MathIllegalArgumentException if the length of the data array is * not a power of two plus one */ - public double[] transform(final double[] f, final TransformType type) { + public double[] transform(final double[] f, final TransformType type) + throws MathIllegalArgumentException { if (type == TransformType.FORWARD) { if (normalization == DctNormalization.ORTHOGONAL_DCT_I) { final double s = FastMath.sqrt(2.0 / (f.length - 1)); @@ -124,7 +125,7 @@ public class FastCosineTransformer implements RealTransformer, Serializable { */ public double[] transform(final UnivariateFunction f, final double min, final double max, final int n, - final TransformType type) { + final TransformType type) throws MathIllegalArgumentException { final double[] data = FunctionUtils.sample(f, min, max, n); return transform(data, type); diff --git a/src/main/java/org/apache/commons/math3/transform/RealTransformer.java b/src/main/java/org/apache/commons/math3/transform/RealTransformer.java index 69a18dfd6..623be0c78 100644 --- a/src/main/java/org/apache/commons/math3/transform/RealTransformer.java +++ b/src/main/java/org/apache/commons/math3/transform/RealTransformer.java @@ -17,6 +17,9 @@ package org.apache.commons.math3.transform; import org.apache.commons.math3.analysis.UnivariateFunction; +import org.apache.commons.math3.exception.MathIllegalArgumentException; +import org.apache.commons.math3.exception.NonMonotonicSequenceException; +import org.apache.commons.math3.exception.NotStrictlyPositiveException; /** *

Interface for one-dimensional data sets transformations producing real @@ -39,8 +42,11 @@ public interface RealTransformer { * @param f the real data array to be transformed (signal) * @param type the type of transform (forward, inverse) to be performed * @return the real transformed array (spectrum) + * @throws MathIllegalArgumentException if the array cannot be transformed + * with the given type (this may be for example due to array size, which is + * constrained in some transforms) */ - double[] transform(double[] f, TransformType type); + double[] transform(double[] f, TransformType type) throws MathIllegalArgumentException; /** * Returns the (forward, inverse) transform of the specified real function, @@ -52,12 +58,15 @@ public interface RealTransformer { * @param n the number of sample points * @param type the type of transform (forward, inverse) to be performed * @return the real transformed array - * @throws org.apache.commons.math3.exception.NonMonotonicSequenceException - * if the lower bound is greater than, or equal to the upper bound - * @throws org.apache.commons.math3.exception.NotStrictlyPositiveException - * if the number of sample points is negative + * @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 sample cannot be transformed + * with the given type (this may be for example due to sample size, which is + * constrained in some transforms) */ - double[] transform(UnivariateFunction f, - double min, double max, int n, - TransformType type); + double[] transform(UnivariateFunction f, double min, double max, int n, + TransformType type) + throws NonMonotonicSequenceException, NotStrictlyPositiveException, MathIllegalArgumentException; + }