last day (23 days later) » 

10:14
I am not fluent in low-level MathLink and I have to experiment and read docs every time before doing something like this.
However, my impression was that transferring an array through a link does not unpack it.
If a given thing is put on a link, there are usually multiple ways to retrieve it. E.g. if you put an integer, you get still get a string (a string representation of the integer).
I'd assume that if you put a Real packed array, the optimal way to get it would be MLGetReal64Array
I don't have the time to test these things right now.
Why do you think the kernel unpacks?
I'm not sure. But WSGetType do not give WSTKPACKED or alike
What I'm trying to say is that even if you send a packed array, you could retrieve it as a "Funtcion" with head "List", then get numbers one by one. That's effective unpacking.
The efficient way to get it would be WSGetReal64List or WSGetReal64Array
What does it give then? MLTKARRAY?
No, just MLTKFUNC, then MLTKREAL
everything the client side sees are just MKTL{FUNC,INT,REAL,SYM,STR}
I'd have to experiment with this, and unfortunately I wouldn't really have the time until the weekend
Thank you for your time
10:19
But it sound like a very exciting and useful project to do this for Python
and a potential basis for a good Python link
not like the ExternalEvaluate stuff but much better
It's still in very early stage of dev, I would be open to design suggestions.
10:31
@Kh40tiK So basically you just want to detect if it's possible to use MLGetReal64Array or MLGetInteger64Array to get the next thing on the link, for performance reasons.
I confirm your finding with MLGetType
Yup. Iteratively filling a multidim array in python could be horribly slow.
Have you investigated MLGetRawType?
Hum, didn't know this one.
If you work with MathLink, don't rely on the documentation
It's incomplete and on occasion incorrect
You need to look at the header file and experiment
I also didn't know MLGetRawType, I just found it in the header right next to MLGetType
Okay I see. Thanks.
I'll update later.
10:35
Now I'm getting an A for a packed integer array
that's ...
#define MLTKARRAY 'A' /* 65 0x41 01000001 */
I guess you did look at the header, otherwise you wouldn't have found MLTKPACKED. right?
Is it documented anywhere?
So now we know it's an array, but we don't know its dimension and type (Integer or Real)
It also says, /* The following defines are for internal use only */, for these codes ...
WSGetArrayType maybe this one?
let me try
what's an array_meterp meterp?
dunno, could be a "dtype" or "shape" thing as in numpy
opaque struct
First: is that argument an input or an output of that function? If an input, how do we get it? Is there another function for that?
It looks very much like an input
this link looks helpful
10:44
That would suggest that any function that outputs it must take a pointer to an array_meterp, i.e. an array_meterpp (note the two Ps)
There are only a few such function, but they're even more cryptic
development turns into hacking :P
That's a very old thread, and MLGetArrayType0 seems deprecated
it's replaced with MLGetArrayTypeWithDepthAndLeafType
BUT the post you found explains what the "heads link" is, so progress!
I really can't spend more time on it today, but please keep posting your findings in this room
I'll keep updating
Bye
Make sure you look at the #if MLINTERFACE >= 4 parts of the header. The rest will not work with interface 4. It's useful to use an IDE that understands some of the code to browse the header. E.g. I see this:
Makes it much easier to browse the code and ignore parts belonging to earlier APIs
I use Qt Creator, but there are many other tools that can do this
Bye

  last day (23 days later) »