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

learn more… | top users | synonyms

8
votes
3answers
547 views

What is wrong with my expression for compiling?

Following code was translated from a snippet matlab code. Without compiling it worked slowly. I want to compile it, but am getting a numerical error. How do I compile this in a correct way? ...
23
votes
3answers
791 views

Which Distributions can be Compiled using RandomVariate

Recently, Oleksandr kindly showed a list of Mathematica commands that can be compiled. RandomVariate was part of that list. However, whether this can be compiled depends upon the distribution that is ...
4
votes
2answers
136 views

Improve simulation speed using Compile

I have two square matrices, a hermitian matrix h and an unitary matrix v. I am interested in the following function ...
15
votes
0answers
211 views

Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0 and persisting through 10.1.0 or later In the following example, inside the minimumX's Module, ...
6
votes
1answer
233 views

Compiling a function that takes lots of optional arguments

I have a function that takes lots of optional arguments (basically some design parameters, about 10 of them) and performs some basic algebraic calculations involving complex numbers with the options. ...
1
vote
0answers
48 views

Compilation of a function that needs to call Subsets

I'm working on a code that runs many (easy) operations on combinations (subsets) of different size (6, 7, 8, 9) taken from a big set of numbers (normally more that 40). So, this means the code has to ...
0
votes
1answer
80 views

How to compile a function whose arguments are lists containing strings?

I'm unsuccessfully trying to compile this function check[argA_, argB_] := argA[[1]] == argB[[1]]; assuming that both arguments argA and argB are of the form ...
12
votes
1answer
146 views

CompiledFunctionCall vs. LibraryFunction

When compiling code to C, and the compiled code calls other compiled functions, I see CompiledFunctionCall in the output of ...
7
votes
1answer
231 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 ...
5
votes
1answer
93 views

Compilation of `Total` with CompensatedSummation

I sometimes obtain an unexpected error when trying to call a compiled version of Total with compensated summation turned on. More specifically I define ...
9
votes
1answer
392 views
11
votes
2answers
263 views

Can RecurrenceTable make use of CompiledFunction?

I'm trying to implement a discrete-time 2D Verlet algorithm for a point-mass subject to a softened gravitational interaction as a test for a more computationally intensive simulation using ...
2
votes
3answers
75 views

NIntegrate-ing a compiled function

I'm trying to integrate numerically in 6 dimensions a very long expression and I read about the option to NIntegrate a compiled function which should be faster. ...
7
votes
1answer
137 views

Compiled function crashes kernel when trying to list over different length arguments

I'm trying to speed up a tally/binning operation that I have to run many times. I have many lists of between 1 and 10 numbers from the range [1,5] and I want to ...
5
votes
2answers
104 views

A problem with Compile and Map

There is a weird behavior of Compile that I do not understand. Consider the following example: ...
2
votes
1answer
54 views
6
votes
5answers
455 views

How to compile the code for generate Pythagorean_triple?

I am finding Pythagorean_triple, it worked slowly. I tried to compile, but it gives some warnings. I also use "Case" or "Do" ,both of them failed.I'm sure my CCompiler has been set correctly. How can ...
0
votes
1answer
45 views

What is the meaning of the lists of numbers in the FullForm of a compiled function?

For example, f = Compile[{{x, _Real}}, x]; FullForm[f] has this output: ...
5
votes
1answer
190 views

Is there any strategy to have a compiled version of FindFit or NonlinearModelFit?

Disclaimer: This is not a precise question with a definite answer. I know that neither FindFit nor NonlinearModelFit is in the ...
3
votes
2answers
120 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
0
votes
0answers
66 views
14
votes
2answers
172 views

CompiledFunction returns machine numbers smaller than $MinMachineNumber

When thinking on the workaround for this LogLogPlot bug suggested by halirutan I noticed that CompiledFunction actually can ...
0
votes
1answer
62 views

Why does Compile redo the calculation when overflow happens?

When implementing the Numerov method solving Schrodinger equation, I encountered this problem. In order to show the order of the evaluation, Print is added. ...
5
votes
1answer
191 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 ...
0
votes
2answers
98 views

Numerical 3D Integration in Mathematica [closed]

My question in short is: Is it possible to make numerical 3D integration in mathematica efficiently? Or am I gonna have to move this to C++? I feel this problem is way too trivial to go to C++, so ...
7
votes
0answers
123 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 ...
0
votes
1answer
64 views

Correct use of Solve inside Compile

I have a function that behaves itself, but I want to make it much faster so I tried to put it into a compilable form After much fiddling I can't get it to work. Here's one of my failed attempts: ...
1
vote
0answers
69 views

How to get Mathematica to compile with target C?

I have been trying to compile some functions in mathematica with target C for speed. basically when I try: ...
0
votes
0answers
24 views

Returning multiple results from compiled functions in M10 [duplicate]

I have found a similar question from 2012 here. It has been 3 years now and we have version 10. Have there been any attempt to solve this problem either by Wolfram or by the community - how to return ...
5
votes
1answer
116 views

Slow-down encountered when using NMinimize with a compiled function

I'm minimizing a large function. Evaluating the function is very slow symbolically but using Compile I can get ~100x speed-up on this step. However, despite this, the NMinimize process is only ...
89
votes
8answers
7k views

List of compilable functions

Is there somewhere a list on the functions that Compile can compile, or the cases in which a particular function can be compiled that I haven't found? I'd be glad ...
4
votes
2answers
181 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 ...
1
vote
1answer
68 views
2
votes
0answers
58 views

Goto and Compile to C

When I use Goto inside compile and use CompilationTarget->"C" I get error message: ...
4
votes
1answer
133 views

Throw and Catch return wrong result inside Compile

Consider this code: fun = Compile[{{i, _Integer}}, Catch[Do[ If[j >= i, Throw[j]] , {j, 1, 10}]] ] I put an integer as argument then if this ...
3
votes
1answer
70 views

Package and imbricated compiled functions

I would like to build up a Mathematica package Pck which contains compiled functions. However when loading this library I obtain an error. When reduced to a minimal ...
2
votes
1answer
182 views

Compile a MeijerG function [duplicate]

I am not very experienced with Compile, I tried to use it for a Meijer-G function ...
1
vote
0answers
47 views

Complex input for Compile makes it slow

I asked a question here and then tried to use Compile for the solution to gain even more speed. Inside Compile there is a loop ...
103
votes
5answers
8k views

How to compile effectively?

What are the best practices of compiling functions? I understand that this is a vague question, but let me list some aspects that might trigger useful answers. Some of these have already been answered ...
4
votes
1answer
116 views

A problem about CompilationTarget -> “C” [duplicate]

In my Windows 7 system, I installed two Mathematica versions (V8 and V9) In V8 Compile[ {{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"] ...
20
votes
1answer
270 views

M9 performance regression for Fold?

Bug introduced in 8.0 and persisting through 10.0.2 or later I noticed an over 10x performance drop on Mathematica v9.0.1 (as Oleksandr R. commented, also v8) compared with v7.01 for this code: ...
1
vote
1answer
81 views
0
votes
2answers
80 views

Compile a Module wich has a loop with undetermined bound

Suppose I have such a module as below: test[int_] := Module[{m}, m = Table[i, {i, 1, 10}]; Do[m[[i]] = i*i, {i, 1, int}]; Return[m] ] The bound for ...
3
votes
1answer
61 views

Is it possible to change the MinPrecision in command “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 Precision in command "Compile" to some $MinPrecision?
4
votes
1answer
101 views

Why is C-compiled (but not WVM-compiled) code so slow in Manipulate?

Here is a small section of code from this SE question which computes the real part of the dilogarithm (the upper limit of the sum is increased for demonstration purposes): ...
1
vote
1answer
108 views

Use Compile to speed up evaluation

I have read, that using Compile command can speed up evaluations in mathematica. I have a mathematical expression, which I evaluate using following command: ...
3
votes
1answer
163 views

How can I trans-compile Mathematica into another language?

I'm looking for an exhaustive list of source-to-source compilers to all other languages, if any exist that is.
3
votes
0answers
37 views

Escaping out of (or exiting) a Compiled Function

How do I manually escape out of a compiled function without forcing an error and compromising its speed? Here is an example: ...