[Issue 15081] New: [Vector Extensions]
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Sep 17 13:24:28 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15081
Issue ID: 15081
Summary: [Vector Extensions]
Product: D
Version: D2
Hardware: x86_64
URL: http://dlang.org/
OS: Windows
Status: NEW
Severity: minor
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: 00pebuis at bsu.edu
void axpy (float[] x, const float[] y, const float a) {
x[] = a*x[] + y[];
}
void axpy1 (float[] x, const float[] y, const float a) {
x[] *= a;
x[] += y[];
}
void axpy2(float[] x, const float[] y, const float a) {
size_t index = 0;
for (;index < x.length; index++) {
x[index] = a * x[index] + y[index];
}
}
axpy1 and axpy2 compile fine, but axpy only compiles if I omit the const on the
"y" parameter.
Error message is:
Error: invalid array operation cast(const(float)[])(a * x[]) + y[] (possible
missing [])
Not clear to me why a*x[] is being cast to const or where the extra [] could be
inserted. Seems like maybe underlying implementation doesn't support a binary
operator between scalars and vectors, only an opAssign when one is const and
the other isn't.
It appears the scalar multiply results in a const float[] and then
--
More information about the Digitalmars-d-bugs
mailing list