Return-Path: X-Original-To: apmail-mahout-user-archive@www.apache.org Delivered-To: apmail-mahout-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C4A87659 for ; Wed, 20 Jul 2011 15:43:13 +0000 (UTC) Received: (qmail 30065 invoked by uid 500); 20 Jul 2011 15:43:12 -0000 Delivered-To: apmail-mahout-user-archive@mahout.apache.org Received: (qmail 29999 invoked by uid 500); 20 Jul 2011 15:43:11 -0000 Mailing-List: contact user-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@mahout.apache.org Delivered-To: mailing list user@mahout.apache.org Received: (qmail 29991 invoked by uid 99); 20 Jul 2011 15:43:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 15:43:11 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.216.177 as permitted sender) Received: from [209.85.216.177] (HELO mail-qy0-f177.google.com) (209.85.216.177) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2011 15:43:04 +0000 Received: by qyk7 with SMTP id 7so383514qyk.1 for ; Wed, 20 Jul 2011 08:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gVPTKkCS/eo1t7ctxCbhFCxE0NLTDFa+8EID8cEIGJ0=; b=HWH3HDX2tny1BL3uSrSlAt3UiKXF0B4fah8x0g0OneTuuEyH5jTZJGdx+IanX30noA 6mkJBFqI+PP7VFf+qJ9IysiYJhNlERfNzVi7yrYyH/LP9JOj8lACa5ix5Sgd1DQdWZ3G 5sI8KdecKrF5dQBPclz33ztZen0uZBn8jdV+k= Received: by 10.224.100.201 with SMTP id z9mr6722680qan.386.1311176564125; Wed, 20 Jul 2011 08:42:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.54.15 with HTTP; Wed, 20 Jul 2011 08:42:24 -0700 (PDT) In-Reply-To: References: From: Ted Dunning Date: Wed, 20 Jul 2011 08:42:24 -0700 Message-ID: Subject: Re: Problem with method Plus in the Vector class To: user@mahout.apache.org Content-Type: multipart/alternative; boundary=20cf3074b2c257af5d04a882155a --20cf3074b2c257af5d04a882155a Content-Type: text/plain; charset=UTF-8 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 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 > --20cf3074b2c257af5d04a882155a--