Message Boards Message Boards

0
|
3276 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Use function inside compile

Posted 9 years ago

I noticed that inside Compile there seems to be no way to define a function. It always call MainEvalute:

fun = Compile[{x, _Real}, Module[{y = x, f}, f[y_] = y^2; y + f[y]]]

Any way to overcome it?

Thanks.

POSTED BY: Al Guy
5 Replies

enter image description here

POSTED BY: Simon Cadrin
Posted 9 years ago

The point is not just to use Module to get the answer, I need to make multiple function assignments inside Module and it should be compiled by function Compile to ensure a fast execution as it needs to be called hundreds thousands of times.

POSTED BY: Al Guy

enter image description here

POSTED BY: Simon Cadrin
Posted 9 years ago

I don't see how that answers the question.

POSTED BY: Al Guy

enter image description here

POSTED BY: Simon Cadrin
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