Message Boards Message Boards

0
|
2998 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How do I eliminate a thread error regarding array length for matrices?

Posted 11 years ago
Hi,

Everyone here was so helpful last time, I am back with another sticking point.  I am trying to add a 4x4 matrix to the product of a 4x2*2x2*2x4 matrix, which should result in a 4x4 matrix.  The matrices in question are psiuu1 (4x4), psiuv1 (4x2), Z1 (2X2) and Z2 (2X4).  The four matrices are listed in the code below, along with the expression for Tx1 that I need to evaluate.  When I try to evaluate Tx1, I get a thread length error that tells me that the lengths are not compatible.

 In[78]:= psiuu1
 
 Out[78]= {{-1.77954 + 0.192603 I, -0.442094 - 0.00401247 I,
   2.87584*10^6 + 0.000417968 I, -59911.9 -
    8.27209*10^-6 I}, {133.421 - 9.2452 I, -1.77954 +
    0.192603 I, -1.38044*10^8 - 0.0210661 I,
   2.87584*10^6 + 0.000417968 I}, {-6404.38 + 443.781 I,
   133.421 - 9.2452 I,
   6.62628*10^9 + 1.05935 I, -1.38044*10^8 - 0.0210661 I}, {307418. -
   21302. I, -6404.38 + 443.781 I, -3.18069*10^11 - 53.1613 I,
  6.62628*10^9 + 1.05935 I}}

In[81]:= psiuv1

Out[81]= {{1248.13 + 1.63261*10^-7 I, -26.0021 -
   3.21224*10^-9 I}, {-59911.9 - 8.27209*10^-6 I,
  1248.13 + 1.63261*10^-7 I}, {2.87584*10^6 +
   0.000417968 I, -59911.9 - 8.27209*10^-6 I}, {-1.38044*10^8 -
   0.0210661 I, 2.87584*10^6 + 0.000417968 I}}

In[95]:= Z1

Out[95]= {{16637. + 33266.8 I, -3.55271*10^-14 -
   7.10543*10^-14 I}, {7.95808*10^-15 + 1.59162*10^-14 I,
  3.94652 + 0.69304 I}}

In[96]:= Z2

Out[96]= {{1.91119*10^7 - 568.324 I,
  0.0000151459 + 0.0000302918 I, -3.83252*10^7 - 7.66505*10^7 I,
  1.51924*10^-16 - 7.59619*10^-17 I}, {4.74904*10^-9 +
   9.49808*10^-9 I, 1.91122*10^7 - 0.158457 I,
  2.32831*10^-12 + 4.65661*10^-12 I, -798.422 - 1596.84 I}}

Tx1 = psiuu1 + psiuv1*Inverse[Z1]*Z2;

and here is the error I get:
During evaluation of In[97]:= Thread::tdlen: Objects of unequal length in {{1248.13 +1.63261*10^-7 I,-26.0021-3.21224*10^-9 I},{-59911.9-8.27209*10^-6 I,1248.13 +1.63261*10^-7 I},{2.87584*10^6+0.000417968 I,-59911.9-8.27209*10^-6 I},{-1.38044*10^8-0.0210661 I,2.87584*10^6+0.000417968 I}} <<1>> {<<1>>,{4.74904*10^-9+9.49808*10^-9 I,<<1>>,<<1>>,-798.422-<<19>> I}}
cannot be combined. >>

As far as I can tell, all of the matrices are of the correct size, and I am not actually sure why the Thread command is even here... Getting the psi and Z matrices was pretty complicated, could it be that there is an attribute to these matrices that is making Mathematica unhappy?  When I try Attribute[psiuu1] it just gives me empty curly braces.

Any help on how to eliminate this error and calculate Tx1 would be appreciated!  Thanks!
POSTED BY: Kaitlin Smith
2 Replies
Posted 11 years ago
Yep, thank you!
POSTED BY: Kaitlin Smith
Posted 11 years ago
Use . to do matrix multiply, not * and the problem appears to go away
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract