commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: [Math] MATH-894
Date Thu, 15 Nov 2012 18:29:00 GMT
On Thu, Nov 15, 2012 at 10:04 AM, Phil Steitz <phil.steitz@gmail.com> wrote:

> Do you know how to do that with a primitive array?  Can you provide
> some sample code?
>

You don't.  See my next paragraph.

See the assign method in this class:

https://github.com/apache/mahout/blob/trunk/math/src/main/java/org/apache/mahout/math/VectorView.java





>
> Thanks for your help on this.
>
> Phil
> >
> > The Colt/Mahout approach is to define a view object which opaquely
> > remembers a reference to the original, an offset and a length.  Functions
> > and other arguments can be passed to this view object which operates on a
> > subset of the original contents by calling the function.  Performance is
> > actually quite good.  The JIT seems to in-line the view object access to
> > the underlying object and also in-lines evaluation of the function so
> that
> > the actual code that is executed is pretty much what you would write in
> C,
> > but you don't have to worry as much since the pattern of access is more
> > controlled.
> >
> > For completeness, this is essentially what java.nio does with the *Buffer
> > classes as well.  You can wrap an array and then you can ask for slices
> out
> > of that array while retaining the reference semantics.
> >
>

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