commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Brisard <>
Subject [math] A bug in OpenMathRealVector
Date Sat, 13 Aug 2011 13:19:03 GMT
while testing the implementation of UnmodifiableRealVector which has
previously been discussed on Commons Developers, I came across the
following problem. The simple code below

import org.apache.commons.math.linear.OpenMapRealVector;
import org.apache.commons.math.linear.RealVector;

public class DemoBugOpenMapRealVector {
    public static void main(String[] args) {
        final RealVector u = new OpenMapRealVector(3, 1E-6);
        u.setEntry(0, 1.);
        u.setEntry(1, 0.);
        u.setEntry(2, 2.);
        final RealVector v = new OpenMapRealVector(3, 1E-6);
        v.setEntry(0, 0.);
        v.setEntry(1, 3.);
        v.setEntry(2, 0.);


Raises an exception
Exception in thread "main"
org.apache.commons.math.MathRuntimeException$6: map has been modified
while iterating
	at org.apache.commons.math.MathRuntimeException.createConcurrentModificationException(
	at org.apache.commons.math.util.OpenIntToDoubleHashMap$Iterator.advance(
	at org.apache.commons.math.linear.OpenMapRealVector.ebeMultiply(
	at DemoBugOpenMapRealVector.main(

I think I misunderstood the use of OpenMapRealVector. Could you help me?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message