Tagged Questions
5
votes
0answers
77 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
2answers
307 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 ...
10
votes
3answers
239 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 ...
13
votes
3answers
271 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:-
...
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 ...
6
votes
1answer
272 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 ...
6
votes
2answers
194 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 ...
6
votes
1answer
265 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
...
10
votes
1answer
177 views
Removing calls to MainEvalute when using inlined compiled closures
This question is tightly related to the answer Shaving the last 50 ms off NMinimize.
There @OleksandR shows how inlined closures can be used to eliminate calls to ...
6
votes
1answer
128 views
Elementwise, compilable min function
I am trying to implement efficiently a transfer-matrix like algorithm. On each iteration, I have two vectors $x=\{x_1,\dots,x_n\}$, $y=\{y_1,\dots,y_n\}$ with real numbers and I need to compute the ...
8
votes
0answers
178 views
Using Compile to speed up Function with PermutationProduct
I have the following fairly simple routine dot involving PermutationProduct that I wish to speed up using ...
7
votes
1answer
295 views
9
votes
3answers
272 views
Compiled function error - nontensor object created
I'm trying to optimize code that uses Position MANY times.
The following toy code works:
...
11
votes
3answers
281 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 ...
11
votes
2answers
563 views
Speeding up random walk for many particles
I am trying to speed up this code for many particles to take a random walk. I'm not sure why it is so slow for such a simple task.
I got a few hints from colleagues to reduce the precision of the ...
7
votes
2answers
392 views
Working with large data, pass-by-reference, compiled functions
I think I know the answer to this, but after two days of Googling, this is my last effort before going down an unwanted path...
I have a function that takes lots of large data as arguments as well as ...
12
votes
2answers
415 views
Efficiently collecting results inside a compiled function
When we don't know the number of results that will be generated, the usual way to collect results is Reap/Sow. Another ...
10
votes
3answers
426 views
Function does not compile with Greater in it
I have to speed up a matrix-calculation and would like to use Compile for it, though it fails and produces an unknown error message:
...
32
votes
2answers
985 views
Internal`Bag inside Compile
Since Internal`Bag, Internal`StuffBag and Internal`BagPart can be compiled down, it is a ...
11
votes
2answers
119 views
How do you determine the optimal autocompilation length on your system
When you pack lists there is an overhead therefore packing a list with, say, 2 elements is likely to cost more than you get back in efficiency. Mathematica has default list lengths for which functions ...
31
votes
4answers
1k views
Speeding up this fractal-generating code
I used the code below (which is a sample from this gist containing more similar code) in my answer to my own question about Mandelbrot-like sets for functions other than the simple quadratic on ...