Questions tagged [compile]

Questions about the generation and use of compiled functions using Compile.

Filter by
Sorted by
Tagged with
1 vote
1 answer
75 views

How to produce the following table faster?

Consider two data files, acc.m and distr.dat. They contain some functions that I need to multiply to obtain function ...
3 votes
0 answers
73 views

Compiling a function that uses MapThread

I'm looking for tips on quickly applying the following update to $B$ pairs of $(w_i,x_i)$ $$\text{step}(w_i,x_i)=w_i-a x_i \langle w_i, x_i \rangle$$ Below is a readable but very slow version ...
2 votes
0 answers
54 views

Argument value loss using Listable C-Compiled Function

In my recent studies, I have come across a very strange anomaly with C compiled functions. When I call a function that has the 'Listable' attribute while global variables are accessed through ...
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)....
1 vote
1 answer
55 views

How to speedup calling the interpolation function? [duplicate]

Consider the following data: ...
0 votes
0 answers
65 views

How to generate points belonging to some region very fast?

Consider two variables Ex,th. th ranges within thmin=10^-5; thmax=Pi/2; while ...
0 votes
0 answers
34 views

Compile a code evaluating a condition only if another condition is positive

Consider the following three tables: ...
2 votes
1 answer
50 views

How to assign a new value to the table inside Compile?

Consider some tables and function func: phivals=RandomReal[{-Pi,Pi},10^5]; func[phi_]=phi^5*Exp[-phi]; acc=Table[0,10^5]; I ...
3 votes
1 answer
140 views

Why the ugly code is faster than the pretty code?

The task Consider two tables, Tab1,Tab2, that include some real-number data. I need to evaluate the product of some boolean conditions on the value of some function ...
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$ ...
4 votes
3 answers
163 views

Compile code involving two matrix multiplications

Consider the following simple matrix operation ($a_j, b_j, z, w$ are matrices) $$ w=\sum_j a_j\cdot z\cdot b_j$$ For performance reasons I am compiling the code ...
3 votes
1 answer
70 views

How to keep the code compact in the following case?

Consider the following code: ...
2 votes
3 answers
171 views

Compile integer functions

I need to speed up a function that uses Binomial and QuotientRemainder. I used Compile, but ...
2 votes
0 answers
46 views

SymbolicGPU documentation

I found an interesting files there $CUDALinkPath -> ../GPUTools here ...
2 votes
0 answers
38 views

Can NumericArray be Compiled?

I've have a big block of code written under Compile. Some other part of the code which receives data from shared Q useing ...
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)) ...
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 ...
1 vote
0 answers
119 views

How can I set up Compile[] correctly on my Windows 11? I keep on getting an error that I have no compilers installed (but I do)

I'm trying to use Mathematica's Compile[] function to speed up some of my computations: ...
4 votes
1 answer
86 views

(Too) Slow Compiled Function To Sum Waves

I have some code that sums planar waves and outputs a graphical result, as per the mock up below : ...
18 votes
1 answer
1k views

Why can Mathematica not use the compiled code?

...
1 vote
2 answers
125 views

Speed up calculation of recursively defined list

I have two lists $a$ and $b$ of length $n$ and $n-1$ respectively (typically I have $n \approx 1000$). I have to compute a list $\theta$ of length $n$ which is defined recursively by the following ...
0 votes
1 answer
49 views

Why association slows down compiled function in the following example?

Consider the following code, which generates some data and performs some selections: ...
3 votes
1 answer
83 views

Is there any way to speedup the list selection further?

Consider some test data: ...
5 votes
0 answers
85 views

Warning from CompiledFunction is permanently off silently after generating for 3 times, bug or feature?

I've been vaguely aware of this behavior for a long time but never looked into it. Consider this sample: ...
2 votes
2 answers
77 views

How to speedup comparison in the following example?

I have the following problem: I would like to generate random values of some variable $z$ obeying some distribution, but simultaneously within the interval zmin<...
1 vote
1 answer
70 views

Speed up summation of many inverse matrices

Physical background I am trying to write a code that computes the Green function of a system, given the Self energy $\hat{\Sigma}_n$, a list of Matsubara frequencies $z_n$ ($n=1,...,N_{Mats}$) and the ...
2 votes
1 answer
44 views

Error thrown by compiled expression

The following code is a minimal model of an error I am getting. It returns the error Compiled expression {{0,2},{2,0}} should be a machine-size real number. and <...
14 votes
1 answer
524 views

3D stable fluids algorithm based on FFT

This code is 3D extension of the code from my answer here. As well known the stably fluids algorithm is some kind of predictor corrector algorithm - see my answer here. This algorithm includes 3 steps ...
1 vote
2 answers
88 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 ...
0 votes
1 answer
40 views

Set return type in compilation of a function of list

I hope to compile a complicated function with the process that create an complex list and sum over it. However, system always tell me the output should be a real number and I cannot change them. How ...
1 vote
2 answers
157 views

Using Compile with vector expressions

Consider a vector vec[x_,y_,z_]={x^0.5*y^0.1,y^0.3*z^0.1,z^2*x*y}; I need to calculate, say, a table with vector values for the coordinates ...
2 votes
2 answers
143 views

Speed up counting of digits in binary number

I am writing a large numerical code where I care a lot about performance, so I am trying to write compiled functions that are as fast as possible. I need to write a function that does the following. ...
2 votes
0 answers
86 views

Fast value extraction for refreshing large data

I am trying to fine tune a procedure to reduce its running time. It involves two large arrays "data" and "positions": ...
2 votes
2 answers
99 views

Replacing symbolic variables inside of a compile

As the result of a symbolic integration, I have a very long array with symbolic variables u[i] which I would like to substitute for real number values. Moreover, I ...
4 votes
1 answer
86 views

Speed up functions using variable types but not Compile

I am writing a large numerical code and I have set up many functions that take several arguments as input. In the functions I am using several built in Mathematica functions, such as Sum[], Part[], ...
0 votes
0 answers
54 views

Getting symbolic form of `RotationMatrix`

Calling Compile seems to run into trouble compiling RotationMatrix, I'm guessing because it has type restriction to return ...
0 votes
0 answers
59 views

Compile error in recursive code due to large integer

I am trying to implement a compiled version for the original algorithm that is supposed to run faster . It works fine for small iteration loop number when max=100. However, when loop number gets ...
13 votes
1 answer
268 views

How can CompiledCodeFunctions be optimized and parallelized?

Fast generation of random variates as test case The earlier question (195435) about performance tuning with regard to fast generation of random variates for a gamma distribution has stirred my ...
16 votes
1 answer
235 views

How to use CompilerOptions?

The refpage for FunctionCompile's option CompilerOptions is empty of examples: Does anyone know what keys and values can be ...
1 vote
0 answers
61 views

What do the Compile options" RuntimeAttributes -> {Listable}, Parallelization -> True" mean?

I am confused about what Compile's Listable and Parallelization options do. (edit: This post is relevant: stack exchange "The option parallelization for compile") My initial assumption was ...
1 vote
0 answers
33 views

Multi-NIntegral with a compiled function: Why not improved so much?

I want to compute the multi-dimensional integral by using NIntegral with the compiled function. I have compiled an integrand function. It made the computation time of the integrand about 100 times ...
10 votes
1 answer
192 views

How to programmatically construct a function or a compiled function?

I'd like to programmatically construct a function from a long expression with many duplicate terms. The objective is to programmatically create a set of compiled functions with expressions that were ...
0 votes
0 answers
44 views

How to compile a matrix with mixed values?

Consider some matrix matrix = {{a,,...,b,...},...}, where a,b are some strings (like "Name"), ... inside the row corresponds to numbers, and ... are ...
13 votes
3 answers
359 views

To accelerate FunctionCompile

I have a function value like this: ...
14 votes
2 answers
164 views

Help understanding a bug when FoldList using RandomChoice is Compiled

Bug introduced in 3.0, persisting through 13.1. Preamble: I submitted this bug to support@wolfram.com and it was acknowledged. I assume it will be fixed eventually. In the meantime I'd like to ...
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 ...
13 votes
1 answer
272 views

How to convert the ListVector into PackedArray in FunctionCompile

Cross post here I have a compile function cf to calculate the mean for a ragged list: ...
3 votes
0 answers
70 views

Using a compiled function in NMinimize

I can get NMinimize to work with compiled functions in simple cases. This works with a constraint: ...
4 votes
1 answer
87 views

OptionValue not inserting correct option

I am using OptionsPattern and OptionValue to define some switches for my custom function. Here is a minimal example: ...
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 ...

1
2 3 4 5
13