Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [compile]

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

4
votes
0answers
70 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
67 views

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

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
65 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
139 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
49 views

How to make a compiled version of a function?

I'm trying to make a compiled version of this function ...
2
votes
2answers
57 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
96 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
98 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 "...
5
votes
0answers
119 views

Possible Compile bug

Bug introduced in 11.3 or earlier The program: ...
0
votes
1answer
74 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
71 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
95 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
43 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
71 views

Compile a Module

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

Pick inside Compile

I want to compile this function: ...
5
votes
4answers
180 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. ...
0
votes
0answers
56 views

Create Compiled Function - Matrix Initialization

I am attempting to compile the following function: But I receive the following error messages: How should I initialize the matrix Vw to enable the assignment to Vw[[1,1]]? ...
7
votes
0answers
56 views

Substitute for Association inside Compile?

Associations are not compilable, so I’m looking for a workaround to this. That is, I need a mutable hashtable-like data structure with fast key value lookups ...
1
vote
1answer
32 views

NIntegrate fails with functions that have (necessarily) numeric lists as arguments

I'm not able to NIntegrate a function that has a numeric list as an argument. My original problem involves a compiled function, but a MWE is the following: ...
6
votes
3answers
124 views

CompiledFunction showing its contents

CompiledFunctions usually appear very compactly, for instance: ...
1
vote
1answer
71 views
0
votes
1answer
94 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
60 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
108 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
146 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
57 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
78 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
76 views

How to compile with list?

I try to compile this code, but always failed, could anybody guide me? ...
1
vote
1answer
63 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
39 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
41 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
51 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
60 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
53 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
36 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
149 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
45 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
596 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
50 views

Eliminating a call to MainEvaluate from a compiled function

I would like to write a compile function ...
2
votes
0answers
85 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
174 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
76 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
0answers
64 views

What are the minimal components of Visual Studio 2017 15.8 to install?

I know that there are a few very similar questions to this one on this website. But I still cannot figure out how to setup both on Visual Studio 2017 (what minimal components to install in community ...
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
61 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
86 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
44 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
63 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
163 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. ...