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

learn more… | top users | synonyms

6
votes
2answers
78 views

How to define a complicated function inside the body of Compile?

I want to compile a function in a way to keep its memory footprint down. In the example below, I am trying to compile a function f that makes three calls to ...
3
votes
0answers
32 views

weird behaviour of Listable fortran Librarylink function: different result each evaluation

I am working with fotran librarylink function currently. In this post, I will show some weird result of Listable fortran librarylink generated by intel compiler under windows (I tried gcc on linux the ...
1
vote
1answer
27 views

Length in Compile encounter “type Integer encountered in assignment of Type Real ”

Compile[{}, Module[{n}, n = Length[{1, 2, 3, 4}]; n = n/2]] The above code will emit errors Compile::cset: Variable n of type _Integer encountered in ...
1
vote
0answers
53 views

Compiled function and integration

I'm using the recursive functions defined here: MyFnc and myFncC (compiled version). I want to call this functions in the ...
2
votes
1answer
216 views

Speeding up this recursive function

I have a recursive function defined like this: ...
1
vote
1answer
89 views

How to do this Function with compile

There is 4 lists, 3 of them are at same length (l0, l1 and l3). ...
1
vote
1answer
89 views

Manipulating Some Lists in Compile

Consider a list of lists, such as: Z={{1,4,3},{2,1,3},{3,1,4}} Z is an $n \times n$ matrix (here $3 \times 3$) which ...
3
votes
1answer
73 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]] ...
1
vote
0answers
43 views

Compilation error: “Could not complete external evaluation at…”

I'm pretty new to trying to use Compile[], and I just can't see why I'm getting this error. I have two functions to define beforehand; one of them is a bit odd: ...
4
votes
0answers
78 views

Is it possible to prohibit unnecessary CopyTensor in Compile? Just like .noalias() in Eigen library?

Turn on Needs["CompiledFunctionTools`"] First example ...
2
votes
1answer
129 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
5
votes
1answer
93 views

Compilation, square roots, and integers

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

Error message when using a compiled function in NSum [duplicate]

Below is a simple example to illustrate the problem test = Compile[{{n, _Integer}}, n] Now, Table works fine ...
3
votes
3answers
98 views

about Compile and return type

In the mathematica document "tutorial/CompilingWolframLanguageExpressions" 1 It says about how to set return type of a called function you used in Compile. ...
6
votes
1answer
58 views

Compile Select returns “Null tensor with rank > 1 encountered at instruction 24”

This is the problematic part of one long function, wich should applyied many times to the list ...
3
votes
1answer
77 views

Is there any way to use compile and still maintain high precision in Mathematica? [duplicate]

Is there any way to use compile and still maintain Arbitrary-precision like 50 in Mathematica?
5
votes
1answer
180 views

How to compile this code?

Could somebody teach me how to compile this code? ...
0
votes
1answer
50 views

Compile decreases the number of returned list elements

I have: LogisticMap = Compile[{μ}, ({μ, #} &) /@ Union[Drop[NestList[μ # (1 - #) &, .2, 300], 100]]]; Then: ...
0
votes
0answers
77 views

Nestlist inside Compile

My question is a continuation of question1 and question2, but I think it may be considered as a self-contained one. I am interested to make the following code faster ...
5
votes
1answer
183 views

My introduction to Compile

I am reading Fractals from the Newton-Raphson method from Peter Young's page [http://young.physics.ucsc.edu/115/]{http://young.physics.ucsc.edu/115/}. I've tried: ...
4
votes
1answer
68 views

`FindMinimum` with compiled function [duplicate]

I don't know how to fix this problem: ...
5
votes
1answer
182 views

Precompiling a Whittaker function

Is there a way to speed up the evaluation of special functions in Mathematica? I am particularly interested in the Whittaker W function. For instance, the following piece of code: ...
3
votes
0answers
68 views

Improving the speed of an optimization algorithm via compilation and parallellization

I have written an implementation of eight variants of the PSO-algorithm and I want to test them over a set of test functions. I am using parallelization as it improves the speed a lot and I have also, ...
1
vote
0answers
101 views

integration of a list of gaussian type orbitals (GTO)

I am currently trying to integrate various components of a current density (j={jx,jy,jz}) over space. The problem is that the current j is extracted from a quantum chemical computation and is a sum of ...
2
votes
0answers
29 views

Unable to set up Mingw-64 compiler to get CompilationTarget-“C” working [duplicate]

I am unable to set up the C compiler on my computer, thus can't not make the option CompilationTarget-"C" work in Compile. I am ...
5
votes
1answer
87 views

Fast 1D BinCounts Alternative

I have lots of data which looks like this example: ...
7
votes
2answers
234 views

How to compile self-referencing functions (to perform recursive a task)

How do I compile a self-referencing function to perform iterative tasks? The naive approach doesn't seem to work. Here is a simple example to illustrate the problem: ...
5
votes
0answers
63 views

Does Compilation option “InlineExternalDefinitions”/“InlineCompiledFunctions” lead to unnecessarily complicated nesting?

Question: When an external (possibly complicated) definition f is used inside a compiled function with ...
7
votes
1answer
149 views

Why does this simple sum function fail to compile?

Consider the following compiled function, which takes a $12 \times 5$ array $x_{ij}$ of real numbers and computes the triple sum $$ \sum_{k=1}^5 \sum_{i=1}^{12} \sum_{j=i+1}^{12} x_{ik} x_{jk}. $$ ...
6
votes
1answer
72 views

Closing over array values makes Compile choke with CompilationTarget -> “C”

When I attempt to Compile a closure which contains an array of the appropriate type, it works just fine with ...
0
votes
1answer
114 views

Numeric error in trivial compilation

I came across this strange problem: dd = Compile[{}, Abs[(10^-200 + 10^-200 I)/(10^-200 + I 10^-200)]^2, CompilationTarget -> "C"] dd[] ...
1
vote
1answer
70 views

Module inside module in `Compile`

How can I make compilation to go through with a module inside module? I tried this, failed, a few other ways failed too. ...
0
votes
0answers
62 views

Is tensor argument passing to module expensive?

I wrote a simple module which is supposed to do recursive computation, however it turns out to be expensive even for 300 points. I am not sure why is it slow, all the computations seem to be ...
11
votes
0answers
192 views

Memory usage of compiled function: C vs WVM

Reported to WRI [CASE:3406803] Why does generating an array in "C"-compiled function uses 50% more memory than doing same thing in ...
2
votes
1answer
116 views

How to solve coupled complex-valued equations faster and get simplified solution

I have six coupled equations. How to solve these equations symbolically faster in Mathematica. In these equations, variables p,q,x,y are ...
1
vote
0answers
80 views

Compile a listable function to be applied over list of lists [closed]

Consider a simple function g[x_,y_,z_] := x + y + z; (indeed, any multivariate function g will illustrate the same thing). ...
18
votes
1answer
623 views

Use Compile to improve performance

I've recently discovered Compile as a way to optimize my code. I wrote a program to learn something new about Compile. I have a ...
3
votes
1answer
86 views

How to use Compile to generate an $n×n$ array using $n$ tensors with both Real and Integer element

This is an extension of my earlier questions Faster use of Condition for a large array (see the example) and How to use Compile to generate an $n\times n$ array using $n$ vectors . In this case each ...
24
votes
2answers
213 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 ...
4
votes
1answer
90 views

Undeclared Identifier error in Compile

I've been trying to compile a couple of functions in Mathematica, and I keep coming across an error that I do not know how to resolve. Consider the following function: ...
2
votes
1answer
51 views

Using Compiled Function in Implicit Region

I am looking for a way to speed up code and thus would like to use a compiled function in an ImplicitRegion. Here is an example of a region that can be plotted ...
4
votes
0answers
145 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: ...
7
votes
1answer
126 views

How to compile procedural program effectively

Consider these four function in different form: ...
3
votes
1answer
126 views

How to use Compile to generate an $n\times n$ array using $n$ vectors

Let's consider the following: ...
1
vote
1answer
147 views

How to speed up an optimization with very long symbolic expressions?

I have 8 very long symbolic expressions (each having around 200,000 summands) - Simplify will run forever, so that is unfortunately not an option. Each of those ...
3
votes
1answer
295 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
135 views

CCompile Problems

Operating System: Windows 8.1 Mathematica: 8 In possession of: Visual Studio 2013 and 2015 Had to alter the visual studios driver file within CCompilerDriver application, add-on so that it found the ...
4
votes
0answers
75 views

Why Function is compiled?

Function isn't mentioned in the list of compilable function, but it can generally be compiled when it's formed by compilable functions, a simple example is: ...
12
votes
1answer
564 views

What function generates random numbers in a compiled function?

I am writing a simulation for 2D random walk. I wrote several version of code, and found that the speed is like this (fastest to slowest): C++, Mathematica compiled procedural code, Mathematica ...