You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/06/17 21:09:37 UTC
svn commit: r668798 - in /commons/proper/math/branches/MATH_2_0/src:
java/org/apache/commons/math/linear/ site/xdoc/
test/org/apache/commons/math/linear/
Author: luc
Date: Tue Jun 17 12:09:36 2008
New Revision: 668798
URL: http://svn.apache.org/viewvc?rev=668798&view=rev
Log:
fixed dimension error in operate method for RealMatrixImpl and BigMatrixImpl
JIRA: MATH-209
Modified:
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java?rev=668798&r1=668797&r2=668798&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/BigMatrixImpl.java Tue Jun 17 12:09:36 2008
@@ -988,7 +988,7 @@
}
final int nRows = this.getRowDimension();
final int nCols = this.getColumnDimension();
- final BigDecimal[] out = new BigDecimal[v.length];
+ final BigDecimal[] out = new BigDecimal[nRows];
for (int row = 0; row < nRows; row++) {
BigDecimal sum = ZERO;
for (int i = 0; i < nCols; i++) {
Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java?rev=668798&r1=668797&r2=668798&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/linear/RealMatrixImpl.java Tue Jun 17 12:09:36 2008
@@ -776,7 +776,7 @@
if (v.length != nCols) {
throw new IllegalArgumentException("vector has wrong length");
}
- final double[] out = new double[v.length];
+ final double[] out = new double[nRows];
for (int row = 0; row < nRows; row++) {
final double[] dataRow = data[row];
double sum = 0;
Modified: commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml?rev=668798&r1=668797&r2=668798&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/branches/MATH_2_0/src/site/xdoc/changes.xml Tue Jun 17 12:09:36 2008
@@ -39,6 +39,10 @@
</properties>
<body>
<release version="2.0" date="TBD" description="TBD">
+ <action dev="luc" type="fix" issue="MATH-209" due-to="Thomas Chust">
+ Fixed dimension error on output vector for the operate method
+ in RealMatrixImpl and BigMatrixImpl classes.
+ </action>
<action dev="luc" type="update">
The FirstOrderDifferentialEquations and FirstOrderIntegrator
interfaces now extends Serializable, allowing integrators and
Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java?rev=668798&r1=668797&r2=668798&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/BigMatrixImplTest.java Tue Jun 17 12:09:36 2008
@@ -435,6 +435,20 @@
;
}
}
+
+ /** test issue MATH-209 */
+ public void testMath209() {
+ BigMatrix a = new BigMatrixImpl(new BigDecimal[][] {
+ { new BigDecimal(1), new BigDecimal(2) },
+ { new BigDecimal(3), new BigDecimal(4) },
+ { new BigDecimal(5), new BigDecimal(6) }
+ }, false);
+ BigDecimal[] b = a.operate(new BigDecimal[] { new BigDecimal(1), new BigDecimal(1) });
+ assertEquals(a.getRowDimension(), b.length);
+ assertEquals( 3.0, b[0].doubleValue(), 1.0e-12);
+ assertEquals( 7.0, b[1].doubleValue(), 1.0e-12);
+ assertEquals(11.0, b[2].doubleValue(), 1.0e-12);
+ }
/** test transpose */
public void testTranspose() {
Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=668798&r1=668797&r2=668798&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/linear/RealMatrixImplTest.java Tue Jun 17 12:09:36 2008
@@ -342,6 +342,18 @@
;
}
}
+
+ /** test issue MATH-209 */
+ public void testMath209() {
+ RealMatrix a = new RealMatrixImpl(new double[][] {
+ { 1, 2 }, { 3, 4 }, { 5, 6 }
+ }, false);
+ double[] b = a.operate(new double[] { 1, 1 });
+ assertEquals(a.getRowDimension(), b.length);
+ assertEquals( 3.0, b[0], 1.0e-12);
+ assertEquals( 7.0, b[1], 1.0e-12);
+ assertEquals(11.0, b[2], 1.0e-12);
+ }
/** test transpose */
public void testTranspose() {