Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -10,10 +10,10 @@ in {
|
|||
foreach (const row; a)
|
||||
assert(row.length == a[0].length);
|
||||
} body {
|
||||
auto r = iota(cast()a.length);
|
||||
auto r = a.length.iota;
|
||||
T tot = 0;
|
||||
foreach (sigma; permutations(r.array()))
|
||||
tot += r.map!(i => a[i][sigma[i]])().prod();
|
||||
foreach (sigma; r.array.permutations)
|
||||
tot += r.map!(i => a[i][sigma[i]]).prod;
|
||||
return tot;
|
||||
}
|
||||
|
||||
|
|
@ -23,13 +23,13 @@ in {
|
|||
assert(row.length == a[0].length);
|
||||
} body {
|
||||
immutable n = a.length;
|
||||
auto r = iota(n);
|
||||
auto r = n.iota;
|
||||
T tot = 0;
|
||||
//foreach (sigma, sign; spermutations(n)) {
|
||||
foreach (sigma_sign; spermutations(n)) {
|
||||
//foreach (sigma, sign; n.spermutations) {
|
||||
foreach (sigma_sign; n.spermutations) {
|
||||
const sigma = sigma_sign[0];
|
||||
immutable sign = sigma_sign[1];
|
||||
tot += sign * r.map!(i => a[i][sigma[i]])().prod();
|
||||
tot += sign * r.map!(i => a[i][sigma[i]]).prod;
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
|
|
@ -37,21 +37,21 @@ in {
|
|||
void main() {
|
||||
import std.stdio;
|
||||
|
||||
foreach (const a; [[[1, 2],
|
||||
[3, 4]],
|
||||
foreach (/*immutable*/ const a; [[[1, 2],
|
||||
[3, 4]],
|
||||
|
||||
[[1, 2, 3, 4],
|
||||
[4, 5, 6, 7],
|
||||
[7, 8, 9, 10],
|
||||
[10, 11, 12, 13]],
|
||||
[[1, 2, 3, 4],
|
||||
[4, 5, 6, 7],
|
||||
[7, 8, 9, 10],
|
||||
[10, 11, 12, 13]],
|
||||
|
||||
[[ 0, 1, 2, 3, 4],
|
||||
[ 5, 6, 7, 8, 9],
|
||||
[10, 11, 12, 13, 14],
|
||||
[15, 16, 17, 18, 19],
|
||||
[20, 21, 22, 23, 24]]]) {
|
||||
[[ 0, 1, 2, 3, 4],
|
||||
[ 5, 6, 7, 8, 9],
|
||||
[10, 11, 12, 13, 14],
|
||||
[15, 16, 17, 18, 19],
|
||||
[20, 21, 22, 23, 24]]]) {
|
||||
writefln("[%([%(%2s, %)],\n %)]]", a);
|
||||
writefln("Permanent: %s, determinant: %s\n",
|
||||
permanent(a), determinant(a));
|
||||
a.permanent, a.determinant);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue