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

learn more… | top users | synonyms

0
votes
0answers
58 views

Numeric error in trivial compilation [on hold]

I came across this strange problem: dd = Compile[{}, Abs[(10^-200 + 10^-200 I)/(10^-200 + I 10^-200)]^2, CompilationTarget -> "C"] In[72]:= dd[] During ...
1
vote
1answer
41 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
56 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 ...
2
votes
1answer
91 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 ...
9
votes
0answers
96 views

Memory usage of compiled function: C vs WVM

Why does generating an array in "C"-compiled function uses 50% more memory than doing same thing in "WVM"-compiled function? ...
19
votes
5answers
780 views

Can (compiled) matrix permanent evaluation be further sped-up?

Update III  Mathematica 10.2.0 now ships with a predefined System`Permanent function, which the PermanentCode package ...
15
votes
3answers
463 views

Compiling LinearSolve[] or creating a compilable procedural version of it

Earlier today I had a discussion with a representative at Premier Support about the 2 questions I've asked here over the past couple of days: Seeking strategies to deploy a function securely ...
15
votes
1answer
530 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 ...
1
vote
0answers
52 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). ...
3
votes
1answer
69 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 ...
4
votes
1answer
79 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: ...
4
votes
2answers
215 views

How can I speed up my compiled RBF interpolating function?

Overview I have a function that acts like the Interpolation on sparse $n$-dimensional data using a simple implementation of RBF interpolation method. I want my ...
18
votes
0answers
151 views

Listable compiled function crashes the kernel with “no more memory available”

Bug introduced in 9.0.0 and persisting through 10.2.0 I am trying to speed up a function that involves continued fractions. Since ContinuedFraction cannot be ...
2
votes
1answer
96 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 ...
1
vote
1answer
108 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: ...
23
votes
1answer
338 views

Performance regression for Fold?

Bug introduced in 8.0 and persisting through 10.2.0 or later I noticed an over 10x performance drop on Mathematica v9.0.1 (as Oleksandr R. commented, also v8) compared with v7.01 for this code: ...
8
votes
2answers
193 views

CompiledFunction crashes kernel

Bug fixed in 10.0.0 This crashes my kernel ...
2
votes
1answer
43 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
119 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
98 views

How to compile procedural program effectively

Consider these four function in different form: ...
1
vote
1answer
133 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
64 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 ...
1
vote
0answers
120 views

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

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 ...
7
votes
2answers
194 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 ...
0
votes
0answers
48 views

Compilable function with the functionality of SingularValueList

I'm doing something that involves finding the singular values of a lot of matrices. Basically I need to find singular values of $n$ matrices of dimension $n\times n$, where $n$ is as large as ...
3
votes
0answers
72 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
482 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
1answer
62 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: ...
12
votes
1answer
454 views
5
votes
0answers
81 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. ...
7
votes
0answers
148 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 ...
3
votes
0answers
78 views

speed up evaluating a listable function

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] ...
13
votes
1answer
421 views

Why is MainEvaluate being used when LinearSolve can be compiled?

According to this question LinearSolve can be compiled. However, CompilePrint[] shows a call to ...
11
votes
1answer
726 views

Example program for calling Mathematica from C

I want to call Mathematica from a C program. Suppose I have two numbers x = 2 and y = 3. I want to define ...
35
votes
4answers
1k views

Compiling more functions that don't call MainEvaluate

I would like to use Compile with functions defined outside Compile. For example if I have the two basic functions ...
6
votes
0answers
112 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 ...
1
vote
2answers
65 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
261 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
92 views

Problem with Compile and Flatten

I want to get two lists within a compiled function, where r is an integer: ...
8
votes
3answers
586 views

What is wrong with my expression for compiling?

Following code was translated from a snippet matlab code. Without compiling it worked slowly. I want to compile it, but am getting a numerical error. How do I compile this in a correct way? ...
24
votes
3answers
857 views

Which Distributions can be Compiled using RandomVariate

Recently, Oleksandr kindly showed a list of Mathematica commands that can be compiled. RandomVariate was part of that list. However, whether this can be compiled depends upon the distribution that is ...
4
votes
2answers
161 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 ...
15
votes
0answers
222 views

Compile not correctly initializing a variable defined inside Module

Bug introduced in 8.0 and persisting through 10.1.0 or later In the following example, inside the minimumX's Module, ...
6
votes
1answer
260 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. ...
2
votes
0answers
58 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 ...
0
votes
1answer
87 views

How to compile a function whose arguments are lists containing strings?

I'm unsuccessfully trying to compile this function check[argA_, argB_] := argA[[1]] == argB[[1]]; assuming that both arguments argA and argB are of the form ...
12
votes
1answer
168 views

CompiledFunctionCall vs. LibraryFunction

When compiling code to C, and the compiled code calls other compiled functions, I see CompiledFunctionCall in the output of ...
7
votes
1answer
294 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 ...
5
votes
1answer
102 views

Compilation of `Total` with CompensatedSummation

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