gmacfadden has asked for the wisdom of the Perl Monks concerning the following question:
Based on complex arithmetic for MX=B, for
| 1 + i , 2+i |
|.................| = A
| 1 -2i , 2-i |
| 3 + i |
|.........| = X
| 2 + i |
then
| 5 + 8i |
|...........| = B and determinant of A = -1 + 4j
| 10 - 5i |
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.
| 1 + i , 2+i |
|.................| = A
| 1 -2i , 2-i |
| 3 + i |
|.........| = X
| 2 + i |
then
| 5 + 8i |
|...........| = B and determinant of A = -1 + 4j
| 10 - 5i |
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.
#! /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);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: PDL works for real number matrix operations, but not working for complex number matrix operations.
by Anno (Deacon) on Mar 17, 2007 at 22:14 UTC | |
by gmacfadden (Sexton) on Mar 19, 2007 at 19:20 UTC | |
by Anno (Deacon) on Mar 19, 2007 at 21:58 UTC | |
by Anno (Deacon) on Mar 20, 2007 at 21:48 UTC | |
by gmacfadden (Sexton) on Mar 21, 2007 at 17:00 UTC | |
by etj (Deacon) on Jun 21, 2022 at 17:44 UTC |
Back to
Seekers of Perl Wisdom