commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles Sadowski <gil...@harfang.homelinux.org>
Subject Re: [Math] New method: "addToEntry" in "RealVector"
Date Thu, 18 Aug 2011 17:47:24 GMT
On Thu, Aug 18, 2011 at 08:42:53AM -0700, Ted Dunning wrote:
> I think that an anonymous inner class will do exactly this.
> 
> I use this all the time to add random numbers to  matrix  (in Mahout-ish
> dialect)
> 
> m.assign(new DoubleFunction() {
>     double eval(double x) { return x + rand.nextGaussian(); }
> })
> 
> Very handy.

Not really if I have to create several such functions that take parameters
of various type, and certainly not if I'd have to define them inline
everywhere there is an "addToEntry".

Not even saying that the code will become unreadable. One instance where
I'd perform "addToEntry", the "value" below is computed from a matrix entry
whose column index is "i". How do you retrieve that from the prototype
above?


Gilles

> On Thu, Aug 18, 2011 at 4:13 AM, Gilles Sadowski <
> gilles@harfang.homelinux.org> wrote:
> 
> >
> > However this is not what I need. The purpose is to have a shortcut for
> > ---CUT---
> > for (int i = 0; i < n; i++) {
> >  final double value = <...>; // Not a constant.
> >  v.setEntry(i, v.getEntry(i) + value);
> > }
> > ---CUT---
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message