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

learn more… | top users | synonyms

10
votes
1answer
107 views

Bug with Compile and Log2?

It seems that Log2 in Compile gives numerical errors (CompiledFunction::cfn) if the input is ...
8
votes
2answers
90 views

Efficiently checking whether a number is a perfect power

Goal The goal is to efficiently check whether a number is a perfect power. Attempts It is possible to check whether a number is a perfect power using ...
8
votes
1answer
134 views

Replace nested external definitions in Compile

f = #^2 &; Compile[{{x, _Real, 1}}, f /@ x, CompilationOptions -> {"InlineExternalDefinitions" -> True}] // CompilePrint works fine. ...
0
votes
0answers
35 views

Compile a function with string list as argument [duplicate]

I would like to know how such a function (even it is useless) can be compiled and what I did wrong. ...
4
votes
2answers
107 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 ...
2
votes
0answers
65 views

How to use Compile? Bivariate Gibbs Sampler

I am trying to use compile to speed up my Gibbs sampler. I know I can use Reap and Sow to speed up tremendously. I have a more complicated Bayesian posterior that I want to speed up with compile so I ...
0
votes
0answers
39 views

Compiling LinearSolve with 2 complex matrices, possible bug

Take two complex matrices depending on one variable, for example: ...
2
votes
1answer
180 views

Compiling in mathematica

I'm trying to compile what I think is a pretty simple function that does matrix multilplications in a loop (see below). But Mathematica issues the message: Could not complete external evaluation ...
3
votes
1answer
81 views

Table with programmatically specified number of iterators in Compile

Compare two ways of computing a table of values of a multivariable Gaussian: ...
10
votes
2answers
241 views

How to boost the performance of my own BSplineFunction

In my CAGD package, I implemented a CAGDBSplineFunction[] like built-in BSplineFunction[]. ...
1
vote
1answer
76 views

Create a Mathematica function that can be called from R or Matlab

I would like to export a function from Mathematica to allow it to be accessed from R and/or Matlab. Is there a way to do this? As an example, suppose I want to export the following (albeit ...
1
vote
0answers
58 views

How to speedup Plot3D with precompiled argument

I have a huge problem with my code: I estimate it to take hours to run. The scheme of the code is the following (I left the steps the same, but took much simpler functions): ...
2
votes
1answer
76 views

Compile with a list as an argument

This is probably trivial, but I couldnt make it work: safeConv = Compile[{{a, _Complex, 10}, {b, _Real}}, If[b > 1, a[[1]], 0] ]; I get a rank-error ...
0
votes
0answers
50 views

Problem with Greater in Compile

I am relatively inexperienced with Mathematica so I apologize for the possibly simple question. I have written the following function which should receive a matrix as input. If I compile this, ...
0
votes
0answers
79 views

How to compile code that involve sparse array?

I have the following code ...
0
votes
0answers
43 views

Compiled funtion don't understand internal compiled function [duplicate]

I work a lot on Mathematica and sometimes I need to optimize my computations by using compiled functions. Now I'm making numerical integrations and I'm trying to compile the functions involved to make ...
1
vote
1answer
85 views

What's the syntax to compile these functions, whose arguments are nested lists? [closed]

In some case the Compile's syntax is quite straightforward. Es. for rank 1 e rank 2 tensors: ...
12
votes
1answer
248 views

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

Bug introduced in 10.4 and persisting through 10.4.1 After updating to 10.4, many of my heavily numerical functions defined by Compile takes a huge amount of time ...
2
votes
2answers
112 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 ...
3
votes
1answer
141 views

Why does Compile not make my function faster?

I need to speed up a large program that repeatedly calls the module below (I've not trimmed the code for this question to ensure there is enough calculation to show a speed improvement.) The obvious ...
2
votes
3answers
147 views

Compile error with MapThread

I have the following code: ...
3
votes
1answer
60 views

List of compiled functions and then plot them 1 by 1.

I would like to create a list of compiled functions and then plot them 1 by 1. To illustrate the problem (In reality the functions I want to compile are of course not x^j but some complicated ...
7
votes
2answers
153 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
45 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
39 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
73 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
247 views

Speeding up this recursive function

I have a recursive function defined like this: ...
1
vote
1answer
96 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
92 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
82 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
54 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
97 views

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

Turn on Needs["CompiledFunctionTools`"] First example ...
3
votes
1answer
156 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
5
votes
1answer
108 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
59 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 ...
4
votes
3answers
142 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
70 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
94 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
206 views

How to compile this code?

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

Compile decreases the number of returned list elements

I have: LogisticMap = Compile[{μ}, ({μ, #} &) /@ Union[Drop[NestList[μ # (1 - #) &, .2, 300], 100]]]; Then: ...
0
votes
0answers
85 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 ...
6
votes
1answer
218 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
105 views

`FindMinimum` with compiled function [duplicate]

I don't know how to fix this problem: ...
6
votes
1answer
240 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: ...
4
votes
0answers
93 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, ...
2
votes
0answers
111 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
31 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
100 views

Fast 1D BinCounts Alternative

I have lots of data which looks like this example: ...
7
votes
2answers
261 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: ...