MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Unexpected behavior with Thread

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21073] Unexpected behavior with Thread
  • From: Joel Cannon <jcannon at jcannon.washjeff.edu>
  • Date: Sun, 12 Dec 1999 23:51:38 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I have encountered an unexpected behavior when using Thread. I have a
function getTorque that I am trying to Thread over two lists. When I
Thread getTorque over the lists, it does not work. However, If I
thread a function "f" over the same lists, and then make the
transformation f->getTorque, it works as it should. Here is what it
looks like. Apologies for the output with all the formatting
commands. I have not been able to get rid of it. The functions and
lists are at the bottom of this post.


*********************************************
Here is what happens when I Thread the function getTorque.

In[95]:= getTorque[rwheels, fwheels, 0] // Thread

Dot::"dotsh": "Tensors \!\({\(\({1, 0, 0}\)\), \(\({0, 1, 0}\)\), \(\({0, 0, \
1}\)\)}\) and \!\({\(\({\(\(\(\(-mu\)\)\\ n1\)\), 0, n1}\)\), \
\(\({\(\(\(\(-mu\)\)\\ n2\)\), 0, n2}\)\)}\) have incompatible shapes."

Out[95]=
\!\({CrossProduct[{w\/2, 
        0, \(-zcm\)}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} . {{\(-mu\)\ n1, 0, 
            n1}, {\(-mu\)\ n2, 0, n2}}], 
    CrossProduct[{\(-\(w\/2\)\), 
        0, \(-zcm\)}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} . {{\(-mu\)\ n1, 0, 
            n1}, {\(-mu\)\ n2, 0, n2}}]}\)

**************************************************
Here I thread the undefined function "f" and /. f->getTorque

In[110]:=
(f[rwheels, fwheels, 0] // Thread) /. f -> getTorque

Out[110]=
\!\({{0, \(-\(\(n1\ w\)\/2\)\) + mu\ n1\ zcm, 
      0}, {0, \(n2\ w\)\/2 + mu\ n2\ zcm, 0}}\)°

*****************************************************************
For reference, here are the  functions and the lists that I am
threading over.

getTorque[rbody_, fspace_, psi_] := CrossProduct[rbody, roty[-psi] . fspace]
 
roty[t_] := {{Cos[t], 0, Sin[t]}, {0, 1, 0}, {-Sin[t], 0, Cos[t]}}
 
rwheels = {{w/2, 0, -zcm}, {-w/2, 0, -zcm}}
 
fwheels = {{-(mu*n1), 0, n1}, {-(mu*n2), 0, n2}}
****************************************************

Thanks to anyone who can help.

------------------------------------------------------------------------------
Joel W. Cannon                   |   (724)223-6146         
Physics Department               |  
Washington and Jefferson College |      
Washington, PA 15301             |      
                                     
                    



  • Prev by Date: Q: efficient in-place list element replacement?
  • Next by Date: Reading data.
  • Previous by thread: Re: Q: efficient in-place list element replacement?
  • Next by thread: Re: Unexpected behavior with Thread