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

           Summary: std.numeric.dotProduct doesn't work with bigints
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc
        Depends on: 4872


--- Comment #0 from bearophile_h...@eml.cc 2010-09-15 14:17:17 PDT ---
With dmd 2.049beta this code compiles (but first see bug 4872 too):


// program #1
import std.bigint;
T dotProduct2(T)(/*in*/ T[] a1, /*in*/ T[] a2) {
    assert(a1.length == a2.length);
    T total = 0;
    foreach (i; 0 .. a1.length)
        total += a1[i] * a2[i];
    return total;
}
void main() {
    BigInt[] a1 = [BigInt(1), BigInt(3), BigInt(-5)];
    BigInt[] a2 = [BigInt(4), BigInt(-2), BigInt(-1)];
    BigInt r = dotProduct2(a1, a2);
}



But the std.numeric.dotProduct() can't be used with bigints:


// program #2
import std.numeric, std.bigint;
void main() {
    BigInt[] a1 = [BigInt(1), BigInt(3), BigInt(-5)];
    BigInt[] a2 = [BigInt(4), BigInt(-2), BigInt(-1)];
    assert(dotProduct(a1, a2) == BigInt(3));
}


If in program #1 arguments are "in" it doesn't compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to