You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ce...@apache.org on 2012/01/03 07:29:17 UTC
svn commit: r1226669 -
/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
Author: celestin
Date: Tue Jan 3 06:29:17 2012
New Revision: 1226669
URL: http://svn.apache.org/viewvc?rev=1226669&view=rev
Log:
Removed references to deprecated MathRuntimeException (MATH-677).
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java?rev=1226669&r1=1226668&r2=1226669&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java Tue Jan 3 06:29:17 2012
@@ -16,9 +16,11 @@
*/
package org.apache.commons.math.transform;
-import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.UnivariateFunction;
import org.apache.commons.math.complex.Complex;
+import org.apache.commons.math.exception.MathIllegalArgumentException;
+import org.apache.commons.math.exception.NonMonotonicSequenceException;
+import org.apache.commons.math.exception.NotStrictlyPositiveException;
import org.apache.commons.math.exception.util.LocalizedFormats;
import org.apache.commons.math.util.FastMath;
@@ -157,8 +159,11 @@ public class FastSineTransformer impleme
* {@inheritDoc}
*
* The first element of the specified data set is required to be {@code 0}.
+ *
+ * @throws MathIllegalArgumentException if the length of the data array is
+ * not a power of two, or the first element of the data array is not zero
*/
- public double[] transform(double[] f) throws IllegalArgumentException {
+ public double[] transform(double[] f) throws MathIllegalArgumentException {
if (orthogonal) {
final double s = FastMath.sqrt(2.0 / f.length);
return FastFourierTransformer.scaleArray(fst(f), s);
@@ -170,9 +175,19 @@ public class FastSineTransformer impleme
* {@inheritDoc}
*
* This implementation enforces {@code f(x) = 0.0} at {@code x = 0.0}.
+ *
+ * @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
*/
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);
data[0] = 0.0;
@@ -187,6 +202,9 @@ public class FastSineTransformer impleme
* {@inheritDoc}
*
* The first element of the specified data set is required to be {@code 0}.
+ *
+ * @throws MathIllegalArgumentException if the length of the data array is
+ * not a power of two, or the first element of the data array is not zero
*/
public double[] inverseTransform(double[] f)
throws IllegalArgumentException {
@@ -202,10 +220,19 @@ public class FastSineTransformer impleme
* {@inheritDoc}
*
* This implementation enforces {@code f(x) = 0.0} at {@code x = 0.0}.
+ *
+ * @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
*/
public double[] inverseTransform(UnivariateFunction f,
- double min, double max, int n)
- throws IllegalArgumentException {
+ double min, double max, int n) throws
+ NonMonotonicSequenceException,
+ NotStrictlyPositiveException,
+ MathIllegalArgumentException {
if (orthogonal) {
return transform(f, min, max, n);
@@ -224,17 +251,18 @@ public class FastSineTransformer impleme
*
* @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, or the first element of the data array is not zero
*/
- protected double[] fst(double[] f) throws IllegalArgumentException {
+ protected double[] fst(double[] f) throws MathIllegalArgumentException {
final double[] transformed = new double[f.length];
FastFourierTransformer.verifyDataSet(f);
if (f[0] != 0.0) {
- throw MathRuntimeException.createIllegalArgumentException(
+ throw new MathIllegalArgumentException(
LocalizedFormats.FIRST_ELEMENT_NOT_ZERO,
- f[0]);
+ Double.valueOf(f[0]));
}
final int n = f.length;
if (n == 1) { // trivial case