Questions tagged [compile]
Questions about the generation and use of compiled functions using Compile.
635
questions
4
votes
0
answers
46
views
Can one have a ragged array as an intermediate step inside Compile? [closed]
I am aware that one should avoid (or be very careful) with ragged arrays as input or output of compiled functions. I, however, would like to be able to have a ragged array as an intermediate result ...
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 ...
0
votes
0
answers
32
views
Compiling functions with unit conversions
I have a numerical function that incorporates many units that I would like to speed up by using Compile. Here is a toy example of what I mean, doing it manually by ...
3
votes
0
answers
78
views
Free up used Memory
When using FunctionCompile[] to generate a large matrix of ranges there seems to be no way of recovering memory even though the variables are either out of scope or overwritten. I am aware that there ...
3
votes
1
answer
93
views
How To Compile The Computation Of Cumulative Returns
I'm trying to compile this function, specifically the second line which computes the cumulative return of 100 daily returns.
...
3
votes
1
answer
94
views
Compile function dynamically
To optimize a brute force algorithm on graphs I want to compile dynamically a list of functions for a list of graphs.
(The representation I'm using for a graph is a list of pairs of integers: integers ...
3
votes
1
answer
85
views
How to compile sum over the compiled expression?
Consider the following toy code:
...
5
votes
1
answer
91
views
Compile with arbitrary array argument
I need solve the task of classification of the points regarding their position. So I use such a function:
...
7
votes
1
answer
147
views
Pick with Unitize vs Pick with Clip vs Compiled Select speed - anything faster?
Given a large list of $n$ dimensional sublists where each sublist has integer elements I am trying to find the quickest way of finding all sublists that satisfy some constraint on their elements.
A ...
0
votes
1
answer
112
views
Trying to speed up finding solutions of quadratic form related to the weight of a matrix
Say I have an integer matrix of size $5 \times 5$ - I am trying to find the solutions to the equation $n^4 wtM = n w^2 + x1^2 + x2^2 +x3^2 +x4^2 + x5^2$ subject to the constraints $x1+x2+x3+x4+x5 = 0$ ...
1
vote
1
answer
55
views
Compiling an expression in a variable
I'm trying to compile a rather long (takes quite some time to scroll through) expression that is in a variable but I'm unsure how it would be done in mathematica. I've tried the obvious
...
0
votes
0
answers
60
views
How to speedup the following evaluation?
Consider the following function:
...
6
votes
1
answer
148
views
Mathematica never stop when running Needs["CCompilerDriver`"]
I am using Mathematica 12.2. I found that running
Needs["CCompilerDriver`"];
kind of freezes my Mathematica, it just never stop. Alt+. can not abort it ...
10
votes
2
answers
246
views
How to compile matrix product?
Consider the following matrices:
...
1
vote
0
answers
86
views
How to compile the following evaluation?
I have the following question. I want to generate three vectors p1Unrotated,p2Unrotated,p3Unrotated at some reference frame, then rotate them by some random angles $...
1
vote
1
answer
80
views
expression evaluation for Compile[] too time consuming
I need to use Compile[] for a very large expression to be integrated. But for Compile[] the expression has to be evaluated, and this takes endless time.
The expression is composed of several functions ...
3
votes
0
answers
112
views
Why does changing this code in a Compile make it work?
This is a follow up question to this one. In that question I asked why the following code didn't work:
...
7
votes
1
answer
202
views
How to correctly use lists inside Compile
Consider the following code:
Compile[{{x,_Real}},Module[{x1=x,W},
W=RandomVariate[NormalDistribution[0, 10^-2], 2];
x1=x1+W[[1]]+W[[2]];
x1]]
It fails ...
2
votes
0
answers
88
views
Lanczos method to tridagonalize a matrix
I want to tridagonalize a sparse matrix using the Lanczos algorithm.
I am working with a very large sparse matrix and I need some speed. In the following for example ...
1
vote
0
answers
89
views
compiled function not mapable
I am currently working on speeding up a larger project and thus using FunctionCompile. I have come across the issue that a manual input of list elements produces a valid results, however if I try to ...
6
votes
0
answers
111
views
How to Compile an Open-Source Java Project which depends on the Wolfram Engine for Developers?
Background:
I have a license-related compile-cycle question. I developed a rather large Java project that partially uses the Wolfram Engine (for Developers) to perform certain computations. The ...
7
votes
1
answer
133
views
What Does Compile`SetIterate Do?
The list of compilable functions (given by Compile`CompilerFunctions[] // Sort) shows one of the more interesting- and core-sounding functions: ...
4
votes
0
answers
162
views
Inconsistent Output Bug and Code-Quits-Kernel Bug with Compile
This is the strangest bug I've encountered. In my experience, variations in the code will unexpectedly crash the kernel, give inconsistent output, or produce expected results with no problems.
1) Code-...
3
votes
2
answers
468
views
Including literals into compiled C code
I have a function that I want to Compile into C for speed. Inside this function is a certain long expression called x, which has been computed earlier in a Mathematica session. However, if you call x ...
9
votes
2
answers
214
views
Looking for a Compilable Form of DeleteDuplicates
Union is Compilable but DeleteDuplicates Isn't?!
First, DeleteDuplicates is not compilable ...
7
votes
1
answer
130
views
Compile Can Handle Passing an Empty List Only When Returned by Some Functions?
There seems to be a bug whereby Compile can deal with empty lists only when passed in some cases. Consider the case below.
...
10
votes
1
answer
288
views
"instruction 9223372036854775807" Bug and Bug with Using DeleteCases[] inside Compile[]
I get an error referring to "instruction 9223372036854775807" as follows.
I run the code
...
1
vote
1
answer
102
views
Mysterious RegionDistanceFunction::regp message
Bug introduced in 12.3.1 or earlier and persisting through 13.1.0 [CASE:4853257]
I encountered a strange problem with RegionDistanceFunction. Consider this list of ...
4
votes
0
answers
86
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 ...
2
votes
1
answer
97
views
Considerations for Compiling and Parallelizing Code Outside or Inside Map[]
Assume f as well as Map[f,list] are parallelizable and compilable, such that parallelization and compilation give significant ...
0
votes
1
answer
67
views
What is the fastest way to read a constant, read-only dataset from compiled function?
I need a compiled function $f(\theta,\mathcal D)$ that uses some variables $\theta$ and some data $\mathcal D$. I will be calling the function multiple times with different values of the variables, ...
0
votes
0
answers
128
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 ...
1
vote
0
answers
53
views
Accelerate the distance function of two point sets
I have two point sets point and impPoint. I want to calculate a distance function from each element in the ...
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 ...
1
vote
2
answers
81
views
Compile generates non-tensor object warning for this simple function
Compile generates the following error (CompiledFunction::cflist: Nontensor object generated; proceeding with uncompiled evaluation.) upon execution of this simple ...
2
votes
2
answers
120
views
How to work symbolically with a compiled function?
I have a compiled function f to be used as a piece of a much larger calculation. I would like to expand out a function that calls ...
2
votes
1
answer
91
views
Why does the integration of this symbolic matrix slow down after compilation?
There's a symbolic matrix as the following. Why does the integration of the symbolic matrix slow down after compilation? How to eliminate the error information in red? Thanks.
Note: The sample matrix ...
13
votes
1
answer
644
views
LLVM compilation in version 12.3
I recently learnt that there is something called numba in python which compiles the codes into LLVM machine language and results in incredible speedups. I also learnt Mathematica 12.3 has introduced ...
4
votes
1
answer
145
views
How to speed up the calculation process of a symbolic matrix?
There are a symbolic matrix and a real number list. I'm going to replace the symbols of the matrix with all the elements of the list, and then to get the Eigenvalues...
10
votes
1
answer
300
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
votes
2
answers
280
views
Optimize molecule distance analyzing code
I have a very large dataset (31552000 lines) of xyz coordinates in the following format
1 2 3
4 5 6
7 8 9
. . .
I have to take a distance using the special ...
0
votes
0
answers
80
views
FunctionCompile returns Part::partd: Part specification 151345[[1]] is longer than depth of object
Today, I install mathematica 12.3 on my computer(windows), then I run the FunctionCompile code
...
0
votes
0
answers
96
views
Compile and NSolve
Consider the following numerical problem. One deals with transcendental complicated function f that depends on several parameters and three variables, say ...
5
votes
2
answers
386
views
Speed up averaging of numerically solved differential equations
I deals with a coupled system with non-linear differential equations of first order. I perform numerical solution with NDSolve and then use obtained solutions, <...
1
vote
0
answers
113
views
FoldList and Compile [closed]
Let me elaborate my previous question about Foldlist and Composition.
...
1
vote
2
answers
144
views
Improving large array manipulation
I am doing an iterative program, which uses large arrays/vectors and where the output of one round is used as an input for the next steps but works slowly when dimensions are bigger.
In brief, we ...
0
votes
0
answers
47
views
How to resolve these errors that pop up when using 'Compile' for a large function? [duplicate]
The problem
I have been wanting to make my code which solves an optimisation problem faster. This led to this question on here and I realised from there that the root of the problem is the very slow <...
4
votes
1
answer
55
views
Irregular array in compile [duplicate]
I am trying to use Module wrapped in a Compile to produce two outputs. One is a vector, the other is a matrix. My actual example is rather complicated, but I managed to find a simple example problem ...
1
vote
2
answers
133
views
How to make the following code work faster?
The problem
I would like to compute the Lorentz transformation $\mathbf{p}'$ of an arbitrary 3-momentum vector $\mathbf{p}$ given a boost characterized by some other momentum vector $\mathbf{p}_{N}$, ...
1
vote
1
answer
103
views
Is there any way to compile and export LearnedDistribution?
I use the LearnDistribution function to learn the distribution of some data. Then, I want to export some code to sample from that learned distribution. I tried to use Compile as follows
...