|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.bugs - [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: nobody puremagic.com ReportedBy: baryluk smp.if.uj.edu.pl --- Comment #0 from Witold Baryluk <baryluk 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: ------- Jan 31 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3760 --- Comment #1 from Don <clugdbug yahoo.com.au> 2010-02-04 05:16:00 PST ---Rationale for this is that modern processors have SSE instructions which Feb 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3760 --- Comment #2 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2010-02-04 15:54:00 PST --- (In reply to comment #1)Rationale for this is that modern processors have SSE instructions which Feb 04 2010
|