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

learn more… | top users | synonyms

1
vote
0answers
57 views

Complex input for Compile makes it slow

I asked a question here and then tried to use Compile for the solution to gain even more speed. Inside Compile there is a loop ...
4
votes
1answer
325 views

A problem about CompilationTarget -> “C” [duplicate]

In my Windows 7 system, I installed two Mathematica versions (V8 and V9) In V8 Compile[ {{x}}, x^2 + Sin[x^2], CompilationTarget -> "C"] CCompilerDriver`...
1
vote
1answer
137 views

Compiling If statement

I'm tring to use Compile in the following code, but it gives me an error message that I don't understand: ...
5
votes
1answer
167 views

Is it possible to change the precision in Compile?

I'm using Compile to do some numerical calculation and I need high Precision. I was wondering if it is possible to change the ...
0
votes
2answers
177 views

Compile a Module wich has a loop with undetermined bound

Suppose I have such a module as below: test[int_] := Module[{m}, m = Table[i, {i, 1, 10}]; Do[m[[i]] = i*i, {i, 1, int}]; Return[m] ] The bound for ...
6
votes
1answer
141 views

Why is C-compiled (but not WVM-compiled) code so slow in Manipulate?

Here is a small section of code from this SE question which computes the real part of the dilogarithm (the upper limit of the sum is increased for demonstration purposes): ...
3
votes
1answer
391 views

How can I trans-compile Mathematica into another language?

I'm looking for an exhaustive list of source-to-source compilers to all other languages, if any exist that is.
5
votes
2answers
122 views

Escaping out of (or exiting) a Compiled Function

How do I manually escape out of a compiled function without forcing an error and compromising its speed? Here is an example: ...
1
vote
1answer
180 views

Finding the index of (x,y) pairs in a list

I have a large list of $(x,y)$ pairs, and I want to find the index of a particular pair in order to extract some data from another array. By way of an example, ...
2
votes
0answers
76 views

Compilation of a function that needs to call Subsets

I'm working on a code that runs many (easy) operations on combinations (subsets) of different size (6, 7, 8, 9) taken from a big set of numbers (normally more that 40). So, this means the code has to ...
2
votes
1answer
315 views

i cannot create a standalone executable from an exported Mathematica function

I generated the C code: compute.c ...
1
vote
1answer
141 views

Apply functions to functions yields slow execution speed

I'm trying to write a function that parametrizes a curve c(t) by its arc length. Technicly I'm finished but if I plot the result for an example curve like ...
1
vote
1answer
191 views

Use Compile to speed up evaluation

I have read, that using Compile command can speed up evaluations in mathematica. I have a mathematical expression, which I evaluate using following command: ...
4
votes
2answers
122 views

Generating compiled functions from inactive expressions

I am working on a project in which I need to dynamically generate CompiledFunctions from Inactive expressions. For example, I ...
2
votes
1answer
115 views

Compile with modification of arguments' values

Is it possible to compile while changing the value of the arguments the function receives, instead of just creating new variables, and then returning those new variables,i.e., is it possible to pass ...
1
vote
1answer
129 views

Problem using Compiled Function within NProbability

I've built a very simple function to estimate the probability for a Long Straddle (derivative strategy) to be positive at expiration. ...
6
votes
0answers
176 views

Fine tuning compiled code that computes dilogarithm function

As an exercise of writing a good Compile function, I want to do the simple task of coding a routine that outputs the real part of the dilogarithm function ...
7
votes
2answers
276 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 ...
21
votes
1answer
892 views

Has this implementation of FDM touched the speed limit of Mathematica?

Still, I'll use the implementation of the 1D FDTD method (you can simply understand it as a kind of explicit finite difference scheme for the Maxwell's equation) as the example. Just for completeness, ...
6
votes
3answers
348 views

How to use a compiled function in numerical optimization

I'm trying to wrap my head around function Compile. So, this is a spin-off question from: a previous question on using compile[] correctly. I have a function that ...
3
votes
1answer
157 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}...
1
vote
1answer
90 views
0
votes
0answers
42 views

How to do replacements in Compile'd code? [duplicate]

I want to do something in the spirit of this code: ...
3
votes
1answer
113 views

Evaluating arguments of module (inside compile)

Note: this is a clarification of 2 earlier unanswered questions, Compile issues, scoping and order of evaluation and Optimising a simple computation with vectors . The problem I have a list of ...
5
votes
1answer
279 views

Compile nested Sums

I want to compile an expressions that contains nested Sum-expressions. A simple example that gives me problems is: ...
6
votes
1answer
163 views

Unable to compile to C

I used to be able to compile to C without problems, but from one day to the next, when I try to compile something, e.g. ...
5
votes
1answer
88 views

Determine return type of CompiledFunction expression

Is there a way to extract the types of the arguments and the return type from a CompiledFunction expression? I am writing a package for code generation (basically a wrapper around CCodeGenerate) where ...
2
votes
0answers
102 views

Compile issues, scoping and order of evaluation

I have a few questions about compiling functions, which I think are all related to scoping and order of evaluation. I will illustrate them by a minimal example of the problem I have. I'm sorry for ...
2
votes
0answers
42 views

Compiled DiagonalMatrix

The standard function DiagonalMatrix cannot be compiled, so I tried writing my own: ...
4
votes
0answers
60 views

CompiledFunction with multiple outputs of different ranks [duplicate]

Below is a simple compiled function f that gives multiple outputs. ...
7
votes
4answers
436 views

Speed up Schwarz-Christoffel mapping

I would like to ask your advice how to speed up Contour and Parametric plots in the following example. Let as start by defining a function ...
6
votes
1answer
506 views

Using Compile Function Options efficiently

While this gives general pointers, I want inputs on ground rules for improved performance of nested/interdependent compiled functions. sample problem: a, ...
1
vote
0answers
155 views

Compiler stack overflow [closed]

I tried to compile a huge function. I used these options: ...
6
votes
0answers
80 views

Listable compiled functions used in NMinimize [duplicate]

This is an example from MMA: cListable = Compile[{x}, (x-1)^2, RuntimeAttributes -> {Listable}] In case of single entry: ...
7
votes
1answer
427 views

Exporting a compiled function for later use

I wish to export compiled functions for later use. This means that I do not want the compiled function to be recompiled every time I reload it. It also means that if my compiled function was for ...
4
votes
2answers
249 views

Problem with machine number precision in compiled functions

When I compile a very big function and give it input the function returns error. I realized that this is because the value of the function becomes smaller than the smallest machine number. Is it ...
0
votes
0answers
294 views

Mathematica cannot find the c compiler

I installed Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 Then, I installed Mathematica 10 trial version. I did: ...
4
votes
0answers
156 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 ...
4
votes
2answers
531 views

Using compiled function inside NMinimize

Consider this code: ...
2
votes
2answers
220 views

How to use Compile

Consider the code below: variable = Sin[x]; fun = Compile[{x}, variable ]; fun[1] When I do this I get the error: ...
1
vote
0answers
73 views

Evaluation inside Compile

here's a simple question: I have a function: ...
3
votes
1answer
196 views

Why is my compiled code slower?

I am trying to make a Mathematica program run faster. Here is part of the original version. It takes as input the integers X (of order 100), J (of order 10000), and n (of order 100), the real number p ...
1
vote
1answer
309 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: ...
1
vote
0answers
294 views

Speeding Up Image Processing Functions

I am working with stacks of 1024x1024 timelapse microscopy images that I am performing a series of image processing functions on to help segment each image. These functions include ...
11
votes
2answers
377 views

How can I prevent a compiled function from using uncompiled evaluation?

I write a code that creates a compiled function, and then call that function over and over to generate a list. I run this code on a remote server via a batch job, and will run several instances of it....
3
votes
2answers
265 views

How to speed up recursive compiled functions?

I'm trying to speed up the recursive function that calculates Rotation numbers: ...
9
votes
1answer
708 views

MinGW-64 and CompilationTarget -> “C”: can't make library

I'm trying to set up my new Windows 8.1 tablet to compile Mathematica (9.0.1) functions to C, using the MinGW-64 compiler. I have it set up so that the following works: ...
1
vote
1answer
178 views

Warning and Errors during Compile

I defined a compiled function cf = Compile[{{x, _Integer}, {n, _Integer}}, z = (n^x); Binomial[n, #]* StirlingS2[x, #] *(#!)/z & /@ Range[x]]; and I ...
16
votes
1answer
359 views

In Compile “InlineExternalDefinitions” doesn't work anymore in Mma v10 like in v9

In Mma 9 using CompilationOptions -> {"InlineExternalDefinitions" -> True} inside of Compile inlined the values of the ...
0
votes
0answers
73 views

Regarding CompilationTarget->“C”

Recently I have read some interesting things about CompilationTarget->"C" on SE, e.g. in http://mathematica.stackexchange.com/a/54459/11116 where @MichaelE2 ...