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

learn more… | top users | synonyms

3
votes
2answers
183 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
270 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
179 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
293 views

Goto and Compile

...
0
votes
1answer
126 views

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

I have defined the following function: ...
0
votes
1answer
122 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
135 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
141 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
401 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
112 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
181 views

Why doesn't my code compile?

...
6
votes
2answers
166 views

ArcTan and Compile

See following three snippet code: ...
2
votes
2answers
116 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
218 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 ...
1
vote
1answer
106 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
170 views

Is the CompiledFunctionCall WVM opcode efficient?

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

how to Compile user-defined function like this

the following function can be compiled successfully ...
7
votes
0answers
232 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
169 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
141 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
138 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
246 views

How to compile Heike's winding number function?

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

How to set return type of `InterpolatingFunction ` in compile

Consider this ...
2
votes
2answers
108 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
158 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
15
votes
1answer
228 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
160 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
75 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
266 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 ...
3
votes
2answers
211 views

Underflow occurred in compilation

This code shown below works well for n<=10, if n>11, Mathematica gives the message CompiledFunction::cfne: Numerical error encountered; proceeding with uncompiled evaluation. >>. So ...
9
votes
0answers
142 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 ...
24
votes
4answers
947 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 F and G F[x_] := x + 2 G[x_] := x And I want ...
6
votes
0answers
94 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 ...
15
votes
1answer
655 views

What technical obstacles prevent all Mathematica code compiling to C

The following represents an attempt at a very simple view of the levels in Mathematica code: We have had lots of questions about deployment and compiling Mathematica code to C. Some of these for ...
14
votes
2answers
1k views

Fastest way to measure Hamming distance of integers

I am looking for a fast and robust way to calculate the Hamming distance of integers. The Hamming distance of two integers is the number of matching bits in their binary representations. I expect that ...
4
votes
1answer
190 views

Is it possible to create a compiled function with some symbolic arguments?

I am trying to create a compiled function that takes in several arguments. However, some of the arguments contain symbolic entries and thus I get the following error message when executing the cell ...
3
votes
1answer
183 views

Compile: Putting integers into a list

The first part below is already answered, but I've got another question which I think is closely related to this one, so I edited my question. First part: I started compiling in Mathematica a few ...
1
vote
1answer
125 views

Efficient evaluation of function defined by multiple Sum

I tried to make a workable example here. The problem is that it is very very slow. I must be doing something very stupid out here. Can somebody give me some clue how to evaluate this multiple sum ...
12
votes
2answers
442 views

How can I compile this function

I want to simplify my function f1 to f2, but f2 can't be compiled. How can I make it ...
0
votes
1answer
156 views

Alleviating a bottleneck involving a function call with symbolic derivatives

I have a bottleneck problem involving a function call with symbolic derivatives. I don't have much experience with Mathematica (or any dynamic language) and I'm certain that the way I've set this up ...
0
votes
0answers
74 views
11
votes
3answers
510 views

Efficient implementation of a linear complexity measure of binary sequences

For a implementation of testing the quality of random number generators I implemented the NIST test suite in Mathematica based on the nice workbook by Ilja Gerhardt. However I took up the challenge ...
0
votes
1answer
389 views

How to use Compile for accelerating matrix multiplications?

I am trying to find the inverse of the matrix $A$ m = n = 500; SeedRandom[123456]; A = RandomReal[10, {m, n}]; iteratively using the following matrix ...
6
votes
1answer
258 views

Why does compiling a function with ConstantArray give an error when used in parallel?

Here is a sample compiled function: ...
1
vote
1answer
74 views

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

Here is a narrowed-down example, the first case works, but the second one refuses to use the compiled version: ...
2
votes
0answers
191 views

Listing over multiple inputs (tensor rank > 1) in a compiled function

I'm trying to optimize the solution given by Michael E2 to my previous problem (Efficiently determining if 3D points are within a surface composed of polygons) which I figured would be relatively ...
6
votes
1answer
203 views

Compiling Error functions of complex values

According to List of compilable functions Erf and Erfc are compilable functions. However, I want to make a compiled version of ...
14
votes
1answer
269 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 ...