A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
8
votes
3answers
633 views

Threading a compiled function over multiple arguments of different lengths

I am interested in threading a compiled function over multiple argument lists of different lengths. I will explain this in two steps: Suppose f is some function. Then one can define another ...
6
votes
1answer
683 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 ...
3
votes
1answer
717 views

Need help with C Code Generator

I'm trying to use the Mathematica C Code Generator package to generate code that is to be included in a web application by a developer. I don't know any C, and this seems to be the only way to ...
3
votes
1answer
399 views

Performance of compiled functions (Project Euler No14)

I was playing around with the project euler problem 14. The solution I came up with is listed below as cf1. The solution works fine but I get the compiler warning: ...
25
votes
2answers
321 views

Listable compiled function crashes the kernel with “no more memory available”

Bug introduced in 9.0.0 and fixed in 10.3 I am trying to speed up a function that involves continued fractions. Since ContinuedFraction cannot be compiled and the ...
17
votes
2answers
281 views

CompiledFunction returns machine numbers smaller than $MinMachineNumber

When thinking on the workaround for this LogLogPlot bug suggested by halirutan I noticed that CompiledFunction actually can ...
14
votes
1answer
284 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 ...
12
votes
2answers
1k views

Using Goto and Label in compiled function?

Below I post some rudimentary code to show that there is something wrong using Goto and Label commands in compiled functions (or I believe there is something wrong). It seems that the command Label is ...
8
votes
2answers
1k views

Why is this compiled function 50x slower?

Why is the compiled function so slow? I have seen question 41344 but don't understand any potential relevance. Here are the two functions for comparison ...
7
votes
2answers
522 views

Catching error in middle of evaluation of compiled function

I have programmed and Compileed a complicated numerical function. The function has singularities (i.e. are infinite) at certain input numerical values. I need to ...
5
votes
2answers
1k views

Expression evaluation inside of FindRoot inside a Compiled Function

I'm trying to get some performance increase out of my own implicit differential equation solver using Compile[]. The uncompiled function is of the following form: ...
5
votes
0answers
54 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 ...
3
votes
2answers
696 views

global variables in compile statement

sorry for posting multiple questions about compile, but this is giving me some headache lately. This time my question is about using globally defined variables in a compile statement. The problem is ...
12
votes
2answers
365 views

Has compilation of big programs become excessively sluggish in v 10.4?

Bug introduced in 10.4 and fixed in 11.0 After updating to 10.4, many of my heavily numerical functions defined by Compile takes a huge amount of time to compile ...
12
votes
1answer
221 views

Compile and uncompilable function bug?

I think I found a bug, but I still have MMA version 11.0.1 installed. Can somebody please check if this persists in the latest version? When I compile this function: ...
10
votes
1answer
443 views

Unexpected behavior of Compile, Return and ;

Could somebody explain why test = Compile[{{x}}, Return[x]; ]; test[0.] returns ...
9
votes
2answers
252 views

How to compile procedural program effectively

Consider these four function in different form: ...
7
votes
1answer
2k views

Mathematica NDSolve and 'Compile'?

Since the consensus is usually that NDSolve speeds fares badly against compiled code such as c++ ODE solvers using GSL say, is it possible to make up for this lag ...
7
votes
1answer
580 views

Is there any strategy to have a compiled version of FindFit or NonlinearModelFit?

Disclaimer: This is not a precise question with a definite answer. I know that neither FindFit nor NonlinearModelFit is in the ...
6
votes
1answer
466 views

How to compile Map and MapAt

I have a long list (say, million of elements, like this one: {{{1.0, 2.0}, 3}, {{4.0, 5.0}, 6},...} I would like to compile a function ...
5
votes
1answer
163 views

Compilation, square roots, and integers

After looking at this question, particularly this answer, I wrote my own performance test, using the two functions ...
4
votes
0answers
241 views

CompilationTarget to C takes long compilation time

Consider I have a function, with one version that compiled to the virtual machine and one that compiled to C: ...
4
votes
1answer
1k views

How to use Compile with NDSolve function for large no of differential equations?

Matrix M[t] and and Hamiltonian of same order L^n x L^n. ...
4
votes
1answer
166 views

Throw and Catch return wrong result inside Compile

Consider this code: fun = Compile[{{i, _Integer}}, Catch[Do[ If[j >= i, Throw[j]] , {j, 1, 10}]] ] I put an integer as argument then if this ...
2
votes
1answer
161 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 ...
2
votes
2answers
305 views

What is the maximum real value for Compile?

Can one be found programmatically? The function I'm compiling, indicesOfMin, gives the indices of the minimum value(s) of a real-valued list, the parameter, in a ...
2
votes
0answers
92 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 ...
10
votes
2answers
169 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 ...
8
votes
2answers
583 views

Why won't this compiled function be inlined?

I've been trying to use Compile to get some code to execute more quickly, because I will need to call it millions of times. I've been using the ...
7
votes
1answer
292 views

How to boost the performance of my own BSplineFunction

In my CAGD package, I implemented a CAGDBSplineFunction[] like built-in BSplineFunction[]. ...
6
votes
2answers
239 views

Puzzled regarding avoiding evaluations and using results of computations as functions

What did I do before? I seem not to be able to understand MMA's evaluation scheme. I read some posts like Preventing Evaluation or a MathGroup post where the topics of evaluation prevention are ...
6
votes
1answer
282 views

If doesn't compile if its output is the output of Compile?

The smallest sample I can find to reproduce this problem is: test = Compile[{}, If[True, 1]]; << CompiledFunctionTools` CompilePrint@test ...
5
votes
1answer
410 views

Error messages from compiling the Piecewise function

The following works Compile[{{x, _Real}}, Piecewise[{{{0., 0.}, x > 5.}}, {1., 1.}]] but if I enter the Piecewise[...] in ...
5
votes
1answer
154 views

Fast 1D BinCounts Alternative

I have lots of data which looks like this example: ...
5
votes
1answer
247 views

MapThread and Compile

After discovering that MapIndexed cannot be used with compile (see MapIndexed and Compile) I am now trying do implement similar functionality using a combination of ...
5
votes
1answer
89 views

Unequal and Compile

...
4
votes
1answer
430 views

Explanation on why Compile statement works only if input and output sizes work

I found the following code: Compile[{{m, _Real, 2}}, Fourier[m]][Table[N[i - j], {i, 4}, {j, 4}]] which doesn't work correctly. But the following was posted as a ...
4
votes
2answers
600 views

Compile with function definition inside

How can I compile a code with target C containing function definition inside? I saw post using With. But this just inserts the function in the appropriate place ...
4
votes
0answers
237 views

Is it possible to Compile the function with string argument? [duplicate]

As we can see from the Compile documentation, the typical arguments for Compile should be ...
3
votes
1answer
132 views

Compile::cplist: error from MapThread [duplicate]

What is the cause of this error? Compile[{{r, _Integer, 2}, {d, _Integer, 2}}, pos = Position[MapThread[#1 > #2 &, {r, d}, 2], x_ /; x == True]] ...
3
votes
1answer
481 views

How do I format Compile[] correctly?

My Mathematica skill is still rusty, so kindly bear with me. I'm having problem formatting expression to compile the function correctly: $\sum _{g=1}^G \sum _{n=1}...
3
votes
1answer
236 views

Compile from String using function arguments

I want to return a Compiled function built from a string that uses values of local variables: ...
3
votes
1answer
170 views

Debug numerical error inside CompiledFunction

I want to speed up evaluation time of a long expression (a function of a single parameter t). To do so, I thought about using ...
3
votes
2answers
105 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: ...
3
votes
1answer
3k views

Use a part specification as the argument to a compiled function

I have some code that needs to generate a large matrix based on some complicated combinations of smaller matrix elements. I find that if I write a function for the element of the larger matrix, and ...
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: ...
2
votes
1answer
306 views

Speeding up this recursive function

I have a recursive function defined like this: ...
2
votes
2answers
263 views

Compile function - error but correct calculation

I am investigating Compile lately and I came across the following problem. I define a 2-variable function ...
2
votes
1answer
103 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
356 views

how to Compile user-defined function like this

the following function can be compiled successfully ...