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 <raviv.granot@gmail.com>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 nonzero
> 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 <ted.dunning@gmail.com>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 tradeoffs.
>>
>> 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 <raviv.granot@gmail.com>
>> 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 rowlength x collength,
>> > the same as for RealMatrix.
>> >
>> > Thanks in advance!
>> >
>> > Raviv
>> >
>>
>
>
