hama-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yexi Jiang <yexiji...@gmail.com>
Subject Re: Implementation of DoubleVector/DenseDoubleVector/SparseDoubleVector
Date Mon, 03 Mar 2014 15:50:53 GMT
> I think SparseDoubleVector can be represented by index/value pairs.
> And, toArray can be implemented like:

> public double[] toArray() {
>  double[] arr = new double[size];
> for(Element e : vector) {
>    arr[e.getIndex()] = e.getValue();
>  }
>}


The above piece of code would still waste a lot of space, supposing the
dimension (size) is 10^6 and only a couple of entries are set. This piece
of code would still return an array with one million entires.

If we do not care about the space cost, this method is fine.





2014-03-03 0:44 GMT-05:00 Edward J. Yoon <edwardyoon@apache.org>:

> > 4. Is the toArray method available for SparseDoubleVector? In my opinion,
> > it is better not to do that.
>
> I think SparseDoubleVector can be represented by index/value pairs.
> And, toArray can be implemented like:
>
> public double[] toArray() {
>   double[] arr = new double[size];
>   for(Element e : vector) {
>     arr[e.getIndex()] = e.getValue();
>   }
> }
>
> For bit vector, java.util.BitSet can be used.
>
> On Tue, Feb 25, 2014 at 6:14 AM, Yexi Jiang <yxjiang@apache.org> wrote:
> > Hi, All,
> >
> > I am currently working on the SparseDoubleVector (HAMA-863) and found
> some
> > unclear places about the vector implementation.
> >
> > 1. What is the definition for a vector? According to the implementation,
> it
> > is implemented as elementwise sqrt. In such a case, problem will occur if
> > the one of the entry is negative.
> >
> > 2. Most of the operators are conducted on a copy of the current object.
> Do
> > we also need to provide a set of operators that directly modify the
> current
> > object itself? e.g. addOriginal, subtractOriginal, etc.
> >
> > 3. When a DenseDoubleVector operates with a SparseDoubleVector, what will
> > be the concrete type of the result object? A simple implementation is to
> > always return a SparseDoubleVector, even if it is dense. A complex
> > implementation is we maintain a sparsity ratio (the ratio of non-default
> > entries), if the ratio exceed a threshold, a DenseDoubleVector will be
> > returned.
> >
> > 4. Is the toArray method available for SparseDoubleVector? In my opinion,
> > it is better not to do that.
> >
> >
> > Regards,
> > Yexi
>
>
>
> --
> Edward J. Yoon (@eddieyoon)
> Chief Executive Officer
> DataSayer, Inc.
>



-- 
------
Yexi Jiang,
ECS 251,  yjian004@cs.fiu.edu
School of Computer and Information Science,
Florida International University
Homepage: http://users.cis.fiu.edu/~yjian004/

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