www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4874] New: std.numeric.dotProduct doesn't work with bigints

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc
        Depends on: 4872



With dmd 2.049beta this code compiles (but first see bug 4872 too):



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:



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));
}




-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4874


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4874


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au



That's the same issue as 4301. BigInt isn't yet const-correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4874




PDT ---
Assigning to Don.

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