Questions about the generation and use of compiled functions using Compile.
7
votes
0answers
79 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 ...
7
votes
2answers
152 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 ...
5
votes
0answers
76 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 ...
13
votes
1answer
483 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 ...
0
votes
1answer
142 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 ...
13
votes
2answers
302 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 ...
2
votes
1answer
96 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 ...
2
votes
0answers
55 views
Compile: Putting integers into a list
I started compiling in Mathematica a few weeks ago.
In the code below, I want to put the integer value 0 into the list "Pre". If I "Print" the list, it will look like {0,0,....,0}. But the output of ...
1
vote
1answer
74 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 ...
8
votes
2answers
212 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
87 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 ...
2
votes
1answer
1k views
Visual Studio Express 2010 on x86-64: libcmt.lib missing
The CCompilerDriver documentation explains that to use visual studio express on 64-bit targets, it's necessary to install the windows SDK after installing visual studio. I have done this, first ...
3
votes
2answers
406 views
Optimize inner loops
I'm Mathematica newbie so please be gentle :)
I have this, heavily non-optimized part of code, which I would like to speed up. I have put all matrices to be RandomReal, but in my code they take ...
10
votes
3answers
237 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
0answers
68 views
6
votes
1answer
151 views
Why does compiling a function with ConstantArray give an error when used in parallel?
Here is a sample compiled function:
...
50
votes
6answers
3k 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 ...
58
votes
4answers
3k 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 ...
13
votes
3answers
270 views
Quick multiple selections from a list
What is the fastest way to make multiple selections from a list? Compiled methods included.
For example, here are two methods for selecting a subset, compared:-
...
13
votes
1answer
181 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 ...
1
vote
1answer
57 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
94 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
116 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 ...
11
votes
1answer
162 views
Is it possible to use Compile on a function with optional arguments?
My Mathematica is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own!
Simple example : ...
3
votes
2answers
117 views
Listable compiled function using Map
I'm trying to minimize the computation time of problem which is too long to post. I use compilein order to gain some speed. To increase speed I would like to use ...
6
votes
1answer
147 views
DistributeDefinitions not working for compiled functions
This is fixed in Mathematica 9.0.0.
I'm having trouble with parallel evaluation of compiled functions. Here is a simple example illustrating the problem:
...
2
votes
2answers
146 views
What is the maximum real value for Compile?
Can one be found programmatically? The function I'm compiling, indicesOfMin, gives the indices of the minimum value(s) of a real-valued list, the parameter, in a ...
0
votes
1answer
161 views
I can't get Compile to work
I've got some problems with my code, and I try to make it faster. Some of you suggested me to split my problem, and I'm here...
I post the same function with and without Compile.
This is a support ...
14
votes
1answer
157 views
How can you profile compiled code?
Is it possible to profile compiled code? I am using Workbench 2.0 and the Profile[] command but I do not get a profile of my compiled function.
I apologize if the answer is readily available but I ...
4
votes
1answer
206 views
Using a compiled function inside NIntegrate gives “CompiledFunction::cfsa” message
The following function is defined for Real input:
FFc = Compile[{{x, _Real}, {EF, _Real}},If[x > EF, 0., If[x == EF, 0.5, 1.]]]
FFc is now used in the ...
5
votes
2answers
133 views
10
votes
2answers
181 views
Compiling LinearSolve[] or creating a compilable procedural version of it
Earlier today I had a discussion with a representative at Premier Support about the 2 questions I've asked here over the past couple of days:
Seeking strategies to deploy a function securely ...
1
vote
1answer
214 views
3 hour calculation? ParallelMap & ParallelTable
I'm having some problems with slow Mathematica code... I'm basically doing a computation that's is expected to take 3 hours (!) in my Core i7 with 4 processors... I'm basically computing an index (of ...
8
votes
1answer
135 views
error when defining a compiled function with ReplacePart
I always have difficulty in writing a non-trivial compiled function. I'm using Mathematica 9. Please see the following code
...
4
votes
4answers
231 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 ...
11
votes
3answers
278 views
What compilers are “suitable” for CompilationTarget->“C”?
The documentation for CompilationTarget says, "if you do not have a suitable C compiler then you will not be able to set CompilationTarget to C". Well at this time, I don't have a compiler installed ...
9
votes
3answers
270 views
Compiled function error - nontensor object created
I'm trying to optimize code that uses Position MANY times.
The following toy code works:
...
7
votes
1answer
162 views
Compiling Map over expression that yields a ragged array
I'm trying to speed up a function that looks in the neighborhood of each 3D point in a large dataset and finds all the points within 1 unit in each direction, x, y, z.
I've started by using ...
10
votes
1answer
519 views
How to install and configure Intel C++ Compiler for Mathematica correctly?
I wish to try the trial version of the latest Intel C++ Compiler for Windows with Mathematica. I have downloaded the current version of IntelĀ® C++ Composer XE 2011 for Windows and installed only the ...
13
votes
1answer
228 views
Using Boost with CreateLibrary
I was looking at the answer of Leonid of Faster alternatives for DayOfWeek and wanted to see how hard it would be to do something similar in C++ using an external library like Boost. I tried to ...
11
votes
1answer
750 views
How do I get Mathematica to recognize a C compiler on a 64-bit Windows machine?
Mathematica does not recognize any C compiler on my computer. I run Mathematica 8.0.4.0 on Windows 7. I've tried to make sure various C compilers are installed on my computer, but I'm not sure how to ...
6
votes
1answer
270 views
Speeding up numerical Fourier Transform
I wrote this function NFourierTransform, which takes a function $f(k)$ and numerically calculates the fourier transform integral for discrete values of $k \in ...
4
votes
2answers
111 views
Error in Compiled function at runtime in spatial competition model
I just did a model of spatial competition between two species with different competitive ability & dispersal rates on a lattice with variables nrs of individuals per site. To speed it up I tried ...
6
votes
2answers
193 views
Compiling a spatial predator-prey model and optimising it for speed
I just made a spatial predator-prey model but it runs a little slow and I am seeking some advice on how to compile it to optimise it for speed.
I first define matrix with 0 for an empty site, 1 for a ...
2
votes
1answer
165 views
2
votes
0answers
116 views
32
votes
2answers
979 views
Internal`Bag inside Compile
Since Internal`Bag, Internal`StuffBag and Internal`BagPart can be compiled down, it is a ...
3
votes
0answers
193 views
Catching and debugging numerical errors in compiled functions
I have a compiled function (that was created using the second method of this question). Basically it's using a compiled closure. The problem is that for some parameter values it does not evaluate. ...
2
votes
1answer
243 views
Mathematica NDSolve and 'Compile'?
Since the consensus is usually that NDSolve speeds fares badly against compiled code such as c++ ODE solvers using GSL say, is it possible to make up for this lag ...
6
votes
1answer
263 views
Compiling a recursive formula
My question is related to computing what is called "invariant measure" for a particular well known fractal - the Sierpinski triangle.
We have an array m of four two by two matrices, say
...



