Questions tagged [compile]

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

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

How to deal with this error in Compiled Function?

...
0
votes
1answer
106 views

Create Compiled Function

I am trying to create a compiled version of this function: ...
0
votes
1answer
70 views

What is the best build-in function to pick or select given element in a huge list

im looking for a best and efficient function works like a search engine it takes for example m=5+6I ,then it goes searching in the list V={1,1+I,2+3I,...} until catch it . My Dr said to use "Select[]"...
2
votes
1answer
66 views

Recursive function to compiled version

I have looked up some articles about the compiling recursive functions. I know usually there is no general solution to these kinds of questions. And my case is a little bit different (or more ...
6
votes
1answer
117 views

Creating a multidimensional array with Compile

For one of my programs I need to preallocate a multidimensional list/array. For performance reasons I want to do this within Compile and compile my program to C-...
5
votes
1answer
150 views

Compile `DeleteCases`

How is the function DeleteCases compilable if Compile does not support patterns? My question refers to this thread here where I ...
1
vote
0answers
58 views

Nested sums in `Compile` [duplicate]

in my code I face the necessity of using nested sums within Compile[]. Unfortunately, nested sums cause a call to MainEvaluate ...
5
votes
0answers
82 views

Random number generation within Compile and Parallelization->True

According to this thread RandomChoice is a compilable function. I use it to generate random numbers in a compiled function with parallelization enabled. I wrote ...
1
vote
1answer
198 views

How to compile with list?

I try to compile this code, but always failed, could anybody guide me? ...
1
vote
1answer
83 views

Compile errors after reloading of laptop contents after challenging MacOS Mojave installation

I tried (foolhardily, it appears) installing macOS Mojave Version10.4 on my MacBookAir, but encountered major problems--that seemed to have been (finally) fixed after a reinstallation and reloading of ...
0
votes
0answers
42 views

Compile elementary functions

I am looking to compile some elementary functions to pseudo C-code by using Mathematica's built-in function Compile as efficiently as possible. I am interested ...
2
votes
1answer
43 views

Indexed variables in compile

In this contribution Leonid Shifrin says that You can not really use indexed variables in Compile, although it may appear that you can. This sounds ambiguous to me. Is it possible or is it not ...
2
votes
1answer
58 views

Compile command does not succeed with list input with Parallelization->True

J. M. suggested that I pose the following as a question, a matter arising in relation to the function probit: ...
0
votes
0answers
62 views

compiling matrix row assignment

I have this relatively simple code, generated with another Mathematica code (this is just an example): (edit: see below for simpler version) ...
3
votes
1answer
80 views

SystemException[“MemoryAllocationFailure”] with compile and speed issues

I am trying to run a code that gives out a matrix but, I seem to encounter some memory issues while trying to run it. The code is: ...
3
votes
1answer
43 views

How to avoid “CopyTensor” in compile function with external call: the other case?

I was very interested in the answer of How to avoid “CopyTensor” in compile function with external call? and tried it on my own example below. And it does not work. Just curious why? ...
10
votes
2answers
165 views

How to avoid “CopyTensor” in compile function with external call?

I am writing a complicated compile function. To make it clear, I want to separate it into two smaller compile functions with one calling another. As you can see the example below, the ...
0
votes
0answers
52 views

CompiledFunction::cfexe: error without compiled function

I get the error: CompiledFunction::cfexe: Could not complete external evaluation; proceeding with uncompiled evaluation. but I am not using any compiled function in my code: how can it be ...
10
votes
3answers
619 views

Can I use Compile to speed up InverseCDF?

I'm repeatedly issuing the command P = InverseCDF[NormalDistribution[0, 1], T] where T is either a 36- or 64-vector of real numbers (points in the unit ...
2
votes
0answers
59 views

Eliminating a call to MainEvaluate from a compiled function

I would like to write a compile function ...
2
votes
0answers
93 views

How to speed up multiple calls of NonlinearModelFit?

I'm trying to do an insane amount of non-linear fits to large amounts of data sets. However, I found that the NonlinearModelFit is horribly slow. Here's the setup: ...
6
votes
1answer
207 views

How to speed up evaluation of expression (multiple variables) to gain speed? Compile?

I obtained some long expression and need to use them with a lot of different parameters inside a simulation. However, evaluation of the expressions is pretty slow, so that I would like to speed it up. ...
4
votes
1answer
85 views

Efficient compilation of a list of functions

Let's say that we have at our disposal nbfunc = 4; functions, whose exact expressions are gathered in the list ...
0
votes
1answer
27 views

SubtractFrom::rvalue with Compile

I want to compile the code described here, but I get the error: SubtractFrom::rvalue: 1.`*^8 is not a variable with a value, so its value cannot be changed. A minimal non working example could ...
1
vote
1answer
64 views

Multiple compiled functions modifying having access to and modifying global variables

I would like to implement the following algorithm for finding strongly connected components in Mathematica: I would prefer to keep the structure of the pseudo-algorithm, and would like each of the ...
3
votes
2answers
93 views

A Compiled Function for the distance between a set of point

I need to increase the speed of my code. I have a set of $n$ points in a square box of length $boxLength$. ...
2
votes
0answers
51 views

Compile with “Listable” only on one argument

I would like to write a Compiled function which is listable only in the first argument, because this allow fast and easy parallelization. How is it possible to do it? In the following way it does not ...
3
votes
1answer
65 views

How can Distribution fitting be sped up?

The first line generates 1050 data points to fit. The second line fits this data to the same distribution. This takes about 100ms on my computer. Doing this with ...
0
votes
0answers
167 views

how to speed up this function?

in this code cumavg1,cumstd1,giuper1,gilower1 are compiled. however, i dont know how to compile ei and fi to further speed up the calculation. any help will be appreciated. ...
7
votes
2answers
181 views

Error during getting CCompilerDriver

I have Window 10, Mathematica 11.3 and Visual Studio Community 2013 (Update 5). If I try to get the package CCOmpilerDriver`, I get follow error: ...
7
votes
2answers
2k views

Can this code be changed to run faster?

I've worked for several days trying to get this code to run faster. The imported data is 15MB. ...
3
votes
0answers
131 views

How to overload and compile pure functions operating on associations

I am writing a small package for myself for operating on zonotopes. I am storing the generator matrix and the center of the zonotope in an association. I decided to write a small constructor: ...
1
vote
0answers
43 views

How to compile the function with FindRoot? [duplicate]

How to compile this function or any function that uses lists and Part[] ? f[x_?NumberQ] := FindRoot[x == Sin[t] - t, {t, 1}][[1, -1]];
1
vote
1answer
87 views

Initialize global variables in a package containing a compiled function

I have created a package that consists of a function which uses Compile. This function contains a parameter, say a, and I want ...
3
votes
1answer
77 views

Speeding up filling a matrix when approximating a double integral

I want to approximate a double integral in the process of solving a partial-integro differential equation, to then put it, next to the differential part. The integral is (after some simplifications): \...
7
votes
1answer
138 views

Efficiency in calculation on graphs: Compile?

Basic Question I have a looping calculation that I need to perform on some large lists a very large number of times, and as I have written the functions the computational speed is prohibitively slow. ...
14
votes
1answer
281 views

Nested Table + GetElement in C-compiled function crashes kernel

Bug introduced in 8.0. [CASE:4075198] Using a nested Table and then Compile`GetElement crashes my kernel when I run a function ...
10
votes
3answers
294 views

Mod slow in CompiledFunction

I've been playing with a little compiled Ising model implementation. It's brutally slow. Decomposing things I've found that the primary culprit appears to be Mod. ...
3
votes
2answers
104 views

Plot compiled function with LogLinearPlot

I have a compiled function which I can plot without issue using Plot. However, when I use LogLinearPlot I get the message: ...
1
vote
1answer
94 views

Numerical error in compile, Strange behaviour in numerical evaluation

First of all, apologies for the large numbers, I couldn't find a working example for a far lower order and the zeros are necessary... my problem is this: I have a large polynomial (from high-order ...
5
votes
1answer
302 views

How to obtain better speed performance with NMinimize over a complicated objective function?

Edit.1: I've rewritten the question in order to make it more accessible for troubleshooting / debugging / maintenance purposes, as suggested in the comments. I apologize for any inconvenience. I'm ...
1
vote
1answer
117 views

compiled function does not extract elements from a matrix, proceed with uncompiled evaluation

I have written a small piece of code for a function that extracts certain elements from a matrix and then sum them and return the result. Although the uncompiled version works, when I try to switch to ...
0
votes
1answer
77 views

How to boost the performance of a function that approximates a 3D object

I have defined a function $f_{a}(\boldsymbol{r})$ that gives a finite discrete approximation of a continuous function $f(\boldsymbol{r})$ that represents a 3D object. Here, the object is a sphere of ...
2
votes
2answers
271 views

WM 11.3.0.0 CompilerDriver[] fails to compile a C code with VS 2017 Community

I am new at using CCompilerDriver[]. I call the C compiler from W Mathematica using recent WM 11.3 update. It successfully identifies the Visual Studio 2017, But calling compiler returns errors. <...
6
votes
1answer
649 views

Can I use Microsoft Visual Studio C compiler with V.11.3?

Mathematica 11.2 supports the C compiler of Microsoft's Visual Studio, which is what I have. But Mathematica 11.3 does not. The only compilers that 11.3 seems to support are gcc and Intel, both of ...
2
votes
1answer
155 views

Calling a CompiledFunction DLL from outside Mathematica

If/when I produce a DLL using, say, Compile[{{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"] I know where the DLL is. What I'm wondering is whether I can ...
0
votes
1answer
60 views

Compilable table of Matrix diagonals function

1, I am trying to make Compilable function which takes Matrix of zeroes and ones f.e: ...
1
vote
1answer
204 views

CreateLibrary fails… path to C header files problem?

How can I tell MMA where to find c header files for compilation? CreateLibrary is returning C1083 can't find stddef.h. Details follow... Windows 10 - 1709 using Visual Studio 2015 (Community Edition, ...
3
votes
2answers
103 views

Avoid hardcoding of variables for Compile by using a list

I want to automatically Compile an expression in between a routine of certain analytical manipulations. The number of arguments for the function may change for ...
0
votes
0answers
68 views

Is it possible to compile this code?

I'm not really familiar with the Compile function at Mathematica yet, but I know that it can, in some cases, be faster than using a non-compiled version of a code. I've been giving some shots in ...