Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
4
votes
1answer
129 views
3
votes
1answer
53 views

Compile a function with undetermined number of variables

I have been wrapping my head about a question it may look simple to you. I want compile a function that depends on a number of undetermined variables as, ...
3
votes
1answer
24 views

How to handle numerical exception within a compiled function

I'm trying to evaluate a series of expressions, which, given a set of parameters, may be complex. Instead of throwing a CompiledFunction::cfn, I'm trying to catch ...
0
votes
0answers
18 views

Compiling generalized correlation doesn't lead to speedup

Mathematica is capable of calculating a generalized correlation of a list lst with a kernel ker. In my case, I'm interested in performing this, ...
1
vote
1answer
37 views

Issue with Compile for Complex Input/Output

I'm writing a Runge-Kutta algorithm for solving a system of coupled differential equations. My code works fine when defined as a module, but when I try to compile it, I get the following error: ...
1
vote
0answers
63 views

Faster methods for performing repeated list manipulations?

I've done my best to pore over the other posts on this site, and to the best of my ability I can't seem to find a good solution to my problem, so I apologize in advance if elements of my question are ...
5
votes
1answer
60 views

Compiling with Listable option and Parallelization

I have a bunch of triangles (200k) I need to calculate the normals of. Here are five of them below, each one with its vertices in CCW order. ...
5
votes
1answer
100 views

Table vs. ConstantArray efficiency with compilation

I've been trying to optimize a bit of code the past couple of days, but think I might be misunderstanding how compilation on certain target functions works. As a most barebones example, I've attached ...
4
votes
1answer
93 views

Compiling a function depending on an external function

Consider the simple case: g[x] := x^3; f[x] := x^2 + g[x]; cf = Compile[{{x, _Real}}, x^2 + g[x]] Evaluating the two functions, Mathematica complains that the ...
2
votes
0answers
46 views

How to use IntegerQ in FunctionCompile?

Seems like an easy request, but I've somehow gotten myself stuck again: ...
0
votes
0answers
27 views

Simulation of a compound renewal process with copula dependency

I'm new to Mathematica and this is brief about my project that I would like to seek advice from this group about my coding. My project is to perform 100 simulations with 1000 iteration each based on ...
10
votes
0answers
123 views

How to use Bags in FunctionCompile?

I was reading this question and it wanted to know how to FunctionCompile this: ...
6
votes
5answers
199 views

Maximizing efficiency of a power-tower (tetration) calculation

I'm working on a power tower $\displaystyle z^{z^{.^{.^{.}}}}$ and wish to maximize the efficiency of my algorithm to compute a cycle map. This is a color-coded diagram of the cycle period of each ...
2
votes
1answer
51 views

Compilation: How to get rid of MainEvaluate[Hold[myFunction][arg1, arg2, arg3]]

I am trying the following code: ...
0
votes
1answer
76 views

how to compile the function correctly?

My calculations are running terribly slow (for a larger number of variables than in the given code). I can't compile the function correctly. Can anyone help me? ...
1
vote
1answer
40 views

How to use FirstPosition in compiled function

I am trying to compile something similar to the following: test = Compile[{{data, _Real, 1}}, First@FirstPosition[data, _?(# > 0 &)]] However I get the ...
9
votes
2answers
306 views

How to detect underflow/overflow (post 11.3)?

This old trick used to work before 11.3: SetSystemOptions["CheckMachineUnderflow" -> True] But no longer... so how can we explicitly check for this in v12+?? ...
5
votes
1answer
185 views

How to execute an existing notebook with Wolfram Engine?

[My related question: mwe-for-compiling-functions-into-standalone-dll-and-calling-them-in-python - here I am exploring an alternative] I have downloaded, installed and activated the wolfram engine (...
5
votes
0answers
67 views

MWE for compiling functions into standalone DLL and calling them in Python?

I have read calling-a-compiledfunction-dll-from-outside-mathematica and the CodeGeneration tutorial and scanned other related questions too numerous to mention, but I am still unclear about how to ...
16
votes
1answer
1k views

Why can Mathematica not use the compiled code?

...
8
votes
3answers
270 views

Faster way to solve android lock valid patterns

With the password grid shown in the Android home screen, how many valid passwords are possible? The rules for creating a pattern is as follows. We must use four nodes or more to make a pattern at ...
0
votes
1answer
35 views

Compiling simple parallel function gives inconsistent results and errors

Im trying to compile the following function: ...
3
votes
1answer
64 views

Compile[] with non-numeric arguments

Suppose I have a function like this foo[x_]:=Switch[x, "dog", Sin[0.17], "cat", Cos[0.18], "frog", 17]. Compiling it won't work, since the argument is a string. ...
0
votes
0answers
62 views

Compiling a function containing Apply

Well, the following function fun1 will be used thousands times (a single argument among these thousands one is called arg in the following) . Speeding is therefore critical for my code (KenKen ...
2
votes
0answers
45 views

Speeding up the process of NDSolve[] when a user-defined function is involved?

I am trying to tackle a (1+4 dimensional PDE) model at which the solution of the first PDE (with some interpolations and changing the domain) would be used in the second PDE. In fact, I must choose ...
0
votes
0answers
48 views

Evaluation control inside Compile

I have the following function ...
2
votes
1answer
56 views

How use the same Compile function with different equations

Say I have 2 equations that take the same parameters and variables that I want to evaluate numerically in compiled code ...
1
vote
1answer
97 views

How do I skip to the end of a loop when a compiled function yields an error?

This is something of a follow-up to my question In an iterative process, how does one simply bypass a step producing an error? which I have been so far (thick-headedly) been unsuccessful in ...
0
votes
2answers
86 views

In an iterative process, how does one simply bypass a step producing an error? [closed]

This is undoubtedly rather elementary, but the remedy escapes me presently (and does not, as far as I can see, readily appear in Help). I'm engaged in an iterative process with several computations ...
2
votes
2answers
44 views

Plot[Evaluate[compiled functions… causes problems

I'm sure there is an easy solution to this, but I have beaten my head against a wall for a couple of days, so I hope someone can help. I have compiled functions. For a minimal example let's take: <...
0
votes
0answers
65 views

Using Compile, after instaling MinGW

I want to use Compile. I got the following error message: ...
4
votes
1answer
66 views

d-dimensional compiled function in NDSolve

Based on this answer, I understand how to use a one dimensional compiled function in NDSolve. Mathematica NDSolve and 'Compile'? I'd like to be able to use a d-dimensional compiled function <...
2
votes
1answer
98 views

Can we compile this function/distribution?

I would like to compile this function to make it faster: ...
1
vote
0answers
164 views

Can I use the Gwnum library to accelerate the multiplication in Mathematica?

Is it possible to use Gwnum library to accelerate the multiplication in Mathematica?
1
vote
1answer
4k views

Compile error: clang: error: linker command failed with exit code 1

After not using Mathematica 10.0.2.0 for a few months (I think since december 2018) on my MacBook Pro from 2013 (now with macOS Mojave 10.14.5) I am suddenly facing issues with ...
2
votes
1answer
121 views

How to compile or speed up a function with eigensystem?

I have defined two functions as following: ...
0
votes
0answers
24 views

Optimizing and Parallel Computing for Large Dyadic Intervals

I need help with the efficiency of my code i.e. less time so I can compute for large range of values. My function n[x] takes in a number x and outputs the ...
10
votes
1answer
91 views

WVM hangs or crashes on empty array when compiled Listable

Bug introduced in 12.0 and persisting through 12.0 or later When I run the following code, the kernel hangs indefinitely: ...
0
votes
1answer
36 views

Replacement inside NIntegrate

I'm computing rather complicated expressions using NIntegrate, and for that, my integrand is created as some compiled function (to speed up evaluation). ...
4
votes
0answers
142 views

Speed improvements and confusion for MapThread and Dot

I have a question / confusion over improving the speed of MapThread[Dot,...] for lists of tensors. My problem involves taking two lists of tensors and then ...
0
votes
0answers
43 views

Specify type in output of a compiled function

I want to prepend an array with a position index in the first column using a compiled function. For some reason, the position index is always returned as a float and not as an integer. How can I ...
2
votes
1answer
46 views

Gyrating particle transmission through rectangle: NIntegrate or something faster?

I need a function that tells me, what transmission a gyrating particle has through a rectangular aperture if you consider all phase angles. So for a specific guiding center position and gyration ...
0
votes
0answers
98 views

CompiledFunction::ctfa - Argument should be a rank 4 tensor of machine-size real number

Dear Mathematica community, I got the following error line: CompiledFunction::ctfa "Argument {<<1>>} at position 1 should be a rank 4 tensor of machine-size real number" This is my function:...
1
vote
1answer
85 views

How to compile properly for performance tuning

I have a question about how to compile functions properly for performance tuning. Currently, I am trying to solve an eigenvalue problem of a large matrix. Initially I just used the conventional ...
5
votes
1answer
49 views

RandomPoint returns compiler errors on RegionIntersection of two Meshs?

Consider the intersection of two ConvexHullMesh's, m1 and m2. ...
4
votes
0answers
106 views

How to compile effectively with recent MMA? Global variables in C code, compilation of C code

I have read the generously comprehensive answers by @leonidshifrin and @xzczd to the question How to compile effectively but more than seven years have now passed, and whilst I am sure much remains ...
1
vote
0answers
100 views

Running a C compiler on Windows Subsystem for LInux [closed]

I want to use the compile-to-C functionality of Mathematica. Has anyone gotten the C compiler driver to recognize a C compiler (for instance gcc) installed on a Windows Subsystem for Linux? I am ...
2
votes
0answers
102 views

Strategies for using mathematica compiled code on a website?

I have developed a chaos detection algorithm which is already used as a compiled (target C) function within Mathematica. The development has been done under Win 10 64-bit with MMA 11.0.1 and the ...
9
votes
1answer
287 views

Question on FunctionCompile

So far, I have mixed feelings about the new compiler in Mathematica 12. Sometimes my results are a little bit faster, sometimes they are considerable slower than those obtained with the old compiler ...
0
votes
0answers
74 views

How to make a compiled version of a function?

I'm trying to make a compiled version of this function ...

1
2 3 4 5
10