perlquestion
gmacfadden
Based on complex arithmetic for MX=B, for<br><br>
| 1 + i , 2+i |<br>
|.................| = A<br>
| 1 -2i , 2-i |<br><br>
| 3 + i |<br>
|.........| = X<br>
| 2 + i |<br><br>
then<br>
| 5 + 8i |<br>
|...........| = B and determinant of A = -1 + 4j<br>
| 10 - 5i |<br><br>
However, when I try to calculate the determinant and / or the inverse of A in the code below to solve for X, the results are not at all what are to be expected.
Please can you identify what I'm missing. Thanks. <br><br>
<code>
#! /usr/bin/perl -w
use strict;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use CGI qw(:standard escapeHTML);
use PDL;
use PDL::Complex;
my $matrixM = pdl [ [ 1+1*i, 2+1*i],[ 1-2*i, 2-1*i] ];
my $matrixB = pdl [ 5+8*i, 10-5*i ];
my $matrixX = pdl [ ];
print header (), start_html (-title => "Matrix Ops");
print "<H1><center>Via Perl Data Language</center></H1><br>\n";
print "\$matrixM = ", $matrixM,"<br>\n";
print "determinant of \$matrixM = ",$matrixM->det,"<br>\n";
print "inverse of \$matrixM = ",$matrixM->det,"<br>\n";
print "\$matrixB = ", $matrixB,"<br>\n";
print "\$matrixX = ", $matrixM->inv x $matrixB,"<br>\n";
print end_html ();
exit(0);
</code>