Skip to main content

Questions tagged [function-compile]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

Function's maximum argument number while compiling [closed]

Dear Mathematica users, As experts know while compiling, ...
Kazim Ahmet Hasim's user avatar
3 votes
1 answer
40 views

Compilation error while adding two matrices [closed]

Dear Mathematica users, I would like to compile my function and my sample code is as: ...
Kazim Ahmet Hasim's user avatar
0 votes
0 answers
39 views

How to make a Do iterator to get a specified value when calling a function? [closed]

Dear Mathematica users, I would like to compile my function first to make the calculations faster. My sample code is as: ...
Kazim Ahmet Hasim's user avatar
0 votes
0 answers
24 views

Compilation of the function that should return vector along with matrix [duplicate]

I am looking for the way how to compile the function that is supposed to return vectors along with matrices. The simplified example looks next: ...
Oleksii Semenov's user avatar
3 votes
2 answers
89 views

Problem compiling derivative of expression

I need to compile functions for an expression and its derivative and then pass these on to a precompiled worker loop for further processing. An If statment detects when the expression parameter expr ...
Mikl's user avatar
  • 101
0 votes
0 answers
33 views

Defining a function for FunctionCompile[]

Lets say that I have the definition EQN4 that is determined from some calculation. If I run it in a cell, I get the following output: ...
Bajablaster's user avatar
23 votes
1 answer
607 views

Compile vs FunctionCompile

I wanted to look at the pros & cons of Compile & FunctionCompile. This code below is from Neat Examples in FunctionCompile documentation. ...
Ted Ersek's user avatar
  • 929
0 votes
0 answers
50 views

Are you surprised with the apparent inconsistency in what this CompiledCodeFunction returns?

I am using Mathematica 12.2 with MacOS, and I do this: ...
Ted Ersek's user avatar
  • 929
2 votes
0 answers
42 views

How can I know what prevents efficient lower level code when using FunctionCompile?

When using the old Compile, I can use CompilePrint and ensure the resulting CompiledFunction doesn't use MainEvaluate. If MainEvaluate isn't used, the CompiledFunction is efficient. How do we know if ...
Ted Ersek's user avatar
  • 929
0 votes
1 answer
152 views

How to compile this function to speed up operation?

...
miss's user avatar
  • 874
1 vote
1 answer
110 views

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

I cloned LMDB* from https://github.com/LMDB/lmdb and compiled on a Mac M1 with make -e clean liblmdb.so CC="cc -target aarch64-macos-none" which produced ...
Adam's user avatar
  • 3,956
2 votes
0 answers
81 views

Large Structured Programming with Compile

Is it possible or wise to build a large program structure with only Compile? With FunctionCompile it is possible to create ...
Michael Haring's user avatar
2 votes
0 answers
100 views

How can I compare two ByteArrays inside FunctionCompile in 13.3

I need a compiled function that takes an array of bytes as input and in the process compares parts of that array. It's really just looking for the occurrence of one array in another. It works if you ...
Kirill Belov's user avatar
3 votes
1 answer
104 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)....
Laff70's user avatar
  • 171
1 vote
0 answers
75 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)) ...
csk 7's user avatar
  • 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 ...
csk 7's user avatar
  • 403
2 votes
2 answers
136 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 ...
swish47's user avatar
  • 153
0 votes
0 answers
75 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, ...
RRas's user avatar
  • 548
1 vote
0 answers
41 views

How use LibraryFunctionDeclaration to call the function with DataStore parameter?

I have a CMakeProject1.dll produced by this code: ...
yode's user avatar
  • 26.8k
2 votes
0 answers
119 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 ...
Daniel Huber's user avatar
  • 52.7k
4 votes
2 answers
212 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 ...
yode's user avatar
  • 26.8k
9 votes
1 answer
315 views

How to restore the compile function from FunctionCompileExportByteArray

We can compile a function into a ByteArray object: ...
yode's user avatar
  • 26.8k
5 votes
2 answers
645 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...
yode's user avatar
  • 26.8k
23 votes
2 answers
627 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: ...
yode's user avatar
  • 26.8k
2 votes
0 answers
64 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 ...
Craig Carter's user avatar
  • 4,510
6 votes
1 answer
252 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 ...
user5601's user avatar
  • 3,655
5 votes
3 answers
262 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 ...
Alexey Popkov's user avatar
3 votes
1 answer
118 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. ...
Craig Carter's user avatar
  • 4,510
11 votes
1 answer
518 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 ...
Matthias's user avatar
  • 353
1 vote
0 answers
99 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
110 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 ...
Bob Lin's user avatar
  • 445
0 votes
0 answers
162 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 ...
Jie Zhu's user avatar
  • 998
16 votes
0 answers
393 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 ...
M.R.'s user avatar
  • 31.5k
12 votes
2 answers
402 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: ...
Craig Carter's user avatar
  • 4,510
11 votes
0 answers
220 views

How to use Bags in FunctionCompile?

I was reading this question and it wanted to know how to FunctionCompile this: ...
M.R.'s user avatar
  • 31.5k