Questions tagged [compile]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
453 views

Compile a program with Fold function

I have the following small program: ...
5
votes
4answers
391 views

Findroot with a precompiled function with parameters

If I want to precompile a function that I intend to put into FindRoot many times, I could do it like this: ...
1
vote
2answers
377 views

Why is CUDALink failing?

I have a new windows 10 laptop with a discrete nvidia graphics card (all drivers up to date). The first example from the documention of CUDAFunctionLoad[] in v11.2 ...
5
votes
2answers
185 views

Making calculation of correlation dimension faster

I am trying to make my calculation faster. I was hoping, when I compiled it, it would work much faster, but in the end its even slower. I don't know if I am using ...
4
votes
2answers
201 views

Numerical Join of two sets of vectors ignoring repeats

I have two sets of numerical vectors which can be either Real or Complex and I want to combine them together, ignoring repeats. ...
5
votes
2answers
340 views

Using Findroot with Precompiled Function

I am writing a Monte Carlo algorithm to solve some algebraic equations. To do this I need to evaluate FindRoot many times on the same function. Following from F'x's answer to Expression evaluation ...
2
votes
0answers
73 views

Can substitution rules be compiled?

I am thinking of having a custom multiplication operation CenterDot[A,B] for non-commutative operators, and some rules that should commute the operators to a ...
0
votes
1answer
65 views

What does the number(1 and 0) mean inside type {_Real,1} and type{_Real,0} and how to fix the nonphysical answer for ThreeJSymbol?

I am using Compile in my code, defining for 'tmp' as a local variable using Block. Then I am giving it the value zero tmp=0.0 and using Do I am trying to calculate the new value of tmp. I do not ...
10
votes
1answer
153 views

On comparable hardware, is Mathematica known to perform better in one operating system over the others?

Have any benchmarks been published by Wolfram Research to compare the performance of Mathematica in the major operating systems (Windows 10, Linux, MacOS)? If not, has anyone here performed such ...
2
votes
1answer
184 views

Compile is slower for simple example

So I have what I assumed to be a textbook example of where compiling my code would be faster. I just make a little ellipse in the complex plane; ...
1
vote
0answers
77 views

Is there a way to reduce size of complex number?

I would like to create huge matrices with hundreds of thousands of elements per side and I would like to use complex numbers in it for further processing by Mathematica functions. When I investigate ...
18
votes
1answer
595 views

Strange behavior of Table

Whenever I run the code a = 0; code := (a++); Table[code; a, {1000}] I get a list of 1000 zeros. However, if I replace 1000 with 100, then a get a list equal to ...
1
vote
0answers
99 views

How to specify precision level of a compiled function? [closed]

In order to speed up the memoization of data generated via NIntegrate, a possible approach is to use Compile on both NIntegrate function and the function itself separately. How can one set the ...
0
votes
0answers
26 views

Compiling a recursive function [duplicate]

I'm trying to compile a recursive function that spits out the n-th Fibonacci number. I have a working uncompiled function, I just can't seem to get the compiled version working. Here's the code: <...
1
vote
1answer
78 views

Speeding up computation of a sequence

I am simulating the dynamics of a spring mass system impact an obstacle. I will not go into the details of the numerical scheme, but here are the general parameters and functions: ...
15
votes
2answers
466 views

Why can't I inject expressions in Compile using (only) With

Generally speaking, With can be used to inject into arbitrarily held expressions, for example: ...
13
votes
4answers
639 views

Implementing a compilable Faddeeva function of complex argument

For those, who are looking at Halirutan's answer and thinking "gee, I wish I was that good at LibraryLink, then I could really speed up my code!" I leave here the ...
1
vote
1answer
156 views

Avoid symbolic evaluation with NSolve and compiled function

Problem I have a compiled function that I want to use in an equation given to NSolve. I can get the code to run, but it first produces warning messages that result from NSolve trying to evaluate the ...
1
vote
1answer
77 views

Position with Compile is acting slower than without

For a big matrix 5000 x 5000 or list2 i am trying to get positions of all entries Except[1.0]. I am using ...
3
votes
1answer
59 views

Why does compiled function give different results than uncompiled version?

I have a simple function that I've written as both a pure function and a compiled pure function, but the compiled version produces different results, suggesting either I don't know how to get it to ...
8
votes
2answers
577 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 ...
2
votes
1answer
134 views

Speeding up compilation of recursive functions

I am trying to understand how to speed up recursive functions via compilation. I am experimenting with the Fibonacci sequence (though this is not really what I want to do eventually). Can somebody ...
12
votes
1answer
219 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: ...
4
votes
1answer
212 views

Fast manipulation of large dimensional arrays

I am dealing with a multiplication of two- and three- dimensional arrays. Since the arrays are large, I am compiling a function to deal with it. The code of the function, with a working example, is as ...
3
votes
2answers
141 views

Can I compile my function?

I'm trying to do some time-consuming simulations but I have no idea how to optimize this. ...
5
votes
2answers
108 views

Optimizing user defined graphicQ, test of graphicness of a sequence

A sequence of non-negative integers is graphic if it is the degree sequence of some simple graph. Graph realization problem is the decision problem where it is asked whether a given sequence is ...
22
votes
2answers
456 views

What can be inlined by “InlineExternalDefinitions” -> True?

This not-well-documented option of Compile has been used quite a bit in this site, and based on these examples, I used to think ...
14
votes
2answers
443 views

How to define a function inside a Compile?

I want to compile a variety of commands, including a function. I need to map this function, inside the compilation, and I can't include the function without facing errors such as "CompiledFunction::...
0
votes
0answers
38 views

Finding root in pre compiled function [duplicate]

I have a pre-compiled function and I need to find its roots. The function seems to be working much faster that before compiling, so I want the compiled version of it. ...
1
vote
3answers
222 views

Fastest way to find roots

I'm working with generative polynomials, and would like to know if there is a faster way to calculate roots. Using the technique below I've managed to cut the time down significantly. However at n=35, ...
7
votes
2answers
150 views

How to create Functions that have Compiled functions effectively

I'm about to build a package that will provide lots of simple functions. I want these functions to run as fast as possible when evaluating numerically but still provide symbolic results when needed. ...
2
votes
1answer
149 views

AceGen: How to use MinGW in Compile[]? [duplicate]

Note: This question is about AceGen package for automatic code generation for finite element analysis. MinGW compiler is recommended for compiling finite element subroutines generated by AceGen and ...
1
vote
1answer
365 views

Dealing with InterpolatingFunction in Compile

I have rather large equations that profit a lot from compiling, unfortunately they require input from external numerics and need to be interpolated. In the end this costs a lot of performance as <...
24
votes
1answer
1k views

Getting Compile to work with Visual Studio 2017 Community Edition

The new Visual Studio is out since a week and I tried to get it to work with Mathematica (versions 11.0 and 11.1). However, the usual tricks for working with a new VS version fail here. Related ...
4
votes
2answers
150 views

Compile Flatten with list as second argument

If you try to evaluate code in which Flatten uses a List as second argument, like the following: ...
3
votes
1answer
120 views

Can't run CreateExecutable example

I'm trying to run this example from the Wolfram website, on Linux Mint 16. ...
1
vote
0answers
159 views

CreateExecutable returns $Failed

My platform is win10 64b, Mathematica 11 and Visual Studio 2015. When I apply CreateExecutable, it always returns $Failed. The ...
6
votes
2answers
237 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 ...
0
votes
1answer
132 views

How do Compile and Module work in a code?

I am trying to understand the following code in this answer regarding Möbius transformation: ...
3
votes
1answer
98 views

What is the most effective way to reassign values in an array based on their positions

I have to reassign values in a big array many times and it turned out to be the most time consuming in my program. The best way I could figure out is this ...
9
votes
1answer
141 views

How to cross-compile LibraryLink code for multi-platform distribution

I am running Mathematica on a Windows 10 machine and I would like to develop a package for public distribution. Most of the package will be Mathematica code, but some timing-critical parts should be ...
6
votes
1answer
204 views

Why is Compile + RandomReal faster than random real?

In the process of playing around with Compile, I discovered something surprising. RandomReal[{-1, 1}, 3] is a lot slower than <...
7
votes
3answers
508 views

Metaprogramming: creating compiled functions from inter-dependent code blocks

I want to create a compiled function from inter-dependent code blocks. Here is a minimal example showing the salient features based on strings: ...
3
votes
1answer
232 views

Compile from String using function arguments

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

Compile intermediate type specification for rank-3 ConstantArray[_,{_,_,_}]

Compile[{}, ConstantArray[0, {1, 2, 3}], CompilationTarget -> "C"][] yields ...
0
votes
0answers
108 views

Performance tuning with memoisation, compilation and vectorization - further possibilities?

In order to tune the performance of noticeably slow code of mine, I had a look at many different excellent posts on this topic here on M.SE, e.g. here to name the most interesting one. Now I ask ...
1
vote
1answer
181 views

Numerical Expectation of a Compiled function

I have an integrand built as a compiled function. A simple test function is: ...
4
votes
2answers
192 views

Slow gains in compiling functions

I am obtaining slow gains in compiling a function, and would like to ask if there is something I am obviously missing. The function I intend to speed up has the form: ...
18
votes
1answer
269 views

Why Function is not identical to `&` in autocompilation?

Here is the example, copied from here square = Function[x, x^2]; square1 = #^2 &; the timing and unpacking status shows ...
0
votes
1answer
210 views

Compiling function solving for the smallest eigenvalue of a matrix

I am trying to speed up my code, which many times finds a lowest eigenvalue of a Hermitian (symmetric, real) matrix. Using a small 2x2 matrix as an example, this works: ...