Questions tagged [compile]
Questions about the generation and use of compiled functions using Compile.
717 questions
0
votes
0
answers
93
views
Question About Possible Ver 14.0 Bug
All: I'm running the following code. It's coming up with a persistent bug that seems to be related to the graph and processing the information; see image. Any advice? This code works fine with Ver 13....
2
votes
0
answers
42
views
Call Compiled Function in Python
How can I call a function made with Compile in Python, Is it possible to just save it using LibraryGenerateand call the ...
3
votes
1
answer
182
views
Something faster than RandomReal and RandomInteger?
I am dealing with the code sequentially producing random numbers and using them further for some operations.
The code snippet looks like
...
9
votes
2
answers
126
views
How can I return an empty list from FunctionCompile?
The following code is for solving a linear congruence of the form $ax=b \; (\mathrm{mod}\ m)$ using FunctionCompile.
...
1
vote
1
answer
51
views
Strange behavior of numerical derivative inside a ParallelTable
I have observed something strange happening with the function ND[] from the package NumericalCalculus.
In particular, if I define a function G that returns the numerical derivative of a compiled ...
0
votes
2
answers
71
views
How to speed up the n-th Laplacian or derivative of function?
We wish to solve for the multiple Laplacian of a function, and here we use sum of E-exponential functions as an example:
...
3
votes
1
answer
143
views
Making faster extraction of table elements in Mathematica or beyond
Consider the following code:
...
0
votes
0
answers
32
views
Unexpected behaviour from NMaximize optimising a stochastic function
I have a complicated function whose output contains noise. I'm interested in Using Differential Evolution via NMaximize to solve it. However, NMaximize appears to compile or somehow 'freeze' the ...
4
votes
0
answers
129
views
Can't compile a standalone app in 14.1
I read the article reviewing the innovations in version 14.1 and am absolutely thrilled to be able to build a standalone app. I tried to replicate the example from the article in an even shorter form, ...
5
votes
0
answers
64
views
Listable attribute for functions compiled with FunctionCompile
Is it possible to create Listable compiled code with FunctionCompile in the same way one may do with ...
7
votes
0
answers
167
views
Compiler with CompilationTarget -> C appears broken in 14.1
On the same Windows 11 machine with the same C compiler (Visual Studio 2022):
...
1
vote
0
answers
100
views
Way to run the script faster
I have a mathematica code, which is running fine, but it takes long time to evaluate.I have already modified the code with compilation and vectorization as you can see from my code.
May be its a ...
1
vote
1
answer
449
views
Use of Compile[] to optimize the code to run faster
I am working on a code that takes long time to evaluate, So I come to know that use of Compile[] function can speed up significantly. Here is my original code.
...
0
votes
0
answers
55
views
Qualitative question: can the code matching the given patterns be made significantly faster if being written in pure C?
I made some code in Mathematica that I compiled in C. It involves operations such as looping inside While, custom random sampling from particular distributions, and ...
1
vote
1
answer
200
views
Parallelization with compile gives an error
I have this uncompiled code with MMA14, win10,64
...
0
votes
0
answers
43
views
Compilation error for multidimensional lists [duplicate]
Dear Mathematica users,
I have a code as:
...
2
votes
0
answers
94
views
How to push the performance of this compiled function
I have the function optvals solving for two variables. For the given example of variables, I need the program to run atmost in a millisecond.
The main part of the ...
1
vote
1
answer
95
views
How to speed up generating and filtering large lists of numbers?
I have the following code where I brute force search for two variables.
list gives a list of 3 dimensional vectors, say {x,y,z}. ...
1
vote
1
answer
88
views
Why using compiled code inside compiled code may slow things down?
I made some code that I compiled. The snippet looks as follows:
...
2
votes
1
answer
64
views
Why is random sampling with ordinary and compiled code so different?
Consider the following code:
...
0
votes
0
answers
25
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:
...
2
votes
1
answer
121
views
Fast sampling from Fermi-Dirac distribution under specific conditions
This question is a continuation of the following one.
Let us assume a Fermi-Dirac (FD) distribution (times $p^{2}$):
...
1
vote
0
answers
42
views
How to quickly check if compiled code calls MainEvaluate?
Consider the following test compiled code:
...
1
vote
1
answer
100
views
How to compile the following code (sampling from a distribution)?
Consider the following code:
...
3
votes
2
answers
105
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 ...
3
votes
0
answers
37
views
Mathematica call CompiledFunction from Python with Listable and Parrallelization attributes
I have a CompiledFunction e.g. this:
...
3
votes
0
answers
75
views
GSL multiroot finding mode Hybrid function load with Mathematica : Crash
Hi everyone
I work on a Mac M1 Sonoma 14.3 with Mathematica 12.3.1 and 14.0
I have an issue when using a C++ multiroot finding from GSL library.
I used this example : https://www.gnu.org/software/gsl/...
0
votes
0
answers
31
views
Compiling an ItoProcess
I am a new mathematica user. I am trying to use the Compile command to speed up my RandomFunction output. The code looks like this:
...
2
votes
2
answers
170
views
Compile does not boost the speed
I have these functions that are used to defineMyFun below
...
4
votes
1
answer
156
views
How can we improve performance when passing data to a function?
I have a defined function $F(x,y,z)$ and data of $(x,y)$ and would like to evaluate the sum of F over data and at different z values. Here is a minimal example:
...
0
votes
0
answers
53
views
Tensors of arbitrary rank inside compiler
I want to create a compiled function that executes operations with lists of tensors. It has two arguments, two lists of tensors, and takes the tensor products between tensors of both lists. Is it ...
0
votes
0
answers
37
views
Compile constraints for NMinimize
I use complicated constraints for optimisation, something like
Table[
EuclideanDistance[pts[[i]], pts[[j]]] >= 1
, {i, numPts - 1}, {j, i + 1, numPts}]
...
4
votes
2
answers
180
views
How to compile inverse error function?
I have the following code:
...
0
votes
0
answers
23
views
Issue with ReplaceAll resulting in Null function return
I am trying to modify some code of mine to change where the final evaluation of a function is performed, as a way to not generate massive tables of data. The code is working fine, until I have started ...
2
votes
1
answer
118
views
How to Compile functions to C in parallel?
I need to Compile functions for use on parallel kernels. There are many such functions, so compiling in parallel is desirable. When compiling functions with ...
7
votes
1
answer
91
views
Strategies and practical advice for using saved compiled functions in a package
I want to use a compiled function in a package without having to rebuild it each time. This slows down unit testing and loading of the package.
I have used the example in the link as my starting point:...
14
votes
1
answer
792
views
When to use WVM instead of C for CompilationTarget?
In which cases is it advantageous to compile using the Wolfram Virtual Machine ("WVM") option rather than the C Code (...
3
votes
0
answers
116
views
Optimizing memoization in compiled Mathematica code
Consider the following two codes - compiledcode and compiledcode1:
...
3
votes
0
answers
67
views
Making speed of MemberQ comparable with explicit If?
Consider the following two lists:
listtest = {11, 13, 22, 221, 1, 3} // Sort // N;
pdglisttest = RandomInteger[{-222, 222}, 10^6] // N;
For the given element of <...
0
votes
0
answers
64
views
Problem using Compile together with Eigensystem
I have been trying to understand what is wrong with this piece of Mathematica code:
...
0
votes
0
answers
130
views
How to quickly generate the values satisfying the given condition?
Consider some domains in variables th, z and some condition cond defining the domain of a ...
2
votes
1
answer
147
views
What can be improved in the following custom bilinear interpolation?
Consider some test data: a grid of x, y, and values of some function on this grid:
...
0
votes
0
answers
72
views
Compilable analog of Nearest?
Is there any analog of Nearest that is compilable?
...
4
votes
1
answer
235
views
How to quickly sample points from the given PDF data?
Consider some data (distr.dat). It is a tabulated PDF: x, y, z, PDF[x,y,z], where x is some parameter (and the integral of ...
0
votes
1
answer
108
views
How to make the function compile into C faster, and how to determine which portion of the code occupies more memory?
If changing the value of 'n' from 2 to 3 in the above code increases the compilation time from one minute to ten minutes, is there a way to speed it up? Also, the code consumes too much memory during ...
10
votes
3
answers
305
views
Is there a faster way to compose a large number of random Gaussians?
I'm looking for a more efficient way to generate an image with a large number of randomly coloured Gaussians. Here's the code I'm using:
...
8
votes
5
answers
585
views
How to use Compile to optimize the performance of a function calculating the distance between two points?
I want to create a function that finds the real space distance between two three-dimensional points. Each point is a list of three real numbers.
I can create functions ...
2
votes
0
answers
103
views
1
vote
0
answers
63
views
Weird slowdown on data returned by compiled function (bug?)
Mathematica 13.1 - I was cleaning up some computations and I got a x3 time increase when I reduced things to loop over.
Full context is a bit convoluted, I stripped the most I could but the problem ...
0
votes
1
answer
91
views
Can I use a C compiler from behind WSL?
I've got 13.3 on Windows 11 (22H2) and a gnu compiler suite under WSL2 (Arch). Seems it is possible to compile in Windows with VS Code (which I also have). Do I still need to install another C ...