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

learn more… | top users | synonyms

116
votes
8answers
10k 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 ...
0
votes
0answers
23 views
3
votes
1answer
72 views

Table with programmatically specified number of iterators in Compile

Compare two ways of computing a table of values of a multivariable Gaussian: ...
4
votes
1answer
74 views

How to compile when function contains Condition?

I use the following triangular recursive algorithm to compute $\{N_{i-p,p},\cdots,N_{i-1,p},N_{i,p}\}$ here, ...
7
votes
1answer
88 views

How to boost the performance of my own BSplineFunction

In my CAGD package, I implemented a CAGDBSplineFunction[] like built-in BSplineFunction[]. ...
1
vote
1answer
62 views

Create a Mathematica function that can be called from R or Matlab

I would like to export a function from Mathematica to allow it to be accessed from R and/or Matlab. Is there a way to do this? As an example, suppose I want to export the following (albeit ...
1
vote
0answers
54 views

How to speedup Plot3D with precompiled argument

I have a huge problem with my code: I estimate it to take hours to run. The scheme of the code is the following (I left the steps the same, but took much simpler functions): ...
12
votes
1answer
212 views

Has compilation of big programs become excessively sluggish in v 10.4?

Bug introduced in 10.4 and persisting through 10.4.1 After updating to 10.4, many of my heavily numerical functions defined by Compile takes a huge amount of time ...
2
votes
1answer
70 views

Compile with a list as an argument

This is probably trivial, but I couldnt make it work: safeConv = Compile[{{a, _Complex, 10}, {b, _Real}}, If[b > 1, a[[1]], 0] ]; I get a rank-error ...
0
votes
0answers
48 views

Problem with Greater in Compile

I am relatively inexperienced with Mathematica so I apologize for the possibly simple question. I have written the following function which should receive a matrix as input. If I compile this, ...
17
votes
2answers
1k views
0
votes
0answers
42 views

Compiled funtion don't understand internal compiled function [duplicate]

I work a lot on Mathematica and sometimes I need to optimize my computations by using compiled functions. Now I'm making numerical integrations and I'm trying to compile the functions involved to make ...
5
votes
1answer
262 views

Error messages from compiling the Piecewise function

The following works Compile[{{x, _Real}}, Piecewise[{{{0., 0.}, x > 5.}}, {1., 1.}]] but if I enter the Piecewise[...] in ...
1
vote
1answer
82 views

What's the syntax to compile these functions, whose arguments are nested lists? [closed]

In some case the Compile's syntax is quite straightforward. Es. for rank 1 e rank 2 tensors: ...
1
vote
1answer
88 views

Compile function - error but correct calculation

I am investigating Compile lately and I came across the following problem. I define a 2-variable function ...
119
votes
6answers
11k 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 ...
3
votes
1answer
137 views

Why does Compile not make my function faster?

I need to speed up a large program that repeatedly calls the module below (I've not trimmed the code for this question to ensure there is enough calculation to show a speed improvement.) The obvious ...
2
votes
3answers
143 views
3
votes
1answer
54 views

List of compiled functions and then plot them 1 by 1.

I would like to create a list of compiled functions and then plot them 1 by 1. To illustrate the problem (In reality the functions I want to compile are of course not x^j but some complicated ...
37
votes
4answers
2k views

Compiling more functions that don't call MainEvaluate

I would like to use Compile with functions defined outside Compile. For example if I have the two basic functions ...
6
votes
2answers
118 views

How to define a complicated function inside the body of Compile?

I want to compile a function in a way to keep its memory footprint down. In the example below, I am trying to compile a function f that makes three calls to ...
3
votes
0answers
45 views

weird behaviour of Listable fortran Librarylink function: different result each evaluation

I am working with fotran librarylink function currently. In this post, I will show some weird result of Listable fortran librarylink generated by intel compiler under windows (I tried gcc on linux the ...
1
vote
1answer
34 views

Length in Compile encounter “type Integer encountered in assignment of Type Real ”

Compile[{}, Module[{n}, n = Length[{1, 2, 3, 4}]; n = n/2]] The above code will emit errors Compile::cset: Variable n of type _Integer encountered in ...
1
vote
0answers
68 views

Compiled function and integration

I'm using the recursive functions defined here: MyFnc and myFncC (compiled version). I want to call this functions in the ...
2
votes
1answer
242 views

Speeding up this recursive function

I have a recursive function defined like this: ...
1
vote
1answer
91 views

Manipulating Some Lists in Compile

Consider a list of lists, such as: Z={{1,4,3},{2,1,3},{3,1,4}} Z is an $n \times n$ matrix (here $3 \times 3$) which ...
1
vote
1answer
93 views

How to do this Function with compile

There is 4 lists, 3 of them are at same length (l0, l1 and l3). ...
1
vote
1answer
102 views

Why doesn't Compile work on the Permutations function with second arguments?

Here is a narrowed-down example, the first case works, but the second one refuses to use the compiled version: ...
3
votes
1answer
79 views

Compile::cplist: error from MapThread [duplicate]

What is the cause of this error? Compile[{{r, _Integer, 2}, {d, _Integer, 2}}, pos = Position[MapThread[#1 > #2 &, {r, d}, 2], x_ /; x == True]] ...
1
vote
0answers
52 views

Compilation error: “Could not complete external evaluation at…”

I'm pretty new to trying to use Compile[], and I just can't see why I'm getting this error. I have two functions to define beforehand; one of them is a bit odd: ...
2
votes
1answer
136 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
19
votes
0answers
259 views

Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0 and persisting through 10.3.1 or later In the following example, inside the minimumX's Module, ...
24
votes
5answers
920 views

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

Update III  Mathematica 10.2.0 now ships with a predefined System`Permanent function, which the PermanentCode package ...
5
votes
1answer
103 views

Compilation, square roots, and integers

After looking at this question, particularly this answer, I wrote my own performance test, using the two functions ...
0
votes
0answers
58 views

Error message when using a compiled function in NSum [duplicate]

Below is a simple example to illustrate the problem test = Compile[{{n, _Integer}}, n] Now, Table works fine ...
3
votes
3answers
121 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. ...
6
votes
1answer
68 views

Compile Select returns “Null tensor with rank > 1 encountered at instruction 24”

This is the problematic part of one long function, wich should applyied many times to the list ...
5
votes
1answer
197 views

How to compile this code?

Could somebody teach me how to compile this code? ...
5
votes
1answer
158 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 ...
3
votes
1answer
91 views

Is there any way to use compile and still maintain high precision in Mathematica? [duplicate]

Is there any way to use compile and still maintain Arbitrary-precision like 50 in Mathematica?
0
votes
1answer
51 views

Compile decreases the number of returned list elements

I have: LogisticMap = Compile[{μ}, ({μ, #} &) /@ Union[Drop[NestList[μ # (1 - #) &, .2, 300], 100]]]; Then: ...
0
votes
0answers
83 views

Nestlist inside Compile

My question is a continuation of question1 and question2, but I think it may be considered as a self-contained one. I am interested to make the following code faster ...
10
votes
1answer
307 views

Using Compile to speed up Function with PermutationProduct [closed]

I have the following fairly simple routine dot involving PermutationProduct that I wish to speed up using ...
6
votes
1answer
209 views

My introduction to Compile

I am reading Fractals from the Newton-Raphson method from Peter Young's page [http://young.physics.ucsc.edu/115/]{http://young.physics.ucsc.edu/115/}. I've tried: ...
5
votes
2answers
121 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: ...
10
votes
2answers
518 views

Compiling the VoigtDistribution PDF

According to List of compilable functions, Erf and Erfc are compilable functions. However, I want to make a compiled version ...
6
votes
2answers
195 views

Challenge: Creating Compilable Permutations Function

As Mathematica's implemented Permutations function is not compilable I tried to write my very own Permutations implementation, called ...