[Issue 3760] New: Allow std.math pure function to be used in array operations.

`http://d.puremagic.com/issues/show_bug.cgi?id=3760`
```
Summary: Allow std.math pure function to be used in array
operations.
Product: D
Version: 2.041
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bary...@smp.if.uj.edu.pl

--- Comment #0 from Witold Baryluk <bary...@smp.if.uj.edu.pl> 2010-01-31
10:22:37 PST ---
It would be good to have possibility to use something like:
a[] = sin(b[]);

To perform sin function on each element of b.

Or more complicated formulars, like:
a[] += sin(a[] * b[] + 0.1*x) - x*a[];

I propose that such expression be supported for all relevant operations in
std.math (cos, sin, tan, exp, log, ...).

I also propose to have property "@arrayoperation" for any custom pure function
of T f(T x) pure. which will equivalent to implicitly implementing:

T[] f(T[] x) pure nothrow {
T[] r = new T[x.length];
foreach (i, ref y; r) { y = f(x[i]); }
return r;
}

which will also be used automatically in array operations expressions and
called automatically by compiler.

There is also need to think about two and more argument functions in std.math,
like pow. For such functions (also pure) i think they should be implemented as

T[] f(T[] a, T[] b) pure nothrow {
T[] r = new T[x.length];
foreach (i, ref y; r) { y = f(a[i],b[i]); }
return r;
}

Of course temporary array r will not be created if f() will be part of array
operation.

Rationale for this is that modern processors have SSE instructions which could
perform up to 4 mathematial operations in parallel (like sin, cos, exp, log,
pow). And one of the reason for array operations is possibility to implement
them this (efficient) way.

--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
```
• [Issue 3760] New: Allow std.math pure function to be used in arr... d-bugmail