mahout-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: Problem with method Plus in the Vector class
Date Wed, 20 Jul 2011 15:42:24 GMT
You constructed the first vector with a dimension of 1.  It looks like you
constructed the second one with a larger dimension of 2.

When you offset a sparse vector, all of the zeros become non-zero and the
vector becomes dense.  This results in a bunch of cells being created.

On Wed, Jul 20, 2011 at 6:28 AM, marco turchi <marco.turchi@gmail.com>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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message