Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 52085 invoked from network); 17 Aug 2010 16:20:28 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Aug 2010 16:20:28 -0000 Received: (qmail 84476 invoked by uid 500); 17 Aug 2010 16:20:27 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 84269 invoked by uid 500); 17 Aug 2010 16:20:26 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 84261 invoked by uid 99); 17 Aug 2010 16:20:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Aug 2010 16:20:26 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of raviv.granot@gmail.com designates 209.85.216.43 as permitted sender) Received: from [209.85.216.43] (HELO mail-qw0-f43.google.com) (209.85.216.43) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Aug 2010 16:20:20 +0000 Received: by qwd6 with SMTP id 6so6107794qwd.30 for ; Tue, 17 Aug 2010 09:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=3M5xLK/l3FqZ8WE8yy8nEVC8+z7Xssthj3UmJ5zpXxQ=; b=O3TSUckZ1HBn2WVHO5oZH//EfkXBPc8xRQBjLyedz1RIl4d7q+Wq1IiYvXlmJyTiVY nas55h2kKqKrv47iG99TAgWuJymauyzijJVCul8FYHwprv0sZVuB8XzaIYm7HFZuEafH Ef38VDLfNGF8delxenU+t+uTtTzISKDHonsCY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Ol3rQ+jTZuWq53oz/1oWmrG3XZiofVrz6aCz/TcNLhzyb2akMzw6/qeEUFzg4+wr7V kWjbQkKleFnPS/qzY8DoeKsjKElQAMZEn4kILIf39GDwEI8JnSW65ucBRkJfsxpjV0FT 8eeDJTxWPQplz/8O+rt66noDX45bf6bhczgLE= MIME-Version: 1.0 Received: by 10.229.235.65 with SMTP id kf1mr4990342qcb.42.1282061999230; Tue, 17 Aug 2010 09:19:59 -0700 (PDT) Received: by 10.229.231.5 with HTTP; Tue, 17 Aug 2010 09:19:58 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 Aug 2010 11:19:58 -0500 Message-ID: Subject: Re: [MATH] Sparse Matrix - visiting all entries From: Raviv Granot To: Commons Users List Content-Type: multipart/alternative; boundary=0016e64bdf540b4d7d048e07528e --0016e64bdf540b4d7d048e07528e Content-Type: text/plain; charset=ISO-8859-1 All, I think I made a mistake in my last question. I now see that sparseIteration() iterates over RealVector.Entry that contains getIndex() and getValue() methods, which solve my problem. Sorry for the trouble, Thanks! On Tue, Aug 17, 2010 at 11:13 AM, Raviv Granot wrote: > Thanks for the info. I will definitely check the Mahout option. > > One more comment about the commons.math library. I noticed that the > implementation for > Sparse Vecotr (OpenMapRealVecotr) provides a method "sparseIteration()", > which > is what I'm looking for in the Matrix implementation. Changing my design a > little bit, > I can work with a map/list of sparse vectors instead of a matrix. However, > it seems there's > still one important functionality that is missing. How can you iterate over > the non-zero > indices efficiently? sparseIteration() iterates over the elements, but can > you know which > index each element belongs to? > I know I can use the "getData()" method to get a double array where every > index maps to an element, but then again, it's the same problem of being > very inefficient. > > Any ideas would be very appreciated. > > Thanks! > > On Tue, Aug 17, 2010 at 9:24 AM, Ted Dunning wrote: > >> Apache Mahout also has a matrix package with sparse matrix support. In >> particular, iterateNonZero is supported and there are multiple sparse >> vector/matrix formats that provide different performance trade-offs. >> >> Our purpose is not necessarily to be a general purpose math package and >> the >> system is still somewhat in flux so there is a good chance that Mahout >> Math >> isn't what you need. On the other hand, because Mahout is much less >> mature, >> changes are much easier to push through. Commons Math has a fairly strict >> back compatibility policy that means that changes such as you want can >> take >> a very long time even for trunk. >> >> On Tue, Aug 17, 2010 at 5:49 AM, Raviv Granot >> wrote: >> >> > Hi, >> > I see 2 implementations of sparse matrix in the math.commons.linear >> > library. >> > >> > 1. OpenMapRealMatrix >> > 2. SparseFieldMatrix >> > Both are documented as "Sparse matrix implementation based on an open >> > addressed map". >> > Does anyone know what are the differences between the two? also, which >> > method should I use to iterate only >> > over the non zero elements? it seems that the WalkInRawOrder method runs >> > over the entire row-length x col-length, >> > the same as for RealMatrix. >> > >> > Thanks in advance! >> > >> > Raviv >> > >> > > --0016e64bdf540b4d7d048e07528e--