digitalmars.D.bugs - [Issue 3377] New: [tdpl] static foreach should be implemented
- d-bugmail puremagic.com (35/35) Oct 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3377
- d-bugmail puremagic.com (31/31) Oct 08 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3377
- Christopher Wright (3/20) Oct 08 2009 downs, you are a genius. You can create code that is both elegant and
- d-bugmail puremagic.com (13/13) Nov 18 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3377
http://d.puremagic.com/issues/show_bug.cgi?id=3377 Summary: [tdpl] static foreach should be implemented Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrei metalanguage.com 12:12:29 PDT --- This should compile: import std.contracts; double unrolledDotProduct(double[] a, double[] b) { enum branches = 4; enforce(a.length == b.length); double result = 0; auto n = (a.length / branches) * branches; double temp[branches]; for (size_t i = 0; i != n; i += branches) { static foreach (j ; 0 .. branches) { temp[j] = a[i + j] * b[i + j]; } result += inline_sum(temp); } foreach (j; n .. a.length) { result += a[j] * b[j]; } return result; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3377 downs <default_357-line yahoo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |default_357-line yahoo.de --- This does compile (on 1.0): template Repeat(T, int I) { static if (!I) alias Tuple!() Repeat; else alias Tuple!(T, Repeat!(T, I - 1)) Repeat; } double unrolledDotProduct(double[] a, double[] b) { const branches = 4; assert(a.length == b.length); double result = 0; auto n = (a.length / branches) * branches; double temp[branches]; for (size_t i = 0; i != n; i += branches) { foreach (j, BOGUS; Repeat!(void, branches)) { temp[j] = a[i + j] * b[i + j]; } result += inline_sum(temp); } foreach (j; n .. a.length) { result += a[j] * b[j]; } return result; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 08 2009
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=3377 downs <default_357-line yahoo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |default_357-line yahoo.de --- This does compile (on 1.0): template Repeat(T, int I) { static if (!I) alias Tuple!() Repeat; else alias Tuple!(T, Repeat!(T, I - 1)) Repeat; }downs, you are a genius. You can create code that is both elegant and dreadful. You make the world a more interesting place.
Oct 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3377 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |WONTFIX 13:38:27 PST --- Many problems have come up with the design of this, so will mark as won't implement until a thorough design is developed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 18 2009