Conjugate transpose: Difference between revisions
m
→{{header|Perl}}: future-proof for 5.36
m (→{{header|J}}: change label on the example matrices here) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36) |
||
Line 2,387:
In general, using two or more modules which overload operators can be problematic. For this task, using both Math::Complex and Math::MatrixReal gives us the behavior we want for everything except matrix I/O, i.e. parsing and stringification.
<syntaxhighlight lang="perl">use strict;
use warnings;
use English;
use Math::Complex;
Line 2,429 ⟶ 2,430:
sub identity {
my $N = shift;
my $m =
$m->one();
return $m;
Line 2,435 ⟶ 2,436:
sub example1 {
my $m =
$m->assign(1, 1, cplx(3, 0));
$m->assign(1, 2, cplx(2, 1));
Line 2,444 ⟶ 2,445:
sub example2 {
my $m =
$m->assign(1, 1, cplx(1, 0));
$m->assign(1, 2, cplx(1, 0));
Line 2,458 ⟶ 2,459:
sub example3 {
my $m =
$m->assign(1, 1, cplx(0.70710677, 0));
$m->assign(1, 2, cplx(0.70710677, 0));
|