Skip to main content
21 votes

Compile vs FunctionCompile

On my M1 Max processor and with Mathematica 13.2.1.0, the speed differences are even more severe: ...
Henrik Schumacher's user avatar
20 votes
Accepted

Why CompilationTarget->"C" doesn't improve computation time

Additional to your (maybe a bit too thorough) safety checks, Mathematica injects quite many more bound checks for the calls to Part in order to avoid segfaults. ...
Henrik Schumacher's user avatar
15 votes
Accepted

Speediest Julia Set "By Hand"

Plotting a million points is rather slow, instead you can use Image. This requires the results in a 2D array, so remove the ...
Simon Woods's user avatar
  • 85.2k
14 votes

How to call the C++ by the new LibraryFunctionDeclaration?

This post is written with Mathematica version 13.1 and is subject to change in the future. Mathematica's C Types does not include vector type but includes ...
Ben Izd's user avatar
  • 9,484
14 votes

Using DataStructures in FunctionCompile

This is a bit too long for a comment, but below is a slightly modified version that uses the "DynamicArray" approach. The basic issue is that all the ...
ilian's user avatar
  • 25.5k
9 votes

How to restore the compile function from FunctionCompileExportByteArray

FunctionCompileExportByteArray@fun differs from FunctionCompile[fun][[1, "CompiledIR", $SystemID]] . The latter is ...
rnotlnglgq's user avatar
  • 3,740
9 votes
Accepted

How to call the C++ by the new LibraryFunctionDeclaration?

This is my program, in fact most of it comes from an unknown author. And it exactly is what I'm after. For more details you need to see follow this article for updates ...
yode's user avatar
  • 26.9k
7 votes

Implementing fast linear search for perfect vertical image alignment

Another, similar strategy could be to downsample the images by employing ArrayResample, derive a first guess for align from the ...
Henrik Schumacher's user avatar
6 votes

Can I efficiently use a compiled function as an input to another compiled function?

From docs, Compile can handle _Integer, _Real, _Complex ...
I.M.'s user avatar
  • 3,106
6 votes

How to get a MTensor variable by a vector object

Here's one way that works, although I am not sure it is the intended way: ...
Lukas Lang's user avatar
  • 34.2k
5 votes
Accepted

Using DataStructures in FunctionCompile

I give a simplified version below that is slightly faster than the solution from illan. ...
Ted Ersek's user avatar
  • 959
5 votes
Accepted

Implementing fast linear search for perfect vertical image alignment

Here is a way to speed up the search for the perfect alignment without loosing the most remarkable feature of the algorithm given in the question, which makes it robust: the true minimum is always ...
Alexey Popkov's user avatar
4 votes
Accepted

Why the Debug .dll is work normall but the Release .dll is crash in librarylink?

When I use WolframLibraryData to initialize the MTensor now, I have solved the crash bug. And don't leak memory anymore´╝Ü ...
yode's user avatar
  • 26.9k
4 votes

FunctionCompiling lists of things

You are correct this type of polymorphism does not yet exist. At compile time the new compiler must be able to determine all of the types. The second type of polymorphism can be used to call ...
A.Richards's user avatar
4 votes

Implementing fast linear search for perfect vertical image alignment

Here is a method with two caveats. (1) It is not quite linear but rather it's softly linear (it has a logarithmic factor).. (2) While the result will show that it works quite well, it was failing ...
Daniel Lichtblau's user avatar
3 votes
Accepted

Why are Packed Arrays limited to signed machine precision types?

(converting comments to answer) why are integer packed arrays limited to signed integers I would say because there is no unsigned integer in WL, or 16-bit or 32-bit integers for that matter, just ...
Jason B.'s user avatar
  • 69.2k
3 votes
Accepted

Problem compiling derivative of expression

In addition to what Domen wrote in their post, I strongly recommend to scope the variable in the expression to make all this less brittle. Currently, some user of your code simply needs to assign some ...
Henrik Schumacher's user avatar
3 votes
Accepted

How do I use a FunctionCompile(d) function in FindMInimum

You had the right idea, but _NumericArray will only match explicit NumericArray expressions, not arrays of numbers in general. ...
Simon Woods's user avatar
  • 85.2k
3 votes

How to use global variables in FunctionCompile?

It seems like it is possible: ...
IntroductionToProbability's user avatar
2 votes

Why the Debug .dll is work normall but the Release .dll is crash in librarylink?

Add a librarylink version, which based on DataStore. It don't crash and doesn't leak memory anymore: ...
yode's user avatar
  • 26.9k
2 votes

How to use global variables in FunctionCompile?

Such as you have a global variables a: a = 7; You can use it in FunctionCompile with a <...
yode's user avatar
  • 26.9k
2 votes

LMDB Library cannot be loaded by `LibraryLoad`, how to compile properly

I've mentioned Java because Wolfram Language can run Java code directly without using ExternalEvaluate or similar functions. To illustrate my point, I've translated ...
Ben Izd's user avatar
  • 9,484
2 votes

Problem compiling derivative of expression

First, remove the second Function, because you already have the Function wrapper. Second, because ...
Domen's user avatar
  • 27.7k
1 vote

How to compile this function to speed up operation?

The following code is original by @flc: ...
miss's user avatar
  • 874
1 vote
Accepted

How to get a MTensor variable by a vector object

I introduce a library WolframRTL_Kernel.lib then solve this problem: ...
yode's user avatar
  • 26.9k

Only top scored, non community-wiki answers of a minimum length are eligible