Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
8
votes
1answer
314 views

Writing compiled functions as fast as Python's Numba

I want to write some code to simulate a damped oscillator that is just as fast as code written using Numba's @njit decorator. I've written the mathematica code and ...
0
votes
0answers
47 views

Basic question of “good” habits during the evaluation of a notebook in mathematica

Suppose that I have notebook, call it Nb1. And I want to evaluate the notebook Nb1, next suppose that the process is slow, but I have to evaluate other notebooks, suppose Nb2, and Nb3. I see that ...
1
vote
0answers
51 views

Optimal code generation for evaluation of a fixed set of multivariate rational polynomials

Given a set of multivariate rational polynomials, is it possible to find the optimal (shortest or least expensive in some other sense) sequence of arithmetical operations, such that it results in ...
8
votes
1answer
90 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 ...
2
votes
1answer
57 views

why this simple code is not giving the right answer under Compile

I have two sets of inputs that are to be fed to a simple function. The inputs are essentially a set of triangles and the normal for each triangle. The function will compute the gradient about the ...
4
votes
1answer
146 views
3
votes
1answer
54 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
26 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
19 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
67 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
61 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
107 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
97 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
52 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
130 views

How to use Bags in FunctionCompile?

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

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

I am trying the following code: ...
0
votes
1answer
78 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
41 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
316 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
197 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
71 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
65 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
48 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
57 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
110 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
88 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
70 views

Using Compile, after instaling MinGW

I want to use Compile. I got the following error message: ...
4
votes
1answer
75 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
168 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
125 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
96 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
147 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
45 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
105 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 ...
1
vote
1answer
87 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
51 views

RandomPoint returns compiler errors on RegionIntersection of two Meshs?

Consider the intersection of two ConvexHullMesh's, m1 and m2. ...

1
2 3 4 5
11