Message Boards Message Boards

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

What is wrong with the syntax below?

Posted 3 years ago
Do[Compile[{{aFile[[i, 1]], _Real}, {aFile[[i, 2]], _Real}, {aFile[[i,3]], _Real}},
         col1 = aFile[[i, 1]];
         col2 = aFile[[i, 2]];
         col3 = aFile[[i, 3]];
         g1 = col1 col3;
         g2 = col2 col3;
         g3 = g1 g2^2;];,
       CompilationOptions -> {InlineExternalDefinitions -> True},
       RuntimeOptions -> "Speed"],
      {i, 100000}];
POSTED BY: Delroy Foster
5 Replies
Posted 3 years ago

Is there a reason for wanting to compile100,000 functions that are essentially the same?

POSTED BY: Rohit Namjoshi
Posted 3 years ago

I imported "aFile" which is a file with 3 columns and 100,000 rows with different values.

POSTED BY: Delroy Foster
Posted 3 years ago

CompliationOptions needs to be part of the call to Complie[], not do. Try something like this:

Do[
  Compile[
   {
    {aFile[[i, 1]], _Real},
    {aFile[[i, 2]], _Real},
    {aFile[[i, 3]], _Real}
    },
   col1 = aFile[[i, 1]];
   col2 = aFile[[i, 2]];
   col3 = aFile[[i, 3]];
   g1 = col1 col3;
   g2 = col2 col3;
   g3 = g1 g2^2;
   , CompilationOptions -> {InlineExternalDefinitions -> True}, 
   RuntimeOptions -> "Speed"
   ]
  , {i, 100000}
  ];
POSTED BY: Mike Besso
Posted 3 years ago

Thanks I will try your code and let you know the results.

POSTED BY: Delroy Foster
Posted 3 years ago

Hi Mike, Your code worked in Mathematica. I tried the same code using the IkernelLink(MathLinkFactory) and MathKernel in C#.Net 2019, but it did not work.

I created a string "codeString" equal to the code and used mathlink.EvaluateToOutputForm(codeString,0); This worked for all other code expect the one above. Any thoughts?

POSTED BY: Delroy Foster
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