Path: news.mathworks.com!not-for-mail From: "Christian " <pepico@hotmail.com> 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$1@fred.mathworks.com> References: <hljabl$72u$1@fred.mathworks.com> <hljkad$se6$1@fred.mathworks.com> Reply-To: "Christian " <pepico@hotmail.com> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1266507560 24696 172.30.248.35 (18 Feb 2010 15:39:20 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 18 Feb 2010 15:39:20 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 926713 Xref: news.mathworks.com comp.soft-sys.matlab:609314 "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <hljkad$se6$1@fred.mathworks.com>... > "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