Removed deprecated class "InvalidMatrixException".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1034220 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2010-11-12 00:13:27 +00:00
parent 9c804e92f7
commit 374abec6b1
11 changed files with 66 additions and 171 deletions

View File

@ -28,7 +28,8 @@ package org.apache.commons.math.linear;
* <li>a {@link #getLT() getLT} method has been added,</li>
* <li>the <code>isspd</code> method has been removed, the constructors of
* implementation classes being expected to throw {@link
* NotPositiveDefiniteMatrixException} when a matrix cannot be decomposed,</li>
* org.apache.commons.math.exception.NonPositiveDefiniteMatrixException}
* when a matrix cannot be decomposed,</li>
* <li>a {@link #getDeterminant() getDeterminant} method has been added,</li>
* <li>the <code>solve</code> method has been replaced by a {@link
* #getSolver() getSolver} method and the equivalent method provided by

View File

@ -269,8 +269,9 @@ public class CholeskyDecompositionImpl implements CholeskyDecomposition {
* <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
* @throws IllegalArgumentException if matrices dimensions don't match
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws DimensionMismatchException if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException if
* the decomposed matrix is singular.
*/
public ArrayRealVector solve(ArrayRealVector b) {
return new ArrayRealVector(solve(b.getDataRef()), false);

View File

@ -40,45 +40,47 @@ public interface DecompositionSolver {
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
double[] solve(final double[] b)
throws IllegalArgumentException, InvalidMatrixException;
double[] solve(final double[] b);
/** Solve the linear equation A &times; X = B for matrices A.
* <p>The A matrix is implicit, it is provided by the underlying
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
RealVector solve(final RealVector b)
throws IllegalArgumentException, InvalidMatrixException;
RealVector solve(final RealVector b);
/** Solve the linear equation A &times; X = B for matrices A.
* <p>The A matrix is implicit, it is provided by the underlying
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
RealMatrix solve(final RealMatrix b)
throws IllegalArgumentException, InvalidMatrixException;
RealMatrix solve(final RealMatrix b);
/**
* Check if the decomposed matrix is non-singular.
* @return true if the decomposed matrix is non-singular
* @return true if the decomposed matrix is non-singular.
*/
boolean isNonSingular();
/** Get the inverse (or pseudo-inverse) of the decomposed matrix.
* @return inverse matrix
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
RealMatrix getInverse()
throws InvalidMatrixException;
RealMatrix getInverse();
}

View File

@ -276,13 +276,10 @@ public class EigenDecompositionImpl implements EigenDecomposition {
* 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 double[] solve(final double[] b) {

View File

@ -42,33 +42,36 @@ public interface FieldDecompositionSolver<T extends FieldElement<T>> {
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
T[] solve(final T[] b)
throws IllegalArgumentException, InvalidMatrixException;
T[] solve(final T[] b);
/** Solve the linear equation A &times; X = B for matrices A.
* <p>The A matrix is implicit, it is provided by the underlying
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
FieldVector<T> solve(final FieldVector<T> b)
throws IllegalArgumentException, InvalidMatrixException;
FieldVector<T> solve(final FieldVector<T> b);
/** Solve the linear equation A &times; X = B for matrices A.
* <p>The A matrix is implicit, it is provided by the underlying
* decomposition algorithm.</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
* @throws org.apache.commons.math.exception.DimensionMismatchException
* if the matrices dimensions do not match.
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
FieldMatrix<T> solve(final FieldMatrix<T> b)
throws IllegalArgumentException, InvalidMatrixException;
FieldMatrix<T> solve(final FieldMatrix<T> b);
/**
* Check if the decomposed matrix is non-singular.
@ -78,9 +81,8 @@ public interface FieldDecompositionSolver<T extends FieldElement<T>> {
/** Get the inverse (or pseudo-inverse) of the decomposed matrix.
* @return inverse matrix
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws org.apache.commons.math.exception.SingularMatrixException
* if the decomposed matrix is singular.
*/
FieldMatrix<T> getInverse()
throws InvalidMatrixException;
FieldMatrix<T> getInverse();
}

View File

@ -344,8 +344,8 @@ public class FieldLUDecompositionImpl<T extends FieldElement<T>> implements Fiel
* <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
* @throws IllegalArgumentException if matrices dimensions don't match
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws DimensionMismatchException if the matrices dimensions do not match.
* @throws SingularMatrixException if the decomposed matrix is singular.
*/
public ArrayFieldVector<T> solve(ArrayFieldVector<T> b) {
return new ArrayFieldVector<T>(solve(b.getDataRef()), false);
@ -407,7 +407,7 @@ public class FieldLUDecompositionImpl<T extends FieldElement<T>> implements Fiel
}
/** {@inheritDoc} */
public FieldMatrix<T> getInverse() throws InvalidMatrixException {
public FieldMatrix<T> getInverse() {
final int m = pivot.length;
final T one = field.getOne();
FieldMatrix<T> identity = new Array2DRowFieldMatrix<T>(field, m, m);

View File

@ -1,68 +0,0 @@
/*
* 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.linear;
import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.exception.util.DummyLocalizable;
import org.apache.commons.math.exception.util.Localizable;
/**
* Thrown when a system attempts an operation on a matrix, and
* that matrix does not satisfy the preconditions for the
* aforementioned operation.
* @version $Revision$ $Date$
* @deprecated since 2.2. Please use the classes in the
* {@link org.apache.commons.math.exception} package.
*/
@Deprecated
public class InvalidMatrixException extends MathRuntimeException {
/** Serializable version identifier. */
private static final long serialVersionUID = -2068020346562029801L;
/**
* Construct an exception with the given message.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.0
*/
public InvalidMatrixException(final String pattern, final Object ... arguments) {
this(new DummyLocalizable(pattern), arguments);
}
/**
* Construct an exception with the given message.
* @param pattern format specifier
* @param arguments format arguments
* @since 2.2
*/
public InvalidMatrixException(final Localizable pattern, final Object ... arguments) {
super(pattern, arguments);
}
/**
* Construct an exception with the given message.
* @param cause the exception or error that caused this exception
* to be thrown.
* @since 2.0
*/
public InvalidMatrixException(final Throwable cause) {
super(cause);
}
}

View File

@ -54,11 +54,10 @@ public class LUDecompositionImpl implements LUDecomposition {
/**
* Calculates the LU-decomposition of the given matrix.
* @param matrix The matrix to decompose.
* @throws InvalidMatrixException if matrix is not square
* @param matrix Matrix to decompose.
* @throws NonSquareMatrixException if matrix is not square.
*/
public LUDecompositionImpl(RealMatrix matrix)
throws InvalidMatrixException {
public LUDecompositionImpl(RealMatrix matrix) {
this(matrix, DEFAULT_TOO_SMALL);
}
@ -333,7 +332,7 @@ public class LUDecompositionImpl implements LUDecomposition {
* @return a vector X such that A &times; X = B
* @throws DimensionMismatchException if the matrices dimensions
* do not match.
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws SingularMatrixException if decomposed matrix is singular.
*/
public ArrayRealVector solve(ArrayRealVector b) {
return new ArrayRealVector(solve(b.getDataRef()), false);
@ -394,7 +393,7 @@ public class LUDecompositionImpl implements LUDecomposition {
}
/** {@inheritDoc} */
public RealMatrix getInverse() throws InvalidMatrixException {
public RealMatrix getInverse() {
return solve(MatrixUtils.createRealIdentityMatrix(pivot.length));
}
}

View File

@ -331,8 +331,8 @@ public class QRDecompositionImpl implements QRDecomposition {
* <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 that minimizes the two norm of A &times; X - B
* @throws IllegalArgumentException if matrices dimensions don't match
* @throws InvalidMatrixException if decomposed matrix is singular
* @throws DimensionMismatchException if the matrices dimensions do not match.
* @throws SingularMatrixException if the decomposed matrix is singular.
*/
public ArrayRealVector solve(ArrayRealVector b) {
return new ArrayRealVector(solve(b.getDataRef()), false);

View File

@ -66,16 +66,9 @@ public class SingularValueDecompositionImpl implements
/**
* Calculates the compact Singular Value Decomposition of the given matrix.
* @param matrix
* The matrix to decompose.
* @exception InvalidMatrixException
* (wrapping a
* {@link org.apache.commons.math.ConvergenceException} if
* algorithm fails to converge
* @param matrix Matrix to decompose.
*/
public SingularValueDecompositionImpl(final RealMatrix matrix)
throws InvalidMatrixException {
public SingularValueDecompositionImpl(final RealMatrix matrix) {
m = matrix.getRowDimension();
n = matrix.getColumnDimension();
@ -154,14 +147,14 @@ public class SingularValueDecompositionImpl implements
}
/** {@inheritDoc} */
public RealMatrix getU() throws InvalidMatrixException {
public RealMatrix getU() {
// return the cached matrix
return cachedU;
}
/** {@inheritDoc} */
public RealMatrix getUT() throws InvalidMatrixException {
public RealMatrix getUT() {
if (cachedUt == null) {
cachedUt = getU().transpose();
@ -173,7 +166,7 @@ public class SingularValueDecompositionImpl implements
}
/** {@inheritDoc} */
public RealMatrix getS() throws InvalidMatrixException {
public RealMatrix getS() {
if (cachedS == null) {
@ -185,19 +178,19 @@ public class SingularValueDecompositionImpl implements
}
/** {@inheritDoc} */
public double[] getSingularValues() throws InvalidMatrixException {
public double[] getSingularValues() {
return singularValues.clone();
}
/** {@inheritDoc} */
public RealMatrix getV() throws InvalidMatrixException {
public RealMatrix getV() {
// return the cached matrix
return cachedV;
}
/** {@inheritDoc} */
public RealMatrix getVT() throws InvalidMatrixException {
public RealMatrix getVT() {
if (cachedVt == null) {
cachedVt = getV().transpose();
@ -240,12 +233,12 @@ public class SingularValueDecompositionImpl implements
}
/** {@inheritDoc} */
public double getNorm() throws InvalidMatrixException {
public double getNorm() {
return singularValues[0];
}
/** {@inheritDoc} */
public double getConditionNumber() throws InvalidMatrixException {
public double getConditionNumber() {
return singularValues[0] / singularValues[singularValues.length - 1];
}

View File

@ -1,32 +0,0 @@
/*
* 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.linear;
import junit.framework.TestCase;
/**
* @version $Revision$ $Date$
*/
public class InvalidMatrixExceptionTest extends TestCase {
public void testConstructorMessage(){
String msg = "message";
InvalidMatrixException ex = new InvalidMatrixException(msg);
assertEquals(msg, ex.getMessage());
}
}