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] New method: "addToEntry" in "RealVector"
Date Thu, 18 Aug 2011 15:42:53 GMT
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.

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---
>

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