One should therefore be able to use complex piddles to obtain B by multiplying M times X, or alternatively obtain X by multiplying the inverse of M times B using the following code:/ 1+i 2+i \ / 3+i \ / 5+8i \ M = | | X = | | and B = | | \1-2i 2-i / \ 2+i / \ 10-5i /
#! /usr/bin/perl -w use warnings; use strict; use PDL; use PDL::Complex; my $matrixM = pdl [ [ 1+1*i, 2+1*i], [ 1-2*i, 2-1*i] ]; my $matrixB_assigned_value = pdl [ 5+8*i, 10-5*i ]; my $matrixX_assigned_value = pdl [ 3+1*i, 2+1*i ]; my ($matrixB_computed_value, $matrixX_computed_value); print "Via Perl Data Language\n"; print "List assigned_values of matrices:\n"; print "\$matrixM = ", $matrixM,"\n"; print "\$matrixX_assigned_value = ", $matrixX_assigned_value,"\n"; print "\$matrixB_assigned_value = ", $matrixB_assigned_value,"<br>\n"; print "List computed values of matrices:\n"; print "\$matrixB_computed_value = ", $matrixM x $matrixX_assigned_value,"\n"; print "\$matrixX_computed_value = ", $matrixM->inv x $matrixB_assigned_value,"\n"; exit(0);
Notice how the assigned values for M, X, and B dutifully print as expected. However the computed values for X and B are strange. Please can you explain what I need to change to correctly compute the values of X and B in my little example.Via Perl Data Language List assigned_values of matrices: $matrixM = [ [ [1 1] [2 1] ] [ [ 1 -2] [ 2 -1] ] ] $matrixX_assigned_value = [ [3 1] [2 1] ] $matrixB_assigned_value = [ [ 5 8] [10 -5] ] <br> List computed values of matrices: $matrixB_computed_value = [ [ [5 2] [8 3] ] [ [-1 -1] [ 4 1] ] ] $matrixX_computed_value = [ [ [ 5 -13] [ 0 21] ] [ [ 5 -6] [ 0 -7] ] ]
In reply to PDL::Complex question by gmacfadden
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |