commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1033486 [1/2] - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/ main/java/org/apache/commons/math/estimation/ main/java/org/apache/commons/math/exception/ main/java/org/apache/commons/math/exception/util/ main/java/or...
Date Wed, 10 Nov 2010 14:23:38 GMT
Author: erans
Date: Wed Nov 10 14:23:36 2010
New Revision: 1033486

URL: http://svn.apache.org/viewvc?rev=1033486&view=rev
Log:
MATH-425
Removed usage of exceptions defined in the package "linear". Added
replacements in package "exception". Modified tests to catch the
new exception type. Deleted the deprecated package "estimation" (test
failed because of the changes).
Deprecated "MaxIterationsExceededException".
Changes in package "optimization.general" were necessary to comply with
the new exceptions and to be consistent in reporting the actual cause
of failure.

Added:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java   (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java   (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java   (with props)
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java   (with props)
Removed:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/estimation/
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/
Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalNumberException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
    commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/Array2DRowRealMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockFieldMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/BlockRealMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/CholeskyDecompositionImplTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/EigenSolverTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldLUDecompositionImplTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/FieldMatrixImplTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUDecompositionImplTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/LUSolverTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/QRSolverTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseFieldMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/SparseRealMatrixTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/MaxIterationsExceededException.java Wed Nov 10 14:23:36 2010
@@ -28,6 +28,9 @@ import org.apache.commons.math.exception
  *
  * @version $Revision$ $Date$
  * @since 1.2
+ * @deprecated in 2.2 (to be removed in 3.0). Please use
+ * {@link org.apache.commons.math.exception.MaxCountExceededException}
+ * instead.
  */
 public class MaxIterationsExceededException extends ConvergenceException {
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/DimensionMismatchException.java Wed Nov 10 14:23:36 2010
@@ -17,6 +17,7 @@
 package org.apache.commons.math.exception;
 
 import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.util.Localizable;
 
 /**
  * Exception to be thrown when two dimensions differ.
@@ -25,28 +26,39 @@ import org.apache.commons.math.exception
  * @version $Revision$ $Date$
  */
 public class DimensionMismatchException extends MathIllegalNumberException {
-
     /** Serializable version Id. */
     private static final long serialVersionUID = -8415396756375798143L;
-
     /** Correct dimension. */
     private final int dimension;
 
     /**
      * Construct an exception from the mismatched dimensions.
      *
+     * @param specific Specific context information pattern.
      * @param wrong Wrong dimension.
      * @param expected Expected dimension.
      */
-    public DimensionMismatchException(int wrong,
+    public DimensionMismatchException(Localizable specific,
+                                      int wrong,
                                       int expected) {
-        super(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
+        super(specific,
               LocalizedFormats.DIMENSIONS_MISMATCH,
               wrong, expected);
         dimension = expected;
     }
 
     /**
+     * Construct an exception from the mismatched dimensions.
+     *
+     * @param wrong Wrong dimension.
+     * @param expected Expected dimension.
+     */
+    public DimensionMismatchException(int wrong,
+                                      int expected) {
+        this(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, wrong, expected);
+    }
+
+    /**
      * @return the expected dimension.
      */
     public int getDimension() {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalNumberException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalNumberException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalNumberException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalNumberException.java Wed Nov 10 14:23:36 2010
@@ -40,7 +40,7 @@ public class MathIllegalNumberException 
      *
      * @param specific Localizable pattern.
      * @param general Localizable pattern.
-     * @param wrong wrong number
+     * @param wrong Wrong number.
      * @param arguments Arguments.
      */
     protected MathIllegalNumberException(Localizable specific,
@@ -55,7 +55,7 @@ public class MathIllegalNumberException 
      * Construct an exception.
      *
      * @param general Localizable pattern.
-     * @param wrong wrong number
+     * @param wrong Wrong number.
      * @param arguments Arguments.
      */
     protected MathIllegalNumberException(Localizable general,

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MaxCountExceededException.java Wed Nov 10 14:23:36 2010
@@ -28,7 +28,6 @@ import org.apache.commons.math.exception
 public class MaxCountExceededException extends MathIllegalStateException {
     /** Serializable version Id. */
     private static final long serialVersionUID = 4330003017885151975L;
-
     /**
      * Maximum number of evaluations.
      */
@@ -50,10 +49,7 @@ public class MaxCountExceededException e
      */
     public MaxCountExceededException(Localizable specific,
                                      Number max) {
-        super(specific,
-              LocalizedFormats.MAX_COUNT_EXCEEDED,
-              max);
-
+        super(specific, LocalizedFormats.MAX_COUNT_EXCEEDED, max);
         this.max = max;
     }
 

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java?rev=1033486&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java Wed Nov 10 14:23:36 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when a symmetric matrix is expected.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class NonPositiveDefiniteMatrixException extends MathIllegalArgumentException {
+    /** Index (diagonal element). */
+    private final int index;
+    /** Threshold. */
+    private final double threshold;
+
+    /**
+     * Construct an exception.
+     *
+     * @param index Row (and column) index.
+     * @param threshold Absolute positivity threshold.
+     */
+    public NonPositiveDefiniteMatrixException(int index,
+                                              double threshold) {
+        super(LocalizedFormats.NON_POSITIVE_DEFINITE_MATRIX, index, threshold);
+        this.index = index;
+        this.threshold = threshold;
+    }
+
+    /**
+     * @return the row index.
+     */
+    public int getRow() {
+        return index;
+    }
+    /**
+     * @return the column index.
+     */
+    public int getColumn() {
+        return index;
+    }
+    /**
+     * @return the absolute positivity threshold.
+     */
+    public double getThreshold() {
+        return threshold;
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonPositiveDefiniteMatrixException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java?rev=1033486&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java Wed Nov 10 14:23:36 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when a square matrix is expected.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class NonSquareMatrixException extends DimensionMismatchException {
+    /**
+     * Construct an exception from the mismatched dimensions.
+     *
+     * @param wrong Row dimension.
+     * @param expected Column dimension.
+     */
+    public NonSquareMatrixException(int wrong,
+                                    int expected) {
+        super(LocalizedFormats.NON_SQUARE_MATRIX, wrong, expected);
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSquareMatrixException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java?rev=1033486&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java Wed Nov 10 14:23:36 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when a symmetric matrix is expected.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class NonSymmetricMatrixException extends MathIllegalArgumentException {
+    /** Row. */
+    private final int row;
+    /** Column. */
+    private final int column;
+    /** Threshold. */
+    private final double threshold;
+
+    /**
+     * Construct an exception.
+     *
+     * @param row Row index.
+     * @param column Column index.
+     * @param threshold Relative symmetry threshold.
+     */
+    public NonSymmetricMatrixException(int row,
+                                       int column,
+                                       double threshold) {
+        super(LocalizedFormats.NON_SYMMETRIC_MATRIX, row, column, threshold);
+        this.row = row;
+        this.column = column;
+        this.threshold = threshold;
+    }
+
+    /**
+     * @return the row index of the entry.
+     */
+    public int getRow() {
+        return row;
+    }
+    /**
+     * @return the column index of the entry.
+     */
+    public int getColumn() {
+        return column;
+    }
+    /**
+     * @return the relative symmetry threshold.
+     */
+    public double getThreshold() {
+        return threshold;
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NonSymmetricMatrixException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java?rev=1033486&view=auto
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java (added)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java Wed Nov 10 14:23:36 2010
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.exception;
+
+import org.apache.commons.math.exception.util.LocalizedFormats;
+
+/**
+ * Exception to be thrown when a non-singular matrix is expected.
+ *
+ * @since 3.0
+ * @version $Revision$ $Date$
+ */
+public class SingularMatrixException extends MathIllegalArgumentException {
+    /**
+     * Construct an exception.
+     */
+    public SingularMatrixException() {
+        super(LocalizedFormats.SINGULAR_MATRIX);
+    }
+}

Propchange: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/SingularMatrixException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/util/LocalizedFormats.java Wed Nov 10 14:23:36 2010
@@ -181,6 +181,7 @@ public enum LocalizedFormats implements 
     BETA("beta"), /* keep */
     NOT_POSITIVE_COLUMNDIMENSION("invalid column dimension: {0} (must be positive)"),
     NOT_POSITIVE_DEFINITE_MATRIX("not positive definite matrix"),
+    NON_POSITIVE_DEFINITE_MATRIX("not positive definite matrix: diagonal element at ({0},{0}) is larger than {2}"), /* keep */
     DEGREES_OF_FREEDOM("degrees of freedom ({0})"), /* keep */
     NOT_POSITIVE_DEGREES_OF_FREEDOM("degrees of freedom must be positive ({0})"),
     NOT_POSITIVE_ELEMENT_AT_INDEX("element {0} is not positive: {1}"),
@@ -217,6 +218,7 @@ public enum LocalizedFormats implements 
     NOT_STRICTLY_INCREASING_SEQUENCE("points {3} and {2} are not strictly increasing ({1} >= {0})"), /* keep */
     NOT_SUBTRACTION_COMPATIBLE_MATRICES("{0}x{1} and {2}x{3} matrices are not subtraction compatible"),
     NOT_SYMMETRIC_MATRIX("not symmetric matrix"),
+    NON_SYMMETRIC_MATRIX("non symmetric matrix: the difference between entries at ({0},{1}) and ({1},{0}) is larger than {2}"), /* keep */
     NO_BIN_SELECTED("no bin selected"),
     NO_CONVERGENCE_WITH_ANY_START_POINT("none of the {0} start points lead to convergence"), /* keep */
     NO_DATA("no data"), /* keep */
@@ -276,7 +278,7 @@ public enum LocalizedFormats implements 
     SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE("sample size ({0}) must be less than or equal to population size ({1})"),
     SIMPLEX_NEED_ONE_POINT("simplex must contain at least one point"),
     SIMPLE_MESSAGE("{0}"),
-    SINGULAR_MATRIX("matrix is singular"),
+    SINGULAR_MATRIX("matrix is singular"), /* keep */
     SUBARRAY_ENDS_AFTER_ARRAY_END("subarray ends after array end"),
     TOO_LARGE_CUTOFF_SINGULAR_VALUE("cutoff singular value is {0}, should be at most {1}"),
     TOO_MANY_ELEMENTS_TO_DISCARD_FROM_ARRAY("cannot discard {0} elements from a {1} elements array"),

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractFieldMatrix.java Wed Nov 10 14:23:36 2010
@@ -23,6 +23,7 @@ import java.util.Arrays;
 import org.apache.commons.math.Field;
 import org.apache.commons.math.FieldElement;
 import org.apache.commons.math.exception.MatrixDimensionMismatchException;
+import org.apache.commons.math.exception.NonSquareMatrixException;
 import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.exception.NoDataException;
 import org.apache.commons.math.exception.OutOfRangeException;
@@ -620,8 +621,7 @@ public abstract class AbstractFieldMatri
     public abstract int getColumnDimension();
 
     /** {@inheritDoc} */
-    public T getTrace()
-        throws NonSquareMatrixException {
+    public T getTrace() {
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
         if (nRows != nCols) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/AbstractRealMatrix.java Wed Nov 10 14:23:36 2010
@@ -20,6 +20,7 @@ package org.apache.commons.math.linear;
 import org.apache.commons.math.exception.NoDataException;
 import org.apache.commons.math.exception.NotStrictlyPositiveException;
 import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NonSquareMatrixException;
 import org.apache.commons.math.exception.MatrixDimensionMismatchException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
@@ -576,8 +577,7 @@ public abstract class AbstractRealMatrix
     public abstract int getColumnDimension();
 
     /** {@inheritDoc} */
-    public double getTrace()
-        throws NonSquareMatrixException {
+    public double getTrace() {
         final int nRows = getRowDimension();
         final int nCols = getColumnDimension();
         if (nRows != nCols) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java Wed Nov 10 14:23:36 2010
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math.linear;
 
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NonSquareMatrixException;
+import org.apache.commons.math.exception.NonSymmetricMatrixException;
+import org.apache.commons.math.exception.NonPositiveDefiniteMatrixException;
 import org.apache.commons.math.util.FastMath;
 
 
@@ -34,21 +36,20 @@ import org.apache.commons.math.util.Fast
  * @since 2.0
  */
 public class CholeskyDecompositionImpl implements CholeskyDecomposition {
-
-    /** Default threshold above which off-diagonal elements are considered too different
-     * and matrix not symmetric. */
+    /**
+     * Default threshold above which off-diagonal elements are considered too different
+     * and matrix not symmetric.
+     */
     public static final double DEFAULT_RELATIVE_SYMMETRY_THRESHOLD = 1.0e-15;
-
-    /** Default threshold below which diagonal elements are considered null
-     * and matrix not positive definite. */
+    /**
+     * Default threshold below which diagonal elements are considered null
+     * and matrix not positive definite.
+     */
     public static final double DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD = 1.0e-10;
-
     /** Row-oriented storage for L<sup>T</sup> matrix data. */
     private double[][] lTData;
-
     /** Cached value of L. */
     private RealMatrix cachedL;
-
     /** Cached value of LT. */
     private RealMatrix cachedLT;
 
@@ -62,17 +63,15 @@ public class CholeskyDecompositionImpl i
      * #DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD}
      * </p>
      * @param matrix the matrix to decompose
-     * @exception NonSquareMatrixException if matrix is not square
-     * @exception NotSymmetricMatrixException if matrix is not symmetric
-     * @exception NotPositiveDefiniteMatrixException if the matrix is not
-     * strictly positive definite
+     * @throws NonSquareMatrixException if the matrix is not square.
+     * @throws NonSymmetricMatrixException if the matrix is not symmetric.
+     * @throws NonPositiveDefiniteMatrixException if the matrix is not
+     * strictly positive definite.
      * @see #CholeskyDecompositionImpl(RealMatrix, double, double)
      * @see #DEFAULT_RELATIVE_SYMMETRY_THRESHOLD
      * @see #DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD
      */
-    public CholeskyDecompositionImpl(final RealMatrix matrix)
-        throws NonSquareMatrixException,
-               NotSymmetricMatrixException, NotPositiveDefiniteMatrixException {
+    public CholeskyDecompositionImpl(final RealMatrix matrix) {
         this(matrix, DEFAULT_RELATIVE_SYMMETRY_THRESHOLD,
              DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD);
     }
@@ -84,20 +83,17 @@ public class CholeskyDecompositionImpl i
      * elements are considered too different and matrix not symmetric
      * @param absolutePositivityThreshold threshold below which diagonal
      * elements are considered null and matrix not positive definite
-     * @exception NonSquareMatrixException if matrix is not square
-     * @exception NotSymmetricMatrixException if matrix is not symmetric
-     * @exception NotPositiveDefiniteMatrixException if the matrix is not
-     * strictly positive definite
+     * @throws NonSquareMatrixException if the matrix is not square.
+     * @throws NonSymmetricMatrixException if the matrix is not symmetric.
+     * @throws NonPositiveDefiniteMatrixException if the matrix is not
+     * strictly positive definite.
      * @see #CholeskyDecompositionImpl(RealMatrix)
      * @see #DEFAULT_RELATIVE_SYMMETRY_THRESHOLD
      * @see #DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD
      */
     public CholeskyDecompositionImpl(final RealMatrix matrix,
                                      final double relativeSymmetryThreshold,
-                                     final double absolutePositivityThreshold)
-        throws NonSquareMatrixException,
-               NotSymmetricMatrixException, NotPositiveDefiniteMatrixException {
-
+                                     final double absolutePositivityThreshold) {
         if (!matrix.isSquare()) {
             throw new NonSquareMatrixException(matrix.getRowDimension(),
                                                matrix.getColumnDimension());
@@ -110,7 +106,6 @@ public class CholeskyDecompositionImpl i
 
         // check the matrix before transformation
         for (int i = 0; i < order; ++i) {
-
             final double[] lI = lTData[i];
 
             // check off-diagonal elements (and reset them to 0)
@@ -121,7 +116,7 @@ public class CholeskyDecompositionImpl i
                 final double maxDelta =
                     relativeSymmetryThreshold * FastMath.max(FastMath.abs(lIJ), FastMath.abs(lJI));
                 if (FastMath.abs(lIJ - lJI) > maxDelta) {
-                    throw new NotSymmetricMatrixException();
+                    throw new NonSymmetricMatrixException(i, j, relativeSymmetryThreshold);
                 }
                 lJ[i] = 0;
            }
@@ -134,7 +129,7 @@ public class CholeskyDecompositionImpl i
 
             // check diagonal element
             if (ltI[i] < absolutePositivityThreshold) {
-                throw new NotPositiveDefiniteMatrixException();
+                throw new NonPositiveDefiniteMatrixException(i, absolutePositivityThreshold);
             }
 
             ltI[i] = FastMath.sqrt(ltI[i]);
@@ -147,9 +142,7 @@ public class CholeskyDecompositionImpl i
                     ltQ[p] -= ltI[q] * ltI[p];
                 }
             }
-
         }
-
     }
 
     /** {@inheritDoc} */
@@ -169,7 +162,6 @@ public class CholeskyDecompositionImpl i
 
         // return the cached matrix
         return cachedLT;
-
     }
 
     /** {@inheritDoc} */
@@ -189,7 +181,6 @@ public class CholeskyDecompositionImpl i
 
     /** Specialized solver. */
     private static class Solver implements DecompositionSolver {
-
         /** Row-oriented storage for L<sup>T</sup> matrix data. */
         private final double[][] lTData;
 
@@ -208,14 +199,10 @@ public class CholeskyDecompositionImpl i
         }
 
         /** {@inheritDoc} */
-        public double[] solve(double[] b)
-            throws IllegalArgumentException, InvalidMatrixException {
-
+        public double[] solve(double[] b) {
             final int m = lTData.length;
             if (b.length != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                        b.length, m);
+                throw new DimensionMismatchException(b.length, m);
             }
 
             final double[] x = b.clone();
@@ -240,21 +227,17 @@ public class CholeskyDecompositionImpl i
             }
 
             return x;
-
         }
 
         /** {@inheritDoc} */
-        public RealVector solve(RealVector b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public RealVector solve(RealVector b) {
             try {
                 return solve((ArrayRealVector) b);
             } catch (ClassCastException cce) {
 
                 final int m = lTData.length;
                 if (b.getDimension() != m) {
-                    throw MathRuntimeException.createIllegalArgumentException(
-                            LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                            b.getDimension(), m);
+                    throw new DimensionMismatchException(b.getDimension(), m);
                 }
 
                 final double[] x = b.getData();
@@ -279,7 +262,6 @@ public class CholeskyDecompositionImpl i
                 }
 
                 return new ArrayRealVector(x, false);
-
             }
         }
 
@@ -287,23 +269,18 @@ public class CholeskyDecompositionImpl i
          * <p>The A matrix is implicit here. It is </p>
          * @param b right-hand side of the equation A &times; X = B
          * @return a vector X such that A &times; X = B
-         * @exception IllegalArgumentException if matrices dimensions don't match
-         * @exception InvalidMatrixException if decomposed matrix is singular
+         * @throws IllegalArgumentException if matrices dimensions don't match
+         * @throws InvalidMatrixException if decomposed matrix is singular
          */
-        public ArrayRealVector solve(ArrayRealVector b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public ArrayRealVector solve(ArrayRealVector b) {
             return new ArrayRealVector(solve(b.getDataRef()), false);
         }
 
         /** {@inheritDoc} */
-        public RealMatrix solve(RealMatrix b)
-            throws IllegalArgumentException, InvalidMatrixException {
-
+        public RealMatrix solve(RealMatrix b) {
             final int m = lTData.length;
             if (b.getRowDimension() != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                        b.getRowDimension(), b.getColumnDimension(), m, "n");
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
 
             final int nColB = b.getColumnDimension();
@@ -347,10 +324,8 @@ public class CholeskyDecompositionImpl i
         }
 
         /** {@inheritDoc} */
-        public RealMatrix getInverse() throws InvalidMatrixException {
+        public RealMatrix getInverse() {
             return solve(MatrixUtils.createRealIdentityMatrix(lTData.length));
         }
-
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java Wed Nov 10 14:23:36 2010
@@ -17,8 +17,10 @@
 
 package org.apache.commons.math.linear;
 
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.MaxIterationsExceededException;
+import org.apache.commons.math.exception.MaxCountExceededException;
+import org.apache.commons.math.exception.SingularMatrixException;
+import org.apache.commons.math.exception.NonSymmetricMatrixException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.util.MathUtils;
 import org.apache.commons.math.util.FastMath;
@@ -88,39 +90,33 @@ public class EigenDecompositionImpl impl
 
     /**
      * Calculates the eigen decomposition of the given symmetric matrix.
-     * @param matrix The <strong>symmetric</strong> matrix to decompose.
-     * @param splitTolerance dummy parameter, present for backward compatibility only.
-     * @exception InvalidMatrixException (wrapping a
-     * {@link org.apache.commons.math.ConvergenceException} if algorithm
-     * fails to converge
+     *
+     * @param matrix Matrix to decompose. It <em>must</em> be symmetric.
+     * @param splitTolerance Dummy parameter (present for backward
+     * compatibility only).
+     * @throws NonSymmetricMatrixException if the matrix is not symmetric.
+     * @throws MaxCountExceededException if the algorithm fails to converge.
      */
-    public EigenDecompositionImpl(final RealMatrix matrix,final double splitTolerance)
-            throws InvalidMatrixException {
-        if (isSymmetric(matrix)) {
+    public EigenDecompositionImpl(final RealMatrix matrix,
+                                  final double splitTolerance)  {
+        if (isSymmetric(matrix, true)) {
             transformToTridiagonal(matrix);
             findEigenVectors(transformer.getQ().getData());
-        } else {
-            // as of 2.0, non-symmetric matrices (i.e. complex eigenvalues) are
-            // NOT supported
-            // see issue https://issues.apache.org/jira/browse/MATH-235
-            throw new InvalidMatrixException(
-                    LocalizedFormats.ASSYMETRIC_EIGEN_NOT_SUPPORTED);
         }
     }
 
     /**
      * Calculates the eigen decomposition of the symmetric tridiagonal
      * matrix.  The Householder matrix is assumed to be the identity matrix.
+     *
      * @param main Main diagonal of the symmetric triadiagonal form
      * @param secondary Secondary of the tridiagonal form
-     * @param splitTolerance dummy parameter, present for backward compatibility only.
-     * @exception InvalidMatrixException (wrapping a
-     * {@link org.apache.commons.math.ConvergenceException} if algorithm
-     * fails to converge
+     * @param splitTolerance Dummy parameter (present for backward
+     * compatibility only).
+     * @throws MaxCountExceededException if the algorithm fails to converge.
      */
     public EigenDecompositionImpl(final double[] main,final double[] secondary,
-            final double splitTolerance)
-            throws InvalidMatrixException {
+                                  final double splitTolerance) {
         this.main      = main.clone();
         this.secondary = secondary.clone();
         transformer    = null;
@@ -134,11 +130,16 @@ public class EigenDecompositionImpl impl
 
     /**
      * Check if a matrix is symmetric.
-     * @param matrix
-     *            matrix to check
-     * @return true if matrix is symmetric
+     *
+     * @param matrix Matrix to check.
+     * @param raiseException If {@code true}, the method will throw an
+     * exception if {@code matrix} is not symmetric.
+     * @return {@code true} if {@code matrix} is symmetric.
+     * @throws NonSymmetricMatrixException if the matrix is not symmetric and
+     * {@code raiseException} is {@code true}.
      */
-    private boolean isSymmetric(final RealMatrix matrix) {
+    private boolean isSymmetric(final RealMatrix matrix,
+                                boolean raiseException) {
         final int rows = matrix.getRowDimension();
         final int columns = matrix.getColumnDimension();
         final double eps = 10 * rows * columns * MathUtils.EPSILON;
@@ -148,6 +149,9 @@ public class EigenDecompositionImpl impl
                 final double mji = matrix.getEntry(j, i);
                 if (FastMath.abs(mij - mji) >
                     (FastMath.max(FastMath.abs(mij), FastMath.abs(mji)) * eps)) {
+                    if (raiseException) {
+                        throw new NonSymmetricMatrixException(i, j, eps);
+                    }
                     return false;
                 }
             }
@@ -156,7 +160,7 @@ public class EigenDecompositionImpl impl
     }
 
     /** {@inheritDoc} */
-    public RealMatrix getV() throws InvalidMatrixException {
+    public RealMatrix getV() {
 
         if (cachedV == null) {
             final int m = eigenvectors.length;
@@ -171,7 +175,7 @@ public class EigenDecompositionImpl impl
     }
 
     /** {@inheritDoc} */
-    public RealMatrix getD() throws InvalidMatrixException {
+    public RealMatrix getD() {
         if (cachedD == null) {
             // cache the matrix for subsequent calls
             cachedD = MatrixUtils.createRealDiagonalMatrix(realEigenvalues);
@@ -180,7 +184,7 @@ public class EigenDecompositionImpl impl
     }
 
     /** {@inheritDoc} */
-    public RealMatrix getVT() throws InvalidMatrixException {
+    public RealMatrix getVT() {
 
         if (cachedVt == null) {
             final int m = eigenvectors.length;
@@ -196,30 +200,27 @@ public class EigenDecompositionImpl impl
     }
 
     /** {@inheritDoc} */
-    public double[] getRealEigenvalues() throws InvalidMatrixException {
+    public double[] getRealEigenvalues() {
         return realEigenvalues.clone();
     }
 
     /** {@inheritDoc} */
-    public double getRealEigenvalue(final int i) throws InvalidMatrixException,
-            ArrayIndexOutOfBoundsException {
+    public double getRealEigenvalue(final int i) {
         return realEigenvalues[i];
     }
 
     /** {@inheritDoc} */
-    public double[] getImagEigenvalues() throws InvalidMatrixException {
+    public double[] getImagEigenvalues() {
         return imagEigenvalues.clone();
     }
 
     /** {@inheritDoc} */
-    public double getImagEigenvalue(final int i) throws InvalidMatrixException,
-            ArrayIndexOutOfBoundsException {
+    public double getImagEigenvalue(final int i) {
         return imagEigenvalues[i];
     }
 
     /** {@inheritDoc} */
-    public RealVector getEigenvector(final int i)
-            throws InvalidMatrixException, ArrayIndexOutOfBoundsException {
+    public RealVector getEigenvector(final int i) {
         return eigenvectors[i].copy();
     }
 
@@ -283,8 +284,7 @@ public class EigenDecompositionImpl impl
          * @exception InvalidMatrixException
          *                if decomposed matrix is singular
          */
-        public double[] solve(final double[] b)
-                throws IllegalArgumentException, InvalidMatrixException {
+        public double[] solve(final double[] b) {
 
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
@@ -292,9 +292,7 @@ public class EigenDecompositionImpl impl
 
             final int m = realEigenvalues.length;
             if (b.length != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                        b.length, m);
+                throw new DimensionMismatchException(b.length, m);
             }
 
             final double[] bp = new double[m];
@@ -317,26 +315,19 @@ public class EigenDecompositionImpl impl
          * This method only find exact linear solutions, i.e. solutions for
          * which ||A &times; X - B|| is exactly 0.
          * </p>
-         * @param b
-         *            right-hand side of the equation A &times; X = B
-         * @return a vector X that minimizes the two norm of A &times; X - B
-         * @exception IllegalArgumentException
-         *                if matrices dimensions don't match
-         * @exception InvalidMatrixException
-         *                if decomposed matrix is singular
+         * @param b Right-hand side of the equation A &times; X = B
+         * @return a Vector X that minimizes the two norm of A &times; X - B
+         * @throws DimensionMismatchException if the matrices dimensions do not match.
+         * @throws SingularMatrixException if the decomposed matrix is singular.
          */
-        public RealVector solve(final RealVector b)
-                throws IllegalArgumentException, InvalidMatrixException {
-
+        public RealVector solve(final RealVector b) {
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
             }
 
             final int m = realEigenvalues.length;
             if (b.getDimension() != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH, b
-                                .getDimension(), m);
+                throw new DimensionMismatchException(b.getDimension(), m);
             }
 
             final double[] bp = new double[m];
@@ -350,7 +341,6 @@ public class EigenDecompositionImpl impl
             }
 
             return new ArrayRealVector(bp, false);
-
         }
 
         /**
@@ -359,16 +349,12 @@ public class EigenDecompositionImpl impl
          * This method only find exact linear solutions, i.e. solutions for
          * which ||A &times; X - B|| is exactly 0.
          * </p>
-         * @param b
-         *            right-hand side of the equation A &times; X = B
-         * @return a matrix X that minimizes the two norm of A &times; X - B
-         * @exception IllegalArgumentException
-         *                if matrices dimensions don't match
-         * @exception InvalidMatrixException
-         *                if decomposed matrix is singular
+         * @param b Right-hand side of the equation A &times; X = B
+         * @return a Matrix X that minimizes the two norm of A &times; X - B
+         * @throws DimensionMismatchException if the matrices dimensions do not match.
+         * @throws SingularMatrixException if the decomposed matrix is singular.
          */
-        public RealMatrix solve(final RealMatrix b)
-                throws IllegalArgumentException, InvalidMatrixException {
+        public RealMatrix solve(final RealMatrix b) {
 
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
@@ -376,11 +362,7 @@ public class EigenDecompositionImpl impl
 
             final int m = realEigenvalues.length;
             if (b.getRowDimension() != m) {
-                throw MathRuntimeException
-                        .createIllegalArgumentException(
-                                LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                                b.getRowDimension(), b.getColumnDimension(), m,
-                                "n");
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
 
             final int nColB = b.getColumnDimension();
@@ -419,12 +401,11 @@ public class EigenDecompositionImpl impl
 
         /**
          * Get the inverse of the decomposed matrix.
-         * @return inverse matrix
-         * @throws InvalidMatrixException
-         *             if decomposed matrix is singular
+         *
+         * @return the inverse matrix.
+         * @throws SingularMatrixException if the decomposed matrix is singular.
          */
-        public RealMatrix getInverse() throws InvalidMatrixException {
-
+        public RealMatrix getInverse() {
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
             }
@@ -444,32 +425,28 @@ public class EigenDecompositionImpl impl
                 }
             }
             return MatrixUtils.createRealMatrix(invData);
-
         }
-
     }
 
     /**
      * Transform matrix to tridiagonal.
-     * @param matrix
-     *            matrix to transform
+     *
+     * @param matrix Matrix to transform.
      */
     private void transformToTridiagonal(final RealMatrix matrix) {
-
         // transform the matrix to tridiagonal
         transformer = new TriDiagonalTransformer(matrix);
         main = transformer.getMainDiagonalRef();
         secondary = transformer.getSecondaryDiagonalRef();
-
     }
 
     /**
      * Find eigenvalues and eigenvectors (Dubrulle et al., 1971)
+     *
      * @param householderMatrix Householder matrix of the transformation
-     *  to tri-diagonal form.
+     * to tri-diagonal form.
      */
     private void findEigenVectors(double[][] householderMatrix) {
-
         double[][]z = householderMatrix.clone();
         final int n = main.length;
         realEigenvalues = new double[n];
@@ -515,9 +492,10 @@ public class EigenDecompositionImpl impl
                     }
                 }
                 if (m != j) {
-                    if (its == maxIter)
-                        throw new InvalidMatrixException(
-                                new MaxIterationsExceededException(maxIter));
+                    if (its == maxIter) {
+                        throw new MaxCountExceededException(LocalizedFormats.CONVERGENCE_FAILED,
+                                                            maxIter);
+                    }
                     its++;
                     double q = (realEigenvalues[j + 1] - realEigenvalues[j]) / (2 * e[j]);
                     double t = FastMath.sqrt(1 + q * q);

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldLUDecompositionImpl.java Wed Nov 10 14:23:36 2010
@@ -21,8 +21,9 @@ import java.lang.reflect.Array;
 
 import org.apache.commons.math.Field;
 import org.apache.commons.math.FieldElement;
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NonSquareMatrixException;
+import org.apache.commons.math.exception.SingularMatrixException;
 
 /**
  * Calculates the LUP-decomposition of a square matrix.
@@ -67,13 +68,12 @@ public class FieldLUDecompositionImpl<T 
     /**
      * Calculates the LU-decomposition of the given matrix.
      * @param matrix The matrix to decompose.
-     * @exception NonSquareMatrixException if matrix is not square
+     * @throws NonSquareMatrixException if matrix is not square
      */
-    public FieldLUDecompositionImpl(FieldMatrix<T> matrix)
-        throws NonSquareMatrixException {
-
+    public FieldLUDecompositionImpl(FieldMatrix<T> matrix) {
         if (!matrix.isSquare()) {
-            throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
+            throw new NonSquareMatrixException(matrix.getRowDimension(),
+                                               matrix.getColumnDimension());
         }
 
         final int m = matrix.getColumnDimension();
@@ -258,14 +258,10 @@ public class FieldLUDecompositionImpl<T 
         }
 
         /** {@inheritDoc} */
-        public T[] solve(T[] b)
-            throws IllegalArgumentException, InvalidMatrixException {
-
+        public T[] solve(T[] b) {
             final int m = pivot.length;
             if (b.length != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                        b.length, m);
+                throw new DimensionMismatchException(b.length, m);
             }
             if (singular) {
                 throw new SingularMatrixException();
@@ -301,17 +297,14 @@ public class FieldLUDecompositionImpl<T 
         }
 
         /** {@inheritDoc} */
-        public FieldVector<T> solve(FieldVector<T> b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public FieldVector<T> solve(FieldVector<T> b) {
             try {
                 return solve((ArrayFieldVector<T>) b);
             } catch (ClassCastException cce) {
 
                 final int m = pivot.length;
                 if (b.getDimension() != m) {
-                    throw MathRuntimeException.createIllegalArgumentException(
-                            LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                            b.getDimension(), m);
+                    throw new DimensionMismatchException(b.getDimension(), m);
                 }
                 if (singular) {
                     throw new SingularMatrixException();
@@ -351,23 +344,18 @@ public class FieldLUDecompositionImpl<T 
          * <p>The A matrix is implicit here. It is </p>
          * @param b right-hand side of the equation A &times; X = B
          * @return a vector X such that A &times; X = B
-         * @exception IllegalArgumentException if matrices dimensions don't match
-         * @exception InvalidMatrixException if decomposed matrix is singular
+         * @throws IllegalArgumentException if matrices dimensions don't match
+         * @throws InvalidMatrixException if decomposed matrix is singular
          */
-        public ArrayFieldVector<T> solve(ArrayFieldVector<T> b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public ArrayFieldVector<T> solve(ArrayFieldVector<T> b) {
             return new ArrayFieldVector<T>(solve(b.getDataRef()), false);
         }
 
         /** {@inheritDoc} */
-        public FieldMatrix<T> solve(FieldMatrix<T> b)
-            throws IllegalArgumentException, InvalidMatrixException {
-
+        public FieldMatrix<T> solve(FieldMatrix<T> b) {
             final int m = pivot.length;
             if (b.getRowDimension() != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                        b.getRowDimension(), b.getColumnDimension(), m, "n");
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
             if (singular) {
                 throw new SingularMatrixException();
@@ -428,7 +416,5 @@ public class FieldLUDecompositionImpl<T 
             }
             return solve(identity);
         }
-
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/FieldMatrix.java Wed Nov 10 14:23:36 2010
@@ -424,7 +424,8 @@ public interface FieldMatrix<T extends F
      * trace</a> of the matrix (the sum of the elements on the main diagonal).
      *
      * @return trace
-     * @throws NonSquareMatrixException if the matrix is not square
+     * @throws org.apache.commons.math.exception.NonSquareMatrixException
+     * if the matrix is not square.
      */
     T getTrace();
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/LUDecompositionImpl.java Wed Nov 10 14:23:36 2010
@@ -17,8 +17,9 @@
 
 package org.apache.commons.math.linear;
 
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.NonSquareMatrixException;
+import org.apache.commons.math.exception.SingularMatrixException;
 import org.apache.commons.math.util.FastMath;
 
 /**
@@ -34,35 +35,27 @@ import org.apache.commons.math.util.Fast
  * @since 2.0
  */
 public class LUDecompositionImpl implements LUDecomposition {
-
     /** Default bound to determine effective singularity in LU decomposition */
     private static final double DEFAULT_TOO_SMALL = 10E-12;
-
     /** Entries of LU decomposition. */
     private double lu[][];
-
     /** Pivot permutation associated with LU decomposition */
     private int[] pivot;
-
     /** Parity of the permutation associated with the LU decomposition */
     private boolean even;
-
     /** Singularity indicator. */
     private boolean singular;
-
     /** Cached value of L. */
     private RealMatrix cachedL;
-
     /** Cached value of U. */
     private RealMatrix cachedU;
-
     /** Cached value of P. */
     private RealMatrix cachedP;
 
     /**
      * Calculates the LU-decomposition of the given matrix.
      * @param matrix The matrix to decompose.
-     * @exception InvalidMatrixException if matrix is not square
+     * @throws InvalidMatrixException if matrix is not square
      */
     public LUDecompositionImpl(RealMatrix matrix)
         throws InvalidMatrixException {
@@ -74,13 +67,12 @@ public class LUDecompositionImpl impleme
      * @param matrix The matrix to decompose.
      * @param singularityThreshold threshold (based on partial row norm)
      * under which a matrix is considered singular
-     * @exception NonSquareMatrixException if matrix is not square
+     * @throws NonSquareMatrixException if matrix is not square
      */
-    public LUDecompositionImpl(RealMatrix matrix, double singularityThreshold)
-        throws NonSquareMatrixException {
-
+    public LUDecompositionImpl(RealMatrix matrix, double singularityThreshold) {
         if (!matrix.isSquare()) {
-            throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
+            throw new NonSquareMatrixException(matrix.getRowDimension(),
+                                               matrix.getColumnDimension());
         }
 
         final int m = matrix.getColumnDimension();
@@ -158,7 +150,6 @@ public class LUDecompositionImpl impleme
                 lu[row][col] /= luDiag;
             }
         }
-
     }
 
     /** {@inheritDoc} */
@@ -258,13 +249,10 @@ public class LUDecompositionImpl impleme
         }
 
         /** {@inheritDoc} */
-        public double[] solve(double[] b)
-            throws IllegalArgumentException, InvalidMatrixException {
-
+        public double[] solve(double[] b) {
             final int m = pivot.length;
             if (b.length != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH, b.length, m);
+                throw new DimensionMismatchException(b.length, m);
             }
             if (singular) {
                 throw new SingularMatrixException();
@@ -295,20 +283,17 @@ public class LUDecompositionImpl impleme
             }
 
             return bp;
-
         }
 
         /** {@inheritDoc} */
-        public RealVector solve(RealVector b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public RealVector solve(RealVector b) {
             try {
                 return solve((ArrayRealVector) b);
             } catch (ClassCastException cce) {
 
                 final int m = pivot.length;
                 if (b.getDimension() != m) {
-                    throw MathRuntimeException.createIllegalArgumentException(
-                            LocalizedFormats.VECTOR_LENGTH_MISMATCH, b.getDimension(), m);
+                    throw new DimensionMismatchException(b.getDimension(), m);
                 }
                 if (singular) {
                     throw new SingularMatrixException();
@@ -339,7 +324,6 @@ public class LUDecompositionImpl impleme
                 }
 
                 return new ArrayRealVector(bp, false);
-
             }
         }
 
@@ -347,23 +331,20 @@ public class LUDecompositionImpl impleme
          * <p>The A matrix is implicit here. It is </p>
          * @param b right-hand side of the equation A &times; X = B
          * @return a vector X such that A &times; X = B
-         * @exception IllegalArgumentException if matrices dimensions don't match
-         * @exception InvalidMatrixException if decomposed matrix is singular
+         * @throws DimensionMismatchException if the matrices dimensions
+         * do not match.
+         * @throws InvalidMatrixException if decomposed matrix is singular
          */
-        public ArrayRealVector solve(ArrayRealVector b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public ArrayRealVector solve(ArrayRealVector b) {
             return new ArrayRealVector(solve(b.getDataRef()), false);
         }
 
         /** {@inheritDoc} */
-        public RealMatrix solve(RealMatrix b)
-            throws IllegalArgumentException, InvalidMatrixException {
+        public RealMatrix solve(RealMatrix b) {
 
             final int m = pivot.length;
             if (b.getRowDimension() != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                        b.getRowDimension(), b.getColumnDimension(), m, "n");
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
             if (singular) {
                 throw new SingularMatrixException();
@@ -410,14 +391,11 @@ public class LUDecompositionImpl impleme
             }
 
             return new Array2DRowRealMatrix(bp, false);
-
         }
 
         /** {@inheritDoc} */
         public RealMatrix getInverse() throws InvalidMatrixException {
             return solve(MatrixUtils.createRealIdentityMatrix(pivot.length));
         }
-
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NonSquareMatrixException.java Wed Nov 10 14:23:36 2010
@@ -24,6 +24,8 @@ import org.apache.commons.math.exception
  * Thrown when an operation defined only for square matrices is applied to non-square ones.
  * @version $Revision$ $Date$
  * @since 2.0
+ * @deprecated in 2.2 (to be removed in 3.0). Please use
+ * {@link org.apache.commons.math.exception.DimensionMismatchException} instead.
  */
 public class NonSquareMatrixException extends InvalidMatrixException {
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotPositiveDefiniteMatrixException.java Wed Nov 10 14:23:36 2010
@@ -26,6 +26,8 @@ import org.apache.commons.math.exception
  *
  * @since 1.2
  * @version $Revision$ $Date$
+ * @deprecated in 2.2 (to be removed in 3.0). Please use
+ * {@link org.apache.commons.math.exception.NonPositiveDefiniteMatrixException} instead.
  */
 
 public class NotPositiveDefiniteMatrixException extends MathException {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/NotSymmetricMatrixException.java Wed Nov 10 14:23:36 2010
@@ -26,6 +26,8 @@ import org.apache.commons.math.exception
  *
  * @since 2.0
  * @version $Revision$ $Date$
+ * @deprecated in 2.2 (to be removed in 3.0). Please use
+ * {@link org.apache.commons.math.exception.NonSymmetricMatrixException} instead.
  */
 
 public class NotSymmetricMatrixException extends MathException {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/QRDecompositionImpl.java Wed Nov 10 14:23:36 2010
@@ -19,8 +19,8 @@ package org.apache.commons.math.linear;
 
 import java.util.Arrays;
 
-import org.apache.commons.math.MathRuntimeException;
-import org.apache.commons.math.exception.util.LocalizedFormats;
+import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.SingularMatrixException;
 import org.apache.commons.math.util.FastMath;
 
 
@@ -162,12 +162,10 @@ public class QRDecompositionImpl impleme
                     cachedR.setEntry(row, col, qrt[col][row]);
                 }
             }
-
         }
 
         // return the cached matrix
         return cachedR;
-
     }
 
     /** {@inheritDoc} */
@@ -180,7 +178,6 @@ public class QRDecompositionImpl impleme
 
     /** {@inheritDoc} */
     public RealMatrix getQT() {
-
         if (cachedQT == null) {
 
             // QT is supposed to be m x m
@@ -214,17 +211,14 @@ public class QRDecompositionImpl impleme
                     }
                 }
             }
-
         }
 
         // return the cached matrix
         return cachedQT;
-
     }
 
     /** {@inheritDoc} */
     public RealMatrix getH() {
-
         if (cachedH == null) {
 
             final int n = qrt.length;
@@ -235,12 +229,10 @@ public class QRDecompositionImpl impleme
                     cachedH.setEntry(i, j, qrt[j][i] / -rDiag[j]);
                 }
             }
-
         }
 
         // return the cached matrix
         return cachedH;
-
     }
 
     /** {@inheritDoc} */
@@ -281,19 +273,14 @@ public class QRDecompositionImpl impleme
                 }
             }
             return true;
-
         }
 
         /** {@inheritDoc} */
-        public double[] solve(double[] b)
-        throws IllegalArgumentException, InvalidMatrixException {
-
+        public double[] solve(double[] b) {
             final int n = qrt.length;
             final int m = qrt[0].length;
             if (b.length != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.VECTOR_LENGTH_MISMATCH,
-                        b.length, m);
+                throw new DimensionMismatchException(b.length, m);
             }
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
@@ -315,7 +302,6 @@ public class QRDecompositionImpl impleme
                 for (int row = minor; row < m; row++) {
                     y[row] += dotProduct * qrtMinor[row];
                 }
-
             }
 
             // solve triangular system R.x = y
@@ -330,12 +316,10 @@ public class QRDecompositionImpl impleme
             }
 
             return x;
-
         }
 
         /** {@inheritDoc} */
-        public RealVector solve(RealVector b)
-        throws IllegalArgumentException, InvalidMatrixException {
+        public RealVector solve(RealVector b) {
             try {
                 return solve((ArrayRealVector) b);
             } catch (ClassCastException cce) {
@@ -350,21 +334,16 @@ public class QRDecompositionImpl impleme
          * @throws IllegalArgumentException if matrices dimensions don't match
          * @throws InvalidMatrixException if decomposed matrix is singular
          */
-        public ArrayRealVector solve(ArrayRealVector b)
-        throws IllegalArgumentException, InvalidMatrixException {
+        public ArrayRealVector solve(ArrayRealVector b) {
             return new ArrayRealVector(solve(b.getDataRef()), false);
         }
 
         /** {@inheritDoc} */
-        public RealMatrix solve(RealMatrix b)
-        throws IllegalArgumentException, InvalidMatrixException {
-
+        public RealMatrix solve(RealMatrix b) {
             final int n = qrt.length;
             final int m = qrt[0].length;
             if (b.getRowDimension() != m) {
-                throw MathRuntimeException.createIllegalArgumentException(
-                        LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
-                        b.getRowDimension(), b.getColumnDimension(), m, "n");
+                throw new DimensionMismatchException(b.getRowDimension(), m);
             }
             if (!isNonSingular()) {
                 throw new SingularMatrixException();
@@ -409,7 +388,6 @@ public class QRDecompositionImpl impleme
                             yRow[k] += alpha[k] * d;
                         }
                     }
-
                 }
 
                 // solve triangular system R.x = y
@@ -433,21 +411,15 @@ public class QRDecompositionImpl impleme
                             yI[k] -= yJ[k] * rIJ;
                         }
                     }
-
                 }
-
             }
 
             return new BlockRealMatrix(n, columns, xBlocks, false);
-
         }
 
         /** {@inheritDoc} */
-        public RealMatrix getInverse()
-        throws InvalidMatrixException {
+        public RealMatrix getInverse() {
             return solve(MatrixUtils.createRealIdentityMatrix(rDiag.length));
         }
-
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/RealMatrix.java Wed Nov 10 14:23:36 2010
@@ -466,8 +466,9 @@ public interface RealMatrix extends AnyM
      * Returns the <a href="http://mathworld.wolfram.com/MatrixTrace.html">
      * trace</a> of the matrix (the sum of the elements on the main diagonal).
      *
-     * @return trace
-     * @throws NonSquareMatrixException if the matrix is not square
+     * @return the trace.
+     * @throws org.apache.commons.math.exception.NonSquareMatrixException
+     * if the matrix is not square.
      */
     double getTrace();
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularMatrixException.java Wed Nov 10 14:23:36 2010
@@ -24,6 +24,8 @@ import org.apache.commons.math.exception
  * Thrown when a matrix is singular.
  * @version $Revision$ $Date$
  * @since 2.0
+ * @deprecated in 2.2 (to be removed in 3.0). Please use
+ * {@link org.apache.commons.math.exception.SingularMatrixException} instead.
  */
 public class SingularMatrixException extends InvalidMatrixException {
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/TriDiagonalTransformer.java Wed Nov 10 14:23:36 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
 
 import java.util.Arrays;
 
+import org.apache.commons.math.exception.NonSquareMatrixException;
 import org.apache.commons.math.util.FastMath;
 
 
@@ -38,22 +39,16 @@ import org.apache.commons.math.util.Fast
  * @since 2.0
  */
 class TriDiagonalTransformer {
-
     /** Householder vectors. */
     private final double householderVectors[][];
-
     /** Main diagonal. */
     private final double[] main;
-
     /** Secondary diagonal. */
     private final double[] secondary;
-
     /** Cached value of Q. */
     private RealMatrix cachedQ;
-
     /** Cached value of Qt. */
     private RealMatrix cachedQt;
-
     /** Cached value of T. */
     private RealMatrix cachedT;
 
@@ -61,11 +56,11 @@ class TriDiagonalTransformer {
      * Build the transformation to tridiagonal shape of a symmetrical matrix.
      * <p>The specified matrix is assumed to be symmetrical without any check.
      * Only the upper triangular part of the matrix is used.</p>
-     * @param matrix the symmetrical matrix to transform.
-     * @exception InvalidMatrixException if matrix is not square
+     *
+     * @param matrix Symmetrical matrix to transform.
+     * @exception NonSquareMatrixException if the matrix is not square.
      */
-    public TriDiagonalTransformer(RealMatrix matrix)
-        throws InvalidMatrixException {
+    public TriDiagonalTransformer(RealMatrix matrix) {
         if (!matrix.isSquare()) {
             throw new NonSquareMatrixException(matrix.getRowDimension(), matrix.getColumnDimension());
         }
@@ -80,7 +75,6 @@ class TriDiagonalTransformer {
 
         // transform matrix
         transform();
-
     }
 
     /**
@@ -101,9 +95,7 @@ class TriDiagonalTransformer {
      * @return the Q matrix
      */
     public RealMatrix getQT() {
-
         if (cachedQt == null) {
-
             final int m = householderVectors.length;
             cachedQt = MatrixUtils.createRealMatrix(m, m);
 
@@ -132,12 +124,10 @@ class TriDiagonalTransformer {
                 }
             }
             cachedQt.setEntry(0, 0, 1);
-
         }
 
         // return the cached matrix
         return cachedQt;
-
     }
 
     /**
@@ -145,9 +135,7 @@ class TriDiagonalTransformer {
      * @return the T matrix
      */
     public RealMatrix getT() {
-
         if (cachedT == null) {
-
             final int m = main.length;
             cachedT = MatrixUtils.createRealMatrix(m, m);
             for (int i = 0; i < m; ++i) {
@@ -164,7 +152,6 @@ class TriDiagonalTransformer {
 
         // return the cached matrix
         return cachedT;
-
     }
 
     /**
@@ -202,7 +189,6 @@ class TriDiagonalTransformer {
      * <p>Transformation is done using Householder transforms.</p>
      */
     private void transform() {
-
         final int m = householderVectors.length;
         final double[] z = new double[m];
         for (int k = 0; k < m - 1; k++) {
@@ -260,11 +246,8 @@ class TriDiagonalTransformer {
                         hI[j] -= hK[i] * z[j] + z[i] * hK[j];
                     }
                 }
-
             }
-
         }
         main[m - 1] = householderVectors[m - 1][m - 1];
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java Wed Nov 10 14:23:36 2010
@@ -17,12 +17,11 @@
 
 package org.apache.commons.math.optimization.general;
 
-import org.apache.commons.math.exception.FunctionEvaluationException;
-import org.apache.commons.math.exception.ConvergenceException;
+import org.apache.commons.math.exception.NumberIsTooSmallException;
+import org.apache.commons.math.exception.DimensionMismatchException;
 import org.apache.commons.math.analysis.DifferentiableMultivariateVectorialFunction;
 import org.apache.commons.math.analysis.MultivariateMatrixFunction;
 import org.apache.commons.math.exception.util.LocalizedFormats;
-import org.apache.commons.math.linear.InvalidMatrixException;
 import org.apache.commons.math.linear.LUDecompositionImpl;
 import org.apache.commons.math.linear.MatrixUtils;
 import org.apache.commons.math.linear.RealMatrix;
@@ -95,15 +94,17 @@ public abstract class AbstractLeastSquar
 
     /**
      * Update the jacobian matrix.
-     * @exception FunctionEvaluationException if the function jacobian
-     * cannot be evaluated or its dimension doesn't match problem dimension
+     *
+     * @throws org.apache.commons.math.exception.FunctionEvaluationException
+     * if the function Jacobian cannot be evaluated.
+     * @throws DimensionMismatchException if the Jacobian dimension does not
+     * match problem dimension.
      */
-    protected void updateJacobian() throws FunctionEvaluationException {
+    protected void updateJacobian() {
         ++jacobianEvaluations;
         weightedResidualJacobian = jF.value(point);
         if (weightedResidualJacobian.length != rows) {
-            throw new FunctionEvaluationException(point, LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
-                                                  weightedResidualJacobian.length, rows);
+            throw new DimensionMismatchException(weightedResidualJacobian.length, rows);
         }
 
         final double[] residualsWeights = getWeightRef();
@@ -120,15 +121,17 @@ public abstract class AbstractLeastSquar
 
     /**
      * Update the residuals array and cost function value.
-     * @exception FunctionEvaluationException if the function cannot be evaluated
-     * or its dimension doesn't match problem dimension or maximal number of
-     * of evaluations is exceeded
+     * @throws org.apache.commons.math.exception.FunctionEvaluationException
+     * if the function cannot be evaluated.
+     * @throws DimensionMismatchException if the dimension does not match the
+     * problem dimension.
+     * @throws org.apache.commons.math.exception.TooManyEvaluationsException
+     * if the maximal number of evaluations is exceeded.
      */
-    protected void updateResidualsAndCost() throws FunctionEvaluationException {
+    protected void updateResidualsAndCost() {
         objective = computeObjectiveValue(point);
         if (objective.length != rows) {
-            throw new FunctionEvaluationException(point, LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
-                                                  objective.length, rows);
+            throw new DimensionMismatchException(objective.length, rows);
         }
 
         final double[] targetValues = getTargetRef();
@@ -170,16 +173,15 @@ public abstract class AbstractLeastSquar
     }
 
     /**
-     * Get the covariance matrix of optimized parameters.
-     * @return covariance matrix
-     * @exception FunctionEvaluationException if the function jacobian cannot
-     * be evaluated
-     * @exception ConvergenceException if the covariance matrix
-     * cannot be computed (singular problem)
+     * Get the covariance matrix of the optimized parameters.
+     *
+     * @return the covariance matrix.
+     * @throws org.apache.commons.math.exception.FunctionEvaluationException
+     * if the function Jacobian cannot be evaluated.
+     * @throws org.apache.commons.math.exception.SingularMatrixException
+     * if the covariance matrix cannot be computed (singular problem).
      */
-    public double[][] getCovariances()
-        throws FunctionEvaluationException {
-
+    public double[][] getCovariances() {
         // set up the jacobian
         updateJacobian();
 
@@ -196,31 +198,29 @@ public abstract class AbstractLeastSquar
             }
         }
 
-        try {
-            // compute the covariances matrix
-            RealMatrix inverse =
-                new LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj)).getSolver().getInverse();
-            return inverse.getData();
-        } catch (InvalidMatrixException ime) {
-            throw new ConvergenceException(LocalizedFormats.UNABLE_TO_COMPUTE_COVARIANCE_SINGULAR_PROBLEM);
-        }
-
+        // compute the covariances matrix
+        RealMatrix inverse =
+            new LUDecompositionImpl(MatrixUtils.createRealMatrix(jTj)).getSolver().getInverse();
+        return inverse.getData();
     }
 
     /**
      * Guess the errors in optimized parameters.
-     * <p>Guessing is covariance-based, it only gives rough order of magnitude.</p>
+     * Guessing is covariance-based: It only gives a rough order of magnitude.
+     *
      * @return errors in optimized parameters
-     * @exception FunctionEvaluationException if the function jacobian cannot b evaluated
-     * @exception ConvergenceException if the covariances matrix cannot be computed
-     * or the number of degrees of freedom is not positive (number of measurements
-     * lesser or equal to number of parameters)
+     * @throws org.apache.commons.math.exception.FunctionEvaluationException
+     * if the function Jacobian cannot be evaluated.
+     * @throws org.apache.commons.math.exception.SingularMatrixException if
+     * the covariances matrix cannot be computed.
+     * @throws NumberIsTooSmallException if the number of degrees of freedom is not
+     * positive, i.e. the number of measurements is less or equal to the number of
+     * parameters.
      */
-    public double[] guessParametersErrors()
-        throws FunctionEvaluationException {
+    public double[] guessParametersErrors() {
         if (rows <= cols) {
-            throw new ConvergenceException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
-                                           rows, cols);
+            throw new NumberIsTooSmallException(LocalizedFormats.NO_DEGREES_OF_FREEDOM,
+                                                rows, cols, false);
         }
         double[] errors = new double[cols];
         final double c = FastMath.sqrt(getChiSquare() / (rows - cols));
@@ -235,8 +235,7 @@ public abstract class AbstractLeastSquar
     @Override
     public VectorialPointValuePair optimize(final DifferentiableMultivariateVectorialFunction f,
                                             final double[] target, final double[] weights,
-                                            final double[] startPoint)
-        throws FunctionEvaluationException {
+                                            final double[] startPoint) {
         // Reset counter.
         jacobianEvaluations = 0;
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java?rev=1033486&r1=1033485&r2=1033486&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizer.java Wed Nov 10 14:23:36 2010
@@ -17,15 +17,15 @@
 
 package org.apache.commons.math.optimization.general;
 
+import org.apache.commons.math.exception.SingularMatrixException;
 import org.apache.commons.math.exception.FunctionEvaluationException;
+import org.apache.commons.math.exception.ConvergenceException;
 import org.apache.commons.math.exception.util.LocalizedFormats;
 import org.apache.commons.math.linear.BlockRealMatrix;
 import org.apache.commons.math.linear.DecompositionSolver;
-import org.apache.commons.math.linear.InvalidMatrixException;
 import org.apache.commons.math.linear.LUDecompositionImpl;
 import org.apache.commons.math.linear.QRDecompositionImpl;
 import org.apache.commons.math.linear.RealMatrix;
-import org.apache.commons.math.exception.ConvergenceException;
 import org.apache.commons.math.optimization.VectorialPointValuePair;
 import org.apache.commons.math.optimization.ConvergenceChecker;
 
@@ -120,7 +120,7 @@ public class GaussNewtonOptimizer extend
                 for (int i = 0; i < cols; ++i) {
                     point[i] += dX[i];
                 }
-            } catch (InvalidMatrixException e) {
+            } catch (SingularMatrixException e) {
                 throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM);
             }
 



Mime
View raw message