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

learn more… | top users | synonyms

2
votes
2answers
78 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
22 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 ...
0
votes
1answer
42 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: ...
5
votes
1answer
93 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 ...
83
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
167 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
64 views
2
votes
0answers
53 views

Goto and Compile to C

When I use Goto inside compile and use CompilationTarget->"C" I get error message: ...
4
votes
1answer
125 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
62 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 ...
1
vote
1answer
91 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 ...
2
votes
1answer
171 views

Compile a MeijerG function [duplicate]

I am not very experienced with Compile, I tried to use it for a Meijer-G function ...
11
votes
0answers
181 views

Compile not correctly initializing a variable defined inside Module

In the following example, inside the minimumX's Module, x is initialized to 1, but the ...
1
vote
0answers
45 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 ...
96
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
92 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
266 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
76 views
0
votes
2answers
74 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
56 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
93 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
94 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
136 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
36 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: ...
4
votes
1answer
338 views

MinGW-64 and CompilationTarget -> “C”: can't make library

I'm trying to set up my new Windows 8.1 tablet to compile Mathematica (9.0.1) functions to C, using the MinGW-64 compiler. I have it set up so that the following works: ...
1
vote
1answer
122 views

Finding the index of (x,y) pairs in a list

I have a large list of $(x,y)$ pairs, and I want to find the index of a particular pair in order to extract some data from another array. By way of an example, ...
1
vote
0answers
39 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 ...
22
votes
3answers
717 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 ...
37
votes
4answers
3k views

How well does Mathematica code exported to C compare to code directly written for C?

Essentially what it says in the title. Mathematica can export its code to C. How much overhead does that inflict on the code, as compared to writing it from scratch in C?
1
vote
1answer
83 views

Apply functions to functions yields slow execution speed

I'm trying to write a function that parametrizes a curve c(t) by its arc length. Technicly I'm finished but if I plot the result for an example curve like ...
3
votes
2answers
95 views

Generating compiled functions from inactive expressions

I am working on a project in which I need to dynamically generate CompiledFunctions from Inactive expressions. For example, I ...
13
votes
4answers
575 views

Can (compiled) matrix permanent evaluation be further sped-up?

Update II  Sample code for simulating boson-sampling experiments has been added (as an answer). This code exploits new Mathematica capabilities relating to both empirical and smooth ...
2
votes
1answer
86 views

Compile with modification of arguments' values

Is it possible to compile while changing the value of the arguments the function receives, instead of just creating new variables, and then returning those new variables,i.e., is it possible to pass ...
2
votes
0answers
78 views

How to use a C compiler without having SystemModeler

In this question the answer given implies that I must compile a certain function. When I try to compile I get the error A C compiler cannot be found on your system. Please consult the ...
1
vote
1answer
92 views

Problem using Compiled Function within NProbability

I've built a very simple function to estimate the probability for a Long Straddle (derivative strategy) to be positive at expiration. ...
7
votes
2answers
147 views

Catching error in middle of evaluation of compiled function

I have programmed and Compileed a complicated numerical function. The function has singularities (i.e. are infinite) at certain input numerical values. I need to ...
6
votes
1answer
129 views

Unable to compile to C

I used to be able to compile to C without problems, but from one day to the next, when I try to compile something, e.g. ...
0
votes
1answer
120 views

How to Use Mathematica as a C/C++ compiler [closed]

I am learning C/C++ programming, but I don't wannna install new software for compiling C/C++, so, is there any possibility to compile C/C++ code using Mathematica? Here is the first program I want to ...
15
votes
1answer
583 views

Has this implementation of FDM touched the speed limit of Mathematica?

Still, I'll use the implementation of the 1D FDTD method (you can simply understand it as a kind of explicit finite difference scheme for the Maxwell's equation) as the example. Just for completeness, ...
2
votes
0answers
48 views

Fine tuning compiled code that computes dilogarithm function

As an exercise of writing a good Compile function, I want to do the simple task of coding a routine that outputs the real part of the dilogarithm function ...
6
votes
3answers
215 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 ...
3
votes
1answer
129 views

How do I format Compile[] correctly?

My Mathematica skill is still rusty, so kindly bear with me. I'm having problem formatting expression to compile the function correctly: $\sum _{g=1}^G \sum ...
0
votes
0answers
41 views
3
votes
1answer
78 views

Evaluating arguments of module (inside compile)

Note: this is a clarification of 2 earlier unanswered questions, Compile issues, scoping and order of evaluation and Optimising a simple computation with vectors . The problem I have a list of ...
5
votes
1answer
145 views

Compile nested Sums

I want to compile an expressions that contains nested Sum-expressions. A simple example that gives me problems is: ...