MathGroup Archive 2011

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

Search the Archive

Thread vs MapThread with Compiled functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115133] Thread vs MapThread with Compiled functions
  • From: "Eric Michielssen" <emichiel at eecs.umich.edu>
  • Date: Sat, 1 Jan 2011 04:26:20 -0500 (EST)

All,

It seems like I can MapThread with a compiled function, but not Thread w/o
Mathematica complaining... Any explanation?

myadd = Compile[{{x1, _Real}, {x2, _Real}}, x1 + x2];
x1t = Table[RandomReal[], {i, 1, 4}]; 
x2t = Table[RandomReal[], {i, 1, 4}];
MapThread[myadd, {x1t, x2t}]  (** Works, see below **)
Thread[myadd[x1t, x2t]] (** Minor (?) trouble, see below **)

Out[1591]= {0.987826, 0.739118, 0.483543, 1.03504}

During evaluation of In[1587]:= CompiledFunction::cfsa: Argument
{0.0803627,0.64419,0.240207,0.35777} at position 1 should be a machine-size
real number. >>

Out[1592]= {0.987826, 0.739118, 0.483543, 1.03504}   (** Still goes through
despite complaint... **)

Eric Michielssen





  • Prev by Date: How to change the directory for the docs?
  • Next by Date: Re: Manually culling a list
  • Previous by thread: Re: How to change the directory for the docs?
  • Next by thread: Re: Thread vs MapThread with Compiled functions