Questions tagged [librarylink]
Wolfram LibraryLink provides a powerful way to connect external code to Mathematica, enabling high-speed and memory-efficient execution.
155
questions
1
vote
1
answer
35
views
Exported function discovery with LibraryFunction
Many internal calls boil down to invocations like
LibraryFunction["path/to/library", "funcName" , ...]
I'm on a mac, so I can use the ...
2
votes
0
answers
41
views
How do I identify which external routine is potentially internally used when executing some built-in function?
Wolfram's website declares that "a large fraction of Mathematica's numerical algorithms are based on original research at Wolfram Research" (cf. So Many Original Wolfram Algorithms). So, ...
1
vote
1
answer
69
views
LMDB Library cannot be loaded by `LibraryLoad`, how to compile properly
I cloned LMDB* from https://github.com/LMDB/lmdb and compiled on a Mac M1 with
make -e clean liblmdb.so CC="cc -target aarch64-macos-none"
which produced ...
18
votes
1
answer
655
views
Fast Hankel Function in Mathematica
I am working on a project that requires repeated calls to HankelH1[0, r] for $r$ spanning the full real axis. When I use the mathematica routine, it can be as much ...
4
votes
1
answer
147
views
Third party libraries in LibraryLink
I am trying to use third-party libraries in LibraryLink, but the kernel crashes when I call their functions.
In particular, I want to make available some functions of SuiteSparse to manipulate ...
2
votes
0
answers
53
views
Bug: managed library expressions are freed prematurely during evaluation
I believe I have run into a bug with managed library expressions and garbage collection behavior. In the example below, adapted from the documentation for ...
3
votes
1
answer
98
views
Can I efficiently use a compiled function as an input to another compiled function?
I have a compiled function(such as $f\left(z,c\right)=z^2+c$) which will get replaced by different equations as the code runs. I'm using this compiled function(#1) inside another compiled function(#2)....
5
votes
1
answer
201
views
How to assign pointer to a rank 2 MTensor in Mathematica C code?
I've the following code
...
0
votes
0
answers
39
views
How can we change the EoS (to PR using the Flags function) for REFPROP used within Mathematica?
I would like to change the EoS used by REFPROP to the PR EoS for several calculations.
It's stated that the Flags function must be used.
"
Peng-Robinson or PR 0: Turn off the Peng-Robinson ...
3
votes
1
answer
106
views
How to call the librarylink api in 13.1
Local file demo.c have some library link API example, such as:
example 1:
...
4
votes
2
answers
203
views
How to get a MTensor variable by a vector object
librarylink have a dirty signature such as:
EXTERN_C DLLEXPORT int fun(WolframLibraryData libData,mint Argc, MArgument* Args, MArgument Res)
But when we are in ...
23
votes
2
answers
598
views
How to call the C++ by the new LibraryFunctionDeclaration?
When we arrive at V13.1, we have a great LibraryFunctionDeclaration now, which can call C function in MMA as this article:
...
1
vote
0
answers
94
views
It is possible to call C functions with pointers as arguments in Mathematica?
Here is my goal: I want to call external library functions, written in C (not by me), in Mathematica.
I may have found a way to do it using LibraryLink by following this scheme:
First, for each ...
23
votes
2
answers
400
views
Which Mathematica versions have changed WolframLibraryVersion?
A LibraryLink library compiled with headers having a certain WolframLibraryVersion will not work with Mathematica versions that support only earlier ...
0
votes
0
answers
50
views
Is it possible to run kernel in address space of another process?
Kernel executables seem to be relatively small wrappers around "dynamic link library" that contains all the functionality of the kernel.
Is it possible to load the kernel (as a dynamic link ...
2
votes
0
answers
114
views
LibraryFunctionLoad with swift library
I'm trying to figure out if there is any sane way to call a swift function using the LibraryLoadFunction.
In Swift it seems possible to use @_cdecl to get a c callable dynamic library.
When I test ...
6
votes
2
answers
407
views
Speedup the production of a sparse symmetric matrix with a dense vector
The optimization of the production of a sparse symmetric matrix with a dense vector has existed for a long time. Someone once compared the matrix operations of Mathematica with MATLAB, and then came ...
6
votes
1
answer
476
views
Mathematica call C++ Eigen to calculate sparsematrix multiplication
I want to use the C++ Eigen library in Mathematica's LibraryLink function.
In the past, matheorem called C++ Eigen in Mathematica successfully. However, I am not ...
4
votes
0
answers
67
views
Should I worry about concurrent access to LibraryLinked code?
According to these answers, when several heterogeneous results (say {MTensor, mint, double}) are needed to be returned from a LibraryLink ...
8
votes
3
answers
232
views
Can LibraryLink receive and output a list of strings?
I need to use libraryLink to process a list of strings, I haven't found a suitable example, confused about the types of the arguments and return types. Does libraryLink directly support it, which one ...
1
vote
0
answers
56
views
Substitute for MathLink to integrate PARI with Mathematica?
How does one access MathLink with current version of Mathematica?
I'm trying to integrate the "computer algebra system" PARI with Mathematica, as documented at https://pari.math.u-bordeaux....
3
votes
2
answers
121
views
MTensor of MTensor (aka List of List)
In C++ I have a vector of 2D points :
typedef std::array<double, 2> Point;
std::vector<Point> samples;
Now, I'm in LibraryLink and I'd want to pass a ...
5
votes
1
answer
142
views
Difference between MTensor and MNumericArray in Mathematica
Since I'm starting to look into C-programming using LibraryLink to connect Mathematica to computational expensive calculations, I was wondering about the two available options within LibraryLink for ...
2
votes
0
answers
120
views
LTemplate and external library Armadillo
As a great fan of the simplicity of the LTemplate library for the end user I am now faced with a problem when apparently everything compiles correctly but the functions are not loaded from the library....
6
votes
1
answer
83
views
Default compiler optimization flag used by LibraryLink (CreateLibrary)?
What's the default optimization level (e.g. -O2, -O3) used by the function CreateLibrary, which invokes the system compiler to compile C/C++ code for use in LibraryLink?
3
votes
0
answers
209
views
Using MinGW-w64 from MSYS2 with LibraryLink
I am looking to use the MinGW-w64 version of gcc, as bundled with msys2, with LibraryLink.
It was communicated to me that in recent versions of Mathematica, one may use the MinGWCompiler compiler ...
3
votes
1
answer
242
views
How to get information from all built-in Mathematica functions in order to create a Kotlin library like the Wolfram Client Library for Python?
I'd like to use (if this already exists) or create a library to use Mathematica together with Kotlin (or Java) (not JLink, please see below).
We already have this very useful implementation for ...
5
votes
2
answers
211
views
Using WSTP with LibraryLink
I'm building an interface for a Fortran library. I would like to use LibraryLink and Mathematica to do the compilation (via CreateLibrary), Visual Studio is ...
2
votes
1
answer
76
views
ParallelTable does not evaluate DLL functions
I have a function programed in C which I load in MMA with
...
1
vote
1
answer
153
views
LibraryFunctionLoad with Cool Prop documentation
I use the following command
...
0
votes
0
answers
36
views
Improving performance of LibraryLink evaluation
I have a large function that I want to integrate with an integration routine.
The function is supposed to be built out of LibraryLink functions, but I find evaluating the function to be very slow, and ...
2
votes
2
answers
662
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 ...
0
votes
0
answers
97
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.
...
5
votes
1
answer
113
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 <...
3
votes
1
answer
311
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 ...
1
vote
0
answers
71
views
Loading machine learning library without enabling my discrete Nvidia GPU? [closed]
I've asked a similar question
[here].
I cannot use some of the machine learning modules without enabling my discrete Nvidia GPU.
My setup:
Ubuntu 16.04 on a Dell XPS-15 9560 Intel i7 CPU with 8-...
1
vote
0
answers
158
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
1
answer
94
views
Problem with calling dll file using LibraryLink with ParallelMap and Map for large data
I am trying to call a .dll file via LibraryFunctionLoad where the .dll file is placed in "C:\ProgramData\Mathematica\SystemFiles\LibraryResources\Windows-\
x86-64\CoolProp.dll".
When I call this ...
2
votes
2
answers
232
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
0
answers
108
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
1
answer
173
views
Compile errors after reloading of laptop contents after challenging MacOS Mojave installation
I tried (foolhardily, it appears) installing macOS Mojave Version10.4 on my MacBookAir, but encountered major problems--that seemed to have been (finally) fixed after a reinstallation and reloading of ...
3
votes
1
answer
68
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 ...
12
votes
0
answers
153
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 ...
5
votes
2
answers
93
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 ...
4
votes
1
answer
80
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 ...
0
votes
0
answers
119
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):
...
8
votes
0
answers
142
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 ...
2
votes
0
answers
49
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 ...
5
votes
0
answers
120
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. ...
4
votes
1
answer
69
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 ...