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

learn more… | top users | synonyms

2
votes
1answer
82 views

Determine types of input, output and internal variables in compiled functions

I am trying to speedup the computation of a longer function using Compile. For illustration consider the following short example: ...
15
votes
2answers
200 views

Third argument of Compile

In his last comment on this answer, halirutan shows an example in which the third argument of Compile does not have any effect. The example is as follows. ...
20
votes
1answer
221 views

M9 performance regression for Fold?

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: ...
3
votes
2answers
161 views

Why is my compiled function slower than a regular function?

I have the following functions: ...
1
vote
1answer
219 views

How to use Compile with NDSolve function for large no of differential equations?

Matrix M[t] and and Hamiltonian of same order L^n x L^n. ...
8
votes
0answers
146 views

Check whether a working CCompiler is installed

Let me give a bit background: As many of my answers imply, I often use the auto-parallelization (meaning, that Mathematica distributes the calculation automatically over several cores when ...
1
vote
0answers
88 views

Compiled version of user-defined function

I have a function for parameter estimation with these codes: ...
10
votes
3answers
231 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: ...
4
votes
1answer
799 views

Creating a standalone (executable) from mathematica code

I have written a small mathematica code to input a ".csv" file and output the data in a specific format, in a ".txt" file. I would like to give this program as an executable to my friend as she ...
9
votes
1answer
145 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 ...
0
votes
1answer
85 views

How can a function with an embedded function be compiled?

Compile fun continues today, and I'm trying to get the function below to compile. First the function: ...
4
votes
3answers
188 views

How to compile a diagonal array efficiently?

For example, if we use some functions defined prior to Compile, we usually have the main evaluators in the compiled codes, pointing to the definition of the ...
1
vote
1answer
107 views

How to apply compiled function on list

Compile function output error: How to apply compiled function on list? ...
1
vote
0answers
147 views

Using Part within a Compiled Command

I'm looking to define a multi-line function that makes use of the "Part" command. A toy example: ...
10
votes
3answers
417 views

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

Update  Multiple optimizations that were suggested by members "ssch" and Simon Woods have in aggregate yielded a ~5X code-speedup; and these optimizations now are incorporated in the example ...
0
votes
1answer
200 views

Function won't compile. Is there a workaround? [duplicate]

Here's a simplified form of a function I would like to compile, but it produces errors ...
13
votes
1answer
144 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 ...
8
votes
3answers
415 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? ...
3
votes
2answers
185 views

My code for solving n queens problem Compile Failed

I want to make my code for solving n-queens problem faster, but it seems that MapIndexed can't be compiled. Mathematica return CompiledFunction::cfse: Compiled ...
1
vote
1answer
307 views

CompiledFunction::cfse: "Compiled expression X should be a machine-size integer

I am trying to use a compiled function in order to save time... LegrendeTransform = Compile[{y}, MaxValue[Sin[x] - x *y , x]] Now I want to to evaluate and ...
5
votes
1answer
186 views

How to use Compile to efficiently apply a function to every element of a list

Let's say I have a list of random numbers; list = Table[Random[], {100000}]; I want to apply a function f in every element of ...
8
votes
2answers
310 views

Goto and Compile

...
0
votes
1answer
136 views

How to return the rhs of a transformation rule from within Compile[]

I have defined the following function: ...
1
vote
1answer
146 views

No Speedup Compiled Function in FindMinimum

The problem: I would like to minimize an objective function with respect to 12 variables. Minimization should be executed as fast as possible. Compiling the objective function increases the execution ...
5
votes
1answer
66 views

Unequal and Compile

...
4
votes
1answer
141 views

MapThread and Compile

After discovering that MapIndexed cannot be used with compile (see MapIndexed and Compile) I am now trying do implement similar functionality using a combination of ...
4
votes
1answer
146 views

Can I compile a function containing ArcTanh?

Can I compile a function that contains ArcTanh[]? The following doesn't work Needs["CCodeGenerator`"] c = Compile[ {{x}}, ArcTanh[x]^2]; c[2.5] Mathematica gives ...
9
votes
1answer
449 views

Example program for calling Mathematica from C

I want to call Mathematica from a C program. Suppose I have two numbers x =2 and y=3. I want to define the x, y in a C program and call Mathematica and I want Mathematica to do the sum and return me ...
2
votes
1answer
113 views

Can Map operations be compiled or otherwise sped up for large lists?

I'm performing a series of Map operations in the following script: ...
1
vote
1answer
199 views

Why doesn't my code compile?

...
6
votes
2answers
170 views

ArcTan and Compile

See following three snippet code: ...
2
votes
2answers
128 views

global variables in compile statement

sorry for posting multiple questions about compile, but this is giving me some headache lately. This time my question is about using globally defined variables in a compile statement. The problem is ...
11
votes
1answer
220 views

MapIndexed and Compile

I am having trouble compiling a function that uses the MapIndexed function on the second level. The compilation runs fine, but at evaluation time I get an error ...
3
votes
1answer
118 views

How can I speed up my compiled function that is returned by another 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 ...
13
votes
1answer
188 views

Is the CompiledFunctionCall WVM opcode efficient?

There is example in Mathematica documentation about Compile ...
2
votes
1answer
131 views

how to Compile user-defined function like this

the following function can be compiled successfully ...
7
votes
0answers
245 views

Compile recursive function modifying global variables

How to compile recursive formula when it relies on more than a few global variables (global to the topmost compiled function)? It is unreasonable to pass on all such variables to each recursive ...
5
votes
2answers
177 views

Can we compile using only Integers Of Unusual Size?

I coined Integers Of Unusual Size to mean "bignum" using GMP, the underpinning of Mathematica's ability to craft very big numbers. I have these functions from this question: ...
3
votes
1answer
149 views

What is the correct way to use Compiled function in Table and Plot without slow down?

On V 9.01 on windows 7, all 64 bit. I am sure I am missing something simple here, but I used all the tricks of the trade that I know about, and read docs, and do not see anything that helps. Here is ...
2
votes
2answers
144 views

Compile error from If but not from Piecewise

Consider this: point={1.,2.}; f1 = Compile[{{t, _Real}}, Evaluate[Block[{a, b}, {a, b} = point; If[t > 0., a*b*Sin[t], 0.]]]]; f1[2.] ...
8
votes
1answer
251 views

How to compile Heike's winding number function?

Heike gave the following function for winding number: ...
4
votes
1answer
144 views

How to set return type of `InterpolatingFunction ` in compile

Consider this ...
2
votes
2answers
114 views

Error when compiling function containing InterpolationFunction

I'm trying to solve a coupled ODE system using NDSolve. The coupling can turn on and off in some regions, and when the coupling is off, the solution can be written ...
5
votes
1answer
161 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 ...
0
votes
0answers
54 views
16
votes
1answer
233 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 ...
1
vote
1answer
171 views

Calling several compiled functions inside another

Below, there is an example how I tried to call the compiled function "position" (which i got from this link position) inside another one. ...
1
vote
0answers
76 views

How can I compile function with Apply?

For example, I tried to compile this function but Mathematica gives "The only function arguments supported are Times, Plus, or List", I have no a way to compile this. ...
8
votes
1answer
271 views

Mathematica8 can compile this function but Mathematica 9 can't if I set CompilationTarget -> “C”

Following code worked on Mathematica 8, but in Mathematica 9 it can't be compiled, it return this message CompiledFunction::cflist: Nontensor object generated; proceeding with uncompiled ...