[Issue 4810] New: dotProduct problem with ints

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 4 06:19:01 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4810

           Summary: dotProduct problem with ints
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-09-04 06:18:42 PDT ---
With DMD 2.048 this dotProduct doesn't work:

import std.numeric;
void main() {
    assert(dotProduct([1, 3, -5], [4, -2, -1]) == 3);
}



This is the first part of dotProduct:

Unqual!(CommonType!(F1, F2))
dotProduct(F1, F2)(in F1[] avector, in F2[] bvector)
{
    immutable n = avector.length;
    assert(n == bvector.length);
    auto avec = avector.ptr, bvec = bvector.ptr;
    typeof(return) sum0 = 0.0, sum1 = 0.0;


To fix it replace this:
typeof(return) sum0 = 0.0, sum1 = 0.0;

With:
typeof(return) sum0 = 0, sum1 = 0;

-- 
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