[Issue 3377] New: [tdpl] static foreach should be implemented
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 8 12:12:30 PDT 2009
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 at puremagic.com
ReportedBy: andrei at metalanguage.com
--- Comment #0 from Andrei Alexandrescu <andrei at metalanguage.com> 2009-10-08 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: -------
More information about the Digitalmars-d-bugs
mailing list