Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -3,7 +3,7 @@ import std.stdio, std.typetuple, std.traits;
|
|||
T[][] elementwise(string op, T, U)(in T[][] A, in U B)
|
||||
@safe pure nothrow
|
||||
if (isNumeric!U || (isArray!U && isArray!(ForeachType!U) &&
|
||||
isNumeric!(ForeachType!(ForeachType!U)))) {
|
||||
isNumeric!(ForeachType!(ForeachType!U)))) {
|
||||
static if (!isNumeric!U)
|
||||
assert(A.length == B.length);
|
||||
if (!A.length)
|
||||
|
|
@ -22,13 +22,13 @@ if (isNumeric!U || (isArray!U && isArray!(ForeachType!U) &&
|
|||
}
|
||||
|
||||
void main() {
|
||||
/*immutable*/ const matrix = [[3, 5, 7],
|
||||
[1, 2, 3],
|
||||
[2, 4, 6]];
|
||||
enum scalar = 2;
|
||||
enum matFormat = "[%([%(%d, %)],\n %)]]\n";
|
||||
immutable matrix = [[3, 5, 7],
|
||||
[1, 2, 3],
|
||||
[2, 4, 6]];
|
||||
|
||||
foreach (op; TypeTuple!("+", "-", "*", "/", "^^")) {
|
||||
foreach (immutable op; TypeTuple!("+", "-", "*", "/", "^^")) {
|
||||
writeln(op, ":");
|
||||
writefln(matFormat, elementwise!op(matrix, scalar));
|
||||
writefln(matFormat, elementwise!op(matrix, matrix));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue