I should also note that the reason why any correctness error has
not been seen in minus() is that it's basically not used - any time
I want to use something like that, I first check whether a new copy
is needed, or whether a mutating method can be allowed, and if
it can, I just do:

  mutatableOne.assign(otherVector, Functions.minus)

which does in-place subtraction without creating a new vector.

Similarly for plus, either of these work nicely:

  mutatableOne.assign(otherVector, Functions.plus)

or the shorthand

  otherVector.addTo(mutableOne)

  -jake

On Mon, Apr 19, 2010 at 9:52 AM, Sean Owen <sro...@gmail.com> wrote:

> On Mon, Apr 19, 2010 at 5:33 PM, Jake Mannix <jake.man...@gmail.com>
> wrote:
> > result.times(-1.0)
> > with
> > result.assign(Functions.negate)
>
> Cool, good one.
>
> > The efficiency points are twofold: number of nonzero elements, and
> > the impl: you don't want to iterate over a vector of any type while
> > continually calling setQuick() on a SequentialAccessSparseVector -
> > that is horribly inefficient, as it causes a binary search each time,
> > followed by a possible copy/shift of most of the index and value
> > arrays.
>
> ah yeah sure. So really it'd be easier to specialize the one where
> random access is slow. I can manage that.
>

Reply via email to