commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1348396 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
Date Sat, 09 Jun 2012 13:11:38 GMT
Author: celestin
Date: Sat Jun  9 13:11:38 2012
New Revision: 1348396

URL: http://svn.apache.org/viewvc?rev=1348396&view=rev
Log:
MATH-802.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java?rev=1348396&r1=1348395&r2=1348396&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/RealVector.java
Sat Jun  9 13:11:38 2012
@@ -248,12 +248,12 @@ public abstract class RealVector {
      * if {@code v} is not the same size as this vector.
      */
     public RealVector subtract(RealVector v) {
-        RealVector result = v.copy();
+        RealVector result = v.mapMultiply(-1d);
         Iterator<Entry> it = sparseIterator();
         while (it.hasNext()) {
             final Entry e = it.next();
             final int index = e.getIndex();
-            result.setEntry(index, e.getValue() - result.getEntry(index));
+            result.setEntry(index, e.getValue() + result.getEntry(index));
         }
         return result;
     }



Mime
View raw message