Skip to main content

Timeline for Compile error with MapThread

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Mar 1, 2016 at 11:24 comment added xzczd @AlexeyGolyshev Wow, seems that I'll have a lot of answers to revise soon :D
Mar 1, 2016 at 9:47 comment added Alexey Golyshev @xzczd +1 to your answer. In comments you wrote: "function defined with pattern-matching cannot be compiled". Very good comment, not only this phrase. Also +1. But in the next Mathematica it will be possible: youtu.be/… A lot of cool things expected ^_^
Mar 1, 2016 at 2:10 comment added xzczd @syhpphys "we can throw away the Flatten and Transpose and just replace the {n,nd,4} with {n*nd,4}" You are right, I forgot to take the code inside RandomVariate into account, thanks for pointing out, edited.
Mar 1, 2016 at 2:10 history edited xzczd CC BY-SA 3.0
deleted 23 characters in body
Mar 1, 2016 at 2:08 comment added xzczd @syhpphys I think the 2 key points here are 1. Normalize can not be compiled so one needs to replace it with a compiled equivalent i.e. #/Sqrt@Total[#^2] & . 2. function defined with pattern-matching cannot be compiled (see the 3rd rule here?), so one needs to replace it with a pure function, which can usually be compiled if it's formed by compilable function.
Feb 29, 2016 at 23:46 vote accept syhpphys
Feb 29, 2016 at 22:46 comment added syhpphys The key thing that makes this work seems to be to normalize the vectors first, then pass them to the function defined within the Function[ , ]. May I ask how you figured this out?
Feb 29, 2016 at 22:35 comment added syhpphys Now that you've written it so nicely, it is clear that we can throw away the Flatten and Transpose and just replace the {n,nd,4} with {n*nd,4}.
Feb 29, 2016 at 8:13 history edited xzczd CC BY-SA 3.0
added 101 characters in body
Feb 29, 2016 at 7:57 history edited xzczd CC BY-SA 3.0
deleted 1 character in body
Feb 29, 2016 at 7:52 history answered xzczd CC BY-SA 3.0