From: "Christian " <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Long double precision mxArray in mex file?
Date: Thu, 18 Feb 2010 15:39:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <hljmv8$o3o$>
References: <hljabl$72u$> <hljkad$se6$>
Reply-To: "Christian " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1266507560 24696 (18 Feb 2010 15:39:20 GMT)
NNTP-Posting-Date: Thu, 18 Feb 2010 15:39:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 926713
Xref: comp.soft-sys.matlab:609314

"Oliver Woodford" <> wrote in message <hljkad$se6$>...
> "Christian " wrote:
> > Hello all
> > 
> > I am trying to model a communication system in Matlab. Because of time computation, I have moved a part of the code into some mex files. When running the program with just Matlab the results are more satisfactory than the results when Matlab/MEX is used. My only explanation for this is a difference of precision in the computations involved The code programmed in these MEX files are computationally costful, complex data is involved and require a high degree of precision.
> > 
> > Since the mxArray are double precision, my question is: how can I use mxArray structures in MEX files with long double precision? The pointers at these mxArray have been declared as long double *, but I do not see any change and the results are still different from those obtained when only Matlab is used.
> > 
> > Thanks in advance
> I understand why the results might be different. MATLAB follows IEEE floating point arithmetic rules, so uses a 53-bit mantissa in calculations. However, most modern CPUs use a 64-bit mantissa internally when doing the same calculations, which the compiled mex code will make use of. Therefore these results should be more accurate. Are you MATLAB's results are the more accurate of the two?
> Oliver

Well, I could not say which one is more accurate. I am trying a technique to detect the information signal sent, and using only matlab the number of errors is smaller.  It would be more convenient for me that Matlab used a higher precision than mex. 

The algorithm involves complex operations, the results depends on previous computations,...a smaller difference in the precision computation may explain the difference. Why Matlab does obtain a smaller number of errors? Strange