turicum a écrit :
> Hi everybody!
>
> The following code throws an exception if x > 160
>
> package test;
> import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
> public class Test {
> public static void main(String[] strings) {
> int x = 161; // 160 works
> DescriptiveStatistics descriptiveStatistics = new
> DescriptiveStatistics(100);
> for (int i = 0; i < x; i++) descriptiveStatistics.addValue(1.2);
> descriptiveStatistics.clear();
> descriptiveStatistics.addValue(1.2);
> }
> }
>
>
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 32
> at
> org.apache.commons.math.util.ResizableDoubleArray.addElement(ResizableDoubleArray.java:255)
> at
> org.apache.commons.math.stat.descriptive.DescriptiveStatistics.addValue(DescriptiveStatistics.java:168)
> at test.Test.main(Test.java:11)
>
> Am I missing anything?
This is a bug. The clear() method in ResizableDoubleArray did not reset
startIndex to 0.
I have fixed it in the subversion repository.
thanks for the report,
Luc
> Thanks!
> Alex
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]