Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
10
votes
0answers
113 views

How to use Bags in FunctionCompile?

I was reading this question and it wanted to know how to FunctionCompile this: ...
6
votes
5answers
187 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
45 views

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

I am trying the following code: ...
0
votes
1answer
70 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
38 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
289 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
141 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
57 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
259 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
63 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
54 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
44 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
55 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 ...
0
votes
1answer
84 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
83 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
43 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
51 views

Using Compile, after instaling MinGW

I want to use Compile. I got the following error message: ...
4
votes
1answer
61 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
94 views

Can we compile this function/distribution?

I would like to compile this function to make it faster: ...
1
vote
0answers
155 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
3k 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
105 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
82 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
30 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
134 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
40 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
44 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
82 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
84 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
102 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
83 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
94 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
257 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
69 views

How to make a compiled version of a function?

I'm trying to make a compiled version of this function ...
2
votes
2answers
71 views

Changeable global variables in compile statement

If a global variable is changed before each call of the function then answer is not changed accordingly. Please see a toy example: ...
3
votes
0answers
161 views

How to get the executable out of a compiled function and run it in cmd

Can someone please guide how to run the function compiled by Wolfram Language in cmd independent of the kernel. It seems to export it into ...
5
votes
0answers
122 views

Optimize Use of PeakDetect in Mathematica

I am quite new to Mathematica and I am looking for some advice in order to improve and optimize my code. Here is what I am trying to do: Open a stream Read the stream line by line and store it in "...
6
votes
0answers
143 views

Possible Compile bug

Bug introduced in 11.3 or earlier The program: ...
0
votes
1answer
84 views

How can I use Compile to implement recurrence?

I am trying to make the code for the following recurrence. Here wjoin[[i]] is used for calling values from a data set and a is a ...
3
votes
0answers
74 views

What are the recommended best practices for and common pitfalls of using Compile? [duplicate]

As evidenced in my last question there is much I do not know about how to write compilable functions. The basics are clear: one must load the appropriate packages ...
2
votes
1answer
111 views

Why won't nominally compilable function compile? (err Compile::cpintlt)

Context: I have millisecond timestamped sample data that I want to convert to a uniformly sampled series. This I do by padding each interval with repeated values (pbp ~ 'pad by position'}. The ...
2
votes
1answer
78 views

Return multiple results from compiled function [duplicate]

I wrote a function with Compile that produces a large array of data and later does some computation on it. Now, I want to return from the compiled function not only ...
0
votes
0answers
110 views

Compile a Module

Itried first to compile this Module ...
1
vote
1answer
54 views

Pick inside Compile

I want to compile this function: ...
6
votes
4answers
250 views

Numerical contour plot of compiled function

I have come across a problem in Mathematica when I have tried to plot the contours of a compiled function. ...

1 2 3 4 5 10