Conjugate transpose: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: whitespace tweaks)
m (→‎{{header|Perl 6}}: minor style tweaks)
Line 1,120: Line 1,120:
say "\nTranspose:";
say "\nTranspose:";
@t.&say-it;
@t.&say-it;
say "Is Hermitian? {is-Hermitian(@m, @t)}";
say "Is Hermitian?\t{is-Hermitian(@m, @t)}";
say "Is Normal? {is-Normal(@m, @t)}";
say "Is Normal?\t{is-Normal(@m, @t)}";
say "Is Unitary? {is-Unitary(@m, @t)}";
say "Is Unitary?\t{is-Unitary(@m, @t)}";
}
}


Line 1,130: Line 1,130:


sub is-Normal (@m, @t, --> Bool) {
sub is-Normal (@m, @t, --> Bool) {
mat-mult(@m, @t)».Complex eqv mat-mult(@t, @m)».Complex;
so mat-mult(@m, @t)».Complex eqv mat-mult(@t, @m)».Complex
}
}


Line 1,147: Line 1,147:
@p[$r][$c].=round(ε); # avoid floating point math errors
@p[$r][$c].=round(ε); # avoid floating point math errors
}
}
@p;
@p
}
}


Line 1,161: Line 1,161:
[ 1-1i 5 -3]
[ 1-1i 5 -3]
[ 0-2i -3 0]
[ 0-2i -3 0]
Is Hermitian? True
Is Hermitian? True
Is Normal? True
Is Normal? True
Is Unitary? False
Is Unitary? False


Matrix:
Matrix:
Line 1,174: Line 1,174:
[ 1 1 0]
[ 1 1 0]
[ 0 1 1]
[ 0 1 1]
Is Hermitian? False
Is Hermitian? False
Is Normal? True
Is Normal? True
Is Unitary? False
Is Unitary? False


Matrix:
Matrix:
Line 1,187: Line 1,187:
[ 0.707 0+0.707i 0]
[ 0.707 0+0.707i 0]
[ 0 0 0-1i]
[ 0 0 0-1i]
Is Hermitian? False
Is Hermitian? False
Is Normal? True
Is Normal? True
Is Unitary? True
Is Unitary? True
</pre>
</pre>