You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by md...@apache.org on 2003/06/25 03:39:36 UTC
cvs commit: jakarta-commons-sandbox/math/src/java/org/apache/commons/math/linear RealMatrix.java RealMatrixImpl.java
mdiggory 2003/06/24 18:39:36
Modified: math/src/test/org/apache/commons/math/linear
RealMatrixImplTest.java
math/src/java/org/apache/commons/math/linear RealMatrix.java
RealMatrixImpl.java
Log:
PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21005
Submitted by: phil@steitz.com
Revision Changes Path
1.2 +16 -2 jakarta-commons-sandbox/math/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
Index: RealMatrixImplTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/math/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RealMatrixImplTest.java 22 Jun 2003 03:57:57 -0000 1.1
+++ RealMatrixImplTest.java 25 Jun 2003 01:39:36 -0000 1.2
@@ -114,6 +114,8 @@
assertEquals("testData2 row dimension",m2.getRowDimension(),2);
assertEquals("testData2 column dimension",m2.getColumnDimension(),3);
assertTrue("testData2 is not square",!m2.isSquare());
+ RealMatrixImpl m3 = new RealMatrixImpl();
+ m3.setData(testData);
}
/** test copy functions */
@@ -251,7 +253,19 @@
fail("Expecting illegalArgumentException");
} catch (IllegalArgumentException ex) {
;
- }
+ }
+ try {
+ RealMatrix a = (new RealMatrixImpl(testData2)).solve(bs);
+ fail("Expecting illegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ ;
+ }
+ try {
+ (new RealMatrixImpl(testData2)).LUDecompose();
+ fail("Expecting illegalArgumentException");
+ } catch (IllegalArgumentException ex) {
+ ;
+ }
}
/** test determinant */
1.2 +2 -2 jakarta-commons-sandbox/math/src/java/org/apache/commons/math/linear/RealMatrix.java
Index: RealMatrix.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/linear/RealMatrix.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RealMatrix.java 22 Jun 2003 03:57:57 -0000 1.1
+++ RealMatrix.java 25 Jun 2003 01:39:36 -0000 1.2
@@ -276,7 +276,7 @@
* to solve
* @return matrix of solution vectors
* @throws IllegalArgumentException if rowDimension != row dimension of b
- * or this is singular
+ * or this is not square or singular
*/
RealMatrix solve(RealMatrix b) throws IllegalArgumentException;
}
1.2 +9 -1 jakarta-commons-sandbox/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
Index: RealMatrixImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/linear/RealMatrixImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RealMatrixImpl.java 22 Jun 2003 03:57:57 -0000 1.1
+++ RealMatrixImpl.java 25 Jun 2003 01:39:36 -0000 1.2
@@ -576,6 +576,10 @@
* do not match.
*/
public RealMatrix solve(RealMatrix b) throws IllegalArgumentException {
+ if (!this.isSquare()) {
+ throw new IllegalArgumentException
+ ("coefficient matrix is not square");
+ }
if (b.getRowDimension() != this.getRowDimension()) {
throw new IllegalArgumentException("Incorrect row dimension");
}
@@ -645,6 +649,10 @@
public void LUDecompose() throws IllegalArgumentException {
int nRows = this.getRowDimension();
int nCols = this.getColumnDimension();
+ if (nRows < nCols) {
+ throw new IllegalArgumentException
+ ("LU decomposition requires row dimension >= column dimension");
+ }
lu = this.getData();
// Initialize pivot array and parity
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org