Questions tagged [compile]

Questions about the generation and use of compiled functions using Compile.

Filter by
Sorted by
Tagged with
19
votes
1answer
445 views

In Compile “InlineExternalDefinitions” doesn't work anymore in Mma v10 like in v9

In Mma 9 using CompilationOptions -> {"InlineExternalDefinitions" -> True} inside of Compile inlined the values of the ...
22
votes
2answers
456 views

What can be inlined by “InlineExternalDefinitions” -> True?

This not-well-documented option of Compile has been used quite a bit in this site, and based on these examples, I used to think ...
16
votes
2answers
1k views

Speeding up random walk for many particles

I am trying to speed up this code for many particles to take a random walk. I'm not sure why it is so slow for such a simple task. I got a few hints from colleagues to reduce the precision of the ...
14
votes
1answer
271 views

CompiledFunctionCall vs. LibraryFunction

When compiling code to C, and the compiled code calls other compiled functions, I see CompiledFunctionCall in the output of ...
15
votes
1answer
313 views

Is the CompiledFunctionCall WVM opcode efficient?

There is example in Mathematica documentation about Compile ...
15
votes
1answer
485 views

Is the sharing of variables in Module/Block within Compile documented behavior?

Today I noticed something, I think for the first time. When used inside Compile variable values within Module (and ...
10
votes
3answers
724 views

How can I speed up my compiled RBF interpolating function?

Overview I have a function that acts like the Interpolation on sparse $n$-dimensional data using a simple implementation of RBF interpolation method. I want my ...
6
votes
1answer
1k views

Catching and debugging numerical errors in compiled functions

I have a compiled function (that was created using the second method of this question). Basically it's using a compiled closure. The problem is that for some parameter values it does not evaluate. ...
17
votes
1answer
366 views

Memory usage of compiled function: C vs WVM

Reported to WRI [CASE:3406803] Why does generating an array in "C"-compiled function uses 50% more memory than doing same thing in ...
11
votes
2answers
870 views

How can I prevent a compiled function from using uncompiled evaluation?

I write a code that creates a compiled function, and then call that function over and over to generate a list. I run this code on a remote server via a batch job, and will run several instances of it....
10
votes
2answers
670 views

How to compile self-referencing functions (to perform recursive a task)

How do I compile a self-referencing function to perform iterative tasks? The naive approach doesn't seem to work. Here is a simple example to illustrate the problem: ...
9
votes
2answers
227 views

CompiledFunction crashes kernel

Bug fixed in 10.0.0 This crashes my kernel ...
7
votes
2answers
1k views

Using compiled function inside NMinimize

Consider this code: ...
4
votes
2answers
618 views

Why is my compiled function slower than a regular function?

I have the following functions: ...
18
votes
1answer
595 views

Strange behavior of Table

Whenever I run the code a = 0; code := (a++); Table[code; a, {1000}] I get a list of 1000 zeros. However, if I replace 1000 with 100, then a get a list equal to ...
10
votes
1answer
461 views

How to compile Heike's winding number function?

Heike gave the following function for winding number: ...
10
votes
1answer
585 views

error when defining a compiled function with ReplacePart

I always have difficulty in writing a non-trivial compiled function. I'm using Mathematica 9. Please see the following code ...
8
votes
2answers
943 views

Working with large data, pass-by-reference, compiled functions

I think I know the answer to this, but after two days of Googling, this is my last effort before going down an unwanted path... I have a function that takes lots of large data as arguments as well as ...
7
votes
3answers
508 views

Metaprogramming: creating compiled functions from inter-dependent code blocks

I want to create a compiled function from inter-dependent code blocks. Here is a minimal example showing the salient features based on strings: ...
23
votes
0answers
401 views

Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0, fixed in 10.4, intentionally reintroduced in 11.0 and persisting through 12.0. In the following example, inside the minimumX's ...
7
votes
1answer
369 views

How to set return type of `InterpolatingFunction ` in compile

Consider this ...
7
votes
1answer
777 views

Compile nested Sums

I want to compile an expressions that contains nested Sum-expressions. A simple example that gives me problems is: ...
6
votes
1answer
639 views

Compile, “global variables” and recursion

I am trying to do something similar to this, namely to make a Compile'd function outer that itself calls a ...
5
votes
1answer
541 views

Is it possible to change the precision in Compile?

I'm using Compile to do some numerical calculation and I need high Precision. I was wondering if it is possible to change the ...
5
votes
2answers
340 views

Using Findroot with Precompiled Function

I am writing a Monte Carlo algorithm to solve some algebraic equations. To do this I need to evaluate FindRoot many times on the same function. Following from F'x's answer to Expression evaluation ...
5
votes
4answers
391 views

Findroot with a precompiled function with parameters

If I want to precompile a function that I intend to put into FindRoot many times, I could do it like this: ...
5
votes
2answers
736 views

Can SetDelayed (:=) be compiled?

Is it possible to put an If statement as below within a compile (see below)? I received a warning about SetDelayed. ...
4
votes
3answers
660 views

about Compile and return type

In the mathematica document "tutorial/CompilingWolframLanguageExpressions" 1 It says about how to set return type of a called function you used in Compile. ...
3
votes
1answer
232 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
3
votes
2answers
478 views

How to speed up recursive compiled functions?

I'm trying to speed up the recursive function that calculates Rotation numbers: ...
2
votes
3answers
320 views

Random Geometric Graphs, but fast

I am optimising the random geometric graph generation ideas in this post. I need to generate a large number of random geometric graphs with probabilistic connectivity (soft random geometric graphs), ...
10
votes
2answers
486 views

Avoiding MainEvaluate in a CompiledFunction to fetch global variables

I'm trying to write a simulation using Mathematica 8.0. Since I will most likely be doing the same operation over and over again, I'm trying to Compile whatever I ...
16
votes
2answers
537 views

Using Boost with CreateLibrary

I was looking at the answer of Leonid of Faster alternatives for DayOfWeek and wanted to see how hard it would be to do something similar in C++ using an external library like Boost. I tried to ...
14
votes
1answer
3k views

Step-by-step instruction to Install C Compiler

I remember using C compiler on my previous computers, and I never had any problems installing them. At this time, however, I failed to work through the instructions provided in Mathematica ...
16
votes
3answers
762 views

Compiling LinearSolve[] or creating a compilable procedural version of it

Earlier today I had a discussion with a representative at Premier Support about the 2 questions I've asked here over the past couple of days: Seeking strategies to deploy a function securely ...
14
votes
3answers
1k views

What compilers are “suitable” for CompilationTarget->“C”?

The documentation for CompilationTarget says, "if you do not have a suitable C compiler then you will not be able to set CompilationTarget to C". Well at this time, I don't have a compiler installed ...
21
votes
1answer
402 views

Performance of compiled functions

I am trying to find the fastest way to calculate two values where both of them are sum of different expressions. I combine both calculations in one Sum[]. I'm ...
15
votes
1answer
742 views

Save a C compiled function without losing the blessing of C compiler

Consider the following example: ...
9
votes
1answer
842 views

Exporting a compiled function for later use

I wish to export compiled functions for later use. This means that I do not want the compiled function to be recompiled every time I reload it. It also means that if my compiled function was for ...
18
votes
1answer
269 views

Why Function is not identical to `&` in autocompilation?

Here is the example, copied from here square = Function[x, x^2]; square1 = #^2 &; the timing and unpacking status shows ...
17
votes
1answer
2k views

How to install and configure Intel C++ Compiler for Mathematica correctly?

I wish to try the trial version of the latest Intel C++ Compiler for Windows with Mathematica. I have downloaded the current version of Intel® C++ Composer XE 2011 for Windows and installed only the "...
13
votes
1answer
606 views

Is it possible to use Compile on a function with optional arguments?

My Mathematica is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own! Simple example : ...
13
votes
2answers
6k views

How to use a matrix variable for a compiled function

I want to compile the following function which takes a matrix variable. ...
12
votes
1answer
393 views

How to avoid CopyTensor in CompiledFunctions?

In a reply here Leonid wrote, “Compile can handle a number of higher-level functions, such as Transpose, Partition, Map, MapThread, etc. Most of these functions return expressions, and even though ...
11
votes
3answers
319 views

Can I return lists with different dimensions from a compiled function?

Sometimes I'll need several lists with different dimensions to be returned by a compiled function, but compiled function will fail if an irregular list contained: ...
8
votes
1answer
404 views

Compiling Map over expression that yields a ragged array

I'm trying to speed up a function that looks in the neighborhood of each 3D point in a large dataset and finds all the points within 1 unit in each direction, x, y, z. I've started by using ...
6
votes
3answers
903 views

How to use a compiled function in numerical optimization

I'm trying to wrap my head around function Compile. So, this is a spin-off question from: a previous question on using compile[] correctly. I have a function that ...
6
votes
2answers
697 views

Optimize inner loops

I'm Mathematica newbie so please be gentle :) I have this, heavily non-optimized part of code, which I would like to speed up. I have put all matrices to be RandomReal, but in my code they take ...
8
votes
3answers
630 views

Threading a compiled function over multiple arguments of different lengths

I am interested in threading a compiled function over multiple argument lists of different lengths. I will explain this in two steps: Suppose f is some function. Then one can define another ...
8
votes
2answers
652 views

Goto and Compile

...