www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15081] New: [Vector Extensions]

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 puremagic.com
          Reporter: 00pebuis 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

--
Sep 17 2015