Group Abstract Group Abstract

Message Boards Message Boards

WSTP: Handling lists

Posted 5 years ago

I am writing a WSTP application in C, and would like to "receive" a list from Mathematica, however, it should be able to handle multiple datatypes (i.e. int, real, etc.); is there a way to do this with a single function or I need to write a function per datatype, i.e.

processIntegerList(int *a, long b); progressReaList(double *a, long b);

If this can be achieved with a single function, could you paste a snippet of code that would then identify the datatype of the list passed (we assume here that the argument is always a list).

Thank you for looking.

POSTED BY: jerome ibanes
8 Replies

Actually, with LibraryLink, it is not necessary to fix either the element type (Integer, Real, Complex) or the dimension (1D, 2D, etc.) of either the input arguments or the return value. Is this flexible enough for your purposes?

POSTED BY: Szabolcs Horvát
Posted 5 years ago
POSTED BY: jerome ibanes

I linked to a number of pointers in my previous posts: do those help?

POSTED BY: Szabolcs Horvát
POSTED BY: Szabolcs Horvát
POSTED BY: Szabolcs Horvát
Posted 5 years ago
POSTED BY: jerome ibanes
POSTED BY: Szabolcs Horvát

Can you explain a bit more why you want to do this please? Of course, this is a reasonable question, but the situation is a bit more complicated than you may be aware. The best solution will depend on what you are trying to achieve.

Why is just using reals not sufficient? Integer values can be stored in doubles.

Is this about performance? If yes, why are you using MathLink and not LibraryLink (which has much better data passing performance)?

POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard