Questions tagged [function-compile]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
81 views

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

I have a compiled function(such as $f\left(z,c\right)=z^2+c$) which will get replaced by different equations as the code runs. I'm using this compiled function(#1) inside another compiled function(#2)....
  • 171
1 vote
0 answers
49 views

How to use FunctionCompile and Compile as external definition?

Let's consider the following functions (in $Version: 12.3.0 for Linux x86 (64-bit) (May 10, 2021)) ...
  • 403
11 votes
1 answer
1k views

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

I wrote a simple code to test the computation time under CompilationTarget->"C". I get barely any improvement on the computation time from ...
  • 403
1 vote
2 answers
89 views

How to use global variables in FunctionCompile?

In FunctionCompile, system does not recognize external functions and external global variables by default. But we can use ...
  • 123
0 votes
0 answers
67 views

Sharing state among FunctionCompile'd functions

Understanding that the new Wolfram compiler remains a work in progress: Global variables apparently aren't accessible from FunctionCompile'd functions. However, ...
  • 518
1 vote
0 answers
38 views

How use LibraryFunctionDeclaration to call the function with DataStore parameter?

I have a CMakeProject1.dll produced by this code: ...
  • 25.3k
2 votes
0 answers
112 views

Problem with "FunctionCompile"

MMA version 13.1 Windows 10 Can someone explain why the following compiles: f = Function[{}, Table[i, {i, 2}]]; FunctionCompile[f] But if we have 2 iterators it ...
  • 37.7k
4 votes
2 answers
198 views

How to get a MTensor variable by a vector object

librarylink have a dirty signature such as: EXTERN_C DLLEXPORT int fun(WolframLibraryData libData,mint Argc, MArgument* Args, MArgument Res) But when we are in ...
  • 25.3k
9 votes
1 answer
300 views

How to restore the compile function from FunctionCompileExportByteArray

We can compile a function into a ByteArray object: ...
  • 25.3k
5 votes
2 answers
258 views

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

The Catenate is very slow in FunctionCompile. So I want to use the librarylink to make a .dll...
  • 25.3k
22 votes
2 answers
556 views

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

When we arrive at V13.1, we have a great LibraryFunctionDeclaration now, which can call C function in MMA as this article: ...
  • 25.3k
2 votes
0 answers
53 views

Using FunctionCompile to emulate DistanceMatrix with my own DistanceFunction

I'd like to create a distance matrix with an expensive distance function. To explore how to do this for a simpler case, consider these three ways of creating a Euclidean distance matrix: Using a ...
  • 3,140
6 votes
1 answer
216 views

FunctionCompiling lists of things

I have a compiled function that works on a list of some atomic type e.g. strings, but also want it to work on lists of others (e.g. integers, reals, symbols, etc). Moreover, nothing in the code has to ...
  • 3,637
5 votes
3 answers
239 views

Implementing fast linear search for perfect vertical image alignment

After experimenting with image alignment aprroaches presented here and here and some other approaches involving ImageDistance and ...
3 votes
1 answer
103 views

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

Suppose I would like to speed up the function in FindMinimum[function[variables],startingPoint] by compiling function I've constructed a minimal working example to describe what I would like to do. ...
  • 3,140
11 votes
1 answer
390 views

Speediest Julia Set "By Hand"

While being aware of the built-in command, I would like to show my students how the Julia set is actually generated. The code I came up with is slow, even though I am quite happy with the picture it ...
  • 333
1 vote
0 answers
80 views

FunctionCompile Type Errors

This function works uncompiled: Function[{n, m, k}, ParallelSum[ Length[Permutations[i]], {i, IntegerPartitions[m, {n}, Range[0, k]]} ]] but compiling with <...
user avatar
4 votes
0 answers
87 views

How to efficiently build a large sparse matrix and overloading a compiled function?

I would like to construct a large sparse matrix folding from rank-4 tensor given by the following: $\mathcal{L}_{1L}^{00}(i,j)=\mathcal{L}_{1L}^{00}(m_1,m_2;M_1,M_2)$ The indices of matrix $(i,j)$ are ...
  • 445
0 votes
0 answers
129 views

How to calculate this summation numerically?

I want to calculate this summation numerically: $\sum_{n=1}^{10^{10}}\frac{1}{n^3\sin(n)^2}$ First I try NSum[1/(n^3 Sin[n]^2), {n, 1, 10^10}] however it gives a ...
  • 483
15 votes
0 answers
370 views

FunctionCompile examples for Computer Vision

I'm looking for some good examples of FunctionCompile applied to image processing code since there doesn't seem to be anything on this in the documentation. So here's a first attempt at a hello world ...
  • 30.8k
10 votes
1 answer
301 views

Using DataStructures in FunctionCompile

This is a follow up to this StackExchange question I am trying to do the equivalent of Select on a "FixedArray" data structure. Here is what I have tried so far: ...
  • 3,140
11 votes
0 answers
218 views

How to use Bags in FunctionCompile?

I was reading this question and it wanted to know how to FunctionCompile this: ...
  • 30.8k