Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 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 ...
user avatar
  • 3,720
4 votes
0 answers
19 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 ...
user avatar
4 votes
3 answers
192 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 ...
user avatar
0 votes
0 answers
28 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 ...
user avatar
  • 1,458
2 votes
0 answers
44 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 ...
user avatar
  • 101
3 votes
1 answer
70 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. ...
user avatar
3 votes
1 answer
64 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 ...
user avatar
3 votes
1 answer
62 views

How to compile sum over the compiled expression?

Consider the following toy code: ...
user avatar
  • 3,544
5 votes
1 answer
73 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: ...
user avatar
  • 4,867
7 votes
1 answer
138 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 ...
user avatar
  • 485
0 votes
1 answer
78 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$ ...
user avatar
  • 485
1 vote
1 answer
38 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 ...
user avatar
  • 143
0 votes
0 answers
56 views

How to speedup the following evaluation?

Consider the following function: ...
user avatar
  • 3,544
5 votes
1 answer
140 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 ...
user avatar
  • 15.6k
10 votes
2 answers
204 views

How to compile matrix product?

Consider the following matrices: ...
user avatar
  • 3,544
1 vote
0 answers
67 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 $...
user avatar
  • 3,544
1 vote
1 answer
73 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 ...
user avatar
  • 135
3 votes
0 answers
109 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: ...
user avatar
  • 6,114
7 votes
1 answer
188 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 ...
user avatar
  • 6,114
2 votes
0 answers
70 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 ...
user avatar
1 vote
0 answers
84 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 ...
user avatar
6 votes
0 answers
91 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 ...
user avatar
7 votes
1 answer
125 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: ...
user avatar
4 votes
0 answers
157 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-...
user avatar
3 votes
2 answers
462 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 ...
user avatar
9 votes
2 answers
203 views

Looking for a Compilable Form of DeleteDuplicates

Union is Compilable but DeleteDuplicates Isn't?! First, DeleteDuplicates is not compilable ...
user avatar
7 votes
1 answer
114 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. ...
user avatar
10 votes
1 answer
269 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 ...
user avatar
1 vote
1 answer
79 views

Mysterious RegionDistanceFunction::regp message

Bug introduced in 12.3.1 or earlier and persisting through 13.0.0 [CASE:4853257] I encountered a strange problem with RegionDistanceFunction. Consider this list of ...
user avatar
4 votes
0 answers
72 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 ...
user avatar
  • 425
0 votes
0 answers
36 views

Compiling using Which function is slower than without it! [duplicate]

I have a list of functions that I'd like to compile to speed up the evaluation. I'll use the list length to be n=5, but in general I'm interested in longer lists. ...
user avatar
  • 179
2 votes
1 answer
83 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 ...
user avatar
0 votes
1 answer
55 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, ...
user avatar
  • 245
0 votes
0 answers
91 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 ...
user avatar
  • 463
1 vote
0 answers
40 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 ...
user avatar
  • 141
14 votes
0 answers
348 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 ...
user avatar
  • 30.3k
0 votes
0 answers
57 views

How to use compile with input form a list?

as a minimum example this is how I usually use Compile ...
user avatar
1 vote
2 answers
53 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 ...
user avatar
  • 8,528
1 vote
2 answers
97 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 ...
user avatar
  • 145
2 votes
1 answer
76 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 ...
user avatar
  • 663
13 votes
1 answer
592 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 ...
user avatar
4 votes
1 answer
142 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...
user avatar
  • 663
9 votes
1 answer
242 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: ...
user avatar
  • 2,068
3 votes
2 answers
273 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 ...
user avatar
0 votes
0 answers
69 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 ...
user avatar
0 votes
0 answers
68 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 ...
user avatar
5 votes
2 answers
365 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, <...
user avatar
1 vote
0 answers
101 views

FoldList and Compile [closed]

Let me elaborate my previous question about Foldlist and Composition. ...
user avatar
  • 99
1 vote
2 answers
115 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 ...
user avatar
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 <...
user avatar
  • 215

1
2 3 4 5
12