Questions tagged [librarylink]

Wolfram LibraryLink provides a powerful way to connect external code to Mathematica, enabling high-speed and memory-efficient execution.

Filter by
Sorted by
Tagged with
6
votes
1answer
113 views

getWSLINK documentation vs reality

The example in the documentation for getWSLINK says WSLINK link = libData->getWSLINK(libData); Compiling ...
6
votes
2answers
544 views

Passing Mathematica function via MathLink or LibraryLink to c (or c++)

I want to numerically solve the heat equation. To do so I wrote a program in C++ - It is a BVP $(\alpha T +\kappa \frac{\partial T}{\partial r}=f(t))$, where $f(t)$ is an arbitrary function, whose ...
6
votes
1answer
168 views

Undocumented WolframLibraryData::evaluateExpression

It seem there's this promising function in the callback object provided to MathLink C functions: ...
6
votes
1answer
162 views

Machine precision infinity

Is it possible to obtain the machine precision (double) version of Infinity? This is useful when using LibraryLink and C ...
6
votes
1answer
170 views

Call library function in compile

On the Wolfram official website, there is an example of calling library function in a compiled function: ...
6
votes
1answer
123 views

MTensor from existing memory?

I am wondering whether it's possible to return a tensor from my C++ code using LibraryLink without copying the memory (because it's large). So, instead of ...
6
votes
0answers
60 views

A Swig-like template generator for LibraryLink

I am slowly, manually, constructing an interface to an external-API library (built in .cpp) using LibraryLink. The semi-...
6
votes
0answers
204 views

Compiling/calling Mathematica-generated .so from C

I'm trying to call a compiled function from a C program. I am generating the static object ...
5
votes
2answers
80 views

Bounds for LibraryFunction arguments of integer type

I am trying to load a function written in C++ using LibaryFunctionLoad. Doing so, I have encountered an issue I believe to be a bug (I wanted to ask here first in ...
5
votes
1answer
193 views

Why does this LibraryLink function crash?

Recently, I have rewritten pure Wolfram Language implementation CAGDBSplineSurface[] with C. Below is main LibraryLink code: LibraryLink Code ...
5
votes
1answer
340 views

Accessing methods and properties of C++ objects?

Is it possible to access the properties or methods of C++ objects created with LibraryLink or MathLink like with J/Link ? Such capability doesn't seem built-in yet and I'm not sure it ever will as ...
5
votes
2answers
105 views

How to carry out arithmetic operations on mcomplex in LibraryFunction

I want to perform some arithmetic inside the C++ code using mcomplex data type defined in WolframLibrary.h, but the compiler ...
5
votes
1answer
145 views

Can you trigger update of Dynamic elements from a LinkedLibrary?

Is it possible to write a LinkedLibrary (or WSTP executable) computing a function f such that Dynamic@f[] is updated when the ...
5
votes
1answer
62 views

MathLink: How do I send a bigint?

Suppose I have a big integer from some library such as GMP. I need to return this from a LibraryLink function. What is the most efficient way to do it? The simplest way is to convert it to a string <...
5
votes
1answer
146 views

How to create dll so they can be LibraryFunctionLoad'ed by earlier versions of Mathematica

I found that LibraryFunctionLoad fails to load functions from dylibss created by later versions of Mathematica. When creating ...
5
votes
0answers
77 views

Trying to create rank-1 SparseArray through LibraryLink causes crash

Bug introduced in 10.0 or earlier and fixed in 11.3 When I try to create a 2D SparseArray through LibraryLink's MSparseArray_fromExplicitPositions, it works fine. ...
5
votes
0answers
177 views

Is it possible to call a generic dll/so shared library from Mathematica

In Python, there's something called ctypes. With ctypes, one can call any shared library function and get the results back to your script. It supports all kinds of C-language types, such as int, ...
4
votes
1answer
135 views

Why does LibraryLink return Indeterminate sometimes?

I have a LibraryLink application and I have debugged it with VS. That is to say, the corresponding C code is totally right. However, when I test it in Mathematica, sometimes it gives the correct ...
4
votes
1answer
47 views

How can I test for the size of the mint type at compile time?

It is useful to know the size of LibraryLink's mint type at compile time, for interoperability with other libraries. For example, should I use the ...
4
votes
1answer
70 views

Extract RawArray from Audio

Audio objects backed by in-memory data (not files) seem to contain a RawArray. Is there a way to get the ...
4
votes
0answers
84 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 ...
4
votes
0answers
382 views

Extracting an equation from an interpolated function

Im trying to use LibraryLink to do some calculations in C but part of the expression i want to calculate is an Interpolating Function. C cant use that obviously so I'm trying to shift it to a data ...
4
votes
0answers
72 views

Is it possible to pass a “shared” integer in librarylink?

MTensor supports shared pass, where the argument can be modified in the library function and that modification can be seen in Mathematica side. Is it possible to do the same thing to a integer or ...
4
votes
0answers
171 views

LibraryLink parallel performance

I'm trying to use a LibraryLink function in parallel. It is an embarrassingly parallel problem, so that no dependency between those parallel tasks. However I can only get the parallel efficiency about ...
4
votes
0answers
115 views

2X slower with ; — LibraryLink performance problem [duplicate]

This is the continued problem of the LibraryLink memory usage question here and here. In the following code, there is a 2X performance difference with only the change of ";". ...
4
votes
0answers
153 views

How can I link the c library GAUL into Mathematica?

Is there a way to load the library GAUL (Genetic Algorithm Utility Library) for use within Mathematica?
3
votes
2answers
1k views

What is the best way to work with complex number array in librarylink function in terms of C++ and Eigen?

I want to use C++ Eigen library in Mathematica Librarylink function. Currently, I have no problem dealing with real arrays. But I don't know what is the best way to deal with complex array in ...
3
votes
1answer
322 views

What is causing a type error when trying to modify Mathematica state from a function linked with LibraryLink

I've managed to reduce my problem to a very simple C program: ...
3
votes
1answer
618 views

CreateLibrary for CUDA with NVCCCompiler

I am currently learning to use CUDA to speed up calculations. The book I am working with uses C code on the CPU to supply certain variables etc.. So I would like to compile the give code in ...
3
votes
2answers
237 views

Initialize multiple instances of the same library with global variables

I need to initialize multiple instances of the same library that has global variables. The naive way of LibraryFunctionLoading functions multiple times doesn't ...
3
votes
1answer
202 views

Meson build system + C/C++ LibraryLink, help needed for portability check/fix (Windows &MacOs)

As a proof of concept I have created a github repository that shows how to: use the Meson build system to create a Mathematica package using LibraryLink functions The goal is to provide an easy to ...
3
votes
1answer
108 views

Cross-version compatibility of LibraryLink libraries

I am looking for practical advice on the cross-version compatibility of LibraryLink libraries. In particular, I would like to understand the significance of the ...
3
votes
1answer
74 views

What does the “AutomaticDelete” option for LibraryFunctionLoad do?

Apparently, LibraryFunctionLoad has an option "AutomaticDelete" with default setting ...
3
votes
1answer
160 views

Is it possible to let LibraryLink return multiple results? [duplicate]

I have used the LibraryLink wrapper for some days. In general, there is only one result retruned by the LibraryFunction[]. Below is a simple example: ...
3
votes
1answer
181 views

LibraryLink path problem

I have a library function that need to load some external data files. But it looks that the path in the default path of library function is the path that Mathematica is currently in. Is there a way ...
3
votes
1answer
52 views

Get Library Name from WolframLibraryData

When developing with LibraryLink, is there any way to get the function name from inside the library ? I don't think there is a way to find out the name of the function that have been used to access ...
3
votes
0answers
100 views

Why is a LibraryLink function, which returns a list, not parallelizing with ParallelTable?

First example: librarylink function return a list of two element ...
2
votes
1answer
86 views

Where does the LibraryLink version information come from?

LibraryVersionInformation returns the following information: ...
2
votes
2answers
133 views

LibraryLink C++ void function, mathematica wrapper

I am trying to include a C++ function into the Mathematica wrapper. There is a void function to change the reference state. The original wrapper includes the following C++ function. Here is ...
2
votes
1answer
185 views

How to use OpenCVLink

Since OpenCV provide C++ API,and the Mathemtica provide so many method to connect C++. I think we can call it with our Mathematica. The OpenCV provide many powerfull function for image-processing. It ...
2
votes
1answer
683 views

i cannot create a standalone executable from an exported Mathematica function

I generated the C code: compute.c ...
2
votes
1answer
124 views

Couldn't load OpenSSL library in 12.1 (Windows)

Update: Finally I found a clumsy way to solve this bug by myself: I created an alternate local kernel to run the code, and it surprisingly works out! It is ridiculous that two local kernels contain ...
2
votes
1answer
72 views

How do I return an mcomplex NAN from C++ to Mathematica using LibraryLink?

I need to deliberately return a 'NAN' from a LibraryLink function, which is expected to return mcomplex so it appears as ...
2
votes
1answer
112 views

How to handle ragged-list type argument in LibraryLink?

Given that I have a ragged list as below, raggedList = {U1, U2, ..., Un} where, ui is a sublist($i=1,2,\cdots,n$) and their ...
2
votes
1answer
252 views

Supported options for compiling LibraryLink code with VC++

I have to generate an interface to Mathematica for a fairly large library. I would like to use LibraryLink, as the generation seems much simpler. The platform is Windows (VS 2012), and I am ...
2
votes
2answers
7k views

Visual Studio Express 2010 on x86-64: libcmt.lib missing

The CCompilerDriver documentation explains that to use visual studio express on 64-bit targets, it's necessary to install the windows SDK after installing visual studio. I have done this, first ...
2
votes
2answers
174 views

LibraryFunctionLoad hangs under Windows

I'm running the Wolfram Finance Package version of Mathematica 8, under Windows 7 Professional. Any time I attempt to call LibraryFunctionLoad, the Kernel seems to ...
2
votes
0answers
84 views

LTemplate C++ code seems to run faster than the same code compiled outside of Mathematica

I am slightly puzzled by now and am not able to figure out what's going on inside of LibraryLink (used by LTemplate) to justify what I recognized: I have C++ code that is way too extensive to be ...
2
votes
0answers
37 views

Is it safe to change MSparseArrays which lack column indices?

I am using sparse arrays with LibraryLink. I noticed that when MSparseArray_fromExplicitPositions and MSparseArray_fromMTensor ...
2
votes
0answers
167 views

Trouble loading MXNetLink in console mode [closed]

I'm using v11.1 on ubuntu, any ideas what is wrong here: In[3]:= << MXNetLink` ...