Conjugate transpose: Difference between revisions

Content added Content deleted
(Updated D entry)
Line 325: Line 325:
/// some bits of mantissa.
/// some bits of mantissa.
bool areEqual(T)(in Complex!T[][][] matrices, in size_t nBits=20)
bool areEqual(T)(in Complex!T[][][] matrices, in size_t nBits=20)
/*pure nothrow*/ {
pure nothrow {
static bool allSame(U)(in U[] v) pure nothrow {
static bool allSame(U)(in U[] v) pure nothrow {
return v[1 .. $].all!(c => c == v[0]);
return v[1 .. $].all!(c => c == v[0]);
Line 336: Line 336:
}
}


/*immutable*/ const x = matrices.map!(m => m.length).array;
immutable x = matrices.map!(m => m.length).array;
if (!allSame(x))
if (!allSame(x))
return false;
return false;
/*immutable*/ const y = matrices.map!(m => m[0].length).array;
immutable y = matrices.map!(m => m[0].length).array;
if (!allSame(y))
if (!allSame(y))
return false;
return false;
Line 350: Line 350:


bool isHermitian(T)(in Complex!T[][] m, in Complex!T[][] ct)
bool isHermitian(T)(in Complex!T[][] m, in Complex!T[][] ct)
/*pure nothrow*/ {
pure nothrow {
return [m, ct].areEqual;
return [m, ct].areEqual;
}
}
Line 359: Line 359:
}
}


auto complexIdentitymatrix(in size_t side)/*pure nothrow*/ {
auto complexIdentitymatrix(in size_t side) /*pure nothrow*/ {
return iota(side)
return iota(side)
.map!(r => side.iota.map!(c => complex(r == c)).array)
.map!(r => side.iota.map!(c => complex(r == c)).array)