Ah, good point, that's much better.  Although it's still risky: make sure
you special
case Plus, PlusMult, Mult, Div...  I wonder if it's worth it to do a special
case like
this:

  Vector assign(DoubleFunction f) {
    Iterator<Element> it = f.apply(0) == 0
      ? iterateNonZero()
      : iterate();
    // use whichever iterator you got to assign
  }

So if the function would send 0 => 0, go sparsely, else go densely.

  -jake


On Tue, Sep 6, 2011 at 8:24 AM, Ted Dunning <[email protected]> wrote:

> Shouldn't AbstractVector specially detect the plus case and iterate only on
> non-zeros?
>
> On Tue, Sep 6, 2011 at 9:59 AM, Jake Mannix <[email protected]> wrote:
>
> > Why not just override assign() in the sparse subclasses?
> >
> > On Sep 6, 2011 5:28 AM, "Sebastian Schelter" <[email protected]> wrote:
> >
> > The replacement of addTo() with .assign(..., Functions.PLUS) might cause
> > havoc in sparse vectors with dimension Integer.MAX_VALUE as
> > AbstractVector assign() will run from 0 to Integer.MAX_VALUE.
> >
> > Should we reintroduce it then?
> >
> > --sebastian
> >
>

Reply via email to