commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject Re: [math] RealVector Fluid API vs. Java 8 Arrays.setAll
Date Mon, 04 Jan 2016 02:41:45 GMT
On Sun, 3 Jan 2016 19:41:46 -0600, Ole Ersoy wrote:
> Hi,
>
> RealVector supports the following type of fluid API:
>
> |RealVectorresult
> =v.mapAddToSelf(3.4).mapToSelf(newTan()).mapToSelf(newPower(2.3));
> IIUC each time we call v.mapXXX an iteration happens, so with the
> above expression we loop 3 times. With Java 8 Arrays.setAll we can do
> the same thing like this (Using static imports): ||Arrays.setAll(arr,
> i -> pow(tan(arr[i] + 3.4), 2.3)); So that seems like a pretty good
> fit for ArrayRealVector. WDYT? I have not looked at SparseRealVector
> yet... Cheers, Ole |
>
> ||

[Above message is a tad mangled.]

result = v.mapToSelf(FunctionUtils.compose(new Power(2.3),
                                            new Tan(),
                                            FunctionUtils.combine(new 
Add(),
                                                                  new 
Constant(3.4),
                                                                  new 
Identity())));
Feasible with one loop in CM: yes.
Less compact than the above syntax: yes.
Less efficient than the Java8 construct: I'd guess so...


Regards,
Gilles


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


Mime
View raw message