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

learn more… | top users | synonyms

6
votes
1answer
78 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
128 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
83 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
199 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
123 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
98 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
654 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
98 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
223 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
101 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
60 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
154 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
134 views

How to compile procedural program effectively

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

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

Let's consider the following: ...
1
vote
1answer
167 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
618 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
149 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 ...
13
votes
1answer
596 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 ...
1
vote
0answers
156 views

How to use Wolfram language in an external program with low latency? [duplicate]

Im using Wolfram language on Pi B,and I want to compile a '.m' file (like "test.m" that contains Wolfram functions), in an external program like a C/C++ and then Export the output in an image file ...
5
votes
0answers
108 views

Compiling FoldList implementation for RK4

Original I'm looking to write an integrator for a function of two variables. Here is my implementation for the RK4 update rule using FoldList. ...
3
votes
0answers
84 views

speed up evaluating a listable function [duplicate]

I apologize in advance for the vagueness, but I can't think of a more descriptive title. I am trying to find the average value of the square of BesselJ[0, x] ...
7
votes
0answers
198 views

What is a good way to code long, complex, compilable algorithms?

The functional paradigm of the Wolfram Language used in Mathematica is all around wonderful. For intense numerics, Mathematica comes with the ability to Compile ...
2
votes
2answers
72 views

How to build recursive function which only remembers every pth value and the last two values?

I need to create a recursive function of the natural numbers $f$ which only remembers the last two values it has found and every $p$th value. Below is the form of the code that I am working with, but ...
4
votes
2answers
284 views

How to compile this function

I want to compile my function that calculates the energy of a particle system. This is what I've tried: ...
5
votes
3answers
119 views

Problem with Compile and Flatten

I want to get two lists within a compiled function, where r is an integer: ...
4
votes
2answers
220 views

Improve simulation speed using Compile

I have two square matrices, a hermitian matrix h and an unitary matrix v. I am interested in the following function ...
6
votes
1answer
316 views

Compiling a function that takes lots of optional arguments

I have a function that takes lots of optional arguments (basically some design parameters, about 10 of them) and performs some basic algebraic calculations involving complex numbers with the options. ...
13
votes
1answer
199 views

CompiledFunctionCall vs. LibraryFunction

When compiling code to C, and the compiled code calls other compiled functions, I see CompiledFunctionCall in the output of ...
12
votes
1answer
527 views

Save a C compiled function without losing the blessing of C compiler

Consider the following example: ...
3
votes
3answers
296 views

NIntegrate-ing a compiled function

I'm trying to integrate numerically in 6 dimensions a very long expression and I read about the option to NIntegrate a compiled function which should be faster. ...
5
votes
2answers
129 views

A problem with Compile and Map

There is a weird behavior of Compile that I do not understand. Consider the following example: ...
2
votes
1answer
88 views

Error from Compile with a sum over two indices

I have the following code: ...
1
vote
1answer
74 views

What is the meaning of the lists of numbers in the FullForm of a compiled function?

For example, f = Compile[{{x, _Real}}, x]; FullForm[f] has this output: ...
0
votes
1answer
76 views

Why does Compile redo the calculation when overflow happens?

When implementing the Numerov method solving Schrodinger equation, I encountered this problem. In order to show the order of the evaluation, Print is added. ...
0
votes
2answers
223 views

Numerical 3D Integration in Mathematica [closed]

My question in short is: Is it possible to make numerical 3D integration in mathematica efficiently? Or am I gonna have to move this to C++? I feel this problem is way too trivial to go to C++, so ...
9
votes
0answers
533 views

Step-by-step instruction to Install C Compiler

I remember using C compiler on my previous computers, and I never had any problems installing them. At this time, however, I failed to work through the instructions provided in Mathematica ...
10
votes
1answer
192 views

Compilation of Total with compensated summation

I sometimes obtain an unexpected error when trying to call a compiled version of Total with compensated summation turned on. More specifically I define ...
1
vote
0answers
277 views

How to get Mathematica to compile with target C? [closed]

I have been trying to compile some functions in mathematica with target C for speed. basically when I try: ...
5
votes
1answer
291 views

Compile, “global variables” and recursion

I am trying to do something similar to this, namely to make a Compile'd function outer that itself calls a ...
4
votes
2answers
240 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
0
votes
1answer
80 views

Correct use of Solve inside Compile

I have a function that behaves itself, but I want to make it much faster so I tried to put it into a compilable form After much fiddling I can't get it to work. Here's one of my failed attempts: <...
2
votes
1answer
63 views

Why do messages only appear first time I evaluate my compiled function?

I declare my compiled function: ...
5
votes
1answer
284 views

Slow-down encountered when using NMinimize with a compiled function

I'm minimizing a large function. Evaluating the function is very slow symbolically but using Compile I can get ~100x speed-up on this step. However, despite this, the NMinimize process is only ...
3
votes
0answers
92 views

Goto and Compile to C

When I use Goto inside compile and use CompilationTarget->"C" I get error message: ...
4
votes
1answer
153 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 ...
1
vote
1answer
95 views

Throw and Catch or Return inside Compile

Consider this code: ...
3
votes
1answer
110 views

Package and imbricated compiled functions

I would like to build up a Mathematica package Pck which contains compiled functions. However when loading this library I obtain an error. When reduced to a minimal ...
5
votes
1answer
300 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 ...
2
votes
1answer
229 views

Compile a MeijerG function [duplicate]

I am not very experienced with Compile, I tried to use it for a Meijer-G function ...