Going waaay back to the original question -- I can't reproduce this in the
latest code.
The result ought to be "{}" since RandomAccessSparseVector will only print
entries that have a value set and are not defaulted to 0.0. And it's smart
enough in this case to remove the entry you have set since its value goes
back to 0.0.
But, the output is "{". There's a bug in the toString() method, and I would
not be surprised if it's my fat fingers that made it. I will correct the
method.
Sean
On Wed, Jul 20, 2011 at 2:28 PM, marco turchi <[email protected]>wrote:
> Dear All,
> I have a strange behaviour when I use the method Plus for Vector.
>
> I have a RandomAccessSparseVector vector, if I add a positive number, I got
> a new Vector where each element is the sum of the old value plus the
> positive number. While if I add a negative number, the new vector has 1
> more
> entry:
>
>
> RandomAccessSparseVector distV = new RandomAccessSparseVector(1);
> distV.setQuick(0,1);
> double mean = 1;
> RandomAccessSparseVector app =
> (RandomAccessSparseVector)(distV.plus(mean));
>
> the output is
> {0:2.0}
>
> if I have
> double mean = -1;
> RandomAccessSparseVector app =
> (RandomAccessSparseVector)(distV.plus(mean));
>
> the output is
> {1:1.0,0:-1.0}
>
> For sure I'm doing something wrong. Do you have any ideas where the problem
> is?
>
> Thanks a lot in advance
> Marco
>