Matrix multiplication: Difference between revisions
Content added Content deleted
(Add a C# matrix class with multiply operator) |
(Updated D code) |
||
Line 776:
=={{header|D}}==
<lang d>import std.stdio, std.string, std.conv, std.numeric
std.array, std.algorithm;
return !canFind!((r){ return r.length != M[0].length; })(M);
return false;▼
}
T[][] matrixMul(T)(
}
}
string prettyPrint(T)(
▲ return "[" ~ result.join(",\n ") ~ "]";
}
Line 812 ⟶ 807:
enum b = [[-3, -8, 3,], [-2, 1, 4]];
writeln("A =
writeln("
writeln("
}</lang>
Output:
<pre>A =
[[1, 2],
[3, 4],
[3, 6]]
B =
[[-3, -8, 3],
[-2, 1, 4]]
A * B =
[[-7, -6, 11],
[-17, -20, 25],
|