Questions tagged [librarylink]

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

29 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
23
votes
0answers
482 views

LibraryLink: What can we do with MInputStream and MOutputStream?

Version 9 introduced the WolframStreamsLibrary.h header for LibraryLink. It contains MInputStream and ...
10
votes
0answers
104 views

LibraryLink: How to read from a Mathematica stream in C?

Mathematica has a flexible streams interface. Functions like Read can read from a "stream" that may be backed by a file, pipe, string, network resource, etc. We can ...
10
votes
0answers
113 views

Compile M11.1-compatible LibraryLink libraries using M11.2

WolframLibraryVersion, defined in WolframLibrary.h, was bumped from 3 to 4 in Mathematica 11.2. This causes libraries compiled ...
7
votes
0answers
85 views

LibraryLink: Create SparseArray directly from row pointers and column indices

In Mathematica, sparse arrays use a CSR representation. Suppose I already have data in this format. Is there a way to create an MSparseArray from it directly with ...
7
votes
0answers
108 views

LibraryLink: What are DataStore and WolframIOLibrary?

Version 9 introduced DataStore and WolframIOLibrary_Functions in WolframLibrary.h. They don'...
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
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
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
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
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
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
193 views

How to load to Mathematica functions linking to MKL with LibraryLink on OSX

I'm trying to load library funcitons to Mathematica which are using MKL functions but I'm constatly getting LibraryFunction::libload on OSX (this works fine on ...
2
votes
0answers
53 views

Is it possible to pass a rank-0 tensor to LibraryLink?

There is such a thing as a rank-0 MTensor. It's mentioned here. Can we pass such an object to a LibraryFunction? How? This question is mostly out of curiosity, and not practical need. But it might ...
2
votes
0answers
95 views

How does parallelization of LibraryLink function call work?

I'm trying to call a C function in parallel through LibraryLink. Here is an example kind of demonstrates that library function can be used in parallel. My question is what happened in the library ...
2
votes
0answers
165 views

Why am I getting an error from MLPutFunction after getting the MathLink from LibraryLink?

Based on the example on the documentation page for processMathLink, I've got the following C++ code: ...
1
vote
0answers
64 views

How to check the visibility of and load a dependency Dynamic Link Library (DLL) to the Kernel?

I compiled (on Windows 10, using MinGW) a Dynamic Link Library that implements an interface to another one. I then use LibraryLoad[dependencyDLL] and then ...
1
vote
0answers
60 views

How to find out all function and its parameter in a .dll file

Cross post here Since LibraryFunctionLoad can load a function from .dll file like ...
1
vote
0answers
69 views

Need some help on using LibraryLink

I'm learning to set up a LibraryLink in Mathematica. I'm able to reproduce some basic examples provided in Wolfram community. But I got stuck while doing a new one by myself. My source C file is ...
1
vote
0answers
218 views

Getting error LibraryFunction::version from calls to LibraryFunctionLoad

I am having trouble running my program and keep getting this error: LibraryFunction::version: The version number 2 of the library is not consistent with the current or any previous ...
0
votes
0answers
69 views

NestList with LibraryFunction

Edit Same behavior without FORTRAN and undocumented part. What can be wrong in this case? LibraryFunction below is supposed to be just an identity function. ...
0
votes
0answers
92 views

Use MMA generated function in C

I am trying to use MMA generated function and call it form C. The function is (MMA env): ...
0
votes
0answers
343 views

Using shared library in LibraryLink

Recently I've asked a question somewhat related to this[*], but I consider this an actual new problem. So I hope it is indeed appropriate to ask you again. I have created a shared C++ library (with ...
0
votes
0answers
52 views

How to get a script to print MaxMemoryUsed[] upon getting a system signal?

I want to instrument a Mathematica script so that, upon receiving any system signal (e.g. SIGINT, aka Ctrl-C) it will print1 the ...