Conjugate transpose: Difference between revisions

Updated D entry
(Updated D entry)
(Updated D entry)
Line 311:
 
Complex!T[][] conjugateTranspose(T)(in Complex!T[][] m)
/*pure nothrow*/ nothrow {
return iota(m[0].length)
.map!(i => m.transversal(i).map!conj.array)
Line 317:
}
 
T[][] matMul(T)(in T[][] A, in T[][] B) /*pure nothrow*/ nothrow {
const Bt = B[0].length.iota.map!(i=> B.transversal(i).array).array;
return A.map!(a => Bt.map!(b => a.dotProduct(b)).array).array;
Line 355:
 
bool isNormal(T)(in Complex!T[][] m, in Complex!T[][] ct)
/*pure nothrow*/ nothrow {
return [matMul(m, ct), matMul(ct, m)].areEqual;
}
 
auto complexIdentitymatrix(in size_t side) /*pure nothrow*/ nothrow {
return iota(side).iota
.map!(r => side.iota.map!(c => complex(r == c)).array)
.array;
Line 366:
 
bool isUnitary(T)(in Complex!T[][] m, in Complex!T[][] ct)
/*pure nothrow*/ nothrow {
const mct = matMul(m, ct);
const ident = mct.length.complexIdentitymatrix;