Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
compiling mex on Linux vs. Windows

Subject: compiling mex on Linux vs. Windows

From: Elnaz

Date: 9 May, 2013 19:42:09

Message: 1 of 3

Hi all,

This seems strange but when I compile and run the same exact .cpp code on Linux, the result is different than Windows. I set the rng(0) in the beginning of the MATLAB script which calls the mex function inside. The outputs of the mex are different! Why?

Thanks,
Elnaz

Subject: compiling mex on Linux vs. Windows

From: James Tursa

Date: 9 May, 2013 21:22:10

Message: 2 of 3

"Elnaz " <ebsadeghian@gmail.com> wrote in message <kmgu6h$1gd$1@newscl01ah.mathworks.com>...
> Hi all,
>
> This seems strange but when I compile and run the same exact .cpp code on Linux, the result is different than Windows. I set the rng(0) in the beginning of the MATLAB script which calls the mex function inside. The outputs of the mex are different! Why?
>
> Thanks,
> Elnaz

Different compiler, different order of operations, different precision of background calculations, etc etc etc. What is the mex routine doing and how different are your results?

James Tursa

Subject: compiling mex on Linux vs. Windows

From: Elnaz

Date: 9 May, 2013 21:52:17

Message: 3 of 3

> Different compiler, different order of operations, different precision of background calculations, etc etc etc. What is the mex routine doing and how different are your results?
>
> James Tursa
Both compilers are MATLAB. I just remove the windows.h header from .cpp and compile it on Linux. Not totally different but again.... The mex function is a BCJR equalizer. The input to both cases are the same, exactly. MATLAB script calling the mex is the same. The results are different by a few percentage.
The reason I'm using Linux is because I'm submitting parallel jobs to different computing nodes running Linux.
Do you mean that the definition/precision of a double type is different on Windows vs. Linux?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us