Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

#! /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);

In reply to PDL works for real number matrix operations, but not working for complex number matrix operations. by gmacfadden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-16 22:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found