Thursday, 1 May 2008

Matlab on amdx86_64 linux

About two weeks ago, I bumped into the problem with Matlab, refusing to compile mex file under linux AMD64. My desktop machine is opteron and our nodes on cluster AMD as well, so I spend some time figuring out what went wrong.
It turned out that in order to compile this small mex file (only three for-loops through sparse matrix) I had to pass -largeArrayDims option to mex.
But it caused a problem - instant crash on call to the mex function.
According to matlab help here you have to change all you int either to mwSize or to mwIndex. Since both of them will be translated into size_t it wasn't clear for me which one use and where. I followed tutorial, compiled and run my small mex file (created from fulltosparse.c example long time ago), but my calculation returned only sparse matrix full of zeros.
Matlab solution suggest to debug until you will a problem. I can't imagine a ways to debug 4000 X 4000 matrix multiplication and the problem clearly lies within use of mwIndex or mwSize. Also it is worth mentioning that I managed to repeat the fault on my powerbook just compiling with -largeArrayDims.
After spending whole day, trying to fix it, I found a proper solution, posted in comp.soft-sys.matlab. Unfortunately I cannot find this post now, but it is brilliant. I think it should be in matlab help, instead of the current solution. The chap (Tim Davis from CXSparse? Sorry, I didn't find this post again to give you proper credit) wrote:
#define Int mwSignedIndex
and then replace all int with Int. Hurrah. It is now working and producing meaningful results.

Another almost honest way of ripping your off.

Some of you probably have found scratch and match cards, laying around on the train and bus station.
I have found two of those and discovered that I have won a cash prize. It smells fishy since in order to claim the prize you have to phone or text to specific premium number and the costs of both will be near 9 pounds. After 1 month of waiting I decided to give it a go - I text.
What is the bottom line? I won £5 in cash, but I spend £9 claiming it means I just lost £4 (Assuming that they are honest and actually pay prizes). It's usually called scum or plot.
For those of you, who have found this card (I have seen chap sitting next to me yon the train this Monday found a "wining" card as well) I post wining security codes, so you can check you prize without spending £9 as I did.
654281=£5 (my number)

Next question, should I try to claim something like nintendo? I have another wining card, but again it's 9 quid.
I hope it will help someone, so unless you are really winner don't try to claim it.